babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** nearest is mag = nearest and min = nearest and mip = linear */
  783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** mag = nearest and min = nearest and mip = none */
  797. static readonly TEXTURE_NEAREST_NEAREST: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** mag = linear and min = linear and mip = none */
  803. static readonly TEXTURE_LINEAR_LINEAR: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. /** @hidden */
  1476. export class ShaderProcessor {
  1477. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1478. private static _ProcessPrecision;
  1479. private static _ExtractOperation;
  1480. private static _BuildSubExpression;
  1481. private static _BuildExpression;
  1482. private static _MoveCursorWithinIf;
  1483. private static _MoveCursor;
  1484. private static _EvaluatePreProcessors;
  1485. private static _PreparePreProcessors;
  1486. private static _ProcessShaderConversion;
  1487. private static _ProcessIncludes;
  1488. }
  1489. }
  1490. declare module "babylonjs/Maths/math.like" {
  1491. import { float, int, DeepImmutable } from "babylonjs/types";
  1492. /**
  1493. * @hidden
  1494. */
  1495. export interface IColor4Like {
  1496. r: float;
  1497. g: float;
  1498. b: float;
  1499. a: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IColor3Like {
  1505. r: float;
  1506. g: float;
  1507. b: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IVector4Like {
  1513. x: float;
  1514. y: float;
  1515. z: float;
  1516. w: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IVector3Like {
  1522. x: float;
  1523. y: float;
  1524. z: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IVector2Like {
  1530. x: float;
  1531. y: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IMatrixLike {
  1537. toArray(): DeepImmutable<Float32Array>;
  1538. updateFlag: int;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IViewportLike {
  1544. x: float;
  1545. y: float;
  1546. width: float;
  1547. height: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IPlaneLike {
  1553. normal: IVector3Like;
  1554. d: float;
  1555. normalize(): void;
  1556. }
  1557. }
  1558. declare module "babylonjs/Materials/iEffectFallbacks" {
  1559. import { Effect } from "babylonjs/Materials/effect";
  1560. /**
  1561. * Interface used to define common properties for effect fallbacks
  1562. */
  1563. export interface IEffectFallbacks {
  1564. /**
  1565. * Removes the defines that should be removed when falling back.
  1566. * @param currentDefines defines the current define statements for the shader.
  1567. * @param effect defines the current effect we try to compile
  1568. * @returns The resulting defines with defines of the current rank removed.
  1569. */
  1570. reduce(currentDefines: string, effect: Effect): string;
  1571. /**
  1572. * Removes the fallback from the bound mesh.
  1573. */
  1574. unBindMesh(): void;
  1575. /**
  1576. * Checks to see if more fallbacks are still availible.
  1577. */
  1578. hasMoreFallbacks: boolean;
  1579. }
  1580. }
  1581. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1582. /**
  1583. * Class used to evalaute queries containing `and` and `or` operators
  1584. */
  1585. export class AndOrNotEvaluator {
  1586. /**
  1587. * Evaluate a query
  1588. * @param query defines the query to evaluate
  1589. * @param evaluateCallback defines the callback used to filter result
  1590. * @returns true if the query matches
  1591. */
  1592. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1593. private static _HandleParenthesisContent;
  1594. private static _SimplifyNegation;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/tags" {
  1598. /**
  1599. * Class used to store custom tags
  1600. */
  1601. export class Tags {
  1602. /**
  1603. * Adds support for tags on the given object
  1604. * @param obj defines the object to use
  1605. */
  1606. static EnableFor(obj: any): void;
  1607. /**
  1608. * Removes tags support
  1609. * @param obj defines the object to use
  1610. */
  1611. static DisableFor(obj: any): void;
  1612. /**
  1613. * Gets a boolean indicating if the given object has tags
  1614. * @param obj defines the object to use
  1615. * @returns a boolean
  1616. */
  1617. static HasTags(obj: any): boolean;
  1618. /**
  1619. * Gets the tags available on a given object
  1620. * @param obj defines the object to use
  1621. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1622. * @returns the tags
  1623. */
  1624. static GetTags(obj: any, asString?: boolean): any;
  1625. /**
  1626. * Adds tags to an object
  1627. * @param obj defines the object to use
  1628. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1629. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1630. */
  1631. static AddTagsTo(obj: any, tagsString: string): void;
  1632. /**
  1633. * @hidden
  1634. */
  1635. static _AddTagTo(obj: any, tag: string): void;
  1636. /**
  1637. * Removes specific tags from a specific object
  1638. * @param obj defines the object to use
  1639. * @param tagsString defines the tags to remove
  1640. */
  1641. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1642. /**
  1643. * @hidden
  1644. */
  1645. static _RemoveTagFrom(obj: any, tag: string): void;
  1646. /**
  1647. * Defines if tags hosted on an object match a given query
  1648. * @param obj defines the object to use
  1649. * @param tagsQuery defines the tag query
  1650. * @returns a boolean
  1651. */
  1652. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1653. }
  1654. }
  1655. declare module "babylonjs/Maths/math.scalar" {
  1656. /**
  1657. * Scalar computation library
  1658. */
  1659. export class Scalar {
  1660. /**
  1661. * Two pi constants convenient for computation.
  1662. */
  1663. static TwoPi: number;
  1664. /**
  1665. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1666. * @param a number
  1667. * @param b number
  1668. * @param epsilon (default = 1.401298E-45)
  1669. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. */
  1671. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1672. /**
  1673. * Returns a string : the upper case translation of the number i to hexadecimal.
  1674. * @param i number
  1675. * @returns the upper case translation of the number i to hexadecimal.
  1676. */
  1677. static ToHex(i: number): string;
  1678. /**
  1679. * Returns -1 if value is negative and +1 is value is positive.
  1680. * @param value the value
  1681. * @returns the value itself if it's equal to zero.
  1682. */
  1683. static Sign(value: number): number;
  1684. /**
  1685. * Returns the value itself if it's between min and max.
  1686. * Returns min if the value is lower than min.
  1687. * Returns max if the value is greater than max.
  1688. * @param value the value to clmap
  1689. * @param min the min value to clamp to (default: 0)
  1690. * @param max the max value to clamp to (default: 1)
  1691. * @returns the clamped value
  1692. */
  1693. static Clamp(value: number, min?: number, max?: number): number;
  1694. /**
  1695. * the log2 of value.
  1696. * @param value the value to compute log2 of
  1697. * @returns the log2 of value.
  1698. */
  1699. static Log2(value: number): number;
  1700. /**
  1701. * Loops the value, so that it is never larger than length and never smaller than 0.
  1702. *
  1703. * This is similar to the modulo operator but it works with floating point numbers.
  1704. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1705. * With t = 5 and length = 2.5, the result would be 0.0.
  1706. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1707. * @param value the value
  1708. * @param length the length
  1709. * @returns the looped value
  1710. */
  1711. static Repeat(value: number, length: number): number;
  1712. /**
  1713. * Normalize the value between 0.0 and 1.0 using min and max values
  1714. * @param value value to normalize
  1715. * @param min max to normalize between
  1716. * @param max min to normalize between
  1717. * @returns the normalized value
  1718. */
  1719. static Normalize(value: number, min: number, max: number): number;
  1720. /**
  1721. * Denormalize the value from 0.0 and 1.0 using min and max values
  1722. * @param normalized value to denormalize
  1723. * @param min max to denormalize between
  1724. * @param max min to denormalize between
  1725. * @returns the denormalized value
  1726. */
  1727. static Denormalize(normalized: number, min: number, max: number): number;
  1728. /**
  1729. * Calculates the shortest difference between two given angles given in degrees.
  1730. * @param current current angle in degrees
  1731. * @param target target angle in degrees
  1732. * @returns the delta
  1733. */
  1734. static DeltaAngle(current: number, target: number): number;
  1735. /**
  1736. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1737. * @param tx value
  1738. * @param length length
  1739. * @returns The returned value will move back and forth between 0 and length
  1740. */
  1741. static PingPong(tx: number, length: number): number;
  1742. /**
  1743. * Interpolates between min and max with smoothing at the limits.
  1744. *
  1745. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1746. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1747. * @param from from
  1748. * @param to to
  1749. * @param tx value
  1750. * @returns the smooth stepped value
  1751. */
  1752. static SmoothStep(from: number, to: number, tx: number): number;
  1753. /**
  1754. * Moves a value current towards target.
  1755. *
  1756. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1757. * Negative values of maxDelta pushes the value away from target.
  1758. * @param current current value
  1759. * @param target target value
  1760. * @param maxDelta max distance to move
  1761. * @returns resulting value
  1762. */
  1763. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1764. /**
  1765. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1766. *
  1767. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1768. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1769. * @param current current value
  1770. * @param target target value
  1771. * @param maxDelta max distance to move
  1772. * @returns resulting angle
  1773. */
  1774. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1775. /**
  1776. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1777. * @param start start value
  1778. * @param end target value
  1779. * @param amount amount to lerp between
  1780. * @returns the lerped value
  1781. */
  1782. static Lerp(start: number, end: number, amount: number): number;
  1783. /**
  1784. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1785. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1786. * @param start start value
  1787. * @param end target value
  1788. * @param amount amount to lerp between
  1789. * @returns the lerped value
  1790. */
  1791. static LerpAngle(start: number, end: number, amount: number): number;
  1792. /**
  1793. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1794. * @param a start value
  1795. * @param b target value
  1796. * @param value value between a and b
  1797. * @returns the inverseLerp value
  1798. */
  1799. static InverseLerp(a: number, b: number, value: number): number;
  1800. /**
  1801. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1802. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1803. * @param value1 spline value
  1804. * @param tangent1 spline value
  1805. * @param value2 spline value
  1806. * @param tangent2 spline value
  1807. * @param amount input value
  1808. * @returns hermite result
  1809. */
  1810. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1811. /**
  1812. * Returns a random float number between and min and max values
  1813. * @param min min value of random
  1814. * @param max max value of random
  1815. * @returns random value
  1816. */
  1817. static RandomRange(min: number, max: number): number;
  1818. /**
  1819. * This function returns percentage of a number in a given range.
  1820. *
  1821. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1822. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1823. * @param number to convert to percentage
  1824. * @param min min range
  1825. * @param max max range
  1826. * @returns the percentage
  1827. */
  1828. static RangeToPercent(number: number, min: number, max: number): number;
  1829. /**
  1830. * This function returns number that corresponds to the percentage in a given range.
  1831. *
  1832. * PercentToRange(0.34,0,100) will return 34.
  1833. * @param percent to convert to number
  1834. * @param min min range
  1835. * @param max max range
  1836. * @returns the number
  1837. */
  1838. static PercentToRange(percent: number, min: number, max: number): number;
  1839. /**
  1840. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1841. * @param angle The angle to normalize in radian.
  1842. * @return The converted angle.
  1843. */
  1844. static NormalizeRadians(angle: number): number;
  1845. }
  1846. }
  1847. declare module "babylonjs/Maths/math.constants" {
  1848. /**
  1849. * Constant used to convert a value to gamma space
  1850. * @ignorenaming
  1851. */
  1852. export const ToGammaSpace: number;
  1853. /**
  1854. * Constant used to convert a value to linear space
  1855. * @ignorenaming
  1856. */
  1857. export const ToLinearSpace = 2.2;
  1858. /**
  1859. * Constant used to define the minimal number value in Babylon.js
  1860. * @ignorenaming
  1861. */
  1862. let Epsilon: number;
  1863. export { Epsilon };
  1864. }
  1865. declare module "babylonjs/Maths/math.viewport" {
  1866. /**
  1867. * Class used to represent a viewport on screen
  1868. */
  1869. export class Viewport {
  1870. /** viewport left coordinate */
  1871. x: number;
  1872. /** viewport top coordinate */
  1873. y: number;
  1874. /**viewport width */
  1875. width: number;
  1876. /** viewport height */
  1877. height: number;
  1878. /**
  1879. * Creates a Viewport object located at (x, y) and sized (width, height)
  1880. * @param x defines viewport left coordinate
  1881. * @param y defines viewport top coordinate
  1882. * @param width defines the viewport width
  1883. * @param height defines the viewport height
  1884. */
  1885. constructor(
  1886. /** viewport left coordinate */
  1887. x: number,
  1888. /** viewport top coordinate */
  1889. y: number,
  1890. /**viewport width */
  1891. width: number,
  1892. /** viewport height */
  1893. height: number);
  1894. /**
  1895. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @returns a new Viewport
  1899. */
  1900. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1901. /**
  1902. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1903. * @param renderWidth defines the rendering width
  1904. * @param renderHeight defines the rendering height
  1905. * @param ref defines the target viewport
  1906. * @returns the current viewport
  1907. */
  1908. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1909. /**
  1910. * Returns a new Viewport copied from the current one
  1911. * @returns a new Viewport
  1912. */
  1913. clone(): Viewport;
  1914. }
  1915. }
  1916. declare module "babylonjs/Misc/arrayTools" {
  1917. /**
  1918. * Class containing a set of static utilities functions for arrays.
  1919. */
  1920. export class ArrayTools {
  1921. /**
  1922. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1923. * @param size the number of element to construct and put in the array
  1924. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1925. * @returns a new array filled with new objects
  1926. */
  1927. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1928. }
  1929. }
  1930. declare module "babylonjs/Maths/math.vector" {
  1931. import { Viewport } from "babylonjs/Maths/math.viewport";
  1932. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1933. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1934. /**
  1935. * Class representing a vector containing 2 coordinates
  1936. */
  1937. export class Vector2 {
  1938. /** defines the first coordinate */
  1939. x: number;
  1940. /** defines the second coordinate */
  1941. y: number;
  1942. /**
  1943. * Creates a new Vector2 from the given x and y coordinates
  1944. * @param x defines the first coordinate
  1945. * @param y defines the second coordinate
  1946. */
  1947. constructor(
  1948. /** defines the first coordinate */
  1949. x?: number,
  1950. /** defines the second coordinate */
  1951. y?: number);
  1952. /**
  1953. * Gets a string with the Vector2 coordinates
  1954. * @returns a string with the Vector2 coordinates
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Gets class name
  1959. * @returns the string "Vector2"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Gets current vector hash code
  1964. * @returns the Vector2 hash code as a number
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1969. * @param array defines the source array
  1970. * @param index defines the offset in source array
  1971. * @returns the current Vector2
  1972. */
  1973. toArray(array: FloatArray, index?: number): Vector2;
  1974. /**
  1975. * Copy the current vector to an array
  1976. * @returns a new array with 2 elements: the Vector2 coordinates.
  1977. */
  1978. asArray(): number[];
  1979. /**
  1980. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1981. * @param source defines the source Vector2
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. copyFromFloats(x: number, y: number): Vector2;
  1992. /**
  1993. * Sets the Vector2 coordinates with the given floats
  1994. * @param x defines the first coordinate
  1995. * @param y defines the second coordinate
  1996. * @returns the current updated Vector2
  1997. */
  1998. set(x: number, y: number): Vector2;
  1999. /**
  2000. * Add another vector with the current one
  2001. * @param otherVector defines the other vector
  2002. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2003. */
  2004. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2005. /**
  2006. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @param result defines the target vector
  2009. * @returns the unmodified current Vector2
  2010. */
  2011. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2012. /**
  2013. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns the current updated Vector2
  2016. */
  2017. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns a new Vector2
  2022. */
  2023. addVector3(otherVector: Vector3): Vector2;
  2024. /**
  2025. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. subtract(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Multiplies in place the current Vector2 coordinates by the given ones
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2051. * @param otherVector defines the other vector
  2052. * @returns a new Vector2
  2053. */
  2054. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @param result defines the target vector
  2059. * @returns the unmodified current Vector2
  2060. */
  2061. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2062. /**
  2063. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2064. * @param x defines the first coordinate
  2065. * @param y defines the second coordinate
  2066. * @returns a new Vector2
  2067. */
  2068. multiplyByFloats(x: number, y: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2071. * @param otherVector defines the other vector
  2072. * @returns a new Vector2
  2073. */
  2074. divide(otherVector: Vector2): Vector2;
  2075. /**
  2076. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @param result defines the target vector
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2082. /**
  2083. * Divides the current Vector2 coordinates by the given ones
  2084. * @param otherVector defines the other vector
  2085. * @returns the current updated Vector2
  2086. */
  2087. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2088. /**
  2089. * Gets a new Vector2 with current Vector2 negated coordinates
  2090. * @returns a new Vector2
  2091. */
  2092. negate(): Vector2;
  2093. /**
  2094. * Multiply the Vector2 coordinates by scale
  2095. * @param scale defines the scaling factor
  2096. * @returns the current updated Vector2
  2097. */
  2098. scaleInPlace(scale: number): Vector2;
  2099. /**
  2100. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2101. * @param scale defines the scaling factor
  2102. * @returns a new Vector2
  2103. */
  2104. scale(scale: number): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2114. * @param scale defines the scale factor
  2115. * @param result defines the Vector2 object where to store the result
  2116. * @returns the unmodified current Vector2
  2117. */
  2118. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2119. /**
  2120. * Gets a boolean if two vectors are equals
  2121. * @param otherVector defines the other vector
  2122. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2123. */
  2124. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2125. /**
  2126. * Gets a boolean if two vectors are equals (using an epsilon value)
  2127. * @param otherVector defines the other vector
  2128. * @param epsilon defines the minimal distance to consider equality
  2129. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2130. */
  2131. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2132. /**
  2133. * Gets a new Vector2 from current Vector2 floored values
  2134. * @returns a new Vector2
  2135. */
  2136. floor(): Vector2;
  2137. /**
  2138. * Gets a new Vector2 from current Vector2 floored values
  2139. * @returns a new Vector2
  2140. */
  2141. fract(): Vector2;
  2142. /**
  2143. * Gets the length of the vector
  2144. * @returns the vector length (float)
  2145. */
  2146. length(): number;
  2147. /**
  2148. * Gets the vector squared length
  2149. * @returns the vector squared length (float)
  2150. */
  2151. lengthSquared(): number;
  2152. /**
  2153. * Normalize the vector
  2154. * @returns the current updated Vector2
  2155. */
  2156. normalize(): Vector2;
  2157. /**
  2158. * Gets a new Vector2 copied from the Vector2
  2159. * @returns a new Vector2
  2160. */
  2161. clone(): Vector2;
  2162. /**
  2163. * Gets a new Vector2(0, 0)
  2164. * @returns a new Vector2
  2165. */
  2166. static Zero(): Vector2;
  2167. /**
  2168. * Gets a new Vector2(1, 1)
  2169. * @returns a new Vector2
  2170. */
  2171. static One(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 set from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @returns a new Vector2
  2177. */
  2178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2179. /**
  2180. * Sets "result" from the given index element of the given array
  2181. * @param array defines the data source
  2182. * @param offset defines the offset in the data source
  2183. * @param result defines the target vector
  2184. */
  2185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2186. /**
  2187. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2188. * @param value1 defines 1st point of control
  2189. * @param value2 defines 2nd point of control
  2190. * @param value3 defines 3rd point of control
  2191. * @param value4 defines 4th point of control
  2192. * @param amount defines the interpolation factor
  2193. * @returns a new Vector2
  2194. */
  2195. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2196. /**
  2197. * 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".
  2198. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2199. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2200. * @param value defines the value to clamp
  2201. * @param min defines the lower limit
  2202. * @param max defines the upper limit
  2203. * @returns a new Vector2
  2204. */
  2205. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2208. * @param value1 defines the 1st control point
  2209. * @param tangent1 defines the outgoing tangent
  2210. * @param value2 defines the 2nd control point
  2211. * @param tangent2 defines the incoming tangent
  2212. * @param amount defines the interpolation factor
  2213. * @returns a new Vector2
  2214. */
  2215. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2218. * @param start defines the start vector
  2219. * @param end defines the end vector
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Gets the dot product of the vector "left" and the vector "right"
  2226. * @param left defines first vector
  2227. * @param right defines second vector
  2228. * @returns the dot product (float)
  2229. */
  2230. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2231. /**
  2232. * Returns a new Vector2 equal to the normalized given vector
  2233. * @param vector defines the vector to normalize
  2234. * @returns a new Vector2
  2235. */
  2236. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2246. * @param left defines 1st vector
  2247. * @param right defines 2nd vector
  2248. * @returns a new Vector2
  2249. */
  2250. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2251. /**
  2252. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @returns a new Vector2
  2256. */
  2257. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2258. /**
  2259. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2260. * @param vector defines the vector to transform
  2261. * @param transformation defines the matrix to apply
  2262. * @param result defines the target vector
  2263. */
  2264. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2265. /**
  2266. * Determines if a given vector is included in a triangle
  2267. * @param p defines the vector to test
  2268. * @param p0 defines 1st triangle point
  2269. * @param p1 defines 2nd triangle point
  2270. * @param p2 defines 3rd triangle point
  2271. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2272. */
  2273. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2274. /**
  2275. * Gets the distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the distance between vectors
  2279. */
  2280. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Returns the squared distance between the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns the squared distance between vectors
  2286. */
  2287. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2288. /**
  2289. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2290. * @param value1 defines first vector
  2291. * @param value2 defines second vector
  2292. * @returns a new Vector2
  2293. */
  2294. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2295. /**
  2296. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2297. * @param p defines the middle point
  2298. * @param segA defines one point of the segment
  2299. * @param segB defines the other point of the segment
  2300. * @returns the shortest distance
  2301. */
  2302. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2303. }
  2304. /**
  2305. * Class used to store (x,y,z) vector representation
  2306. * A Vector3 is the main object used in 3D geometry
  2307. * It can represent etiher the coordinates of a point the space, either a direction
  2308. * Reminder: js uses a left handed forward facing system
  2309. */
  2310. export class Vector3 {
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x: number;
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y: number;
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z: number;
  2323. private static _UpReadOnly;
  2324. private static _ZeroReadOnly;
  2325. /**
  2326. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2327. * @param x defines the first coordinates (on X axis)
  2328. * @param y defines the second coordinates (on Y axis)
  2329. * @param z defines the third coordinates (on Z axis)
  2330. */
  2331. constructor(
  2332. /**
  2333. * Defines the first coordinates (on X axis)
  2334. */
  2335. x?: number,
  2336. /**
  2337. * Defines the second coordinates (on Y axis)
  2338. */
  2339. y?: number,
  2340. /**
  2341. * Defines the third coordinates (on Z axis)
  2342. */
  2343. z?: number);
  2344. /**
  2345. * Creates a string representation of the Vector3
  2346. * @returns a string with the Vector3 coordinates.
  2347. */
  2348. toString(): string;
  2349. /**
  2350. * Gets the class name
  2351. * @returns the string "Vector3"
  2352. */
  2353. getClassName(): string;
  2354. /**
  2355. * Creates the Vector3 hash code
  2356. * @returns a number which tends to be unique between Vector3 instances
  2357. */
  2358. getHashCode(): number;
  2359. /**
  2360. * Creates an array containing three elements : the coordinates of the Vector3
  2361. * @returns a new array of numbers
  2362. */
  2363. asArray(): number[];
  2364. /**
  2365. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2366. * @param array defines the destination array
  2367. * @param index defines the offset in the destination array
  2368. * @returns the current Vector3
  2369. */
  2370. toArray(array: FloatArray, index?: number): Vector3;
  2371. /**
  2372. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2373. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2374. */
  2375. toQuaternion(): Quaternion;
  2376. /**
  2377. * Adds the given vector to the current Vector3
  2378. * @param otherVector defines the second operand
  2379. * @returns the current updated Vector3
  2380. */
  2381. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2382. /**
  2383. * Adds the given coordinates to the current Vector3
  2384. * @param x defines the x coordinate of the operand
  2385. * @param y defines the y coordinate of the operand
  2386. * @param z defines the z coordinate of the operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2390. /**
  2391. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2392. * @param otherVector defines the second operand
  2393. * @returns the resulting Vector3
  2394. */
  2395. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2396. /**
  2397. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2398. * @param otherVector defines the second operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2403. /**
  2404. * Subtract the given vector from the current Vector3
  2405. * @param otherVector defines the second operand
  2406. * @returns the current updated Vector3
  2407. */
  2408. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2411. * @param otherVector defines the second operand
  2412. * @returns the resulting Vector3
  2413. */
  2414. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2415. /**
  2416. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2417. * @param otherVector defines the second operand
  2418. * @param result defines the Vector3 object where to store the result
  2419. * @returns the current Vector3
  2420. */
  2421. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2422. /**
  2423. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2430. /**
  2431. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2439. /**
  2440. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2441. * @returns a new Vector3
  2442. */
  2443. negate(): Vector3;
  2444. /**
  2445. * Multiplies the Vector3 coordinates by the float "scale"
  2446. * @param scale defines the multiplier factor
  2447. * @returns the current updated Vector3
  2448. */
  2449. scaleInPlace(scale: number): Vector3;
  2450. /**
  2451. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2452. * @param scale defines the multiplier factor
  2453. * @returns a new Vector3
  2454. */
  2455. scale(scale: number): Vector3;
  2456. /**
  2457. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2458. * @param scale defines the multiplier factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. scaleToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2465. * @param scale defines the scale factor
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the unmodified current Vector3
  2468. */
  2469. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2470. /**
  2471. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2472. * @param otherVector defines the second operand
  2473. * @returns true if both vectors are equals
  2474. */
  2475. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2478. * @param otherVector defines the second operand
  2479. * @param epsilon defines the minimal distance to define values as equals
  2480. * @returns true if both vectors are distant less than epsilon
  2481. */
  2482. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2483. /**
  2484. * Returns true if the current Vector3 coordinates equals the given floats
  2485. * @param x defines the x coordinate of the operand
  2486. * @param y defines the y coordinate of the operand
  2487. * @param z defines the z coordinate of the operand
  2488. * @returns true if both vectors are equals
  2489. */
  2490. equalsToFloats(x: number, y: number, z: number): boolean;
  2491. /**
  2492. * Multiplies the current Vector3 coordinates by the given ones
  2493. * @param otherVector defines the second operand
  2494. * @returns the current updated Vector3
  2495. */
  2496. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2497. /**
  2498. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2499. * @param otherVector defines the second operand
  2500. * @returns the new Vector3
  2501. */
  2502. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2505. * @param otherVector defines the second operand
  2506. * @param result defines the Vector3 object where to store the result
  2507. * @returns the current Vector3
  2508. */
  2509. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2510. /**
  2511. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the new Vector3
  2516. */
  2517. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Divides the current Vector3 coordinates by the given ones.
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. divideInPlace(otherVector: Vector3): Vector3;
  2537. /**
  2538. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2539. * @param other defines the second operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2545. * @param other defines the second operand
  2546. * @returns the current updated Vector3
  2547. */
  2548. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2549. /**
  2550. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2551. * @param x defines the x coordinate of the operand
  2552. * @param y defines the y coordinate of the operand
  2553. * @param z defines the z coordinate of the operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2567. * Check if is non uniform within a certain amount of decimal places to account for this
  2568. * @param epsilon the amount the values can differ
  2569. * @returns if the the vector is non uniform to a certain number of decimal places
  2570. */
  2571. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2572. /**
  2573. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2574. */
  2575. get isNonUniform(): boolean;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. floor(): Vector3;
  2581. /**
  2582. * Gets a new Vector3 from current Vector3 floored values
  2583. * @returns a new Vector3
  2584. */
  2585. fract(): Vector3;
  2586. /**
  2587. * Gets the length of the Vector3
  2588. * @returns the length of the Vector3
  2589. */
  2590. length(): number;
  2591. /**
  2592. * Gets the squared length of the Vector3
  2593. * @returns squared length of the Vector3
  2594. */
  2595. lengthSquared(): number;
  2596. /**
  2597. * Normalize the current Vector3.
  2598. * Please note that this is an in place operation.
  2599. * @returns the current updated Vector3
  2600. */
  2601. normalize(): Vector3;
  2602. /**
  2603. * Reorders the x y z properties of the vector in place
  2604. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2605. * @returns the current updated vector
  2606. */
  2607. reorderInPlace(order: string): this;
  2608. /**
  2609. * Rotates the vector around 0,0,0 by a quaternion
  2610. * @param quaternion the rotation quaternion
  2611. * @param result vector to store the result
  2612. * @returns the resulting vector
  2613. */
  2614. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2615. /**
  2616. * Rotates a vector around a given point
  2617. * @param quaternion the rotation quaternion
  2618. * @param point the point to rotate around
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2623. /**
  2624. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2625. * The cross product is then orthogonal to both current and "other"
  2626. * @param other defines the right operand
  2627. * @returns the cross product
  2628. */
  2629. cross(other: Vector3): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 with the given input length.
  2632. * Please note that this is an in place operation.
  2633. * @param len the length of the vector
  2634. * @returns the current updated Vector3
  2635. */
  2636. normalizeFromLength(len: number): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to a new vector
  2639. * @returns the new Vector3
  2640. */
  2641. normalizeToNew(): Vector3;
  2642. /**
  2643. * Normalize the current Vector3 to the reference
  2644. * @param reference define the Vector3 to update
  2645. * @returns the updated Vector3
  2646. */
  2647. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2648. /**
  2649. * Creates a new Vector3 copied from the current Vector3
  2650. * @returns the new Vector3
  2651. */
  2652. clone(): Vector3;
  2653. /**
  2654. * Copies the given vector coordinates to the current Vector3 ones
  2655. * @param source defines the source Vector3
  2656. * @returns the current updated Vector3
  2657. */
  2658. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2659. /**
  2660. * Copies the given floats to the current Vector3 coordinates
  2661. * @param x defines the x coordinate of the operand
  2662. * @param y defines the y coordinate of the operand
  2663. * @param z defines the z coordinate of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFromFloats(x: number, y: number, z: number): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. set(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given float to the current Vector3 coordinates
  2677. * @param v defines the x, y and z coordinates of the operand
  2678. * @returns the current updated Vector3
  2679. */
  2680. setAll(v: number): Vector3;
  2681. /**
  2682. * Get the clip factor between two vectors
  2683. * @param vector0 defines the first operand
  2684. * @param vector1 defines the second operand
  2685. * @param axis defines the axis to use
  2686. * @param size defines the size along the axis
  2687. * @returns the clip factor
  2688. */
  2689. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2690. /**
  2691. * Get angle between two vectors
  2692. * @param vector0 angle between vector0 and vector1
  2693. * @param vector1 angle between vector0 and vector1
  2694. * @param normal direction of the normal
  2695. * @return the angle between vector0 and vector1
  2696. */
  2697. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. */
  2704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2707. * @param array defines the source array
  2708. * @param offset defines the offset in the source array
  2709. * @returns the new Vector3
  2710. * @deprecated Please use FromArray instead.
  2711. */
  2712. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. */
  2719. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2720. /**
  2721. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2722. * @param array defines the source array
  2723. * @param offset defines the offset in the source array
  2724. * @param result defines the Vector3 where to store the result
  2725. * @deprecated Please use FromArrayToRef instead.
  2726. */
  2727. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the given floats.
  2730. * @param x defines the x coordinate of the source
  2731. * @param y defines the y coordinate of the source
  2732. * @param z defines the z coordinate of the source
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2738. * @returns a new empty Vector3
  2739. */
  2740. static Zero(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2743. * @returns a new unit Vector3
  2744. */
  2745. static One(): Vector3;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2748. * @returns a new up Vector3
  2749. */
  2750. static Up(): Vector3;
  2751. /**
  2752. * Gets a up Vector3 that must not be updated
  2753. */
  2754. static get UpReadOnly(): DeepImmutable<Vector3>;
  2755. /**
  2756. * Gets a zero Vector3 that must not be updated
  2757. */
  2758. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2761. * @returns a new down Vector3
  2762. */
  2763. static Down(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Forward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2771. * @returns a new forward Vector3
  2772. */
  2773. static Backward(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2776. * @returns a new right Vector3
  2777. */
  2778. static Right(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2781. * @returns a new left Vector3
  2782. */
  2783. static Left(): Vector3;
  2784. /**
  2785. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2786. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2787. * @param vector defines the Vector3 to transform
  2788. * @param transformation defines the transformation matrix
  2789. * @returns the transformed Vector3
  2790. */
  2791. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2792. /**
  2793. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2802. * This method computes tranformed coordinates only, not transformed direction vectors
  2803. * @param x define the x coordinate of the source vector
  2804. * @param y define the y coordinate of the source vector
  2805. * @param z define the z coordinate of the source vector
  2806. * @param transformation defines the transformation matrix
  2807. * @param result defines the Vector3 where to store the result
  2808. */
  2809. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2812. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the new Vector3
  2816. */
  2817. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  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 TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2838. * @param value1 defines the first control point
  2839. * @param value2 defines the second control point
  2840. * @param value3 defines the third control point
  2841. * @param value4 defines the fourth control point
  2842. * @param amount defines the amount on the spline to use
  2843. * @returns the new Vector3
  2844. */
  2845. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @returns the new Vector3
  2854. */
  2855. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2856. /**
  2857. * 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"
  2858. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2859. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2860. * @param value defines the current value
  2861. * @param min defines the lower range value
  2862. * @param max defines the upper range value
  2863. * @param result defines the Vector3 where to store the result
  2864. */
  2865. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2866. /**
  2867. * Checks if a given vector is inside a specific range
  2868. * @param v defines the vector to test
  2869. * @param min defines the minimum range
  2870. * @param max defines the maximum range
  2871. */
  2872. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2875. * @param value1 defines the first control point
  2876. * @param tangent1 defines the first tangent vector
  2877. * @param value2 defines the second control point
  2878. * @param tangent2 defines the second tangent vector
  2879. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2880. * @returns the new Vector3
  2881. */
  2882. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2883. /**
  2884. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2885. * @param start defines the start value
  2886. * @param end defines the end value
  2887. * @param amount max defines amount between both (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @param result defines the Vector3 where to store the result
  2897. */
  2898. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2899. /**
  2900. * Returns the dot product (float) between the vectors "left" and "right"
  2901. * @param left defines the left operand
  2902. * @param right defines the right operand
  2903. * @returns the dot product
  2904. */
  2905. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2906. /**
  2907. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2908. * The cross product is then orthogonal to both "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the cross product
  2912. */
  2913. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the cross product of "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2922. /**
  2923. * Returns a new Vector3 as the normalization of the given vector
  2924. * @param vector defines the Vector3 to normalize
  2925. * @returns the new Vector3
  2926. */
  2927. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2928. /**
  2929. * Sets the given vector "result" with the normalization of the given first vector
  2930. * @param vector defines the Vector3 to normalize
  2931. * @param result defines the Vector3 where to store the result
  2932. */
  2933. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2934. /**
  2935. * Project a Vector3 onto screen space
  2936. * @param vector defines the Vector3 to project
  2937. * @param world defines the world matrix to use
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @param viewport defines the screen viewport to use
  2940. * @returns the new Vector3
  2941. */
  2942. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2943. /** @hidden */
  2944. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param transform defines the transform (view x projection) matrix to use
  2952. * @returns the new Vector3
  2953. */
  2954. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Unproject from screen space to object space
  2957. * @param source defines the screen space Vector3 to use
  2958. * @param viewportWidth defines the current width of the viewport
  2959. * @param viewportHeight defines the current height of the viewport
  2960. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2961. * @param view defines the view matrix to use
  2962. * @param projection defines the projection matrix to use
  2963. * @returns the new Vector3
  2964. */
  2965. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Unproject from screen space to object space
  2979. * @param sourceX defines the screen space x coordinate to use
  2980. * @param sourceY defines the screen space y coordinate to use
  2981. * @param sourceZ defines the screen space z coordinate to use
  2982. * @param viewportWidth defines the current width of the viewport
  2983. * @param viewportHeight defines the current height of the viewport
  2984. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2985. * @param view defines the view matrix to use
  2986. * @param projection defines the projection matrix to use
  2987. * @param result defines the Vector3 where to store the result
  2988. */
  2989. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2990. /**
  2991. * Gets the minimal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Gets the maximal coordinate values between two Vector3
  2999. * @param left defines the first operand
  3000. * @param right defines the second operand
  3001. * @returns the new Vector3
  3002. */
  3003. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * Returns the distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the distance
  3009. */
  3010. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns the squared distance between the vectors "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the squared distance
  3016. */
  3017. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3018. /**
  3019. * Returns a new Vector3 located at the center between "value1" and "value2"
  3020. * @param value1 defines the first operand
  3021. * @param value2 defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3027. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3028. * to something in order to rotate it from its local system to the given target system
  3029. * Note: axis1, axis2 and axis3 are normalized during this operation
  3030. * @param axis1 defines the first axis
  3031. * @param axis2 defines the second axis
  3032. * @param axis3 defines the third axis
  3033. * @returns a new Vector3
  3034. */
  3035. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3036. /**
  3037. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @param ref defines the Vector3 where to store the result
  3042. */
  3043. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3044. }
  3045. /**
  3046. * Vector4 class created for EulerAngle class conversion to Quaternion
  3047. */
  3048. export class Vector4 {
  3049. /** x value of the vector */
  3050. x: number;
  3051. /** y value of the vector */
  3052. y: number;
  3053. /** z value of the vector */
  3054. z: number;
  3055. /** w value of the vector */
  3056. w: number;
  3057. /**
  3058. * Creates a Vector4 object from the given floats.
  3059. * @param x x value of the vector
  3060. * @param y y value of the vector
  3061. * @param z z value of the vector
  3062. * @param w w value of the vector
  3063. */
  3064. constructor(
  3065. /** x value of the vector */
  3066. x: number,
  3067. /** y value of the vector */
  3068. y: number,
  3069. /** z value of the vector */
  3070. z: number,
  3071. /** w value of the vector */
  3072. w: number);
  3073. /**
  3074. * Returns the string with the Vector4 coordinates.
  3075. * @returns a string containing all the vector values
  3076. */
  3077. toString(): string;
  3078. /**
  3079. * Returns the string "Vector4".
  3080. * @returns "Vector4"
  3081. */
  3082. getClassName(): string;
  3083. /**
  3084. * Returns the Vector4 hash code.
  3085. * @returns a unique hash code
  3086. */
  3087. getHashCode(): number;
  3088. /**
  3089. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3090. * @returns the resulting array
  3091. */
  3092. asArray(): number[];
  3093. /**
  3094. * Populates the given array from the given index with the Vector4 coordinates.
  3095. * @param array array to populate
  3096. * @param index index of the array to start at (default: 0)
  3097. * @returns the Vector4.
  3098. */
  3099. toArray(array: FloatArray, index?: number): Vector4;
  3100. /**
  3101. * Adds the given vector to the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the updated Vector4.
  3104. */
  3105. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3108. * @param otherVector the vector to add
  3109. * @returns the resulting vector
  3110. */
  3111. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3114. * @param otherVector the vector to add
  3115. * @param result the vector to store the result
  3116. * @returns the current Vector4.
  3117. */
  3118. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3119. /**
  3120. * Subtract in place the given vector from the current Vector4.
  3121. * @param otherVector the vector to subtract
  3122. * @returns the updated Vector4.
  3123. */
  3124. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3127. * @param otherVector the vector to add
  3128. * @returns the new vector with the result
  3129. */
  3130. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3133. * @param otherVector the vector to subtract
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. */
  3141. /**
  3142. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3143. * @param x value to subtract
  3144. * @param y value to subtract
  3145. * @param z value to subtract
  3146. * @param w value to subtract
  3147. * @returns new vector containing the result
  3148. */
  3149. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3150. /**
  3151. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3152. * @param x value to subtract
  3153. * @param y value to subtract
  3154. * @param z value to subtract
  3155. * @param w value to subtract
  3156. * @param result the vector to store the result in
  3157. * @returns the current Vector4.
  3158. */
  3159. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3160. /**
  3161. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3162. * @returns a new vector with the negated values
  3163. */
  3164. negate(): Vector4;
  3165. /**
  3166. * Multiplies the current Vector4 coordinates by scale (float).
  3167. * @param scale the number to scale with
  3168. * @returns the updated Vector4.
  3169. */
  3170. scaleInPlace(scale: number): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns a new vector with the result
  3175. */
  3176. scale(scale: number): Vector4;
  3177. /**
  3178. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @param result a vector to store the result in
  3181. * @returns the current Vector4.
  3182. */
  3183. scaleToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3186. * @param scale defines the scale factor
  3187. * @param result defines the Vector4 object where to store the result
  3188. * @returns the unmodified current Vector4
  3189. */
  3190. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3191. /**
  3192. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3193. * @param otherVector the vector to compare against
  3194. * @returns true if they are equal
  3195. */
  3196. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3199. * @param otherVector vector to compare against
  3200. * @param epsilon (Default: very small number)
  3201. * @returns true if they are equal
  3202. */
  3203. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3204. /**
  3205. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3206. * @param x x value to compare against
  3207. * @param y y value to compare against
  3208. * @param z z value to compare against
  3209. * @param w w value to compare against
  3210. * @returns true if equal
  3211. */
  3212. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3213. /**
  3214. * Multiplies in place the current Vector4 by the given one.
  3215. * @param otherVector vector to multiple with
  3216. * @returns the updated Vector4.
  3217. */
  3218. multiplyInPlace(otherVector: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns resulting new vector
  3223. */
  3224. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @param result vector to store the result
  3229. * @returns the current Vector4.
  3230. */
  3231. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3232. /**
  3233. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3234. * @param x x value multiply with
  3235. * @param y y value multiply with
  3236. * @param z z value multiply with
  3237. * @param w w value multiply with
  3238. * @returns resulting new vector
  3239. */
  3240. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3241. /**
  3242. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3243. * @param otherVector vector to devide with
  3244. * @returns resulting new vector
  3245. */
  3246. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @param result vector to store the result
  3251. * @returns the current Vector4.
  3252. */
  3253. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3254. /**
  3255. * Divides the current Vector3 coordinates by the given ones.
  3256. * @param otherVector vector to devide with
  3257. * @returns the updated Vector3.
  3258. */
  3259. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3260. /**
  3261. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3262. * @param other defines the second operand
  3263. * @returns the current updated Vector4
  3264. */
  3265. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Gets a new Vector4 from current Vector4 floored values
  3274. * @returns a new Vector4
  3275. */
  3276. floor(): Vector4;
  3277. /**
  3278. * Gets a new Vector4 from current Vector3 floored values
  3279. * @returns a new Vector4
  3280. */
  3281. fract(): Vector4;
  3282. /**
  3283. * Returns the Vector4 length (float).
  3284. * @returns the length
  3285. */
  3286. length(): number;
  3287. /**
  3288. * Returns the Vector4 squared length (float).
  3289. * @returns the length squared
  3290. */
  3291. lengthSquared(): number;
  3292. /**
  3293. * Normalizes in place the Vector4.
  3294. * @returns the updated Vector4.
  3295. */
  3296. normalize(): Vector4;
  3297. /**
  3298. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3299. * @returns this converted to a new vector3
  3300. */
  3301. toVector3(): Vector3;
  3302. /**
  3303. * Returns a new Vector4 copied from the current one.
  3304. * @returns the new cloned vector
  3305. */
  3306. clone(): Vector4;
  3307. /**
  3308. * Updates the current Vector4 with the given one coordinates.
  3309. * @param source the source vector to copy from
  3310. * @returns the updated Vector4.
  3311. */
  3312. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Updates the current Vector4 coordinates with the given floats.
  3315. * @param x float to copy from
  3316. * @param y float to copy from
  3317. * @param z float to copy from
  3318. * @param w float to copy from
  3319. * @returns the updated Vector4.
  3320. */
  3321. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3322. /**
  3323. * Updates the current Vector4 coordinates with the given floats.
  3324. * @param x float to set from
  3325. * @param y float to set from
  3326. * @param z float to set from
  3327. * @param w float to set from
  3328. * @returns the updated Vector4.
  3329. */
  3330. set(x: number, y: number, z: number, w: number): Vector4;
  3331. /**
  3332. * Copies the given float to the current Vector3 coordinates
  3333. * @param v defines the x, y, z and w coordinates of the operand
  3334. * @returns the current updated Vector3
  3335. */
  3336. setAll(v: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @returns the new vector
  3342. */
  3343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" from the starting index of the given Float32Array.
  3353. * @param array the array to pull values from
  3354. * @param offset the offset into the array to start at
  3355. * @param result the vector to store the result in
  3356. */
  3357. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3358. /**
  3359. * Updates the given vector "result" coordinates from the given floats.
  3360. * @param x float to set from
  3361. * @param y float to set from
  3362. * @param z float to set from
  3363. * @param w float to set from
  3364. * @param result the vector to the floats in
  3365. */
  3366. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3367. /**
  3368. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3369. * @returns the new vector
  3370. */
  3371. static Zero(): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3374. * @returns the new vector
  3375. */
  3376. static One(): Vector4;
  3377. /**
  3378. * Returns a new normalized Vector4 from the given one.
  3379. * @param vector the vector to normalize
  3380. * @returns the vector
  3381. */
  3382. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Updates the given vector "result" from the normalization of the given one.
  3385. * @param vector the vector to normalize
  3386. * @param result the vector to store the result in
  3387. */
  3388. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3389. /**
  3390. * Returns a vector with the minimum values from the left and right vectors
  3391. * @param left left vector to minimize
  3392. * @param right right vector to minimize
  3393. * @returns a new vector with the minimum of the left and right vector values
  3394. */
  3395. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns a vector with the maximum values from the left and right vectors
  3398. * @param left left vector to maximize
  3399. * @param right right vector to maximize
  3400. * @returns a new vector with the maximum of the left and right vector values
  3401. */
  3402. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Returns the distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors
  3408. */
  3409. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the distance between
  3413. * @param value2 value to calulate the distance between
  3414. * @return the distance between the two vectors squared
  3415. */
  3416. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3417. /**
  3418. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3419. * @param value1 value to calulate the center between
  3420. * @param value2 value to calulate the center between
  3421. * @return the center between the two vectors
  3422. */
  3423. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3426. * This methods computes transformed normalized direction vectors only.
  3427. * @param vector the vector to transform
  3428. * @param transformation the transformation matrix to apply
  3429. * @returns the new vector
  3430. */
  3431. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3432. /**
  3433. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3434. * This methods computes transformed normalized direction vectors only.
  3435. * @param vector the vector to transform
  3436. * @param transformation the transformation matrix to apply
  3437. * @param result the vector to store the result in
  3438. */
  3439. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3440. /**
  3441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param x value to transform
  3444. * @param y value to transform
  3445. * @param z value to transform
  3446. * @param w value to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @param result the vector to store the results in
  3449. */
  3450. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3451. /**
  3452. * Creates a new Vector4 from a Vector3
  3453. * @param source defines the source data
  3454. * @param w defines the 4th component (default is 0)
  3455. * @returns a new Vector4
  3456. */
  3457. static FromVector3(source: Vector3, w?: number): Vector4;
  3458. }
  3459. /**
  3460. * Class used to store quaternion data
  3461. * @see https://en.wikipedia.org/wiki/Quaternion
  3462. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3463. */
  3464. export class Quaternion {
  3465. /** defines the first component (0 by default) */
  3466. x: number;
  3467. /** defines the second component (0 by default) */
  3468. y: number;
  3469. /** defines the third component (0 by default) */
  3470. z: number;
  3471. /** defines the fourth component (1.0 by default) */
  3472. w: number;
  3473. /**
  3474. * Creates a new Quaternion from the given floats
  3475. * @param x defines the first component (0 by default)
  3476. * @param y defines the second component (0 by default)
  3477. * @param z defines the third component (0 by default)
  3478. * @param w defines the fourth component (1.0 by default)
  3479. */
  3480. constructor(
  3481. /** defines the first component (0 by default) */
  3482. x?: number,
  3483. /** defines the second component (0 by default) */
  3484. y?: number,
  3485. /** defines the third component (0 by default) */
  3486. z?: number,
  3487. /** defines the fourth component (1.0 by default) */
  3488. w?: number);
  3489. /**
  3490. * Gets a string representation for the current quaternion
  3491. * @returns a string with the Quaternion coordinates
  3492. */
  3493. toString(): string;
  3494. /**
  3495. * Gets the class name of the quaternion
  3496. * @returns the string "Quaternion"
  3497. */
  3498. getClassName(): string;
  3499. /**
  3500. * Gets a hash code for this quaternion
  3501. * @returns the quaternion hash code
  3502. */
  3503. getHashCode(): number;
  3504. /**
  3505. * Copy the quaternion to an array
  3506. * @returns a new array populated with 4 elements from the quaternion coordinates
  3507. */
  3508. asArray(): number[];
  3509. /**
  3510. * Check if two quaternions are equals
  3511. * @param otherQuaternion defines the second operand
  3512. * @return true if the current quaternion and the given one coordinates are strictly equals
  3513. */
  3514. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3515. /**
  3516. * Clone the current quaternion
  3517. * @returns a new quaternion copied from the current one
  3518. */
  3519. clone(): Quaternion;
  3520. /**
  3521. * Copy a quaternion to the current one
  3522. * @param other defines the other quaternion
  3523. * @returns the updated current quaternion
  3524. */
  3525. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Updates the current quaternion with the given float coordinates
  3528. * @param x defines the x coordinate
  3529. * @param y defines the y coordinate
  3530. * @param z defines the z coordinate
  3531. * @param w defines the w coordinate
  3532. * @returns the updated current quaternion
  3533. */
  3534. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3535. /**
  3536. * Updates the current quaternion from the given float coordinates
  3537. * @param x defines the x coordinate
  3538. * @param y defines the y coordinate
  3539. * @param z defines the z coordinate
  3540. * @param w defines the w coordinate
  3541. * @returns the updated current quaternion
  3542. */
  3543. set(x: number, y: number, z: number, w: number): Quaternion;
  3544. /**
  3545. * Adds two quaternions
  3546. * @param other defines the second operand
  3547. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3548. */
  3549. add(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Add a quaternion to the current one
  3552. * @param other defines the quaternion to add
  3553. * @returns the current quaternion
  3554. */
  3555. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3556. /**
  3557. * Subtract two quaternions
  3558. * @param other defines the second operand
  3559. * @returns a new quaternion as the subtraction result of the given one from the current one
  3560. */
  3561. subtract(other: Quaternion): Quaternion;
  3562. /**
  3563. * Multiplies the current quaternion by a scale factor
  3564. * @param value defines the scale factor
  3565. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3566. */
  3567. scale(value: number): Quaternion;
  3568. /**
  3569. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3570. * @param scale defines the scale factor
  3571. * @param result defines the Quaternion object where to store the result
  3572. * @returns the unmodified current quaternion
  3573. */
  3574. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies in place the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns the current modified quaternion
  3579. */
  3580. scaleInPlace(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies two quaternions
  3590. * @param q1 defines the second operand
  3591. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3592. */
  3593. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @param result defines the target quaternion
  3598. * @returns the current quaternion
  3599. */
  3600. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3601. /**
  3602. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3603. * @param q1 defines the second operand
  3604. * @returns the currentupdated quaternion
  3605. */
  3606. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3609. * @param ref defines the target quaternion
  3610. * @returns the current quaternion
  3611. */
  3612. conjugateToRef(ref: Quaternion): Quaternion;
  3613. /**
  3614. * Conjugates in place (1-q) the current quaternion
  3615. * @returns the current updated quaternion
  3616. */
  3617. conjugateInPlace(): Quaternion;
  3618. /**
  3619. * Conjugates in place (1-q) the current quaternion
  3620. * @returns a new quaternion
  3621. */
  3622. conjugate(): Quaternion;
  3623. /**
  3624. * Gets length of current quaternion
  3625. * @returns the quaternion length (float)
  3626. */
  3627. length(): number;
  3628. /**
  3629. * Normalize in place the current quaternion
  3630. * @returns the current updated quaternion
  3631. */
  3632. normalize(): Quaternion;
  3633. /**
  3634. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns a new Vector3 containing the Euler angles
  3637. */
  3638. toEulerAngles(order?: string): Vector3;
  3639. /**
  3640. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3641. * @param result defines the vector which will be filled with the Euler angles
  3642. * @param order is a reserved parameter and is ignore for now
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toEulerAnglesToRef(result: Vector3): Quaternion;
  3646. /**
  3647. * Updates the given rotation matrix with the current quaternion values
  3648. * @param result defines the target matrix
  3649. * @returns the current unchanged quaternion
  3650. */
  3651. toRotationMatrix(result: Matrix): Quaternion;
  3652. /**
  3653. * Updates the current quaternion from the given rotation matrix values
  3654. * @param matrix defines the source matrix
  3655. * @returns the current updated quaternion
  3656. */
  3657. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Creates a new quaternion from a rotation matrix
  3660. * @param matrix defines the source matrix
  3661. * @returns a new quaternion created from the given rotation matrix values
  3662. */
  3663. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3664. /**
  3665. * Updates the given quaternion with the given rotation matrix values
  3666. * @param matrix defines the source matrix
  3667. * @param result defines the target quaternion
  3668. */
  3669. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3670. /**
  3671. * Returns the dot product (float) between the quaternions "left" and "right"
  3672. * @param left defines the left operand
  3673. * @param right defines the right operand
  3674. * @returns the dot product
  3675. */
  3676. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3677. /**
  3678. * Checks if the two quaternions are close to each other
  3679. * @param quat0 defines the first quaternion to check
  3680. * @param quat1 defines the second quaternion to check
  3681. * @returns true if the two quaternions are close to each other
  3682. */
  3683. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3684. /**
  3685. * Creates an empty quaternion
  3686. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3687. */
  3688. static Zero(): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @returns a new quaternion as the inverted current quaternion
  3693. */
  3694. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Inverse a given quaternion
  3697. * @param q defines the source quaternion
  3698. * @param result the quaternion the result will be stored in
  3699. * @returns the result quaternion
  3700. */
  3701. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates an identity quaternion
  3704. * @returns the identity quaternion
  3705. */
  3706. static Identity(): Quaternion;
  3707. /**
  3708. * Gets a boolean indicating if the given quaternion is identity
  3709. * @param quaternion defines the quaternion to check
  3710. * @returns true if the quaternion is identity
  3711. */
  3712. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3713. /**
  3714. * Creates a quaternion from a rotation around an axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3720. /**
  3721. * Creates a rotation around an axis and stores it into the given quaternion
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle to use
  3724. * @param result defines the target quaternion
  3725. * @returns the target quaternion
  3726. */
  3727. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from data stored into an array
  3730. * @param array defines the data source
  3731. * @param offset defines the offset in the source array where the data starts
  3732. * @returns a new quaternion
  3733. */
  3734. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3735. /**
  3736. * Create a quaternion from Euler rotation angles
  3737. * @param x Pitch
  3738. * @param y Yaw
  3739. * @param z Roll
  3740. * @returns the new Quaternion
  3741. */
  3742. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3743. /**
  3744. * Updates a quaternion from Euler rotation angles
  3745. * @param x Pitch
  3746. * @param y Yaw
  3747. * @param z Roll
  3748. * @param result the quaternion to store the result
  3749. * @returns the updated quaternion
  3750. */
  3751. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3752. /**
  3753. * Create a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation vector
  3760. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3761. * @param result the quaternion to store the result
  3762. * @returns the updated quaternion
  3763. */
  3764. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3767. * @param yaw defines the rotation around Y axis
  3768. * @param pitch defines the rotation around X axis
  3769. * @param roll defines the rotation around Z axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3773. /**
  3774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3775. * @param yaw defines the rotation around Y axis
  3776. * @param pitch defines the rotation around X axis
  3777. * @param roll defines the rotation around Z axis
  3778. * @param result defines the target quaternion
  3779. */
  3780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3781. /**
  3782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3783. * @param alpha defines the rotation around first axis
  3784. * @param beta defines the rotation around second axis
  3785. * @param gamma defines the rotation around third axis
  3786. * @returns the new quaternion
  3787. */
  3788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3789. /**
  3790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3791. * @param alpha defines the rotation around first axis
  3792. * @param beta defines the rotation around second axis
  3793. * @param gamma defines the rotation around third axis
  3794. * @param result defines the target quaternion
  3795. */
  3796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3797. /**
  3798. * 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)
  3799. * @param axis1 defines the first axis
  3800. * @param axis2 defines the second axis
  3801. * @param axis3 defines the third axis
  3802. * @returns the new quaternion
  3803. */
  3804. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3805. /**
  3806. * 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
  3807. * @param axis1 defines the first axis
  3808. * @param axis2 defines the second axis
  3809. * @param axis3 defines the third axis
  3810. * @param ref defines the target quaternion
  3811. */
  3812. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3813. /**
  3814. * Interpolates between two quaternions
  3815. * @param left defines first quaternion
  3816. * @param right defines second quaternion
  3817. * @param amount defines the gradient to use
  3818. * @returns the new interpolated quaternion
  3819. */
  3820. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3821. /**
  3822. * Interpolates between two quaternions and stores it into a target quaternion
  3823. * @param left defines first quaternion
  3824. * @param right defines second quaternion
  3825. * @param amount defines the gradient to use
  3826. * @param result defines the target quaternion
  3827. */
  3828. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3829. /**
  3830. * Interpolate between two quaternions using Hermite interpolation
  3831. * @param value1 defines first quaternion
  3832. * @param tangent1 defines the incoming tangent
  3833. * @param value2 defines second quaternion
  3834. * @param tangent2 defines the outgoing tangent
  3835. * @param amount defines the target quaternion
  3836. * @returns the new interpolated quaternion
  3837. */
  3838. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3839. }
  3840. /**
  3841. * Class used to store matrix data (4x4)
  3842. */
  3843. export class Matrix {
  3844. private static _updateFlagSeed;
  3845. private static _identityReadOnly;
  3846. private _isIdentity;
  3847. private _isIdentityDirty;
  3848. private _isIdentity3x2;
  3849. private _isIdentity3x2Dirty;
  3850. /**
  3851. * Gets the update flag of the matrix which is an unique number for the matrix.
  3852. * It will be incremented every time the matrix data change.
  3853. * You can use it to speed the comparison between two versions of the same matrix.
  3854. */
  3855. updateFlag: number;
  3856. private readonly _m;
  3857. /**
  3858. * Gets the internal data of the matrix
  3859. */
  3860. get m(): DeepImmutable<Float32Array>;
  3861. /** @hidden */
  3862. _markAsUpdated(): void;
  3863. /** @hidden */
  3864. private _updateIdentityStatus;
  3865. /**
  3866. * Creates an empty matrix (filled with zeros)
  3867. */
  3868. constructor();
  3869. /**
  3870. * Check if the current matrix is identity
  3871. * @returns true is the matrix is the identity matrix
  3872. */
  3873. isIdentity(): boolean;
  3874. /**
  3875. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3876. * @returns true is the matrix is the identity matrix
  3877. */
  3878. isIdentityAs3x2(): boolean;
  3879. /**
  3880. * Gets the determinant of the matrix
  3881. * @returns the matrix determinant
  3882. */
  3883. determinant(): number;
  3884. /**
  3885. * Returns the matrix as a Float32Array
  3886. * @returns the matrix underlying array
  3887. */
  3888. toArray(): DeepImmutable<Float32Array>;
  3889. /**
  3890. * Returns the matrix as a Float32Array
  3891. * @returns the matrix underlying array.
  3892. */
  3893. asArray(): DeepImmutable<Float32Array>;
  3894. /**
  3895. * Inverts the current matrix in place
  3896. * @returns the current inverted matrix
  3897. */
  3898. invert(): Matrix;
  3899. /**
  3900. * Sets all the matrix elements to zero
  3901. * @returns the current matrix
  3902. */
  3903. reset(): Matrix;
  3904. /**
  3905. * Adds the current matrix with a second one
  3906. * @param other defines the matrix to add
  3907. * @returns a new matrix as the addition of the current matrix and the given one
  3908. */
  3909. add(other: DeepImmutable<Matrix>): Matrix;
  3910. /**
  3911. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3912. * @param other defines the matrix to add
  3913. * @param result defines the target matrix
  3914. * @returns the current matrix
  3915. */
  3916. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3917. /**
  3918. * Adds in place the given matrix to the current matrix
  3919. * @param other defines the second operand
  3920. * @returns the current updated matrix
  3921. */
  3922. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3923. /**
  3924. * Sets the given matrix to the current inverted Matrix
  3925. * @param other defines the target matrix
  3926. * @returns the unmodified current matrix
  3927. */
  3928. invertToRef(other: Matrix): Matrix;
  3929. /**
  3930. * add a value at the specified position in the current Matrix
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. addAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * mutiply the specified position in the current Matrix by a value
  3938. * @param index the index of the value within the matrix. between 0 and 15.
  3939. * @param value the value to be added
  3940. * @returns the current updated matrix
  3941. */
  3942. multiplyAtIndex(index: number, value: number): Matrix;
  3943. /**
  3944. * Inserts the translation vector (using 3 floats) in the current matrix
  3945. * @param x defines the 1st component of the translation
  3946. * @param y defines the 2nd component of the translation
  3947. * @param z defines the 3rd component of the translation
  3948. * @returns the current updated matrix
  3949. */
  3950. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3951. /**
  3952. * Adds the translation vector (using 3 floats) in the current matrix
  3953. * @param x defines the 1st component of the translation
  3954. * @param y defines the 2nd component of the translation
  3955. * @param z defines the 3rd component of the translation
  3956. * @returns the current updated matrix
  3957. */
  3958. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3959. /**
  3960. * Inserts the translation vector in the current matrix
  3961. * @param vector3 defines the translation to insert
  3962. * @returns the current updated matrix
  3963. */
  3964. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3965. /**
  3966. * Gets the translation value of the current matrix
  3967. * @returns a new Vector3 as the extracted translation from the matrix
  3968. */
  3969. getTranslation(): Vector3;
  3970. /**
  3971. * Fill a Vector3 with the extracted translation from the matrix
  3972. * @param result defines the Vector3 where to store the translation
  3973. * @returns the current matrix
  3974. */
  3975. getTranslationToRef(result: Vector3): Matrix;
  3976. /**
  3977. * Remove rotation and scaling part from the matrix
  3978. * @returns the updated matrix
  3979. */
  3980. removeRotationAndScaling(): Matrix;
  3981. /**
  3982. * Multiply two matrices
  3983. * @param other defines the second operand
  3984. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3985. */
  3986. multiply(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Copy the current matrix from the given one
  3989. * @param other defines the source matrix
  3990. * @returns the current updated matrix
  3991. */
  3992. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3993. /**
  3994. * Populates the given array from the starting index with the current matrix values
  3995. * @param array defines the target array
  3996. * @param offset defines the offset in the target array where to start storing values
  3997. * @returns the current matrix
  3998. */
  3999. copyToArray(array: Float32Array, offset?: number): Matrix;
  4000. /**
  4001. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the matrix where to store the multiplication
  4004. * @returns the current matrix
  4005. */
  4006. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4007. /**
  4008. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4009. * @param other defines the second operand
  4010. * @param result defines the array where to store the multiplication
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4015. /**
  4016. * Check equality between this matrix and a second one
  4017. * @param value defines the second matrix to compare
  4018. * @returns true is the current matrix and the given one values are strictly equal
  4019. */
  4020. equals(value: DeepImmutable<Matrix>): boolean;
  4021. /**
  4022. * Clone the current matrix
  4023. * @returns a new matrix from the current matrix
  4024. */
  4025. clone(): Matrix;
  4026. /**
  4027. * Returns the name of the current matrix class
  4028. * @returns the string "Matrix"
  4029. */
  4030. getClassName(): string;
  4031. /**
  4032. * Gets the hash code of the current matrix
  4033. * @returns the hash code
  4034. */
  4035. getHashCode(): number;
  4036. /**
  4037. * Decomposes the current Matrix into a translation, rotation and scaling components
  4038. * @param scale defines the scale vector3 given as a reference to update
  4039. * @param rotation defines the rotation quaternion given as a reference to update
  4040. * @param translation defines the translation vector3 given as a reference to update
  4041. * @returns true if operation was successful
  4042. */
  4043. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4044. /**
  4045. * Gets specific row of the matrix
  4046. * @param index defines the number of the row to get
  4047. * @returns the index-th row of the current matrix as a new Vector4
  4048. */
  4049. getRow(index: number): Nullable<Vector4>;
  4050. /**
  4051. * Sets the index-th row of the current matrix to the vector4 values
  4052. * @param index defines the number of the row to set
  4053. * @param row defines the target vector4
  4054. * @returns the updated current matrix
  4055. */
  4056. setRow(index: number, row: Vector4): Matrix;
  4057. /**
  4058. * Compute the transpose of the matrix
  4059. * @returns the new transposed matrix
  4060. */
  4061. transpose(): Matrix;
  4062. /**
  4063. * Compute the transpose of the matrix and store it in a given matrix
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. transposeToRef(result: Matrix): Matrix;
  4068. /**
  4069. * Sets the index-th row of the current matrix with the given 4 x float values
  4070. * @param index defines the row index
  4071. * @param x defines the x component to set
  4072. * @param y defines the y component to set
  4073. * @param z defines the z component to set
  4074. * @param w defines the w component to set
  4075. * @returns the updated current matrix
  4076. */
  4077. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4078. /**
  4079. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4080. * @param scale defines the scale factor
  4081. * @returns a new matrix
  4082. */
  4083. scale(scale: number): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor to a given result matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Scale the current matrix values by a factor and add the result to a given matrix
  4093. * @param scale defines the scale factor
  4094. * @param result defines the Matrix to store the result
  4095. * @returns the current matrix
  4096. */
  4097. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4098. /**
  4099. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4100. * @param ref matrix to store the result
  4101. */
  4102. toNormalMatrix(ref: Matrix): void;
  4103. /**
  4104. * Gets only rotation part of the current matrix
  4105. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4106. */
  4107. getRotationMatrix(): Matrix;
  4108. /**
  4109. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4110. * @param result defines the target matrix to store data to
  4111. * @returns the current matrix
  4112. */
  4113. getRotationMatrixToRef(result: Matrix): Matrix;
  4114. /**
  4115. * Toggles model matrix from being right handed to left handed in place and vice versa
  4116. */
  4117. toggleModelMatrixHandInPlace(): void;
  4118. /**
  4119. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4120. */
  4121. toggleProjectionMatrixHandInPlace(): void;
  4122. /**
  4123. * Creates a matrix from an array
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @returns a new Matrix set from the starting index of the given array
  4127. */
  4128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4129. /**
  4130. * Copy the content of an array into a given matrix
  4131. * @param array defines the source array
  4132. * @param offset defines an offset in the source array
  4133. * @param result defines the target matrix
  4134. */
  4135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4136. /**
  4137. * Stores an array into a matrix after having multiplied each component by a given factor
  4138. * @param array defines the source array
  4139. * @param offset defines the offset in the source array
  4140. * @param scale defines the scaling factor
  4141. * @param result defines the target matrix
  4142. */
  4143. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4144. /**
  4145. * Gets an identity matrix that must not be updated
  4146. */
  4147. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4148. /**
  4149. * Stores a list of values (16) inside a given matrix
  4150. * @param initialM11 defines 1st value of 1st row
  4151. * @param initialM12 defines 2nd value of 1st row
  4152. * @param initialM13 defines 3rd value of 1st row
  4153. * @param initialM14 defines 4th value of 1st row
  4154. * @param initialM21 defines 1st value of 2nd row
  4155. * @param initialM22 defines 2nd value of 2nd row
  4156. * @param initialM23 defines 3rd value of 2nd row
  4157. * @param initialM24 defines 4th value of 2nd row
  4158. * @param initialM31 defines 1st value of 3rd row
  4159. * @param initialM32 defines 2nd value of 3rd row
  4160. * @param initialM33 defines 3rd value of 3rd row
  4161. * @param initialM34 defines 4th value of 3rd row
  4162. * @param initialM41 defines 1st value of 4th row
  4163. * @param initialM42 defines 2nd value of 4th row
  4164. * @param initialM43 defines 3rd value of 4th row
  4165. * @param initialM44 defines 4th value of 4th row
  4166. * @param result defines the target matrix
  4167. */
  4168. 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;
  4169. /**
  4170. * Creates new matrix from a list of values (16)
  4171. * @param initialM11 defines 1st value of 1st row
  4172. * @param initialM12 defines 2nd value of 1st row
  4173. * @param initialM13 defines 3rd value of 1st row
  4174. * @param initialM14 defines 4th value of 1st row
  4175. * @param initialM21 defines 1st value of 2nd row
  4176. * @param initialM22 defines 2nd value of 2nd row
  4177. * @param initialM23 defines 3rd value of 2nd row
  4178. * @param initialM24 defines 4th value of 2nd row
  4179. * @param initialM31 defines 1st value of 3rd row
  4180. * @param initialM32 defines 2nd value of 3rd row
  4181. * @param initialM33 defines 3rd value of 3rd row
  4182. * @param initialM34 defines 4th value of 3rd row
  4183. * @param initialM41 defines 1st value of 4th row
  4184. * @param initialM42 defines 2nd value of 4th row
  4185. * @param initialM43 defines 3rd value of 4th row
  4186. * @param initialM44 defines 4th value of 4th row
  4187. * @returns the new matrix
  4188. */
  4189. 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;
  4190. /**
  4191. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4192. * @param scale defines the scale vector3
  4193. * @param rotation defines the rotation quaternion
  4194. * @param translation defines the translation vector3
  4195. * @returns a new matrix
  4196. */
  4197. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4198. /**
  4199. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4200. * @param scale defines the scale vector3
  4201. * @param rotation defines the rotation quaternion
  4202. * @param translation defines the translation vector3
  4203. * @param result defines the target matrix
  4204. */
  4205. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4206. /**
  4207. * Creates a new identity matrix
  4208. * @returns a new identity matrix
  4209. */
  4210. static Identity(): Matrix;
  4211. /**
  4212. * Creates a new identity matrix and stores the result in a given matrix
  4213. * @param result defines the target matrix
  4214. */
  4215. static IdentityToRef(result: Matrix): void;
  4216. /**
  4217. * Creates a new zero matrix
  4218. * @returns a new zero matrix
  4219. */
  4220. static Zero(): Matrix;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the X axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationX(angle: number): Matrix;
  4227. /**
  4228. * Creates a new matrix as the invert of a given matrix
  4229. * @param source defines the source matrix
  4230. * @returns the new matrix
  4231. */
  4232. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4235. * @param angle defines the angle (in radians) to use
  4236. * @param result defines the target matrix
  4237. */
  4238. static RotationXToRef(angle: number, result: Matrix): void;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis
  4241. * @param angle defines the angle (in radians) to use
  4242. * @return the new matrix
  4243. */
  4244. static RotationY(angle: number): Matrix;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4247. * @param angle defines the angle (in radians) to use
  4248. * @param result defines the target matrix
  4249. */
  4250. static RotationYToRef(angle: number, result: Matrix): void;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis
  4253. * @param angle defines the angle (in radians) to use
  4254. * @return the new matrix
  4255. */
  4256. static RotationZ(angle: number): Matrix;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4259. * @param angle defines the angle (in radians) to use
  4260. * @param result defines the target matrix
  4261. */
  4262. static RotationZToRef(angle: number, result: Matrix): void;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @return the new matrix
  4268. */
  4269. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4270. /**
  4271. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4272. * @param axis defines the axis to use
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4277. /**
  4278. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4279. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4280. * @param from defines the vector to align
  4281. * @param to defines the vector to align to
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4285. /**
  4286. * Creates a rotation matrix
  4287. * @param yaw defines the yaw angle in radians (Y axis)
  4288. * @param pitch defines the pitch angle in radians (X axis)
  4289. * @param roll defines the roll angle in radians (X axis)
  4290. * @returns the new rotation matrix
  4291. */
  4292. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4293. /**
  4294. * Creates a rotation matrix and stores it in a given matrix
  4295. * @param yaw defines the yaw angle in radians (Y axis)
  4296. * @param pitch defines the pitch angle in radians (X axis)
  4297. * @param roll defines the roll angle in radians (X axis)
  4298. * @param result defines the target matrix
  4299. */
  4300. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4301. /**
  4302. * Creates a scaling matrix
  4303. * @param x defines the scale factor on X axis
  4304. * @param y defines the scale factor on Y axis
  4305. * @param z defines the scale factor on Z axis
  4306. * @returns the new matrix
  4307. */
  4308. static Scaling(x: number, y: number, z: number): Matrix;
  4309. /**
  4310. * Creates a scaling matrix and stores it in a given matrix
  4311. * @param x defines the scale factor on X axis
  4312. * @param y defines the scale factor on Y axis
  4313. * @param z defines the scale factor on Z axis
  4314. * @param result defines the target matrix
  4315. */
  4316. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4317. /**
  4318. * Creates a translation matrix
  4319. * @param x defines the translation on X axis
  4320. * @param y defines the translation on Y axis
  4321. * @param z defines the translationon Z axis
  4322. * @returns the new matrix
  4323. */
  4324. static Translation(x: number, y: number, z: number): Matrix;
  4325. /**
  4326. * Creates a translation matrix and stores it in a given matrix
  4327. * @param x defines the translation on X axis
  4328. * @param y defines the translation on Y axis
  4329. * @param z defines the translationon Z axis
  4330. * @param result defines the target matrix
  4331. */
  4332. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4333. /**
  4334. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4335. * @param startValue defines the start value
  4336. * @param endValue defines the end value
  4337. * @param gradient defines the gradient factor
  4338. * @returns the new matrix
  4339. */
  4340. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4341. /**
  4342. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4343. * @param startValue defines the start value
  4344. * @param endValue defines the end value
  4345. * @param gradient defines the gradient factor
  4346. * @param result defines the Matrix object where to store data
  4347. */
  4348. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4349. /**
  4350. * Builds a new matrix whose values are computed by:
  4351. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4352. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4353. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4354. * @param startValue defines the first matrix
  4355. * @param endValue defines the second matrix
  4356. * @param gradient defines the gradient between the two matrices
  4357. * @returns the new matrix
  4358. */
  4359. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4360. /**
  4361. * Update a matrix to values which are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @param result defines the target matrix
  4369. */
  4370. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * 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"
  4373. * This function works in left handed mode
  4374. * @param eye defines the final position of the entity
  4375. * @param target defines where the entity should look at
  4376. * @param up defines the up vector for the entity
  4377. * @returns the new matrix
  4378. */
  4379. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4380. /**
  4381. * 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".
  4382. * This function works in left handed mode
  4383. * @param eye defines the final position of the entity
  4384. * @param target defines where the entity should look at
  4385. * @param up defines the up vector for the entity
  4386. * @param result defines the target matrix
  4387. */
  4388. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4389. /**
  4390. * 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"
  4391. * This function works in right handed mode
  4392. * @param eye defines the final position of the entity
  4393. * @param target defines where the entity should look at
  4394. * @param up defines the up vector for the entity
  4395. * @returns the new matrix
  4396. */
  4397. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4398. /**
  4399. * 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".
  4400. * This function works in right handed mode
  4401. * @param eye defines the final position of the entity
  4402. * @param target defines where the entity should look at
  4403. * @param up defines the up vector for the entity
  4404. * @param result defines the target matrix
  4405. */
  4406. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4407. /**
  4408. * Create a left-handed orthographic projection matrix
  4409. * @param width defines the viewport width
  4410. * @param height defines the viewport height
  4411. * @param znear defines the near clip plane
  4412. * @param zfar defines the far clip plane
  4413. * @returns a new matrix as a left-handed orthographic projection matrix
  4414. */
  4415. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4416. /**
  4417. * Store a left-handed orthographic projection to a given matrix
  4418. * @param width defines the viewport width
  4419. * @param height defines the viewport height
  4420. * @param znear defines the near clip plane
  4421. * @param zfar defines the far clip plane
  4422. * @param result defines the target matrix
  4423. */
  4424. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4425. /**
  4426. * Create a left-handed orthographic projection matrix
  4427. * @param left defines the viewport left coordinate
  4428. * @param right defines the viewport right coordinate
  4429. * @param bottom defines the viewport bottom coordinate
  4430. * @param top defines the viewport top coordinate
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Stores a left-handed orthographic projection into a given matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Creates a right-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a right-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a right-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  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 OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a left-handed perspective projection matrix
  4471. * @param width defines the viewport width
  4472. * @param height defines the viewport height
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a left-handed perspective projection matrix
  4476. */
  4477. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Creates a left-handed perspective projection matrix
  4480. * @param fov defines the horizontal field of view
  4481. * @param aspect defines the aspect ratio
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @returns a new matrix as a left-handed perspective projection matrix
  4485. */
  4486. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4487. /**
  4488. * Stores a left-handed perspective projection into a given matrix
  4489. * @param fov defines the horizontal field of view
  4490. * @param aspect defines the aspect ratio
  4491. * @param znear defines the near clip plane
  4492. * @param zfar defines the far clip plane
  4493. * @param result defines the target matrix
  4494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4495. */
  4496. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4497. /**
  4498. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4499. * @param fov defines the horizontal field of view
  4500. * @param aspect defines the aspect ratio
  4501. * @param znear defines the near clip plane
  4502. * @param zfar not used as infinity is used as far clip
  4503. * @param result defines the target matrix
  4504. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4505. */
  4506. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4507. /**
  4508. * Creates a right-handed perspective projection matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @returns a new matrix as a right-handed perspective projection matrix
  4514. */
  4515. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4516. /**
  4517. * Stores a right-handed perspective projection into a given matrix
  4518. * @param fov defines the horizontal field of view
  4519. * @param aspect defines the aspect ratio
  4520. * @param znear defines the near clip plane
  4521. * @param zfar defines the far clip plane
  4522. * @param result defines the target matrix
  4523. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4524. */
  4525. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4526. /**
  4527. * Stores a right-handed perspective projection into a given matrix
  4528. * @param fov defines the horizontal field of view
  4529. * @param aspect defines the aspect ratio
  4530. * @param znear defines the near clip plane
  4531. * @param zfar not used as infinity is used as far clip
  4532. * @param result defines the target matrix
  4533. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4534. */
  4535. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4536. /**
  4537. * Stores a perspective projection for WebVR info a given matrix
  4538. * @param fov defines the field of view
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @param result defines the target matrix
  4542. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4543. */
  4544. static PerspectiveFovWebVRToRef(fov: {
  4545. upDegrees: number;
  4546. downDegrees: number;
  4547. leftDegrees: number;
  4548. rightDegrees: number;
  4549. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4550. /**
  4551. * Computes a complete transformation matrix
  4552. * @param viewport defines the viewport to use
  4553. * @param world defines the world matrix
  4554. * @param view defines the view matrix
  4555. * @param projection defines the projection matrix
  4556. * @param zmin defines the near clip plane
  4557. * @param zmax defines the far clip plane
  4558. * @returns the transformation matrix
  4559. */
  4560. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4561. /**
  4562. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4569. * @param matrix defines the matrix to use
  4570. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4571. */
  4572. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4573. /**
  4574. * Compute the transpose of a given matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @returns the new matrix
  4577. */
  4578. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4579. /**
  4580. * Compute the transpose of a matrix and store it in a target matrix
  4581. * @param matrix defines the matrix to transpose
  4582. * @param result defines the target matrix
  4583. */
  4584. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @returns a new matrix
  4589. */
  4590. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4591. /**
  4592. * Computes a reflection matrix from a plane
  4593. * @param plane defines the reflection plane
  4594. * @param result defines the target matrix
  4595. */
  4596. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4597. /**
  4598. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4599. * @param xaxis defines the value of the 1st axis
  4600. * @param yaxis defines the value of the 2nd axis
  4601. * @param zaxis defines the value of the 3rd axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4605. /**
  4606. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4607. * @param quat defines the quaternion to use
  4608. * @param result defines the target matrix
  4609. */
  4610. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4611. }
  4612. /**
  4613. * @hidden
  4614. */
  4615. export class TmpVectors {
  4616. static Vector2: Vector2[];
  4617. static Vector3: Vector3[];
  4618. static Vector4: Vector4[];
  4619. static Quaternion: Quaternion[];
  4620. static Matrix: Matrix[];
  4621. }
  4622. }
  4623. declare module "babylonjs/Maths/math.path" {
  4624. import { DeepImmutable, Nullable } from "babylonjs/types";
  4625. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4626. /**
  4627. * Defines potential orientation for back face culling
  4628. */
  4629. export enum Orientation {
  4630. /**
  4631. * Clockwise
  4632. */
  4633. CW = 0,
  4634. /** Counter clockwise */
  4635. CCW = 1
  4636. }
  4637. /** Class used to represent a Bezier curve */
  4638. export class BezierCurve {
  4639. /**
  4640. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4641. * @param t defines the time
  4642. * @param x1 defines the left coordinate on X axis
  4643. * @param y1 defines the left coordinate on Y axis
  4644. * @param x2 defines the right coordinate on X axis
  4645. * @param y2 defines the right coordinate on Y axis
  4646. * @returns the interpolated value
  4647. */
  4648. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4649. }
  4650. /**
  4651. * Defines angle representation
  4652. */
  4653. export class Angle {
  4654. private _radians;
  4655. /**
  4656. * Creates an Angle object of "radians" radians (float).
  4657. * @param radians the angle in radians
  4658. */
  4659. constructor(radians: number);
  4660. /**
  4661. * Get value in degrees
  4662. * @returns the Angle value in degrees (float)
  4663. */
  4664. degrees(): number;
  4665. /**
  4666. * Get value in radians
  4667. * @returns the Angle value in radians (float)
  4668. */
  4669. radians(): number;
  4670. /**
  4671. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4672. * @param a defines first vector
  4673. * @param b defines second vector
  4674. * @returns a new Angle
  4675. */
  4676. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4677. /**
  4678. * Gets a new Angle object from the given float in radians
  4679. * @param radians defines the angle value in radians
  4680. * @returns a new Angle
  4681. */
  4682. static FromRadians(radians: number): Angle;
  4683. /**
  4684. * Gets a new Angle object from the given float in degrees
  4685. * @param degrees defines the angle value in degrees
  4686. * @returns a new Angle
  4687. */
  4688. static FromDegrees(degrees: number): Angle;
  4689. }
  4690. /**
  4691. * This represents an arc in a 2d space.
  4692. */
  4693. export class Arc2 {
  4694. /** Defines the start point of the arc */
  4695. startPoint: Vector2;
  4696. /** Defines the mid point of the arc */
  4697. midPoint: Vector2;
  4698. /** Defines the end point of the arc */
  4699. endPoint: Vector2;
  4700. /**
  4701. * Defines the center point of the arc.
  4702. */
  4703. centerPoint: Vector2;
  4704. /**
  4705. * Defines the radius of the arc.
  4706. */
  4707. radius: number;
  4708. /**
  4709. * Defines the angle of the arc (from mid point to end point).
  4710. */
  4711. angle: Angle;
  4712. /**
  4713. * Defines the start angle of the arc (from start point to middle point).
  4714. */
  4715. startAngle: Angle;
  4716. /**
  4717. * Defines the orientation of the arc (clock wise/counter clock wise).
  4718. */
  4719. orientation: Orientation;
  4720. /**
  4721. * Creates an Arc object from the three given points : start, middle and end.
  4722. * @param startPoint Defines the start point of the arc
  4723. * @param midPoint Defines the midlle point of the arc
  4724. * @param endPoint Defines the end point of the arc
  4725. */
  4726. constructor(
  4727. /** Defines the start point of the arc */
  4728. startPoint: Vector2,
  4729. /** Defines the mid point of the arc */
  4730. midPoint: Vector2,
  4731. /** Defines the end point of the arc */
  4732. endPoint: Vector2);
  4733. }
  4734. /**
  4735. * Represents a 2D path made up of multiple 2D points
  4736. */
  4737. export class Path2 {
  4738. private _points;
  4739. private _length;
  4740. /**
  4741. * If the path start and end point are the same
  4742. */
  4743. closed: boolean;
  4744. /**
  4745. * Creates a Path2 object from the starting 2D coordinates x and y.
  4746. * @param x the starting points x value
  4747. * @param y the starting points y value
  4748. */
  4749. constructor(x: number, y: number);
  4750. /**
  4751. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4752. * @param x the added points x value
  4753. * @param y the added points y value
  4754. * @returns the updated Path2.
  4755. */
  4756. addLineTo(x: number, y: number): Path2;
  4757. /**
  4758. * 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.
  4759. * @param midX middle point x value
  4760. * @param midY middle point y value
  4761. * @param endX end point x value
  4762. * @param endY end point y value
  4763. * @param numberOfSegments (default: 36)
  4764. * @returns the updated Path2.
  4765. */
  4766. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4767. /**
  4768. * Closes the Path2.
  4769. * @returns the Path2.
  4770. */
  4771. close(): Path2;
  4772. /**
  4773. * Gets the sum of the distance between each sequential point in the path
  4774. * @returns the Path2 total length (float).
  4775. */
  4776. length(): number;
  4777. /**
  4778. * Gets the points which construct the path
  4779. * @returns the Path2 internal array of points.
  4780. */
  4781. getPoints(): Vector2[];
  4782. /**
  4783. * Retreives the point at the distance aways from the starting point
  4784. * @param normalizedLengthPosition the length along the path to retreive the point from
  4785. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4786. */
  4787. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4788. /**
  4789. * Creates a new path starting from an x and y position
  4790. * @param x starting x value
  4791. * @param y starting y value
  4792. * @returns a new Path2 starting at the coordinates (x, y).
  4793. */
  4794. static StartingAt(x: number, y: number): Path2;
  4795. }
  4796. /**
  4797. * Represents a 3D path made up of multiple 3D points
  4798. */
  4799. export class Path3D {
  4800. /**
  4801. * an array of Vector3, the curve axis of the Path3D
  4802. */
  4803. path: Vector3[];
  4804. private _curve;
  4805. private _distances;
  4806. private _tangents;
  4807. private _normals;
  4808. private _binormals;
  4809. private _raw;
  4810. private _alignTangentsWithPath;
  4811. private readonly _pointAtData;
  4812. /**
  4813. * new Path3D(path, normal, raw)
  4814. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4815. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4816. * @param path an array of Vector3, the curve axis of the Path3D
  4817. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4818. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4819. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4820. */
  4821. constructor(
  4822. /**
  4823. * an array of Vector3, the curve axis of the Path3D
  4824. */
  4825. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4826. /**
  4827. * Returns the Path3D array of successive Vector3 designing its curve.
  4828. * @returns the Path3D array of successive Vector3 designing its curve.
  4829. */
  4830. getCurve(): Vector3[];
  4831. /**
  4832. * Returns the Path3D array of successive Vector3 designing its curve.
  4833. * @returns the Path3D array of successive Vector3 designing its curve.
  4834. */
  4835. getPoints(): Vector3[];
  4836. /**
  4837. * @returns the computed length (float) of the path.
  4838. */
  4839. length(): number;
  4840. /**
  4841. * Returns an array populated with tangent vectors on each Path3D curve point.
  4842. * @returns an array populated with tangent vectors on each Path3D curve point.
  4843. */
  4844. getTangents(): Vector3[];
  4845. /**
  4846. * Returns an array populated with normal vectors on each Path3D curve point.
  4847. * @returns an array populated with normal vectors on each Path3D curve point.
  4848. */
  4849. getNormals(): Vector3[];
  4850. /**
  4851. * Returns an array populated with binormal vectors on each Path3D curve point.
  4852. * @returns an array populated with binormal vectors on each Path3D curve point.
  4853. */
  4854. getBinormals(): Vector3[];
  4855. /**
  4856. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4857. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4858. */
  4859. getDistances(): number[];
  4860. /**
  4861. * Returns an interpolated point along this path
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns a new Vector3 as the point
  4864. */
  4865. getPointAt(position: number): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4870. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4871. */
  4872. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4877. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4878. */
  4879. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4884. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4885. */
  4886. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4887. /**
  4888. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4889. * @param position the position of the point along this path, from 0.0 to 1.0
  4890. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4891. */
  4892. getDistanceAt(position: number): number;
  4893. /**
  4894. * Returns the array index of the previous point of an interpolated point along this path
  4895. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4896. * @returns the array index
  4897. */
  4898. getPreviousPointIndexAt(position: number): number;
  4899. /**
  4900. * 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)
  4901. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4902. * @returns the sub position
  4903. */
  4904. getSubPositionAt(position: number): number;
  4905. /**
  4906. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4907. * @param target the vector of which to get the closest position to
  4908. * @returns the position of the closest virtual point on this path to the target vector
  4909. */
  4910. getClosestPositionTo(target: Vector3): number;
  4911. /**
  4912. * Returns a sub path (slice) of this path
  4913. * @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
  4914. * @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
  4915. * @returns a sub path (slice) of this path
  4916. */
  4917. slice(start?: number, end?: number): Path3D;
  4918. /**
  4919. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4920. * @param path path which all values are copied into the curves points
  4921. * @param firstNormal which should be projected onto the curve
  4922. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4923. * @returns the same object updated.
  4924. */
  4925. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4926. private _compute;
  4927. private _getFirstNonNullVector;
  4928. private _getLastNonNullVector;
  4929. private _normalVector;
  4930. /**
  4931. * Updates the point at data for an interpolated point along this curve
  4932. * @param position the position of the point along this curve, from 0.0 to 1.0
  4933. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4934. * @returns the (updated) point at data
  4935. */
  4936. private _updatePointAtData;
  4937. /**
  4938. * Updates the point at data from the specified parameters
  4939. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4940. * @param point the interpolated point
  4941. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4942. */
  4943. private _setPointAtData;
  4944. /**
  4945. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4946. */
  4947. private _updateInterpolationMatrix;
  4948. }
  4949. /**
  4950. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4951. * A Curve3 is designed from a series of successive Vector3.
  4952. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4953. */
  4954. export class Curve3 {
  4955. private _points;
  4956. private _length;
  4957. /**
  4958. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4960. * @param v1 (Vector3) the control point
  4961. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4962. * @param nbPoints (integer) the wanted number of points in the curve
  4963. * @returns the created Curve3
  4964. */
  4965. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4966. /**
  4967. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4969. * @param v1 (Vector3) the first control point
  4970. * @param v2 (Vector3) the second control point
  4971. * @param v3 (Vector3) the end point of the Cubic Bezier
  4972. * @param nbPoints (integer) the wanted number of points in the curve
  4973. * @returns the created Curve3
  4974. */
  4975. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4976. /**
  4977. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4978. * @param p1 (Vector3) the origin point of the Hermite Spline
  4979. * @param t1 (Vector3) the tangent vector at the origin point
  4980. * @param p2 (Vector3) the end point of the Hermite Spline
  4981. * @param t2 (Vector3) the tangent vector at the end point
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a CatmullRom Spline curve :
  4988. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4989. * @param nbPoints (integer) the wanted number of points between each curve control points
  4990. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4994. /**
  4995. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4996. * A Curve3 is designed from a series of successive Vector3.
  4997. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4998. * @param points points which make up the curve
  4999. */
  5000. constructor(points: Vector3[]);
  5001. /**
  5002. * @returns the Curve3 stored array of successive Vector3
  5003. */
  5004. getPoints(): Vector3[];
  5005. /**
  5006. * @returns the computed length (float) of the curve.
  5007. */
  5008. length(): number;
  5009. /**
  5010. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5011. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5012. * curveA and curveB keep unchanged.
  5013. * @param curve the curve to continue from this curve
  5014. * @returns the newly constructed curve
  5015. */
  5016. continue(curve: DeepImmutable<Curve3>): Curve3;
  5017. private _computeLength;
  5018. }
  5019. }
  5020. declare module "babylonjs/Animations/easing" {
  5021. /**
  5022. * This represents the main contract an easing function should follow.
  5023. * Easing functions are used throughout the animation system.
  5024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5025. */
  5026. export interface IEasingFunction {
  5027. /**
  5028. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5029. * of the easing function.
  5030. * The link below provides some of the most common examples of easing functions.
  5031. * @see https://easings.net/
  5032. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5033. * @returns the corresponding value on the curve defined by the easing function
  5034. */
  5035. ease(gradient: number): number;
  5036. }
  5037. /**
  5038. * Base class used for every default easing function.
  5039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5040. */
  5041. export class EasingFunction implements IEasingFunction {
  5042. /**
  5043. * Interpolation follows the mathematical formula associated with the easing function.
  5044. */
  5045. static readonly EASINGMODE_EASEIN: number;
  5046. /**
  5047. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5048. */
  5049. static readonly EASINGMODE_EASEOUT: number;
  5050. /**
  5051. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5052. */
  5053. static readonly EASINGMODE_EASEINOUT: number;
  5054. private _easingMode;
  5055. /**
  5056. * Sets the easing mode of the current function.
  5057. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5058. */
  5059. setEasingMode(easingMode: number): void;
  5060. /**
  5061. * Gets the current easing mode.
  5062. * @returns the easing mode
  5063. */
  5064. getEasingMode(): number;
  5065. /**
  5066. * @hidden
  5067. */
  5068. easeInCore(gradient: number): number;
  5069. /**
  5070. * Given an input gradient between 0 and 1, this returns the corresponding value
  5071. * of the easing function.
  5072. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5073. * @returns the corresponding value on the curve defined by the easing function
  5074. */
  5075. ease(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a circle shape (see link below).
  5079. * @see https://easings.net/#easeInCirc
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class CircleEase extends EasingFunction implements IEasingFunction {
  5083. /** @hidden */
  5084. easeInCore(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a ease back shape (see link below).
  5088. * @see https://easings.net/#easeInBack
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class BackEase extends EasingFunction implements IEasingFunction {
  5092. /** Defines the amplitude of the function */
  5093. amplitude: number;
  5094. /**
  5095. * Instantiates a back ease easing
  5096. * @see https://easings.net/#easeInBack
  5097. * @param amplitude Defines the amplitude of the function
  5098. */
  5099. constructor(
  5100. /** Defines the amplitude of the function */
  5101. amplitude?: number);
  5102. /** @hidden */
  5103. easeInCore(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a bouncing shape (see link below).
  5107. * @see https://easings.net/#easeInBounce
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class BounceEase extends EasingFunction implements IEasingFunction {
  5111. /** Defines the number of bounces */
  5112. bounces: number;
  5113. /** Defines the amplitude of the bounce */
  5114. bounciness: number;
  5115. /**
  5116. * Instantiates a bounce easing
  5117. * @see https://easings.net/#easeInBounce
  5118. * @param bounces Defines the number of bounces
  5119. * @param bounciness Defines the amplitude of the bounce
  5120. */
  5121. constructor(
  5122. /** Defines the number of bounces */
  5123. bounces?: number,
  5124. /** Defines the amplitude of the bounce */
  5125. bounciness?: number);
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with a power of 3 shape (see link below).
  5131. * @see https://easings.net/#easeInCubic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class CubicEase extends EasingFunction implements IEasingFunction {
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with an elastic shape (see link below).
  5140. * @see https://easings.net/#easeInElastic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5144. /** Defines the number of oscillations*/
  5145. oscillations: number;
  5146. /** Defines the amplitude of the oscillations*/
  5147. springiness: number;
  5148. /**
  5149. * Instantiates an elastic easing function
  5150. * @see https://easings.net/#easeInElastic
  5151. * @param oscillations Defines the number of oscillations
  5152. * @param springiness Defines the amplitude of the oscillations
  5153. */
  5154. constructor(
  5155. /** Defines the number of oscillations*/
  5156. oscillations?: number,
  5157. /** Defines the amplitude of the oscillations*/
  5158. springiness?: number);
  5159. /** @hidden */
  5160. easeInCore(gradient: number): number;
  5161. }
  5162. /**
  5163. * Easing function with an exponential shape (see link below).
  5164. * @see https://easings.net/#easeInExpo
  5165. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5166. */
  5167. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5168. /** Defines the exponent of the function */
  5169. exponent: number;
  5170. /**
  5171. * Instantiates an exponential easing function
  5172. * @see https://easings.net/#easeInExpo
  5173. * @param exponent Defines the exponent of the function
  5174. */
  5175. constructor(
  5176. /** Defines the exponent of the function */
  5177. exponent?: number);
  5178. /** @hidden */
  5179. easeInCore(gradient: number): number;
  5180. }
  5181. /**
  5182. * Easing function with a power shape (see link below).
  5183. * @see https://easings.net/#easeInQuad
  5184. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5185. */
  5186. export class PowerEase extends EasingFunction implements IEasingFunction {
  5187. /** Defines the power of the function */
  5188. power: number;
  5189. /**
  5190. * Instantiates an power base easing function
  5191. * @see https://easings.net/#easeInQuad
  5192. * @param power Defines the power of the function
  5193. */
  5194. constructor(
  5195. /** Defines the power of the function */
  5196. power?: number);
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 2 shape (see link below).
  5202. * @see https://easings.net/#easeInQuad
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 4 shape (see link below).
  5211. * @see https://easings.net/#easeInQuart
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 5 shape (see link below).
  5220. * @see https://easings.net/#easeInQuint
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a sin shape (see link below).
  5229. * @see https://easings.net/#easeInSine
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class SineEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a bezier shape (see link below).
  5238. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the x component of the start tangent in the bezier curve */
  5243. x1: number;
  5244. /** Defines the y component of the start tangent in the bezier curve */
  5245. y1: number;
  5246. /** Defines the x component of the end tangent in the bezier curve */
  5247. x2: number;
  5248. /** Defines the y component of the end tangent in the bezier curve */
  5249. y2: number;
  5250. /**
  5251. * Instantiates a bezier function
  5252. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5253. * @param x1 Defines the x component of the start tangent in the bezier curve
  5254. * @param y1 Defines the y component of the start tangent in the bezier curve
  5255. * @param x2 Defines the x component of the end tangent in the bezier curve
  5256. * @param y2 Defines the y component of the end tangent in the bezier curve
  5257. */
  5258. constructor(
  5259. /** Defines the x component of the start tangent in the bezier curve */
  5260. x1?: number,
  5261. /** Defines the y component of the start tangent in the bezier curve */
  5262. y1?: number,
  5263. /** Defines the x component of the end tangent in the bezier curve */
  5264. x2?: number,
  5265. /** Defines the y component of the end tangent in the bezier curve */
  5266. y2?: number);
  5267. /** @hidden */
  5268. easeInCore(gradient: number): number;
  5269. }
  5270. }
  5271. declare module "babylonjs/Maths/math.color" {
  5272. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5273. /**
  5274. * Class used to hold a RBG color
  5275. */
  5276. export class Color3 {
  5277. /**
  5278. * Defines the red component (between 0 and 1, default is 0)
  5279. */
  5280. r: number;
  5281. /**
  5282. * Defines the green component (between 0 and 1, default is 0)
  5283. */
  5284. g: number;
  5285. /**
  5286. * Defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. b: number;
  5289. /**
  5290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5291. * @param r defines the red component (between 0 and 1, default is 0)
  5292. * @param g defines the green component (between 0 and 1, default is 0)
  5293. * @param b defines the blue component (between 0 and 1, default is 0)
  5294. */
  5295. constructor(
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r?: number,
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g?: number,
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b?: number);
  5308. /**
  5309. * Creates a string with the Color3 current values
  5310. * @returns the string representation of the Color3 object
  5311. */
  5312. toString(): string;
  5313. /**
  5314. * Returns the string "Color3"
  5315. * @returns "Color3"
  5316. */
  5317. getClassName(): string;
  5318. /**
  5319. * Compute the Color3 hash code
  5320. * @returns an unique number that can be used to hash Color3 objects
  5321. */
  5322. getHashCode(): number;
  5323. /**
  5324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5325. * @param array defines the array where to store the r,g,b components
  5326. * @param index defines an optional index in the target array to define where to start storing values
  5327. * @returns the current Color3 object
  5328. */
  5329. toArray(array: FloatArray, index?: number): Color3;
  5330. /**
  5331. * Returns a new Color4 object from the current Color3 and the given alpha
  5332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5333. * @returns a new Color4 object
  5334. */
  5335. toColor4(alpha?: number): Color4;
  5336. /**
  5337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5338. * @returns the new array
  5339. */
  5340. asArray(): number[];
  5341. /**
  5342. * Returns the luminance value
  5343. * @returns a float value
  5344. */
  5345. toLuminance(): number;
  5346. /**
  5347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5348. * @param otherColor defines the second operand
  5349. * @returns the new Color3 object
  5350. */
  5351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5352. /**
  5353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5354. * @param otherColor defines the second operand
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the current Color3
  5357. */
  5358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5359. /**
  5360. * Determines equality between Color3 objects
  5361. * @param otherColor defines the second operand
  5362. * @returns true if the rgb values are equal to the given ones
  5363. */
  5364. equals(otherColor: DeepImmutable<Color3>): boolean;
  5365. /**
  5366. * Determines equality between the current Color3 object and a set of r,b,g values
  5367. * @param r defines the red component to check
  5368. * @param g defines the green component to check
  5369. * @param b defines the blue component to check
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equalsFloats(r: number, g: number, b: number): boolean;
  5373. /**
  5374. * Multiplies in place each rgb value by scale
  5375. * @param scale defines the scaling factor
  5376. * @returns the updated Color3
  5377. */
  5378. scale(scale: number): Color3;
  5379. /**
  5380. * Multiplies the rgb values by scale and stores the result into "result"
  5381. * @param scale defines the scaling factor
  5382. * @param result defines the Color3 object where to store the result
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Scale the current Color3 values by a factor and add the result to a given Color3
  5388. * @param scale defines the scale factor
  5389. * @param result defines color to store the result into
  5390. * @returns the unmodified current Color3
  5391. */
  5392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5393. /**
  5394. * Clamps the rgb values by the min and max values and stores the result into "result"
  5395. * @param min defines minimum clamping value (default is 0)
  5396. * @param max defines maximum clamping value (default is 1)
  5397. * @param result defines color to store the result into
  5398. * @returns the original Color3
  5399. */
  5400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5401. /**
  5402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5403. * @param otherColor defines the second operand
  5404. * @returns the new Color3
  5405. */
  5406. add(otherColor: DeepImmutable<Color3>): Color3;
  5407. /**
  5408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5409. * @param otherColor defines the second operand
  5410. * @param result defines Color3 object to store the result into
  5411. * @returns the unmodified current Color3
  5412. */
  5413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5414. /**
  5415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5416. * @param otherColor defines the second operand
  5417. * @returns the new Color3
  5418. */
  5419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5420. /**
  5421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5422. * @param otherColor defines the second operand
  5423. * @param result defines Color3 object to store the result into
  5424. * @returns the unmodified current Color3
  5425. */
  5426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5427. /**
  5428. * Copy the current object
  5429. * @returns a new Color3 copied the current one
  5430. */
  5431. clone(): Color3;
  5432. /**
  5433. * Copies the rgb values from the source in the current Color3
  5434. * @param source defines the source Color3 object
  5435. * @returns the updated Color3 object
  5436. */
  5437. copyFrom(source: DeepImmutable<Color3>): Color3;
  5438. /**
  5439. * Updates the Color3 rgb values from the given floats
  5440. * @param r defines the red component to read from
  5441. * @param g defines the green component to read from
  5442. * @param b defines the blue component to read from
  5443. * @returns the current Color3 object
  5444. */
  5445. copyFromFloats(r: number, g: number, b: number): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. set(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Compute the Color3 hexadecimal code as a string
  5456. * @returns a string containing the hexadecimal representation of the Color3 object
  5457. */
  5458. toHexString(): string;
  5459. /**
  5460. * Computes a new Color3 converted from the current one to linear space
  5461. * @returns a new Color3 object
  5462. */
  5463. toLinearSpace(): Color3;
  5464. /**
  5465. * Converts current color in rgb space to HSV values
  5466. * @returns a new color3 representing the HSV values
  5467. */
  5468. toHSV(): Color3;
  5469. /**
  5470. * Converts current color in rgb space to HSV values
  5471. * @param result defines the Color3 where to store the HSV values
  5472. */
  5473. toHSVToRef(result: Color3): void;
  5474. /**
  5475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5476. * @param convertedColor defines the Color3 object where to store the linear space version
  5477. * @returns the unmodified Color3
  5478. */
  5479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5480. /**
  5481. * Computes a new Color3 converted from the current one to gamma space
  5482. * @returns a new Color3 object
  5483. */
  5484. toGammaSpace(): Color3;
  5485. /**
  5486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5487. * @param convertedColor defines the Color3 object where to store the gamma space version
  5488. * @returns the unmodified Color3
  5489. */
  5490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5491. private static _BlackReadOnly;
  5492. /**
  5493. * Convert Hue, saturation and value to a Color3 (RGB)
  5494. * @param hue defines the hue
  5495. * @param saturation defines the saturation
  5496. * @param value defines the value
  5497. * @param result defines the Color3 where to store the RGB values
  5498. */
  5499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5500. /**
  5501. * Creates a new Color3 from the string containing valid hexadecimal values
  5502. * @param hex defines a string containing valid hexadecimal values
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromHexString(hex: string): Color3;
  5506. /**
  5507. * Creates a new Color3 from the starting index of the given array
  5508. * @param array defines the source array
  5509. * @param offset defines an offset in the source array
  5510. * @returns a new Color3 object
  5511. */
  5512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5513. /**
  5514. * Creates a new Color3 from integer values (< 256)
  5515. * @param r defines the red component to read from (value between 0 and 255)
  5516. * @param g defines the green component to read from (value between 0 and 255)
  5517. * @param b defines the blue component to read from (value between 0 and 255)
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromInts(r: number, g: number, b: number): Color3;
  5521. /**
  5522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5523. * @param start defines the start Color3 value
  5524. * @param end defines the end Color3 value
  5525. * @param amount defines the gradient value between start and end
  5526. * @returns a new Color3 object
  5527. */
  5528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param left defines the start value
  5532. * @param right defines the end value
  5533. * @param amount defines the gradient factor
  5534. * @param result defines the Color3 object where to store the result
  5535. */
  5536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5537. /**
  5538. * Returns a Color3 value containing a red color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Red(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a green color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Green(): Color3;
  5547. /**
  5548. * Returns a Color3 value containing a blue color
  5549. * @returns a new Color3 object
  5550. */
  5551. static Blue(): Color3;
  5552. /**
  5553. * Returns a Color3 value containing a black color
  5554. * @returns a new Color3 object
  5555. */
  5556. static Black(): Color3;
  5557. /**
  5558. * Gets a Color3 value containing a black color that must not be updated
  5559. */
  5560. static get BlackReadOnly(): DeepImmutable<Color3>;
  5561. /**
  5562. * Returns a Color3 value containing a white color
  5563. * @returns a new Color3 object
  5564. */
  5565. static White(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a purple color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Purple(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a magenta color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Magenta(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a yellow color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Yellow(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a gray color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Gray(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a teal color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Teal(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a random color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Random(): Color3;
  5596. }
  5597. /**
  5598. * Class used to hold a RBGA color
  5599. */
  5600. export class Color4 {
  5601. /**
  5602. * Defines the red component (between 0 and 1, default is 0)
  5603. */
  5604. r: number;
  5605. /**
  5606. * Defines the green component (between 0 and 1, default is 0)
  5607. */
  5608. g: number;
  5609. /**
  5610. * Defines the blue component (between 0 and 1, default is 0)
  5611. */
  5612. b: number;
  5613. /**
  5614. * Defines the alpha component (between 0 and 1, default is 1)
  5615. */
  5616. a: number;
  5617. /**
  5618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5619. * @param r defines the red component (between 0 and 1, default is 0)
  5620. * @param g defines the green component (between 0 and 1, default is 0)
  5621. * @param b defines the blue component (between 0 and 1, default is 0)
  5622. * @param a defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. constructor(
  5625. /**
  5626. * Defines the red component (between 0 and 1, default is 0)
  5627. */
  5628. r?: number,
  5629. /**
  5630. * Defines the green component (between 0 and 1, default is 0)
  5631. */
  5632. g?: number,
  5633. /**
  5634. * Defines the blue component (between 0 and 1, default is 0)
  5635. */
  5636. b?: number,
  5637. /**
  5638. * Defines the alpha component (between 0 and 1, default is 1)
  5639. */
  5640. a?: number);
  5641. /**
  5642. * Adds in place the given Color4 values to the current Color4 object
  5643. * @param right defines the second operand
  5644. * @returns the current updated Color4 object
  5645. */
  5646. addInPlace(right: DeepImmutable<Color4>): Color4;
  5647. /**
  5648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5649. * @returns the new array
  5650. */
  5651. asArray(): number[];
  5652. /**
  5653. * Stores from the starting index in the given array the Color4 successive values
  5654. * @param array defines the array where to store the r,g,b components
  5655. * @param index defines an optional index in the target array to define where to start storing values
  5656. * @returns the current Color4 object
  5657. */
  5658. toArray(array: number[], index?: number): Color4;
  5659. /**
  5660. * Determines equality between Color4 objects
  5661. * @param otherColor defines the second operand
  5662. * @returns true if the rgba values are equal to the given ones
  5663. */
  5664. equals(otherColor: DeepImmutable<Color4>): boolean;
  5665. /**
  5666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5667. * @param right defines the second operand
  5668. * @returns a new Color4 object
  5669. */
  5670. add(right: DeepImmutable<Color4>): Color4;
  5671. /**
  5672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5673. * @param right defines the second operand
  5674. * @returns a new Color4 object
  5675. */
  5676. subtract(right: DeepImmutable<Color4>): Color4;
  5677. /**
  5678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5679. * @param right defines the second operand
  5680. * @param result defines the Color4 object where to store the result
  5681. * @returns the current Color4 object
  5682. */
  5683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5684. /**
  5685. * Creates a new Color4 with the current Color4 values multiplied by scale
  5686. * @param scale defines the scaling factor to apply
  5687. * @returns a new Color4 object
  5688. */
  5689. scale(scale: number): Color4;
  5690. /**
  5691. * Multiplies the current Color4 values by scale and stores the result in "result"
  5692. * @param scale defines the scaling factor to apply
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the current unmodified Color4
  5695. */
  5696. scaleToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Scale the current Color4 values by a factor and add the result to a given Color4
  5699. * @param scale defines the scale factor
  5700. * @param result defines the Color4 object where to store the result
  5701. * @returns the unmodified current Color4
  5702. */
  5703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5704. /**
  5705. * Clamps the rgb values by the min and max values and stores the result into "result"
  5706. * @param min defines minimum clamping value (default is 0)
  5707. * @param max defines maximum clamping value (default is 1)
  5708. * @param result defines color to store the result into.
  5709. * @returns the cuurent Color4
  5710. */
  5711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5712. /**
  5713. * Multipy an Color4 value by another and return a new Color4 object
  5714. * @param color defines the Color4 value to multiply by
  5715. * @returns a new Color4 object
  5716. */
  5717. multiply(color: Color4): Color4;
  5718. /**
  5719. * Multipy a Color4 value by another and push the result in a reference value
  5720. * @param color defines the Color4 value to multiply by
  5721. * @param result defines the Color4 to fill the result in
  5722. * @returns the result Color4
  5723. */
  5724. multiplyToRef(color: Color4, result: Color4): Color4;
  5725. /**
  5726. * Creates a string with the Color4 current values
  5727. * @returns the string representation of the Color4 object
  5728. */
  5729. toString(): string;
  5730. /**
  5731. * Returns the string "Color4"
  5732. * @returns "Color4"
  5733. */
  5734. getClassName(): string;
  5735. /**
  5736. * Compute the Color4 hash code
  5737. * @returns an unique number that can be used to hash Color4 objects
  5738. */
  5739. getHashCode(): number;
  5740. /**
  5741. * Creates a new Color4 copied from the current one
  5742. * @returns a new Color4 object
  5743. */
  5744. clone(): Color4;
  5745. /**
  5746. * Copies the given Color4 values into the current one
  5747. * @param source defines the source Color4 object
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFrom(source: Color4): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Copies the given float values into the current one
  5762. * @param r defines the red component to read from
  5763. * @param g defines the green component to read from
  5764. * @param b defines the blue component to read from
  5765. * @param a defines the alpha component to read from
  5766. * @returns the current updated Color4 object
  5767. */
  5768. set(r: number, g: number, b: number, a: number): Color4;
  5769. /**
  5770. * Compute the Color4 hexadecimal code as a string
  5771. * @returns a string containing the hexadecimal representation of the Color4 object
  5772. */
  5773. toHexString(): string;
  5774. /**
  5775. * Computes a new Color4 converted from the current one to linear space
  5776. * @returns a new Color4 object
  5777. */
  5778. toLinearSpace(): Color4;
  5779. /**
  5780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5781. * @param convertedColor defines the Color4 object where to store the linear space version
  5782. * @returns the unmodified Color4
  5783. */
  5784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5785. /**
  5786. * Computes a new Color4 converted from the current one to gamma space
  5787. * @returns a new Color4 object
  5788. */
  5789. toGammaSpace(): Color4;
  5790. /**
  5791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5792. * @param convertedColor defines the Color4 object where to store the gamma space version
  5793. * @returns the unmodified Color4
  5794. */
  5795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5796. /**
  5797. * Creates a new Color4 from the string containing valid hexadecimal values
  5798. * @param hex defines a string containing valid hexadecimal values
  5799. * @returns a new Color4 object
  5800. */
  5801. static FromHexString(hex: string): Color4;
  5802. /**
  5803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5804. * @param left defines the start value
  5805. * @param right defines the end value
  5806. * @param amount defines the gradient factor
  5807. * @returns a new Color4 object
  5808. */
  5809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5810. /**
  5811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @param result defines the Color4 object where to store data
  5816. */
  5817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5818. /**
  5819. * Creates a new Color4 from a Color3 and an alpha value
  5820. * @param color3 defines the source Color3 to read from
  5821. * @param alpha defines the alpha component (1.0 by default)
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5825. /**
  5826. * Creates a new Color4 from the starting index element of the given array
  5827. * @param array defines the source array to read from
  5828. * @param offset defines the offset in the source array
  5829. * @returns a new Color4 object
  5830. */
  5831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5832. /**
  5833. * Creates a new Color3 from integer values (< 256)
  5834. * @param r defines the red component to read from (value between 0 and 255)
  5835. * @param g defines the green component to read from (value between 0 and 255)
  5836. * @param b defines the blue component to read from (value between 0 and 255)
  5837. * @param a defines the alpha component to read from (value between 0 and 255)
  5838. * @returns a new Color3 object
  5839. */
  5840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5841. /**
  5842. * Check the content of a given array and convert it to an array containing RGBA data
  5843. * If the original array was already containing count * 4 values then it is returned directly
  5844. * @param colors defines the array to check
  5845. * @param count defines the number of RGBA data to expect
  5846. * @returns an array containing count * 4 values (RGBA)
  5847. */
  5848. static CheckColors4(colors: number[], count: number): number[];
  5849. }
  5850. /**
  5851. * @hidden
  5852. */
  5853. export class TmpColors {
  5854. static Color3: Color3[];
  5855. static Color4: Color4[];
  5856. }
  5857. }
  5858. declare module "babylonjs/Animations/animationKey" {
  5859. /**
  5860. * Defines an interface which represents an animation key frame
  5861. */
  5862. export interface IAnimationKey {
  5863. /**
  5864. * Frame of the key frame
  5865. */
  5866. frame: number;
  5867. /**
  5868. * Value at the specifies key frame
  5869. */
  5870. value: any;
  5871. /**
  5872. * The input tangent for the cubic hermite spline
  5873. */
  5874. inTangent?: any;
  5875. /**
  5876. * The output tangent for the cubic hermite spline
  5877. */
  5878. outTangent?: any;
  5879. /**
  5880. * The animation interpolation type
  5881. */
  5882. interpolation?: AnimationKeyInterpolation;
  5883. }
  5884. /**
  5885. * Enum for the animation key frame interpolation type
  5886. */
  5887. export enum AnimationKeyInterpolation {
  5888. /**
  5889. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5890. */
  5891. STEP = 1
  5892. }
  5893. }
  5894. declare module "babylonjs/Animations/animationRange" {
  5895. /**
  5896. * Represents the range of an animation
  5897. */
  5898. export class AnimationRange {
  5899. /**The name of the animation range**/
  5900. name: string;
  5901. /**The starting frame of the animation */
  5902. from: number;
  5903. /**The ending frame of the animation*/
  5904. to: number;
  5905. /**
  5906. * Initializes the range of an animation
  5907. * @param name The name of the animation range
  5908. * @param from The starting frame of the animation
  5909. * @param to The ending frame of the animation
  5910. */
  5911. constructor(
  5912. /**The name of the animation range**/
  5913. name: string,
  5914. /**The starting frame of the animation */
  5915. from: number,
  5916. /**The ending frame of the animation*/
  5917. to: number);
  5918. /**
  5919. * Makes a copy of the animation range
  5920. * @returns A copy of the animation range
  5921. */
  5922. clone(): AnimationRange;
  5923. }
  5924. }
  5925. declare module "babylonjs/Animations/animationEvent" {
  5926. /**
  5927. * Composed of a frame, and an action function
  5928. */
  5929. export class AnimationEvent {
  5930. /** The frame for which the event is triggered **/
  5931. frame: number;
  5932. /** The event to perform when triggered **/
  5933. action: (currentFrame: number) => void;
  5934. /** Specifies if the event should be triggered only once**/
  5935. onlyOnce?: boolean | undefined;
  5936. /**
  5937. * Specifies if the animation event is done
  5938. */
  5939. isDone: boolean;
  5940. /**
  5941. * Initializes the animation event
  5942. * @param frame The frame for which the event is triggered
  5943. * @param action The event to perform when triggered
  5944. * @param onlyOnce Specifies if the event should be triggered only once
  5945. */
  5946. constructor(
  5947. /** The frame for which the event is triggered **/
  5948. frame: number,
  5949. /** The event to perform when triggered **/
  5950. action: (currentFrame: number) => void,
  5951. /** Specifies if the event should be triggered only once**/
  5952. onlyOnce?: boolean | undefined);
  5953. /** @hidden */
  5954. _clone(): AnimationEvent;
  5955. }
  5956. }
  5957. declare module "babylonjs/Behaviors/behavior" {
  5958. import { Nullable } from "babylonjs/types";
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. export interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. export interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module "babylonjs/Misc/smartArray" {
  6004. /**
  6005. * Defines an array and its length.
  6006. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6007. */
  6008. export interface ISmartArrayLike<T> {
  6009. /**
  6010. * The data of the array.
  6011. */
  6012. data: Array<T>;
  6013. /**
  6014. * The active length of the array.
  6015. */
  6016. length: number;
  6017. }
  6018. /**
  6019. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6020. */
  6021. export class SmartArray<T> implements ISmartArrayLike<T> {
  6022. /**
  6023. * The full set of data from the array.
  6024. */
  6025. data: Array<T>;
  6026. /**
  6027. * The active length of the array.
  6028. */
  6029. length: number;
  6030. protected _id: number;
  6031. /**
  6032. * Instantiates a Smart Array.
  6033. * @param capacity defines the default capacity of the array.
  6034. */
  6035. constructor(capacity: number);
  6036. /**
  6037. * Pushes a value at the end of the active data.
  6038. * @param value defines the object to push in the array.
  6039. */
  6040. push(value: T): void;
  6041. /**
  6042. * Iterates over the active data and apply the lambda to them.
  6043. * @param func defines the action to apply on each value.
  6044. */
  6045. forEach(func: (content: T) => void): void;
  6046. /**
  6047. * Sorts the full sets of data.
  6048. * @param compareFn defines the comparison function to apply.
  6049. */
  6050. sort(compareFn: (a: T, b: T) => number): void;
  6051. /**
  6052. * Resets the active data to an empty array.
  6053. */
  6054. reset(): void;
  6055. /**
  6056. * Releases all the data from the array as well as the array.
  6057. */
  6058. dispose(): void;
  6059. /**
  6060. * Concats the active data with a given array.
  6061. * @param array defines the data to concatenate with.
  6062. */
  6063. concat(array: any): void;
  6064. /**
  6065. * Returns the position of a value in the active data.
  6066. * @param value defines the value to find the index for
  6067. * @returns the index if found in the active data otherwise -1
  6068. */
  6069. indexOf(value: T): number;
  6070. /**
  6071. * Returns whether an element is part of the active data.
  6072. * @param value defines the value to look for
  6073. * @returns true if found in the active data otherwise false
  6074. */
  6075. contains(value: T): boolean;
  6076. private static _GlobalId;
  6077. }
  6078. /**
  6079. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6080. * The data in this array can only be present once
  6081. */
  6082. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6083. private _duplicateId;
  6084. /**
  6085. * Pushes a value at the end of the active data.
  6086. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6087. * @param value defines the object to push in the array.
  6088. */
  6089. push(value: T): void;
  6090. /**
  6091. * Pushes a value at the end of the active data.
  6092. * If the data is already present, it won t be added again
  6093. * @param value defines the object to push in the array.
  6094. * @returns true if added false if it was already present
  6095. */
  6096. pushNoDuplicate(value: T): boolean;
  6097. /**
  6098. * Resets the active data to an empty array.
  6099. */
  6100. reset(): void;
  6101. /**
  6102. * Concats the active data with a given array.
  6103. * This ensures no dupplicate will be present in the result.
  6104. * @param array defines the data to concatenate with.
  6105. */
  6106. concatWithNoDuplicate(array: any): void;
  6107. }
  6108. }
  6109. declare module "babylonjs/Cameras/cameraInputsManager" {
  6110. import { Nullable } from "babylonjs/types";
  6111. import { Camera } from "babylonjs/Cameras/camera";
  6112. /**
  6113. * @ignore
  6114. * This is a list of all the different input types that are available in the application.
  6115. * Fo instance: ArcRotateCameraGamepadInput...
  6116. */
  6117. export var CameraInputTypes: {};
  6118. /**
  6119. * This is the contract to implement in order to create a new input class.
  6120. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6121. */
  6122. export interface ICameraInput<TCamera extends Camera> {
  6123. /**
  6124. * Defines the camera the input is attached to.
  6125. */
  6126. camera: Nullable<TCamera>;
  6127. /**
  6128. * Gets the class name of the current intput.
  6129. * @returns the class name
  6130. */
  6131. getClassName(): string;
  6132. /**
  6133. * Get the friendly name associated with the input class.
  6134. * @returns the input friendly name
  6135. */
  6136. getSimpleName(): string;
  6137. /**
  6138. * Attach the input controls to a specific dom element to get the input from.
  6139. * @param element Defines the element the controls should be listened from
  6140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6141. */
  6142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6143. /**
  6144. * Detach the current controls from the specified dom element.
  6145. * @param element Defines the element to stop listening the inputs from
  6146. */
  6147. detachControl(element: Nullable<HTMLElement>): void;
  6148. /**
  6149. * Update the current camera state depending on the inputs that have been used this frame.
  6150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6151. */
  6152. checkInputs?: () => void;
  6153. }
  6154. /**
  6155. * Represents a map of input types to input instance or input index to input instance.
  6156. */
  6157. export interface CameraInputsMap<TCamera extends Camera> {
  6158. /**
  6159. * Accessor to the input by input type.
  6160. */
  6161. [name: string]: ICameraInput<TCamera>;
  6162. /**
  6163. * Accessor to the input by input index.
  6164. */
  6165. [idx: number]: ICameraInput<TCamera>;
  6166. }
  6167. /**
  6168. * This represents the input manager used within a camera.
  6169. * It helps dealing with all the different kind of input attached to a camera.
  6170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6171. */
  6172. export class CameraInputsManager<TCamera extends Camera> {
  6173. /**
  6174. * Defines the list of inputs attahed to the camera.
  6175. */
  6176. attached: CameraInputsMap<TCamera>;
  6177. /**
  6178. * Defines the dom element the camera is collecting inputs from.
  6179. * This is null if the controls have not been attached.
  6180. */
  6181. attachedElement: Nullable<HTMLElement>;
  6182. /**
  6183. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6184. */
  6185. noPreventDefault: boolean;
  6186. /**
  6187. * Defined the camera the input manager belongs to.
  6188. */
  6189. camera: TCamera;
  6190. /**
  6191. * Update the current camera state depending on the inputs that have been used this frame.
  6192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6193. */
  6194. checkInputs: () => void;
  6195. /**
  6196. * Instantiate a new Camera Input Manager.
  6197. * @param camera Defines the camera the input manager blongs to
  6198. */
  6199. constructor(camera: TCamera);
  6200. /**
  6201. * Add an input method to a camera
  6202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6203. * @param input camera input method
  6204. */
  6205. add(input: ICameraInput<TCamera>): void;
  6206. /**
  6207. * Remove a specific input method from a camera
  6208. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6209. * @param inputToRemove camera input method
  6210. */
  6211. remove(inputToRemove: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input type from a camera
  6214. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6215. * @param inputType the type of the input to remove
  6216. */
  6217. removeByType(inputType: string): void;
  6218. private _addCheckInputs;
  6219. /**
  6220. * Attach the input controls to the currently attached dom element to listen the events from.
  6221. * @param input Defines the input to attach
  6222. */
  6223. attachInput(input: ICameraInput<TCamera>): void;
  6224. /**
  6225. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6226. * @param element Defines the dom element to collect the events from
  6227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6230. /**
  6231. * Detach the current manager inputs controls from a specific dom element.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6234. */
  6235. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6236. /**
  6237. * Rebuild the dynamic inputCheck function from the current list of
  6238. * defined inputs in the manager.
  6239. */
  6240. rebuildInputCheck(): void;
  6241. /**
  6242. * Remove all attached input methods from a camera
  6243. */
  6244. clear(): void;
  6245. /**
  6246. * Serialize the current input manager attached to a camera.
  6247. * This ensures than once parsed,
  6248. * the input associated to the camera will be identical to the current ones
  6249. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6250. */
  6251. serialize(serializedCamera: any): void;
  6252. /**
  6253. * Parses an input manager serialized JSON to restore the previous list of inputs
  6254. * and states associated to a camera.
  6255. * @param parsedCamera Defines the JSON to parse
  6256. */
  6257. parse(parsedCamera: any): void;
  6258. }
  6259. }
  6260. declare module "babylonjs/Meshes/buffer" {
  6261. import { Nullable, DataArray } from "babylonjs/types";
  6262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6263. /**
  6264. * Class used to store data that will be store in GPU memory
  6265. */
  6266. export class Buffer {
  6267. private _engine;
  6268. private _buffer;
  6269. /** @hidden */
  6270. _data: Nullable<DataArray>;
  6271. private _updatable;
  6272. private _instanced;
  6273. private _divisor;
  6274. /**
  6275. * Gets the byte stride.
  6276. */
  6277. readonly byteStride: number;
  6278. /**
  6279. * Constructor
  6280. * @param engine the engine
  6281. * @param data the data to use for this buffer
  6282. * @param updatable whether the data is updatable
  6283. * @param stride the stride (optional)
  6284. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6285. * @param instanced whether the buffer is instanced (optional)
  6286. * @param useBytes set to true if the stride in in bytes (optional)
  6287. * @param divisor sets an optional divisor for instances (1 by default)
  6288. */
  6289. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6290. /**
  6291. * Create a new VertexBuffer based on the current buffer
  6292. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6293. * @param offset defines offset in the buffer (0 by default)
  6294. * @param size defines the size in floats of attributes (position is 3 for instance)
  6295. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6296. * @param instanced defines if the vertex buffer contains indexed data
  6297. * @param useBytes defines if the offset and stride are in bytes *
  6298. * @param divisor sets an optional divisor for instances (1 by default)
  6299. * @returns the new vertex buffer
  6300. */
  6301. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6302. /**
  6303. * Gets a boolean indicating if the Buffer is updatable?
  6304. * @returns true if the buffer is updatable
  6305. */
  6306. isUpdatable(): boolean;
  6307. /**
  6308. * Gets current buffer's data
  6309. * @returns a DataArray or null
  6310. */
  6311. getData(): Nullable<DataArray>;
  6312. /**
  6313. * Gets underlying native buffer
  6314. * @returns underlying native buffer
  6315. */
  6316. getBuffer(): Nullable<DataBuffer>;
  6317. /**
  6318. * Gets the stride in float32 units (i.e. byte stride / 4).
  6319. * May not be an integer if the byte stride is not divisible by 4.
  6320. * @returns the stride in float32 units
  6321. * @deprecated Please use byteStride instead.
  6322. */
  6323. getStrideSize(): number;
  6324. /**
  6325. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6326. * @param data defines the data to store
  6327. */
  6328. create(data?: Nullable<DataArray>): void;
  6329. /** @hidden */
  6330. _rebuild(): void;
  6331. /**
  6332. * Update current buffer data
  6333. * @param data defines the data to store
  6334. */
  6335. update(data: DataArray): void;
  6336. /**
  6337. * Updates the data directly.
  6338. * @param data the new data
  6339. * @param offset the new offset
  6340. * @param vertexCount the vertex count (optional)
  6341. * @param useBytes set to true if the offset is in bytes
  6342. */
  6343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6344. /**
  6345. * Release all resources
  6346. */
  6347. dispose(): void;
  6348. }
  6349. /**
  6350. * Specialized buffer used to store vertex data
  6351. */
  6352. export class VertexBuffer {
  6353. /** @hidden */
  6354. _buffer: Buffer;
  6355. private _kind;
  6356. private _size;
  6357. private _ownsBuffer;
  6358. private _instanced;
  6359. private _instanceDivisor;
  6360. /**
  6361. * The byte type.
  6362. */
  6363. static readonly BYTE: number;
  6364. /**
  6365. * The unsigned byte type.
  6366. */
  6367. static readonly UNSIGNED_BYTE: number;
  6368. /**
  6369. * The short type.
  6370. */
  6371. static readonly SHORT: number;
  6372. /**
  6373. * The unsigned short type.
  6374. */
  6375. static readonly UNSIGNED_SHORT: number;
  6376. /**
  6377. * The integer type.
  6378. */
  6379. static readonly INT: number;
  6380. /**
  6381. * The unsigned integer type.
  6382. */
  6383. static readonly UNSIGNED_INT: number;
  6384. /**
  6385. * The float type.
  6386. */
  6387. static readonly FLOAT: number;
  6388. /**
  6389. * Gets or sets the instance divisor when in instanced mode
  6390. */
  6391. get instanceDivisor(): number;
  6392. set instanceDivisor(value: number);
  6393. /**
  6394. * Gets the byte stride.
  6395. */
  6396. readonly byteStride: number;
  6397. /**
  6398. * Gets the byte offset.
  6399. */
  6400. readonly byteOffset: number;
  6401. /**
  6402. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6403. */
  6404. readonly normalized: boolean;
  6405. /**
  6406. * Gets the data type of each component in the array.
  6407. */
  6408. readonly type: number;
  6409. /**
  6410. * Constructor
  6411. * @param engine the engine
  6412. * @param data the data to use for this vertex buffer
  6413. * @param kind the vertex buffer kind
  6414. * @param updatable whether the data is updatable
  6415. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6416. * @param stride the stride (optional)
  6417. * @param instanced whether the buffer is instanced (optional)
  6418. * @param offset the offset of the data (optional)
  6419. * @param size the number of components (optional)
  6420. * @param type the type of the component (optional)
  6421. * @param normalized whether the data contains normalized data (optional)
  6422. * @param useBytes set to true if stride and offset are in bytes (optional)
  6423. * @param divisor defines the instance divisor to use (1 by default)
  6424. */
  6425. 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);
  6426. /** @hidden */
  6427. _rebuild(): void;
  6428. /**
  6429. * Returns the kind of the VertexBuffer (string)
  6430. * @returns a string
  6431. */
  6432. getKind(): string;
  6433. /**
  6434. * Gets a boolean indicating if the VertexBuffer is updatable?
  6435. * @returns true if the buffer is updatable
  6436. */
  6437. isUpdatable(): boolean;
  6438. /**
  6439. * Gets current buffer's data
  6440. * @returns a DataArray or null
  6441. */
  6442. getData(): Nullable<DataArray>;
  6443. /**
  6444. * Gets underlying native buffer
  6445. * @returns underlying native buffer
  6446. */
  6447. getBuffer(): Nullable<DataBuffer>;
  6448. /**
  6449. * Gets the stride in float32 units (i.e. byte stride / 4).
  6450. * May not be an integer if the byte stride is not divisible by 4.
  6451. * @returns the stride in float32 units
  6452. * @deprecated Please use byteStride instead.
  6453. */
  6454. getStrideSize(): number;
  6455. /**
  6456. * Returns the offset as a multiple of the type byte length.
  6457. * @returns the offset in bytes
  6458. * @deprecated Please use byteOffset instead.
  6459. */
  6460. getOffset(): number;
  6461. /**
  6462. * Returns the number of components per vertex attribute (integer)
  6463. * @returns the size in float
  6464. */
  6465. getSize(): number;
  6466. /**
  6467. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6468. * @returns true if this buffer is instanced
  6469. */
  6470. getIsInstanced(): boolean;
  6471. /**
  6472. * Returns the instancing divisor, zero for non-instanced (integer).
  6473. * @returns a number
  6474. */
  6475. getInstanceDivisor(): number;
  6476. /**
  6477. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6478. * @param data defines the data to store
  6479. */
  6480. create(data?: DataArray): void;
  6481. /**
  6482. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6483. * This function will create a new buffer if the current one is not updatable
  6484. * @param data defines the data to store
  6485. */
  6486. update(data: DataArray): void;
  6487. /**
  6488. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6489. * Returns the directly updated WebGLBuffer.
  6490. * @param data the new data
  6491. * @param offset the new offset
  6492. * @param useBytes set to true if the offset is in bytes
  6493. */
  6494. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6495. /**
  6496. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6497. */
  6498. dispose(): void;
  6499. /**
  6500. * Enumerates each value of this vertex buffer as numbers.
  6501. * @param count the number of values to enumerate
  6502. * @param callback the callback function called for each value
  6503. */
  6504. forEach(count: number, callback: (value: number, index: number) => void): void;
  6505. /**
  6506. * Positions
  6507. */
  6508. static readonly PositionKind: string;
  6509. /**
  6510. * Normals
  6511. */
  6512. static readonly NormalKind: string;
  6513. /**
  6514. * Tangents
  6515. */
  6516. static readonly TangentKind: string;
  6517. /**
  6518. * Texture coordinates
  6519. */
  6520. static readonly UVKind: string;
  6521. /**
  6522. * Texture coordinates 2
  6523. */
  6524. static readonly UV2Kind: string;
  6525. /**
  6526. * Texture coordinates 3
  6527. */
  6528. static readonly UV3Kind: string;
  6529. /**
  6530. * Texture coordinates 4
  6531. */
  6532. static readonly UV4Kind: string;
  6533. /**
  6534. * Texture coordinates 5
  6535. */
  6536. static readonly UV5Kind: string;
  6537. /**
  6538. * Texture coordinates 6
  6539. */
  6540. static readonly UV6Kind: string;
  6541. /**
  6542. * Colors
  6543. */
  6544. static readonly ColorKind: string;
  6545. /**
  6546. * Matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesKind: string;
  6549. /**
  6550. * Matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsKind: string;
  6553. /**
  6554. * Additional matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesExtraKind: string;
  6557. /**
  6558. * Additional matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsExtraKind: string;
  6561. /**
  6562. * Deduces the stride given a kind.
  6563. * @param kind The kind string to deduce
  6564. * @returns The deduced stride
  6565. */
  6566. static DeduceStride(kind: string): number;
  6567. /**
  6568. * Gets the byte length of the given type.
  6569. * @param type the type
  6570. * @returns the number of bytes
  6571. */
  6572. static GetTypeByteLength(type: number): number;
  6573. /**
  6574. * Enumerates each value of the given parameters as numbers.
  6575. * @param data the data to enumerate
  6576. * @param byteOffset the byte offset of the data
  6577. * @param byteStride the byte stride of the data
  6578. * @param componentCount the number of components per element
  6579. * @param componentType the type of the component
  6580. * @param count the number of values to enumerate
  6581. * @param normalized whether the data is normalized
  6582. * @param callback the callback function called for each value
  6583. */
  6584. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6585. private static _GetFloatValue;
  6586. }
  6587. }
  6588. declare module "babylonjs/Collisions/intersectionInfo" {
  6589. import { Nullable } from "babylonjs/types";
  6590. /**
  6591. * @hidden
  6592. */
  6593. export class IntersectionInfo {
  6594. bu: Nullable<number>;
  6595. bv: Nullable<number>;
  6596. distance: number;
  6597. faceId: number;
  6598. subMeshId: number;
  6599. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6600. }
  6601. }
  6602. declare module "babylonjs/Maths/math.plane" {
  6603. import { DeepImmutable } from "babylonjs/types";
  6604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Culling/boundingSphere" {
  6713. import { DeepImmutable } from "babylonjs/types";
  6714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6715. import { Plane } from "babylonjs/Maths/math.plane";
  6716. /**
  6717. * Class used to store bounding sphere information
  6718. */
  6719. export class BoundingSphere {
  6720. /**
  6721. * Gets the center of the bounding sphere in local space
  6722. */
  6723. readonly center: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in local space
  6726. */
  6727. radius: number;
  6728. /**
  6729. * Gets the center of the bounding sphere in world space
  6730. */
  6731. readonly centerWorld: Vector3;
  6732. /**
  6733. * Radius of the bounding sphere in world space
  6734. */
  6735. radiusWorld: number;
  6736. /**
  6737. * Gets the minimum vector in local space
  6738. */
  6739. readonly minimum: Vector3;
  6740. /**
  6741. * Gets the maximum vector in local space
  6742. */
  6743. readonly maximum: Vector3;
  6744. private _worldMatrix;
  6745. private static readonly TmpVector3;
  6746. /**
  6747. * Creates a new bounding sphere
  6748. * @param min defines the minimum vector (in local space)
  6749. * @param max defines the maximum vector (in local space)
  6750. * @param worldMatrix defines the new world matrix
  6751. */
  6752. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6753. /**
  6754. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6755. * @param min defines the new minimum vector (in local space)
  6756. * @param max defines the new maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6760. /**
  6761. * Scale the current bounding sphere by applying a scale factor
  6762. * @param factor defines the scale factor to apply
  6763. * @returns the current bounding box
  6764. */
  6765. scale(factor: number): BoundingSphere;
  6766. /**
  6767. * Gets the world matrix of the bounding box
  6768. * @returns a matrix
  6769. */
  6770. getWorldMatrix(): DeepImmutable<Matrix>;
  6771. /** @hidden */
  6772. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6773. /**
  6774. * Tests if the bounding sphere is intersecting the frustum planes
  6775. * @param frustumPlanes defines the frustum planes to test
  6776. * @returns true if there is an intersection
  6777. */
  6778. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6779. /**
  6780. * Tests if the bounding sphere center is in between the frustum planes.
  6781. * Used for optimistic fast inclusion.
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if the sphere center is in between the frustum planes
  6784. */
  6785. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if a point is inside the bounding sphere
  6788. * @param point defines the point to test
  6789. * @returns true if the point is inside the bounding sphere
  6790. */
  6791. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6792. /**
  6793. * Checks if two sphere intersct
  6794. * @param sphere0 sphere 0
  6795. * @param sphere1 sphere 1
  6796. * @returns true if the speres intersect
  6797. */
  6798. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6799. }
  6800. }
  6801. declare module "babylonjs/Culling/boundingBox" {
  6802. import { DeepImmutable } from "babylonjs/types";
  6803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6804. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6805. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6806. import { Plane } from "babylonjs/Maths/math.plane";
  6807. /**
  6808. * Class used to store bounding box information
  6809. */
  6810. export class BoundingBox implements ICullable {
  6811. /**
  6812. * Gets the 8 vectors representing the bounding box in local space
  6813. */
  6814. readonly vectors: Vector3[];
  6815. /**
  6816. * Gets the center of the bounding box in local space
  6817. */
  6818. readonly center: Vector3;
  6819. /**
  6820. * Gets the center of the bounding box in world space
  6821. */
  6822. readonly centerWorld: Vector3;
  6823. /**
  6824. * Gets the extend size in local space
  6825. */
  6826. readonly extendSize: Vector3;
  6827. /**
  6828. * Gets the extend size in world space
  6829. */
  6830. readonly extendSizeWorld: Vector3;
  6831. /**
  6832. * Gets the OBB (object bounding box) directions
  6833. */
  6834. readonly directions: Vector3[];
  6835. /**
  6836. * Gets the 8 vectors representing the bounding box in world space
  6837. */
  6838. readonly vectorsWorld: Vector3[];
  6839. /**
  6840. * Gets the minimum vector in world space
  6841. */
  6842. readonly minimumWorld: Vector3;
  6843. /**
  6844. * Gets the maximum vector in world space
  6845. */
  6846. readonly maximumWorld: Vector3;
  6847. /**
  6848. * Gets the minimum vector in local space
  6849. */
  6850. readonly minimum: Vector3;
  6851. /**
  6852. * Gets the maximum vector in local space
  6853. */
  6854. readonly maximum: Vector3;
  6855. private _worldMatrix;
  6856. private static readonly TmpVector3;
  6857. /**
  6858. * @hidden
  6859. */
  6860. _tag: number;
  6861. /**
  6862. * Creates a new bounding box
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding box by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingBox;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(world: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding box is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding box is entirely inside the frustum planes
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if there is an inclusion
  6898. */
  6899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding box
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding box
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a bounding sphere
  6908. * @param sphere defines the sphere to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6912. /**
  6913. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6914. * @param min defines the min vector to use
  6915. * @param max defines the max vector to use
  6916. * @returns true if there is an intersection
  6917. */
  6918. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Tests if two bounding boxes are intersections
  6921. * @param box0 defines the first box to test
  6922. * @param box1 defines the second box to test
  6923. * @returns true if there is an intersection
  6924. */
  6925. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6926. /**
  6927. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6928. * @param minPoint defines the minimum vector of the bounding box
  6929. * @param maxPoint defines the maximum vector of the bounding box
  6930. * @param sphereCenter defines the sphere center
  6931. * @param sphereRadius defines the sphere radius
  6932. * @returns true if there is an intersection
  6933. */
  6934. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an inclusion
  6940. */
  6941. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6944. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @return true if there is an intersection
  6947. */
  6948. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. }
  6950. }
  6951. declare module "babylonjs/Collisions/collider" {
  6952. import { Nullable, IndicesArray } from "babylonjs/types";
  6953. import { Vector3 } from "babylonjs/Maths/math.vector";
  6954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6955. import { Plane } from "babylonjs/Maths/math.plane";
  6956. /** @hidden */
  6957. export class Collider {
  6958. /** Define if a collision was found */
  6959. collisionFound: boolean;
  6960. /**
  6961. * Define last intersection point in local space
  6962. */
  6963. intersectionPoint: Vector3;
  6964. /**
  6965. * Define last collided mesh
  6966. */
  6967. collidedMesh: Nullable<AbstractMesh>;
  6968. private _collisionPoint;
  6969. private _planeIntersectionPoint;
  6970. private _tempVector;
  6971. private _tempVector2;
  6972. private _tempVector3;
  6973. private _tempVector4;
  6974. private _edge;
  6975. private _baseToVertex;
  6976. private _destinationPoint;
  6977. private _slidePlaneNormal;
  6978. private _displacementVector;
  6979. /** @hidden */
  6980. _radius: Vector3;
  6981. /** @hidden */
  6982. _retry: number;
  6983. private _velocity;
  6984. private _basePoint;
  6985. private _epsilon;
  6986. /** @hidden */
  6987. _velocityWorldLength: number;
  6988. /** @hidden */
  6989. _basePointWorld: Vector3;
  6990. private _velocityWorld;
  6991. private _normalizedVelocity;
  6992. /** @hidden */
  6993. _initialVelocity: Vector3;
  6994. /** @hidden */
  6995. _initialPosition: Vector3;
  6996. private _nearestDistance;
  6997. private _collisionMask;
  6998. get collisionMask(): number;
  6999. set collisionMask(mask: number);
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. get slidePlaneNormal(): Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module "babylonjs/Culling/boundingInfo" {
  7019. import { DeepImmutable } from "babylonjs/types";
  7020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7021. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7022. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7023. import { Plane } from "babylonjs/Maths/math.plane";
  7024. import { Collider } from "babylonjs/Collisions/collider";
  7025. /**
  7026. * Interface for cullable objects
  7027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7028. */
  7029. export interface ICullable {
  7030. /**
  7031. * Checks if the object or part of the object is in the frustum
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isInFrustum(frustumPlanes: Plane[]): boolean;
  7036. /**
  7037. * Checks if a cullable object (mesh...) is in the camera frustum
  7038. * Unlike isInFrustum this cheks the full bounding box
  7039. * @param frustumPlanes Camera near/planes
  7040. * @returns true if the object is in frustum otherwise false
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7043. }
  7044. /**
  7045. * Info for a bounding data of a mesh
  7046. */
  7047. export class BoundingInfo implements ICullable {
  7048. /**
  7049. * Bounding box for the mesh
  7050. */
  7051. readonly boundingBox: BoundingBox;
  7052. /**
  7053. * Bounding sphere for the mesh
  7054. */
  7055. readonly boundingSphere: BoundingSphere;
  7056. private _isLocked;
  7057. private static readonly TmpVector3;
  7058. /**
  7059. * Constructs bounding info
  7060. * @param minimum min vector of the bounding box/sphere
  7061. * @param maximum max vector of the bounding box/sphere
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7065. /**
  7066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7067. * @param min defines the new minimum vector (in local space)
  7068. * @param max defines the new maximum vector (in local space)
  7069. * @param worldMatrix defines the new world matrix
  7070. */
  7071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * min vector of the bounding box/sphere
  7074. */
  7075. get minimum(): Vector3;
  7076. /**
  7077. * max vector of the bounding box/sphere
  7078. */
  7079. get maximum(): Vector3;
  7080. /**
  7081. * If the info is locked and won't be updated to avoid perf overhead
  7082. */
  7083. get isLocked(): boolean;
  7084. set isLocked(value: boolean);
  7085. /**
  7086. * Updates the bounding sphere and box
  7087. * @param world world matrix to be used to update
  7088. */
  7089. update(world: DeepImmutable<Matrix>): void;
  7090. /**
  7091. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7092. * @param center New center of the bounding info
  7093. * @param extend New extend of the bounding info
  7094. * @returns the current bounding info
  7095. */
  7096. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7097. /**
  7098. * Scale the current bounding info by applying a scale factor
  7099. * @param factor defines the scale factor to apply
  7100. * @returns the current bounding info
  7101. */
  7102. scale(factor: number): BoundingInfo;
  7103. /**
  7104. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7105. * @param frustumPlanes defines the frustum to test
  7106. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7107. * @returns true if the bounding info is in the frustum planes
  7108. */
  7109. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7110. /**
  7111. * Gets the world distance between the min and max points of the bounding box
  7112. */
  7113. get diagonalLength(): number;
  7114. /**
  7115. * Checks if a cullable object (mesh...) is in the camera frustum
  7116. * Unlike isInFrustum this cheks the full bounding box
  7117. * @param frustumPlanes Camera near/planes
  7118. * @returns true if the object is in frustum otherwise false
  7119. */
  7120. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /** @hidden */
  7122. _checkCollision(collider: Collider): boolean;
  7123. /**
  7124. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7126. * @param point the point to check intersection with
  7127. * @returns if the point intersects
  7128. */
  7129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7130. /**
  7131. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7132. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7133. * @param boundingInfo the bounding info to check intersection with
  7134. * @param precise if the intersection should be done using OBB
  7135. * @returns if the bounding info intersects
  7136. */
  7137. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7138. }
  7139. }
  7140. declare module "babylonjs/Maths/math.functions" {
  7141. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7142. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7143. /**
  7144. * Extracts minimum and maximum values from a list of indexed positions
  7145. * @param positions defines the positions to use
  7146. * @param indices defines the indices to the positions
  7147. * @param indexStart defines the start index
  7148. * @param indexCount defines the end index
  7149. * @param bias defines bias value to add to the result
  7150. * @return minimum and maximum values
  7151. */
  7152. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7153. minimum: Vector3;
  7154. maximum: Vector3;
  7155. };
  7156. /**
  7157. * Extracts minimum and maximum values from a list of positions
  7158. * @param positions defines the positions to use
  7159. * @param start defines the start index in the positions array
  7160. * @param count defines the number of positions to handle
  7161. * @param bias defines bias value to add to the result
  7162. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. }
  7170. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7172. /** @hidden */
  7173. export class WebGLDataBuffer extends DataBuffer {
  7174. private _buffer;
  7175. constructor(resource: WebGLBuffer);
  7176. get underlyingResource(): any;
  7177. }
  7178. }
  7179. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7180. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7181. import { Nullable } from "babylonjs/types";
  7182. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7183. /** @hidden */
  7184. export class WebGLPipelineContext implements IPipelineContext {
  7185. engine: ThinEngine;
  7186. program: Nullable<WebGLProgram>;
  7187. context?: WebGLRenderingContext;
  7188. vertexShader?: WebGLShader;
  7189. fragmentShader?: WebGLShader;
  7190. isParallelCompiled: boolean;
  7191. onCompiled?: () => void;
  7192. transformFeedback?: WebGLTransformFeedback | null;
  7193. vertexCompilationError: Nullable<string>;
  7194. fragmentCompilationError: Nullable<string>;
  7195. programLinkError: Nullable<string>;
  7196. programValidationError: Nullable<string>;
  7197. get isAsync(): boolean;
  7198. get isReady(): boolean;
  7199. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7200. }
  7201. }
  7202. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7203. import { FloatArray, Nullable } from "babylonjs/types";
  7204. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7205. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7206. module "babylonjs/Engines/thinEngine" {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. }
  7252. declare module "babylonjs/Materials/uniformBuffer" {
  7253. import { Nullable, FloatArray } from "babylonjs/types";
  7254. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7255. import { Engine } from "babylonjs/Engines/engine";
  7256. import { Effect } from "babylonjs/Materials/effect";
  7257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7258. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7259. import { Color3 } from "babylonjs/Maths/math.color";
  7260. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7261. /**
  7262. * Uniform buffer objects.
  7263. *
  7264. * Handles blocks of uniform on the GPU.
  7265. *
  7266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7267. *
  7268. * For more information, please refer to :
  7269. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7270. */
  7271. export class UniformBuffer {
  7272. private _engine;
  7273. private _buffer;
  7274. private _data;
  7275. private _bufferData;
  7276. private _dynamic?;
  7277. private _uniformLocations;
  7278. private _uniformSizes;
  7279. private _uniformLocationPointer;
  7280. private _needSync;
  7281. private _noUBO;
  7282. private _currentEffect;
  7283. /** @hidden */
  7284. _alreadyBound: boolean;
  7285. private static _MAX_UNIFORM_SIZE;
  7286. private static _tempBuffer;
  7287. /**
  7288. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7293. /**
  7294. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7299. /**
  7300. * Lambda to Update a single float in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateFloat: (name: string, x: number) => void;
  7305. /**
  7306. * Lambda to Update a vec2 of float in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7311. /**
  7312. * Lambda to Update a vec3 of float in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update a vec4 of float in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7323. /**
  7324. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7325. * This is dynamic to allow compat with webgl 1 and 2.
  7326. * You will need to pass the name of the uniform as well as the value.
  7327. */
  7328. updateMatrix: (name: string, mat: Matrix) => void;
  7329. /**
  7330. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7331. * This is dynamic to allow compat with webgl 1 and 2.
  7332. * You will need to pass the name of the uniform as well as the value.
  7333. */
  7334. updateVector3: (name: string, vector: Vector3) => void;
  7335. /**
  7336. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7337. * This is dynamic to allow compat with webgl 1 and 2.
  7338. * You will need to pass the name of the uniform as well as the value.
  7339. */
  7340. updateVector4: (name: string, vector: Vector4) => void;
  7341. /**
  7342. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7343. * This is dynamic to allow compat with webgl 1 and 2.
  7344. * You will need to pass the name of the uniform as well as the value.
  7345. */
  7346. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7347. /**
  7348. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7349. * This is dynamic to allow compat with webgl 1 and 2.
  7350. * You will need to pass the name of the uniform as well as the value.
  7351. */
  7352. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7353. /**
  7354. * Instantiates a new Uniform buffer objects.
  7355. *
  7356. * Handles blocks of uniform on the GPU.
  7357. *
  7358. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7359. *
  7360. * For more information, please refer to :
  7361. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7362. * @param engine Define the engine the buffer is associated with
  7363. * @param data Define the data contained in the buffer
  7364. * @param dynamic Define if the buffer is updatable
  7365. */
  7366. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7367. /**
  7368. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7369. * or just falling back on setUniformXXX calls.
  7370. */
  7371. get useUbo(): boolean;
  7372. /**
  7373. * Indicates if the WebGL underlying uniform buffer is in sync
  7374. * with the javascript cache data.
  7375. */
  7376. get isSync(): boolean;
  7377. /**
  7378. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7379. * Also, a dynamic UniformBuffer will disable cache verification and always
  7380. * update the underlying WebGL uniform buffer to the GPU.
  7381. * @returns if Dynamic, otherwise false
  7382. */
  7383. isDynamic(): boolean;
  7384. /**
  7385. * The data cache on JS side.
  7386. * @returns the underlying data as a float array
  7387. */
  7388. getData(): Float32Array;
  7389. /**
  7390. * The underlying WebGL Uniform buffer.
  7391. * @returns the webgl buffer
  7392. */
  7393. getBuffer(): Nullable<DataBuffer>;
  7394. /**
  7395. * std140 layout specifies how to align data within an UBO structure.
  7396. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7397. * for specs.
  7398. */
  7399. private _fillAlignment;
  7400. /**
  7401. * Adds an uniform in the buffer.
  7402. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7403. * for the layout to be correct !
  7404. * @param name Name of the uniform, as used in the uniform block in the shader.
  7405. * @param size Data size, or data directly.
  7406. */
  7407. addUniform(name: string, size: number | number[]): void;
  7408. /**
  7409. * Adds a Matrix 4x4 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param mat A 4x4 matrix.
  7412. */
  7413. addMatrix(name: string, mat: Matrix): void;
  7414. /**
  7415. * Adds a vec2 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. * @param x Define the x component value of the vec2
  7418. * @param y Define the y component value of the vec2
  7419. */
  7420. addFloat2(name: string, x: number, y: number): void;
  7421. /**
  7422. * Adds a vec3 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param x Define the x component value of the vec3
  7425. * @param y Define the y component value of the vec3
  7426. * @param z Define the z component value of the vec3
  7427. */
  7428. addFloat3(name: string, x: number, y: number, z: number): void;
  7429. /**
  7430. * Adds a vec3 to the uniform buffer.
  7431. * @param name Name of the uniform, as used in the uniform block in the shader.
  7432. * @param color Define the vec3 from a Color
  7433. */
  7434. addColor3(name: string, color: Color3): void;
  7435. /**
  7436. * Adds a vec4 to the uniform buffer.
  7437. * @param name Name of the uniform, as used in the uniform block in the shader.
  7438. * @param color Define the rgb components from a Color
  7439. * @param alpha Define the a component of the vec4
  7440. */
  7441. addColor4(name: string, color: Color3, alpha: number): void;
  7442. /**
  7443. * Adds a vec3 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param vector Define the vec3 components from a Vector
  7446. */
  7447. addVector3(name: string, vector: Vector3): void;
  7448. /**
  7449. * Adds a Matrix 3x3 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. */
  7452. addMatrix3x3(name: string): void;
  7453. /**
  7454. * Adds a Matrix 2x2 to the uniform buffer.
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. */
  7457. addMatrix2x2(name: string): void;
  7458. /**
  7459. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7460. */
  7461. create(): void;
  7462. /** @hidden */
  7463. _rebuild(): void;
  7464. /**
  7465. * Updates the WebGL Uniform Buffer on the GPU.
  7466. * If the `dynamic` flag is set to true, no cache comparison is done.
  7467. * Otherwise, the buffer will be updated only if the cache differs.
  7468. */
  7469. update(): void;
  7470. /**
  7471. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. * @param size Define the size of the data.
  7475. */
  7476. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7477. private _valueCache;
  7478. private _cacheMatrix;
  7479. private _updateMatrix3x3ForUniform;
  7480. private _updateMatrix3x3ForEffect;
  7481. private _updateMatrix2x2ForEffect;
  7482. private _updateMatrix2x2ForUniform;
  7483. private _updateFloatForEffect;
  7484. private _updateFloatForUniform;
  7485. private _updateFloat2ForEffect;
  7486. private _updateFloat2ForUniform;
  7487. private _updateFloat3ForEffect;
  7488. private _updateFloat3ForUniform;
  7489. private _updateFloat4ForEffect;
  7490. private _updateFloat4ForUniform;
  7491. private _updateMatrixForEffect;
  7492. private _updateMatrixForUniform;
  7493. private _updateVector3ForEffect;
  7494. private _updateVector3ForUniform;
  7495. private _updateVector4ForEffect;
  7496. private _updateVector4ForUniform;
  7497. private _updateColor3ForEffect;
  7498. private _updateColor3ForUniform;
  7499. private _updateColor4ForEffect;
  7500. private _updateColor4ForUniform;
  7501. /**
  7502. * Sets a sampler uniform on the effect.
  7503. * @param name Define the name of the sampler.
  7504. * @param texture Define the texture to set in the sampler
  7505. */
  7506. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7507. /**
  7508. * Directly updates the value of the uniform in the cache AND on the GPU.
  7509. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7510. * @param data Define the flattened data
  7511. */
  7512. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7513. /**
  7514. * Binds this uniform buffer to an effect.
  7515. * @param effect Define the effect to bind the buffer to
  7516. * @param name Name of the uniform block in the shader.
  7517. */
  7518. bindToEffect(effect: Effect, name: string): void;
  7519. /**
  7520. * Disposes the uniform buffer.
  7521. */
  7522. dispose(): void;
  7523. }
  7524. }
  7525. declare module "babylonjs/Misc/iInspectable" {
  7526. /**
  7527. * Enum that determines the text-wrapping mode to use.
  7528. */
  7529. export enum InspectableType {
  7530. /**
  7531. * Checkbox for booleans
  7532. */
  7533. Checkbox = 0,
  7534. /**
  7535. * Sliders for numbers
  7536. */
  7537. Slider = 1,
  7538. /**
  7539. * Vector3
  7540. */
  7541. Vector3 = 2,
  7542. /**
  7543. * Quaternions
  7544. */
  7545. Quaternion = 3,
  7546. /**
  7547. * Color3
  7548. */
  7549. Color3 = 4,
  7550. /**
  7551. * String
  7552. */
  7553. String = 5
  7554. }
  7555. /**
  7556. * Interface used to define custom inspectable properties.
  7557. * This interface is used by the inspector to display custom property grids
  7558. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7559. */
  7560. export interface IInspectable {
  7561. /**
  7562. * Gets the label to display
  7563. */
  7564. label: string;
  7565. /**
  7566. * Gets the name of the property to edit
  7567. */
  7568. propertyName: string;
  7569. /**
  7570. * Gets the type of the editor to use
  7571. */
  7572. type: InspectableType;
  7573. /**
  7574. * Gets the minimum value of the property when using in "slider" mode
  7575. */
  7576. min?: number;
  7577. /**
  7578. * Gets the maximum value of the property when using in "slider" mode
  7579. */
  7580. max?: number;
  7581. /**
  7582. * Gets the setp to use when using in "slider" mode
  7583. */
  7584. step?: number;
  7585. }
  7586. }
  7587. declare module "babylonjs/Misc/timingTools" {
  7588. /**
  7589. * Class used to provide helper for timing
  7590. */
  7591. export class TimingTools {
  7592. /**
  7593. * Polyfill for setImmediate
  7594. * @param action defines the action to execute after the current execution block
  7595. */
  7596. static SetImmediate(action: () => void): void;
  7597. }
  7598. }
  7599. declare module "babylonjs/Misc/instantiationTools" {
  7600. /**
  7601. * Class used to enable instatition of objects by class name
  7602. */
  7603. export class InstantiationTools {
  7604. /**
  7605. * Use this object to register external classes like custom textures or material
  7606. * to allow the laoders to instantiate them
  7607. */
  7608. static RegisteredExternalClasses: {
  7609. [key: string]: Object;
  7610. };
  7611. /**
  7612. * Tries to instantiate a new object from a given class name
  7613. * @param className defines the class name to instantiate
  7614. * @returns the new object or null if the system was not able to do the instantiation
  7615. */
  7616. static Instantiate(className: string): any;
  7617. }
  7618. }
  7619. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7620. /**
  7621. * Define options used to create a depth texture
  7622. */
  7623. export class DepthTextureCreationOptions {
  7624. /** Specifies whether or not a stencil should be allocated in the texture */
  7625. generateStencil?: boolean;
  7626. /** Specifies whether or not bilinear filtering is enable on the texture */
  7627. bilinearFiltering?: boolean;
  7628. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7629. comparisonFunction?: number;
  7630. /** Specifies if the created texture is a cube texture */
  7631. isCube?: boolean;
  7632. }
  7633. }
  7634. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7635. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7636. import { Nullable } from "babylonjs/types";
  7637. import { Scene } from "babylonjs/scene";
  7638. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7639. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7640. module "babylonjs/Engines/thinEngine" {
  7641. interface ThinEngine {
  7642. /**
  7643. * Creates a depth stencil cube texture.
  7644. * This is only available in WebGL 2.
  7645. * @param size The size of face edge in the cube texture.
  7646. * @param options The options defining the cube texture.
  7647. * @returns The cube texture
  7648. */
  7649. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7650. /**
  7651. * Creates a cube texture
  7652. * @param rootUrl defines the url where the files to load is located
  7653. * @param scene defines the current scene
  7654. * @param files defines the list of files to load (1 per face)
  7655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7656. * @param onLoad defines an optional callback raised when the texture is loaded
  7657. * @param onError defines an optional callback raised if there is an issue to load the texture
  7658. * @param format defines the format of the data
  7659. * @param forcedExtension defines the extension to use to pick the right loader
  7660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7663. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7664. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7665. * @returns the cube texture as an InternalTexture
  7666. */
  7667. 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;
  7668. /**
  7669. * Creates a cube texture
  7670. * @param rootUrl defines the url where the files to load is located
  7671. * @param scene defines the current scene
  7672. * @param files defines the list of files to load (1 per face)
  7673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7674. * @param onLoad defines an optional callback raised when the texture is loaded
  7675. * @param onError defines an optional callback raised if there is an issue to load the texture
  7676. * @param format defines the format of the data
  7677. * @param forcedExtension defines the extension to use to pick the right loader
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /**
  7682. * Creates a cube texture
  7683. * @param rootUrl defines the url where the files to load is located
  7684. * @param scene defines the current scene
  7685. * @param files defines the list of files to load (1 per face)
  7686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7687. * @param onLoad defines an optional callback raised when the texture is loaded
  7688. * @param onError defines an optional callback raised if there is an issue to load the texture
  7689. * @param format defines the format of the data
  7690. * @param forcedExtension defines the extension to use to pick the right loader
  7691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7694. * @returns the cube texture as an InternalTexture
  7695. */
  7696. 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;
  7697. /** @hidden */
  7698. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7699. /** @hidden */
  7700. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7701. /** @hidden */
  7702. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7703. /** @hidden */
  7704. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7705. /**
  7706. * @hidden
  7707. */
  7708. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7709. }
  7710. }
  7711. }
  7712. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7713. import { Nullable } from "babylonjs/types";
  7714. import { Scene } from "babylonjs/scene";
  7715. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7717. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7718. /**
  7719. * Class for creating a cube texture
  7720. */
  7721. export class CubeTexture extends BaseTexture {
  7722. private _delayedOnLoad;
  7723. /**
  7724. * The url of the texture
  7725. */
  7726. url: string;
  7727. /**
  7728. * Gets or sets the center of the bounding box associated with the cube texture.
  7729. * It must define where the camera used to render the texture was set
  7730. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7731. */
  7732. boundingBoxPosition: Vector3;
  7733. private _boundingBoxSize;
  7734. /**
  7735. * Gets or sets the size of the bounding box associated with the cube texture
  7736. * When defined, the cubemap will switch to local mode
  7737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7738. * @example https://www.babylonjs-playground.com/#RNASML
  7739. */
  7740. set boundingBoxSize(value: Vector3);
  7741. /**
  7742. * Returns the bounding box size
  7743. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7744. */
  7745. get boundingBoxSize(): Vector3;
  7746. protected _rotationY: number;
  7747. /**
  7748. * Sets texture matrix rotation angle around Y axis in radians.
  7749. */
  7750. set rotationY(value: number);
  7751. /**
  7752. * Gets texture matrix rotation angle around Y axis radians.
  7753. */
  7754. get rotationY(): number;
  7755. /**
  7756. * Are mip maps generated for this texture or not.
  7757. */
  7758. get noMipmap(): boolean;
  7759. private _noMipmap;
  7760. private _files;
  7761. protected _forcedExtension: Nullable<string>;
  7762. private _extensions;
  7763. private _textureMatrix;
  7764. private _format;
  7765. private _createPolynomials;
  7766. /** @hidden */
  7767. _prefiltered: boolean;
  7768. /**
  7769. * Creates a cube texture from an array of image urls
  7770. * @param files defines an array of image urls
  7771. * @param scene defines the hosting scene
  7772. * @param noMipmap specifies if mip maps are not used
  7773. * @returns a cube texture
  7774. */
  7775. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7776. /**
  7777. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7778. * @param url defines the url of the prefiltered texture
  7779. * @param scene defines the scene the texture is attached to
  7780. * @param forcedExtension defines the extension of the file if different from the url
  7781. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7782. * @return the prefiltered texture
  7783. */
  7784. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7785. /**
  7786. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7787. * as prefiltered data.
  7788. * @param rootUrl defines the url of the texture or the root name of the six images
  7789. * @param scene defines the scene the texture is attached to
  7790. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7791. * @param noMipmap defines if mipmaps should be created or not
  7792. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7793. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7794. * @param onError defines a callback triggered in case of error during load
  7795. * @param format defines the internal format to use for the texture once loaded
  7796. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7797. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7798. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7799. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7800. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7801. * @return the cube texture
  7802. */
  7803. 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);
  7804. /**
  7805. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7806. */
  7807. get isPrefiltered(): boolean;
  7808. /**
  7809. * Get the current class name of the texture useful for serialization or dynamic coding.
  7810. * @returns "CubeTexture"
  7811. */
  7812. getClassName(): string;
  7813. /**
  7814. * Update the url (and optional buffer) of this texture if url was null during construction.
  7815. * @param url the url of the texture
  7816. * @param forcedExtension defines the extension to use
  7817. * @param onLoad callback called when the texture is loaded (defaults to null)
  7818. */
  7819. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7820. /**
  7821. * Delays loading of the cube texture
  7822. * @param forcedExtension defines the extension to use
  7823. */
  7824. delayLoad(forcedExtension?: string): void;
  7825. /**
  7826. * Returns the reflection texture matrix
  7827. * @returns the reflection texture matrix
  7828. */
  7829. getReflectionTextureMatrix(): Matrix;
  7830. /**
  7831. * Sets the reflection texture matrix
  7832. * @param value Reflection texture matrix
  7833. */
  7834. setReflectionTextureMatrix(value: Matrix): void;
  7835. /**
  7836. * Parses text to create a cube texture
  7837. * @param parsedTexture define the serialized text to read from
  7838. * @param scene defines the hosting scene
  7839. * @param rootUrl defines the root url of the cube texture
  7840. * @returns a cube texture
  7841. */
  7842. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7843. /**
  7844. * Makes a clone, or deep copy, of the cube texture
  7845. * @returns a new cube texture
  7846. */
  7847. clone(): CubeTexture;
  7848. }
  7849. }
  7850. declare module "babylonjs/Materials/materialDefines" {
  7851. /**
  7852. * Manages the defines for the Material
  7853. */
  7854. export class MaterialDefines {
  7855. /** @hidden */
  7856. protected _keys: string[];
  7857. private _isDirty;
  7858. /** @hidden */
  7859. _renderId: number;
  7860. /** @hidden */
  7861. _areLightsDirty: boolean;
  7862. /** @hidden */
  7863. _areLightsDisposed: boolean;
  7864. /** @hidden */
  7865. _areAttributesDirty: boolean;
  7866. /** @hidden */
  7867. _areTexturesDirty: boolean;
  7868. /** @hidden */
  7869. _areFresnelDirty: boolean;
  7870. /** @hidden */
  7871. _areMiscDirty: boolean;
  7872. /** @hidden */
  7873. _areImageProcessingDirty: boolean;
  7874. /** @hidden */
  7875. _normals: boolean;
  7876. /** @hidden */
  7877. _uvs: boolean;
  7878. /** @hidden */
  7879. _needNormals: boolean;
  7880. /** @hidden */
  7881. _needUVs: boolean;
  7882. [id: string]: any;
  7883. /**
  7884. * Specifies if the material needs to be re-calculated
  7885. */
  7886. get isDirty(): boolean;
  7887. /**
  7888. * Marks the material to indicate that it has been re-calculated
  7889. */
  7890. markAsProcessed(): void;
  7891. /**
  7892. * Marks the material to indicate that it needs to be re-calculated
  7893. */
  7894. markAsUnprocessed(): void;
  7895. /**
  7896. * Marks the material to indicate all of its defines need to be re-calculated
  7897. */
  7898. markAllAsDirty(): void;
  7899. /**
  7900. * Marks the material to indicate that image processing needs to be re-calculated
  7901. */
  7902. markAsImageProcessingDirty(): void;
  7903. /**
  7904. * Marks the material to indicate the lights need to be re-calculated
  7905. * @param disposed Defines whether the light is dirty due to dispose or not
  7906. */
  7907. markAsLightDirty(disposed?: boolean): void;
  7908. /**
  7909. * Marks the attribute state as changed
  7910. */
  7911. markAsAttributesDirty(): void;
  7912. /**
  7913. * Marks the texture state as changed
  7914. */
  7915. markAsTexturesDirty(): void;
  7916. /**
  7917. * Marks the fresnel state as changed
  7918. */
  7919. markAsFresnelDirty(): void;
  7920. /**
  7921. * Marks the misc state as changed
  7922. */
  7923. markAsMiscDirty(): void;
  7924. /**
  7925. * Rebuilds the material defines
  7926. */
  7927. rebuild(): void;
  7928. /**
  7929. * Specifies if two material defines are equal
  7930. * @param other - A material define instance to compare to
  7931. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7932. */
  7933. isEqual(other: MaterialDefines): boolean;
  7934. /**
  7935. * Clones this instance's defines to another instance
  7936. * @param other - material defines to clone values to
  7937. */
  7938. cloneTo(other: MaterialDefines): void;
  7939. /**
  7940. * Resets the material define values
  7941. */
  7942. reset(): void;
  7943. /**
  7944. * Converts the material define values to a string
  7945. * @returns - String of material define information
  7946. */
  7947. toString(): string;
  7948. }
  7949. }
  7950. declare module "babylonjs/Materials/colorCurves" {
  7951. import { Effect } from "babylonjs/Materials/effect";
  7952. /**
  7953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7955. * 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;
  7956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7957. */
  7958. export class ColorCurves {
  7959. private _dirty;
  7960. private _tempColor;
  7961. private _globalCurve;
  7962. private _highlightsCurve;
  7963. private _midtonesCurve;
  7964. private _shadowsCurve;
  7965. private _positiveCurve;
  7966. private _negativeCurve;
  7967. private _globalHue;
  7968. private _globalDensity;
  7969. private _globalSaturation;
  7970. private _globalExposure;
  7971. /**
  7972. * Gets the global Hue value.
  7973. * 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).
  7974. */
  7975. get globalHue(): number;
  7976. /**
  7977. * Sets the global Hue value.
  7978. * 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).
  7979. */
  7980. set globalHue(value: number);
  7981. /**
  7982. * Gets the global Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. get globalDensity(): number;
  7987. /**
  7988. * Sets the global Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. set globalDensity(value: number);
  7993. /**
  7994. * Gets the global Saturation value.
  7995. * 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.
  7996. */
  7997. get globalSaturation(): number;
  7998. /**
  7999. * Sets the global Saturation value.
  8000. * 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.
  8001. */
  8002. set globalSaturation(value: number);
  8003. /**
  8004. * Gets the global Exposure value.
  8005. * 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.
  8006. */
  8007. get globalExposure(): number;
  8008. /**
  8009. * Sets the global Exposure value.
  8010. * 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.
  8011. */
  8012. set globalExposure(value: number);
  8013. private _highlightsHue;
  8014. private _highlightsDensity;
  8015. private _highlightsSaturation;
  8016. private _highlightsExposure;
  8017. /**
  8018. * Gets the highlights Hue value.
  8019. * 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).
  8020. */
  8021. get highlightsHue(): number;
  8022. /**
  8023. * Sets the highlights Hue value.
  8024. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8025. */
  8026. set highlightsHue(value: number);
  8027. /**
  8028. * Gets the highlights Density value.
  8029. * 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.
  8030. * Values less than zero provide a filter of opposite hue.
  8031. */
  8032. get highlightsDensity(): number;
  8033. /**
  8034. * Sets the highlights Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. set highlightsDensity(value: number);
  8039. /**
  8040. * Gets the highlights Saturation value.
  8041. * 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.
  8042. */
  8043. get highlightsSaturation(): number;
  8044. /**
  8045. * Sets the highlights Saturation value.
  8046. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8047. */
  8048. set highlightsSaturation(value: number);
  8049. /**
  8050. * Gets the highlights Exposure value.
  8051. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8052. */
  8053. get highlightsExposure(): number;
  8054. /**
  8055. * Sets the highlights Exposure value.
  8056. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8057. */
  8058. set highlightsExposure(value: number);
  8059. private _midtonesHue;
  8060. private _midtonesDensity;
  8061. private _midtonesSaturation;
  8062. private _midtonesExposure;
  8063. /**
  8064. * Gets the midtones Hue value.
  8065. * 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).
  8066. */
  8067. get midtonesHue(): number;
  8068. /**
  8069. * Sets the midtones Hue value.
  8070. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8071. */
  8072. set midtonesHue(value: number);
  8073. /**
  8074. * Gets the midtones Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. get midtonesDensity(): number;
  8079. /**
  8080. * Sets the midtones Density value.
  8081. * 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.
  8082. * Values less than zero provide a filter of opposite hue.
  8083. */
  8084. set midtonesDensity(value: number);
  8085. /**
  8086. * Gets the midtones Saturation value.
  8087. * 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.
  8088. */
  8089. get midtonesSaturation(): number;
  8090. /**
  8091. * Sets the midtones Saturation value.
  8092. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8093. */
  8094. set midtonesSaturation(value: number);
  8095. /**
  8096. * Gets the midtones Exposure value.
  8097. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8098. */
  8099. get midtonesExposure(): number;
  8100. /**
  8101. * Sets the midtones Exposure value.
  8102. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8103. */
  8104. set midtonesExposure(value: number);
  8105. private _shadowsHue;
  8106. private _shadowsDensity;
  8107. private _shadowsSaturation;
  8108. private _shadowsExposure;
  8109. /**
  8110. * Gets the shadows Hue value.
  8111. * 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).
  8112. */
  8113. get shadowsHue(): number;
  8114. /**
  8115. * Sets the shadows Hue value.
  8116. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8117. */
  8118. set shadowsHue(value: number);
  8119. /**
  8120. * Gets the shadows Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. get shadowsDensity(): number;
  8125. /**
  8126. * Sets the shadows Density value.
  8127. * 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.
  8128. * Values less than zero provide a filter of opposite hue.
  8129. */
  8130. set shadowsDensity(value: number);
  8131. /**
  8132. * Gets the shadows Saturation value.
  8133. * 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.
  8134. */
  8135. get shadowsSaturation(): number;
  8136. /**
  8137. * Sets the shadows Saturation value.
  8138. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8139. */
  8140. set shadowsSaturation(value: number);
  8141. /**
  8142. * Gets the shadows Exposure value.
  8143. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8144. */
  8145. get shadowsExposure(): number;
  8146. /**
  8147. * Sets the shadows Exposure value.
  8148. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8149. */
  8150. set shadowsExposure(value: number);
  8151. /**
  8152. * Returns the class name
  8153. * @returns The class name
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Binds the color curves to the shader.
  8158. * @param colorCurves The color curve to bind
  8159. * @param effect The effect to bind to
  8160. * @param positiveUniform The positive uniform shader parameter
  8161. * @param neutralUniform The neutral uniform shader parameter
  8162. * @param negativeUniform The negative uniform shader parameter
  8163. */
  8164. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8165. /**
  8166. * Prepare the list of uniforms associated with the ColorCurves effects.
  8167. * @param uniformsList The list of uniforms used in the effect
  8168. */
  8169. static PrepareUniforms(uniformsList: string[]): void;
  8170. /**
  8171. * Returns color grading data based on a hue, density, saturation and exposure value.
  8172. * @param filterHue The hue of the color filter.
  8173. * @param filterDensity The density of the color filter.
  8174. * @param saturation The saturation.
  8175. * @param exposure The exposure.
  8176. * @param result The result data container.
  8177. */
  8178. private getColorGradingDataToRef;
  8179. /**
  8180. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8181. * @param value The input slider value in range [-100,100].
  8182. * @returns Adjusted value.
  8183. */
  8184. private static applyColorGradingSliderNonlinear;
  8185. /**
  8186. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8187. * @param hue The hue (H) input.
  8188. * @param saturation The saturation (S) input.
  8189. * @param brightness The brightness (B) input.
  8190. * @result An RGBA color represented as Vector4.
  8191. */
  8192. private static fromHSBToRef;
  8193. /**
  8194. * Returns a value clamped between min and max
  8195. * @param value The value to clamp
  8196. * @param min The minimum of value
  8197. * @param max The maximum of value
  8198. * @returns The clamped value.
  8199. */
  8200. private static clamp;
  8201. /**
  8202. * Clones the current color curve instance.
  8203. * @return The cloned curves
  8204. */
  8205. clone(): ColorCurves;
  8206. /**
  8207. * Serializes the current color curve instance to a json representation.
  8208. * @return a JSON representation
  8209. */
  8210. serialize(): any;
  8211. /**
  8212. * Parses the color curve from a json representation.
  8213. * @param source the JSON source to parse
  8214. * @return The parsed curves
  8215. */
  8216. static Parse(source: any): ColorCurves;
  8217. }
  8218. }
  8219. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8220. import { Observable } from "babylonjs/Misc/observable";
  8221. import { Nullable } from "babylonjs/types";
  8222. import { Color4 } from "babylonjs/Maths/math.color";
  8223. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8224. import { Effect } from "babylonjs/Materials/effect";
  8225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8226. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8227. /**
  8228. * Interface to follow in your material defines to integrate easily the
  8229. * Image proccessing functions.
  8230. * @hidden
  8231. */
  8232. export interface IImageProcessingConfigurationDefines {
  8233. IMAGEPROCESSING: boolean;
  8234. VIGNETTE: boolean;
  8235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8236. VIGNETTEBLENDMODEOPAQUE: boolean;
  8237. TONEMAPPING: boolean;
  8238. TONEMAPPING_ACES: boolean;
  8239. CONTRAST: boolean;
  8240. EXPOSURE: boolean;
  8241. COLORCURVES: boolean;
  8242. COLORGRADING: boolean;
  8243. COLORGRADING3D: boolean;
  8244. SAMPLER3DGREENDEPTH: boolean;
  8245. SAMPLER3DBGRMAP: boolean;
  8246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8247. }
  8248. /**
  8249. * @hidden
  8250. */
  8251. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8252. IMAGEPROCESSING: boolean;
  8253. VIGNETTE: boolean;
  8254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8255. VIGNETTEBLENDMODEOPAQUE: boolean;
  8256. TONEMAPPING: boolean;
  8257. TONEMAPPING_ACES: boolean;
  8258. CONTRAST: boolean;
  8259. COLORCURVES: boolean;
  8260. COLORGRADING: boolean;
  8261. COLORGRADING3D: boolean;
  8262. SAMPLER3DGREENDEPTH: boolean;
  8263. SAMPLER3DBGRMAP: boolean;
  8264. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8265. EXPOSURE: boolean;
  8266. constructor();
  8267. }
  8268. /**
  8269. * This groups together the common properties used for image processing either in direct forward pass
  8270. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8271. * or not.
  8272. */
  8273. export class ImageProcessingConfiguration {
  8274. /**
  8275. * Default tone mapping applied in BabylonJS.
  8276. */
  8277. static readonly TONEMAPPING_STANDARD: number;
  8278. /**
  8279. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8280. * to other engines rendering to increase portability.
  8281. */
  8282. static readonly TONEMAPPING_ACES: number;
  8283. /**
  8284. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8285. */
  8286. colorCurves: Nullable<ColorCurves>;
  8287. private _colorCurvesEnabled;
  8288. /**
  8289. * Gets wether the color curves effect is enabled.
  8290. */
  8291. get colorCurvesEnabled(): boolean;
  8292. /**
  8293. * Sets wether the color curves effect is enabled.
  8294. */
  8295. set colorCurvesEnabled(value: boolean);
  8296. private _colorGradingTexture;
  8297. /**
  8298. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8299. */
  8300. get colorGradingTexture(): Nullable<BaseTexture>;
  8301. /**
  8302. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8303. */
  8304. set colorGradingTexture(value: Nullable<BaseTexture>);
  8305. private _colorGradingEnabled;
  8306. /**
  8307. * Gets wether the color grading effect is enabled.
  8308. */
  8309. get colorGradingEnabled(): boolean;
  8310. /**
  8311. * Sets wether the color grading effect is enabled.
  8312. */
  8313. set colorGradingEnabled(value: boolean);
  8314. private _colorGradingWithGreenDepth;
  8315. /**
  8316. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8317. */
  8318. get colorGradingWithGreenDepth(): boolean;
  8319. /**
  8320. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8321. */
  8322. set colorGradingWithGreenDepth(value: boolean);
  8323. private _colorGradingBGR;
  8324. /**
  8325. * Gets wether the color grading texture contains BGR values.
  8326. */
  8327. get colorGradingBGR(): boolean;
  8328. /**
  8329. * Sets wether the color grading texture contains BGR values.
  8330. */
  8331. set colorGradingBGR(value: boolean);
  8332. /** @hidden */
  8333. _exposure: number;
  8334. /**
  8335. * Gets the Exposure used in the effect.
  8336. */
  8337. get exposure(): number;
  8338. /**
  8339. * Sets the Exposure used in the effect.
  8340. */
  8341. set exposure(value: number);
  8342. private _toneMappingEnabled;
  8343. /**
  8344. * Gets wether the tone mapping effect is enabled.
  8345. */
  8346. get toneMappingEnabled(): boolean;
  8347. /**
  8348. * Sets wether the tone mapping effect is enabled.
  8349. */
  8350. set toneMappingEnabled(value: boolean);
  8351. private _toneMappingType;
  8352. /**
  8353. * Gets the type of tone mapping effect.
  8354. */
  8355. get toneMappingType(): number;
  8356. /**
  8357. * Sets the type of tone mapping effect used in BabylonJS.
  8358. */
  8359. set toneMappingType(value: number);
  8360. protected _contrast: number;
  8361. /**
  8362. * Gets the contrast used in the effect.
  8363. */
  8364. get contrast(): number;
  8365. /**
  8366. * Sets the contrast used in the effect.
  8367. */
  8368. set contrast(value: number);
  8369. /**
  8370. * Vignette stretch size.
  8371. */
  8372. vignetteStretch: number;
  8373. /**
  8374. * Vignette centre X Offset.
  8375. */
  8376. vignetteCentreX: number;
  8377. /**
  8378. * Vignette centre Y Offset.
  8379. */
  8380. vignetteCentreY: number;
  8381. /**
  8382. * Vignette weight or intensity of the vignette effect.
  8383. */
  8384. vignetteWeight: number;
  8385. /**
  8386. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8387. * if vignetteEnabled is set to true.
  8388. */
  8389. vignetteColor: Color4;
  8390. /**
  8391. * Camera field of view used by the Vignette effect.
  8392. */
  8393. vignetteCameraFov: number;
  8394. private _vignetteBlendMode;
  8395. /**
  8396. * Gets the vignette blend mode allowing different kind of effect.
  8397. */
  8398. get vignetteBlendMode(): number;
  8399. /**
  8400. * Sets the vignette blend mode allowing different kind of effect.
  8401. */
  8402. set vignetteBlendMode(value: number);
  8403. private _vignetteEnabled;
  8404. /**
  8405. * Gets wether the vignette effect is enabled.
  8406. */
  8407. get vignetteEnabled(): boolean;
  8408. /**
  8409. * Sets wether the vignette effect is enabled.
  8410. */
  8411. set vignetteEnabled(value: boolean);
  8412. private _applyByPostProcess;
  8413. /**
  8414. * Gets wether the image processing is applied through a post process or not.
  8415. */
  8416. get applyByPostProcess(): boolean;
  8417. /**
  8418. * Sets wether the image processing is applied through a post process or not.
  8419. */
  8420. set applyByPostProcess(value: boolean);
  8421. private _isEnabled;
  8422. /**
  8423. * Gets wether the image processing is enabled or not.
  8424. */
  8425. get isEnabled(): boolean;
  8426. /**
  8427. * Sets wether the image processing is enabled or not.
  8428. */
  8429. set isEnabled(value: boolean);
  8430. /**
  8431. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8432. */
  8433. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8434. /**
  8435. * Method called each time the image processing information changes requires to recompile the effect.
  8436. */
  8437. protected _updateParameters(): void;
  8438. /**
  8439. * Gets the current class name.
  8440. * @return "ImageProcessingConfiguration"
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Prepare the list of uniforms associated with the Image Processing effects.
  8445. * @param uniforms The list of uniforms used in the effect
  8446. * @param defines the list of defines currently in use
  8447. */
  8448. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8449. /**
  8450. * Prepare the list of samplers associated with the Image Processing effects.
  8451. * @param samplersList The list of uniforms used in the effect
  8452. * @param defines the list of defines currently in use
  8453. */
  8454. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8455. /**
  8456. * Prepare the list of defines associated to the shader.
  8457. * @param defines the list of defines to complete
  8458. * @param forPostProcess Define if we are currently in post process mode or not
  8459. */
  8460. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8461. /**
  8462. * Returns true if all the image processing information are ready.
  8463. * @returns True if ready, otherwise, false
  8464. */
  8465. isReady(): boolean;
  8466. /**
  8467. * Binds the image processing to the shader.
  8468. * @param effect The effect to bind to
  8469. * @param overrideAspectRatio Override the aspect ratio of the effect
  8470. */
  8471. bind(effect: Effect, overrideAspectRatio?: number): void;
  8472. /**
  8473. * Clones the current image processing instance.
  8474. * @return The cloned image processing
  8475. */
  8476. clone(): ImageProcessingConfiguration;
  8477. /**
  8478. * Serializes the current image processing instance to a json representation.
  8479. * @return a JSON representation
  8480. */
  8481. serialize(): any;
  8482. /**
  8483. * Parses the image processing from a json representation.
  8484. * @param source the JSON source to parse
  8485. * @return The parsed image processing
  8486. */
  8487. static Parse(source: any): ImageProcessingConfiguration;
  8488. private static _VIGNETTEMODE_MULTIPLY;
  8489. private static _VIGNETTEMODE_OPAQUE;
  8490. /**
  8491. * Used to apply the vignette as a mix with the pixel color.
  8492. */
  8493. static get VIGNETTEMODE_MULTIPLY(): number;
  8494. /**
  8495. * Used to apply the vignette as a replacement of the pixel color.
  8496. */
  8497. static get VIGNETTEMODE_OPAQUE(): number;
  8498. }
  8499. }
  8500. declare module "babylonjs/Shaders/postprocess.vertex" {
  8501. /** @hidden */
  8502. export var postprocessVertexShader: {
  8503. name: string;
  8504. shader: string;
  8505. };
  8506. }
  8507. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8509. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8510. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8511. module "babylonjs/Engines/thinEngine" {
  8512. interface ThinEngine {
  8513. /**
  8514. * Creates a new render target texture
  8515. * @param size defines the size of the texture
  8516. * @param options defines the options used to create the texture
  8517. * @returns a new render target texture stored in an InternalTexture
  8518. */
  8519. createRenderTargetTexture(size: number | {
  8520. width: number;
  8521. height: number;
  8522. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8523. /**
  8524. * Creates a depth stencil texture.
  8525. * This is only available in WebGL 2 or with the depth texture extension available.
  8526. * @param size The size of face edge in the texture.
  8527. * @param options The options defining the texture.
  8528. * @returns The texture
  8529. */
  8530. createDepthStencilTexture(size: number | {
  8531. width: number;
  8532. height: number;
  8533. }, options: DepthTextureCreationOptions): InternalTexture;
  8534. /** @hidden */
  8535. _createDepthStencilTexture(size: number | {
  8536. width: number;
  8537. height: number;
  8538. }, options: DepthTextureCreationOptions): InternalTexture;
  8539. }
  8540. }
  8541. }
  8542. declare module "babylonjs/Maths/math.axis" {
  8543. import { Vector3 } from "babylonjs/Maths/math.vector";
  8544. /** Defines supported spaces */
  8545. export enum Space {
  8546. /** Local (object) space */
  8547. LOCAL = 0,
  8548. /** World space */
  8549. WORLD = 1,
  8550. /** Bone space */
  8551. BONE = 2
  8552. }
  8553. /** Defines the 3 main axes */
  8554. export class Axis {
  8555. /** X axis */
  8556. static X: Vector3;
  8557. /** Y axis */
  8558. static Y: Vector3;
  8559. /** Z axis */
  8560. static Z: Vector3;
  8561. }
  8562. }
  8563. declare module "babylonjs/Cameras/targetCamera" {
  8564. import { Nullable } from "babylonjs/types";
  8565. import { Camera } from "babylonjs/Cameras/camera";
  8566. import { Scene } from "babylonjs/scene";
  8567. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8568. /**
  8569. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8570. * This is the base of the follow, arc rotate cameras and Free camera
  8571. * @see http://doc.babylonjs.com/features/cameras
  8572. */
  8573. export class TargetCamera extends Camera {
  8574. private static _RigCamTransformMatrix;
  8575. private static _TargetTransformMatrix;
  8576. private static _TargetFocalPoint;
  8577. /**
  8578. * Define the current direction the camera is moving to
  8579. */
  8580. cameraDirection: Vector3;
  8581. /**
  8582. * Define the current rotation the camera is rotating to
  8583. */
  8584. cameraRotation: Vector2;
  8585. /**
  8586. * When set, the up vector of the camera will be updated by the rotation of the camera
  8587. */
  8588. updateUpVectorFromRotation: boolean;
  8589. private _tmpQuaternion;
  8590. /**
  8591. * Define the current rotation of the camera
  8592. */
  8593. rotation: Vector3;
  8594. /**
  8595. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8596. */
  8597. rotationQuaternion: Quaternion;
  8598. /**
  8599. * Define the current speed of the camera
  8600. */
  8601. speed: number;
  8602. /**
  8603. * Add constraint to the camera to prevent it to move freely in all directions and
  8604. * around all axis.
  8605. */
  8606. noRotationConstraint: boolean;
  8607. /**
  8608. * Define the current target of the camera as an object or a position.
  8609. */
  8610. lockedTarget: any;
  8611. /** @hidden */
  8612. _currentTarget: Vector3;
  8613. /** @hidden */
  8614. _initialFocalDistance: number;
  8615. /** @hidden */
  8616. _viewMatrix: Matrix;
  8617. /** @hidden */
  8618. _camMatrix: Matrix;
  8619. /** @hidden */
  8620. _cameraTransformMatrix: Matrix;
  8621. /** @hidden */
  8622. _cameraRotationMatrix: Matrix;
  8623. /** @hidden */
  8624. _referencePoint: Vector3;
  8625. /** @hidden */
  8626. _transformedReferencePoint: Vector3;
  8627. protected _globalCurrentTarget: Vector3;
  8628. protected _globalCurrentUpVector: Vector3;
  8629. /** @hidden */
  8630. _reset: () => void;
  8631. private _defaultUp;
  8632. /**
  8633. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8634. * This is the base of the follow, arc rotate cameras and Free camera
  8635. * @see http://doc.babylonjs.com/features/cameras
  8636. * @param name Defines the name of the camera in the scene
  8637. * @param position Defines the start position of the camera in the scene
  8638. * @param scene Defines the scene the camera belongs to
  8639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8640. */
  8641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8642. /**
  8643. * Gets the position in front of the camera at a given distance.
  8644. * @param distance The distance from the camera we want the position to be
  8645. * @returns the position
  8646. */
  8647. getFrontPosition(distance: number): Vector3;
  8648. /** @hidden */
  8649. _getLockedTargetPosition(): Nullable<Vector3>;
  8650. private _storedPosition;
  8651. private _storedRotation;
  8652. private _storedRotationQuaternion;
  8653. /**
  8654. * Store current camera state of the camera (fov, position, rotation, etc..)
  8655. * @returns the camera
  8656. */
  8657. storeState(): Camera;
  8658. /**
  8659. * Restored camera state. You must call storeState() first
  8660. * @returns whether it was successful or not
  8661. * @hidden
  8662. */
  8663. _restoreStateValues(): boolean;
  8664. /** @hidden */
  8665. _initCache(): void;
  8666. /** @hidden */
  8667. _updateCache(ignoreParentClass?: boolean): void;
  8668. /** @hidden */
  8669. _isSynchronizedViewMatrix(): boolean;
  8670. /** @hidden */
  8671. _computeLocalCameraSpeed(): number;
  8672. /**
  8673. * Defines the target the camera should look at.
  8674. * @param target Defines the new target as a Vector or a mesh
  8675. */
  8676. setTarget(target: Vector3): void;
  8677. /**
  8678. * Return the current target position of the camera. This value is expressed in local space.
  8679. * @returns the target position
  8680. */
  8681. getTarget(): Vector3;
  8682. /** @hidden */
  8683. _decideIfNeedsToMove(): boolean;
  8684. /** @hidden */
  8685. _updatePosition(): void;
  8686. /** @hidden */
  8687. _checkInputs(): void;
  8688. protected _updateCameraRotationMatrix(): void;
  8689. /**
  8690. * 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)
  8691. * @returns the current camera
  8692. */
  8693. private _rotateUpVectorWithCameraRotationMatrix;
  8694. private _cachedRotationZ;
  8695. private _cachedQuaternionRotationZ;
  8696. /** @hidden */
  8697. _getViewMatrix(): Matrix;
  8698. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8699. /**
  8700. * @hidden
  8701. */
  8702. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8703. /**
  8704. * @hidden
  8705. */
  8706. _updateRigCameras(): void;
  8707. private _getRigCamPositionAndTarget;
  8708. /**
  8709. * Gets the current object class name.
  8710. * @return the class name
  8711. */
  8712. getClassName(): string;
  8713. }
  8714. }
  8715. declare module "babylonjs/Events/keyboardEvents" {
  8716. /**
  8717. * Gather the list of keyboard event types as constants.
  8718. */
  8719. export class KeyboardEventTypes {
  8720. /**
  8721. * The keydown event is fired when a key becomes active (pressed).
  8722. */
  8723. static readonly KEYDOWN: number;
  8724. /**
  8725. * The keyup event is fired when a key has been released.
  8726. */
  8727. static readonly KEYUP: number;
  8728. }
  8729. /**
  8730. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8731. */
  8732. export class KeyboardInfo {
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number;
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent;
  8741. /**
  8742. * Instantiates a new keyboard info.
  8743. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8744. * @param type Defines the type of event (KeyboardEventTypes)
  8745. * @param event Defines the related dom event
  8746. */
  8747. constructor(
  8748. /**
  8749. * Defines the type of event (KeyboardEventTypes)
  8750. */
  8751. type: number,
  8752. /**
  8753. * Defines the related dom event
  8754. */
  8755. event: KeyboardEvent);
  8756. }
  8757. /**
  8758. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8759. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8760. */
  8761. export class KeyboardInfoPre extends KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8772. */
  8773. skipOnPointerObservable: boolean;
  8774. /**
  8775. * Instantiates a new keyboard pre info.
  8776. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. }
  8791. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8792. import { Nullable } from "babylonjs/types";
  8793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8794. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8795. /**
  8796. * Manage the keyboard inputs to control the movement of a free camera.
  8797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8798. */
  8799. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8800. /**
  8801. * Defines the camera the input is attached to.
  8802. */
  8803. camera: FreeCamera;
  8804. /**
  8805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8806. */
  8807. keysUp: number[];
  8808. /**
  8809. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8810. */
  8811. keysDown: number[];
  8812. /**
  8813. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8814. */
  8815. keysLeft: number[];
  8816. /**
  8817. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8818. */
  8819. keysRight: number[];
  8820. private _keys;
  8821. private _onCanvasBlurObserver;
  8822. private _onKeyboardObserver;
  8823. private _engine;
  8824. private _scene;
  8825. /**
  8826. * Attach the input controls to a specific dom element to get the input from.
  8827. * @param element Defines the element the controls should be listened from
  8828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8829. */
  8830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8831. /**
  8832. * Detach the current controls from the specified dom element.
  8833. * @param element Defines the element to stop listening the inputs from
  8834. */
  8835. detachControl(element: Nullable<HTMLElement>): void;
  8836. /**
  8837. * Update the current camera state depending on the inputs that have been used this frame.
  8838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8839. */
  8840. checkInputs(): void;
  8841. /**
  8842. * Gets the class name of the current intput.
  8843. * @returns the class name
  8844. */
  8845. getClassName(): string;
  8846. /** @hidden */
  8847. _onLostFocus(): void;
  8848. /**
  8849. * Get the friendly name associated with the input class.
  8850. * @returns the input friendly name
  8851. */
  8852. getSimpleName(): string;
  8853. }
  8854. }
  8855. declare module "babylonjs/Lights/shadowLight" {
  8856. import { Camera } from "babylonjs/Cameras/camera";
  8857. import { Scene } from "babylonjs/scene";
  8858. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8860. import { Light } from "babylonjs/Lights/light";
  8861. /**
  8862. * Interface describing all the common properties and methods a shadow light needs to implement.
  8863. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8864. * as well as binding the different shadow properties to the effects.
  8865. */
  8866. export interface IShadowLight extends Light {
  8867. /**
  8868. * The light id in the scene (used in scene.findLighById for instance)
  8869. */
  8870. id: string;
  8871. /**
  8872. * The position the shdow will be casted from.
  8873. */
  8874. position: Vector3;
  8875. /**
  8876. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8877. */
  8878. direction: Vector3;
  8879. /**
  8880. * The transformed position. Position of the light in world space taking parenting in account.
  8881. */
  8882. transformedPosition: Vector3;
  8883. /**
  8884. * The transformed direction. Direction of the light in world space taking parenting in account.
  8885. */
  8886. transformedDirection: Vector3;
  8887. /**
  8888. * The friendly name of the light in the scene.
  8889. */
  8890. name: string;
  8891. /**
  8892. * Defines the shadow projection clipping minimum z value.
  8893. */
  8894. shadowMinZ: number;
  8895. /**
  8896. * Defines the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8901. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8902. */
  8903. computeTransformedInformation(): boolean;
  8904. /**
  8905. * Gets the scene the light belongs to.
  8906. * @returns The scene
  8907. */
  8908. getScene(): Scene;
  8909. /**
  8910. * Callback defining a custom Projection Matrix Builder.
  8911. * This can be used to override the default projection matrix computation.
  8912. */
  8913. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8914. /**
  8915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8916. * @param matrix The materix to updated with the projection information
  8917. * @param viewMatrix The transform matrix of the light
  8918. * @param renderList The list of mesh to render in the map
  8919. * @returns The current light
  8920. */
  8921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8922. /**
  8923. * Gets the current depth scale used in ESM.
  8924. * @returns The scale
  8925. */
  8926. getDepthScale(): number;
  8927. /**
  8928. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8929. * @returns true if a cube texture needs to be use
  8930. */
  8931. needCube(): boolean;
  8932. /**
  8933. * Detects if the projection matrix requires to be recomputed this frame.
  8934. * @returns true if it requires to be recomputed otherwise, false.
  8935. */
  8936. needProjectionMatrixCompute(): boolean;
  8937. /**
  8938. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8939. */
  8940. forceProjectionMatrixCompute(): void;
  8941. /**
  8942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8945. */
  8946. getShadowDirection(faceIndex?: number): Vector3;
  8947. /**
  8948. * Gets the minZ used for shadow according to both the scene and the light.
  8949. * @param activeCamera The camera we are returning the min for
  8950. * @returns the depth min z
  8951. */
  8952. getDepthMinZ(activeCamera: Camera): number;
  8953. /**
  8954. * Gets the maxZ used for shadow according to both the scene and the light.
  8955. * @param activeCamera The camera we are returning the max for
  8956. * @returns the depth max z
  8957. */
  8958. getDepthMaxZ(activeCamera: Camera): number;
  8959. }
  8960. /**
  8961. * Base implementation IShadowLight
  8962. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8963. */
  8964. export abstract class ShadowLight extends Light implements IShadowLight {
  8965. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8966. protected _position: Vector3;
  8967. protected _setPosition(value: Vector3): void;
  8968. /**
  8969. * Sets the position the shadow will be casted from. Also use as the light position for both
  8970. * point and spot lights.
  8971. */
  8972. get position(): Vector3;
  8973. /**
  8974. * Sets the position the shadow will be casted from. Also use as the light position for both
  8975. * point and spot lights.
  8976. */
  8977. set position(value: Vector3);
  8978. protected _direction: Vector3;
  8979. protected _setDirection(value: Vector3): void;
  8980. /**
  8981. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8982. * Also use as the light direction on spot and directional lights.
  8983. */
  8984. get direction(): Vector3;
  8985. /**
  8986. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8987. * Also use as the light direction on spot and directional lights.
  8988. */
  8989. set direction(value: Vector3);
  8990. private _shadowMinZ;
  8991. /**
  8992. * Gets the shadow projection clipping minimum z value.
  8993. */
  8994. get shadowMinZ(): number;
  8995. /**
  8996. * Sets the shadow projection clipping minimum z value.
  8997. */
  8998. set shadowMinZ(value: number);
  8999. private _shadowMaxZ;
  9000. /**
  9001. * Sets the shadow projection clipping maximum z value.
  9002. */
  9003. get shadowMaxZ(): number;
  9004. /**
  9005. * Gets the shadow projection clipping maximum z value.
  9006. */
  9007. set shadowMaxZ(value: number);
  9008. /**
  9009. * Callback defining a custom Projection Matrix Builder.
  9010. * This can be used to override the default projection matrix computation.
  9011. */
  9012. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9013. /**
  9014. * The transformed position. Position of the light in world space taking parenting in account.
  9015. */
  9016. transformedPosition: Vector3;
  9017. /**
  9018. * The transformed direction. Direction of the light in world space taking parenting in account.
  9019. */
  9020. transformedDirection: Vector3;
  9021. private _needProjectionMatrixCompute;
  9022. /**
  9023. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9024. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9025. */
  9026. computeTransformedInformation(): boolean;
  9027. /**
  9028. * Return the depth scale used for the shadow map.
  9029. * @returns the depth scale.
  9030. */
  9031. getDepthScale(): number;
  9032. /**
  9033. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9034. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9035. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9036. */
  9037. getShadowDirection(faceIndex?: number): Vector3;
  9038. /**
  9039. * Returns the ShadowLight absolute position in the World.
  9040. * @returns the position vector in world space
  9041. */
  9042. getAbsolutePosition(): Vector3;
  9043. /**
  9044. * Sets the ShadowLight direction toward the passed target.
  9045. * @param target The point to target in local space
  9046. * @returns the updated ShadowLight direction
  9047. */
  9048. setDirectionToTarget(target: Vector3): Vector3;
  9049. /**
  9050. * Returns the light rotation in euler definition.
  9051. * @returns the x y z rotation in local space.
  9052. */
  9053. getRotation(): Vector3;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /** @hidden */
  9069. _initCache(): void;
  9070. /** @hidden */
  9071. _isSynchronized(): boolean;
  9072. /**
  9073. * Computes the world matrix of the node
  9074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9075. * @returns the world matrix
  9076. */
  9077. computeWorldMatrix(force?: boolean): Matrix;
  9078. /**
  9079. * Gets the minZ used for shadow according to both the scene and the light.
  9080. * @param activeCamera The camera we are returning the min for
  9081. * @returns the depth min z
  9082. */
  9083. getDepthMinZ(activeCamera: Camera): number;
  9084. /**
  9085. * Gets the maxZ used for shadow according to both the scene and the light.
  9086. * @param activeCamera The camera we are returning the max for
  9087. * @returns the depth max z
  9088. */
  9089. getDepthMaxZ(activeCamera: Camera): number;
  9090. /**
  9091. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9092. * @param matrix The materix to updated with the projection information
  9093. * @param viewMatrix The transform matrix of the light
  9094. * @param renderList The list of mesh to render in the map
  9095. * @returns The current light
  9096. */
  9097. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9098. }
  9099. }
  9100. declare module "babylonjs/Materials/effectFallbacks" {
  9101. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9102. import { Effect } from "babylonjs/Materials/effect";
  9103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9104. /**
  9105. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9106. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9107. */
  9108. export class EffectFallbacks implements IEffectFallbacks {
  9109. private _defines;
  9110. private _currentRank;
  9111. private _maxRank;
  9112. private _mesh;
  9113. /**
  9114. * Removes the fallback from the bound mesh.
  9115. */
  9116. unBindMesh(): void;
  9117. /**
  9118. * Adds a fallback on the specified property.
  9119. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9120. * @param define The name of the define in the shader
  9121. */
  9122. addFallback(rank: number, define: string): void;
  9123. /**
  9124. * Sets the mesh to use CPU skinning when needing to fallback.
  9125. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9126. * @param mesh The mesh to use the fallbacks.
  9127. */
  9128. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9129. /**
  9130. * Checks to see if more fallbacks are still availible.
  9131. */
  9132. get hasMoreFallbacks(): boolean;
  9133. /**
  9134. * Removes the defines that should be removed when falling back.
  9135. * @param currentDefines defines the current define statements for the shader.
  9136. * @param effect defines the current effect we try to compile
  9137. * @returns The resulting defines with defines of the current rank removed.
  9138. */
  9139. reduce(currentDefines: string, effect: Effect): string;
  9140. }
  9141. }
  9142. declare module "babylonjs/Materials/materialHelper" {
  9143. import { Nullable } from "babylonjs/types";
  9144. import { Scene } from "babylonjs/scene";
  9145. import { Engine } from "babylonjs/Engines/engine";
  9146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9147. import { Light } from "babylonjs/Lights/light";
  9148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9149. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9151. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9152. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9153. /**
  9154. * "Static Class" containing the most commonly used helper while dealing with material for
  9155. * rendering purpose.
  9156. *
  9157. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9158. *
  9159. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9160. */
  9161. export class MaterialHelper {
  9162. /**
  9163. * Bind the current view position to an effect.
  9164. * @param effect The effect to be bound
  9165. * @param scene The scene the eyes position is used from
  9166. */
  9167. static BindEyePosition(effect: Effect, scene: Scene): void;
  9168. /**
  9169. * Helps preparing the defines values about the UVs in used in the effect.
  9170. * UVs are shared as much as we can accross channels in the shaders.
  9171. * @param texture The texture we are preparing the UVs for
  9172. * @param defines The defines to update
  9173. * @param key The channel key "diffuse", "specular"... used in the shader
  9174. */
  9175. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9176. /**
  9177. * Binds a texture matrix value to its corrsponding uniform
  9178. * @param texture The texture to bind the matrix for
  9179. * @param uniformBuffer The uniform buffer receivin the data
  9180. * @param key The channel key "diffuse", "specular"... used in the shader
  9181. */
  9182. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9183. /**
  9184. * Gets the current status of the fog (should it be enabled?)
  9185. * @param mesh defines the mesh to evaluate for fog support
  9186. * @param scene defines the hosting scene
  9187. * @returns true if fog must be enabled
  9188. */
  9189. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9190. /**
  9191. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9192. * @param mesh defines the current mesh
  9193. * @param scene defines the current scene
  9194. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9195. * @param pointsCloud defines if point cloud rendering has to be turned on
  9196. * @param fogEnabled defines if fog has to be turned on
  9197. * @param alphaTest defines if alpha testing has to be turned on
  9198. * @param defines defines the current list of defines
  9199. */
  9200. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9201. /**
  9202. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9203. * @param scene defines the current scene
  9204. * @param engine defines the current engine
  9205. * @param defines specifies the list of active defines
  9206. * @param useInstances defines if instances have to be turned on
  9207. * @param useClipPlane defines if clip plane have to be turned on
  9208. */
  9209. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9210. /**
  9211. * Prepares the defines for bones
  9212. * @param mesh The mesh containing the geometry data we will draw
  9213. * @param defines The defines to update
  9214. */
  9215. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9216. /**
  9217. * Prepares the defines for morph targets
  9218. * @param mesh The mesh containing the geometry data we will draw
  9219. * @param defines The defines to update
  9220. */
  9221. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9222. /**
  9223. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9224. * @param mesh The mesh containing the geometry data we will draw
  9225. * @param defines The defines to update
  9226. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9227. * @param useBones Precise whether bones should be used or not (override mesh info)
  9228. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9229. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9230. * @returns false if defines are considered not dirty and have not been checked
  9231. */
  9232. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9233. /**
  9234. * Prepares the defines related to multiview
  9235. * @param scene The scene we are intending to draw
  9236. * @param defines The defines to update
  9237. */
  9238. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9239. /**
  9240. * Prepares the defines related to the light information passed in parameter
  9241. * @param scene The scene we are intending to draw
  9242. * @param mesh The mesh the effect is compiling for
  9243. * @param light The light the effect is compiling for
  9244. * @param lightIndex The index of the light
  9245. * @param defines The defines to update
  9246. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9247. * @param state Defines the current state regarding what is needed (normals, etc...)
  9248. */
  9249. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9250. needNormals: boolean;
  9251. needRebuild: boolean;
  9252. shadowEnabled: boolean;
  9253. specularEnabled: boolean;
  9254. lightmapMode: boolean;
  9255. }): void;
  9256. /**
  9257. * Prepares the defines related to the light information passed in parameter
  9258. * @param scene The scene we are intending to draw
  9259. * @param mesh The mesh the effect is compiling for
  9260. * @param defines The defines to update
  9261. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9262. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9263. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9264. * @returns true if normals will be required for the rest of the effect
  9265. */
  9266. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9267. /**
  9268. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9269. * @param lightIndex defines the light index
  9270. * @param uniformsList The uniform list
  9271. * @param samplersList The sampler list
  9272. * @param projectedLightTexture defines if projected texture must be used
  9273. * @param uniformBuffersList defines an optional list of uniform buffers
  9274. */
  9275. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9276. /**
  9277. * Prepares the uniforms and samplers list to be used in the effect
  9278. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9279. * @param samplersList The sampler list
  9280. * @param defines The defines helping in the list generation
  9281. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9282. */
  9283. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9284. /**
  9285. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9286. * @param defines The defines to update while falling back
  9287. * @param fallbacks The authorized effect fallbacks
  9288. * @param maxSimultaneousLights The maximum number of lights allowed
  9289. * @param rank the current rank of the Effect
  9290. * @returns The newly affected rank
  9291. */
  9292. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9293. private static _TmpMorphInfluencers;
  9294. /**
  9295. * Prepares the list of attributes required for morph targets according to the effect defines.
  9296. * @param attribs The current list of supported attribs
  9297. * @param mesh The mesh to prepare the morph targets attributes for
  9298. * @param influencers The number of influencers
  9299. */
  9300. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9301. /**
  9302. * Prepares the list of attributes required for morph targets according to the effect defines.
  9303. * @param attribs The current list of supported attribs
  9304. * @param mesh The mesh to prepare the morph targets attributes for
  9305. * @param defines The current Defines of the effect
  9306. */
  9307. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9308. /**
  9309. * Prepares the list of attributes required for bones according to the effect defines.
  9310. * @param attribs The current list of supported attribs
  9311. * @param mesh The mesh to prepare the bones attributes for
  9312. * @param defines The current Defines of the effect
  9313. * @param fallbacks The current efffect fallback strategy
  9314. */
  9315. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9316. /**
  9317. * Check and prepare the list of attributes required for instances according to the effect defines.
  9318. * @param attribs The current list of supported attribs
  9319. * @param defines The current MaterialDefines of the effect
  9320. */
  9321. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9322. /**
  9323. * Add the list of attributes required for instances to the attribs array.
  9324. * @param attribs The current list of supported attribs
  9325. */
  9326. static PushAttributesForInstances(attribs: string[]): void;
  9327. /**
  9328. * Binds the light information to the effect.
  9329. * @param light The light containing the generator
  9330. * @param effect The effect we are binding the data to
  9331. * @param lightIndex The light index in the effect used to render
  9332. */
  9333. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9334. /**
  9335. * Binds the lights information from the scene to the effect for the given mesh.
  9336. * @param light Light to bind
  9337. * @param lightIndex Light index
  9338. * @param scene The scene where the light belongs to
  9339. * @param effect The effect we are binding the data to
  9340. * @param useSpecular Defines if specular is supported
  9341. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9343. */
  9344. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9345. /**
  9346. * Binds the lights information from the scene to the effect for the given mesh.
  9347. * @param scene The scene the lights belongs to
  9348. * @param mesh The mesh we are binding the information to render
  9349. * @param effect The effect we are binding the data to
  9350. * @param defines The generated defines for the effect
  9351. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9352. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9353. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9354. */
  9355. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9356. private static _tempFogColor;
  9357. /**
  9358. * Binds the fog information from the scene to the effect for the given mesh.
  9359. * @param scene The scene the lights belongs to
  9360. * @param mesh The mesh we are binding the information to render
  9361. * @param effect The effect we are binding the data to
  9362. * @param linearSpace Defines if the fog effect is applied in linear space
  9363. */
  9364. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9365. /**
  9366. * Binds the bones information from the mesh to the effect.
  9367. * @param mesh The mesh we are binding the information to render
  9368. * @param effect The effect we are binding the data to
  9369. */
  9370. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9371. /**
  9372. * Binds the morph targets information from the mesh to the effect.
  9373. * @param abstractMesh The mesh we are binding the information to render
  9374. * @param effect The effect we are binding the data to
  9375. */
  9376. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9377. /**
  9378. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9379. * @param defines The generated defines used in the effect
  9380. * @param effect The effect we are binding the data to
  9381. * @param scene The scene we are willing to render with logarithmic scale for
  9382. */
  9383. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9384. /**
  9385. * Binds the clip plane information from the scene to the effect.
  9386. * @param scene The scene the clip plane information are extracted from
  9387. * @param effect The effect we are binding the data to
  9388. */
  9389. static BindClipPlane(effect: Effect, scene: Scene): void;
  9390. }
  9391. }
  9392. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9393. /** @hidden */
  9394. export var packingFunctions: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9400. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9401. /** @hidden */
  9402. export var shadowMapPixelShader: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9408. /** @hidden */
  9409. export var bonesDeclaration: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9415. /** @hidden */
  9416. export var morphTargetsVertexGlobalDeclaration: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9422. /** @hidden */
  9423. export var morphTargetsVertexDeclaration: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9429. /** @hidden */
  9430. export var instancesDeclaration: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9436. /** @hidden */
  9437. export var helperFunctions: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9443. /** @hidden */
  9444. export var morphTargetsVertex: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9450. /** @hidden */
  9451. export var instancesVertex: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9457. /** @hidden */
  9458. export var bonesVertex: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9464. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9472. /** @hidden */
  9473. export var shadowMapVertexShader: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9479. /** @hidden */
  9480. export var depthBoxBlurPixelShader: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9486. import { Nullable } from "babylonjs/types";
  9487. import { Scene } from "babylonjs/scene";
  9488. import { Matrix } from "babylonjs/Maths/math.vector";
  9489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9491. import { Mesh } from "babylonjs/Meshes/mesh";
  9492. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9493. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9494. import { Effect } from "babylonjs/Materials/effect";
  9495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9496. import "babylonjs/Shaders/shadowMap.fragment";
  9497. import "babylonjs/Shaders/shadowMap.vertex";
  9498. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9499. import { Observable } from "babylonjs/Misc/observable";
  9500. /**
  9501. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9502. */
  9503. export interface ICustomShaderOptions {
  9504. /**
  9505. * Gets or sets the custom shader name to use
  9506. */
  9507. shaderName: string;
  9508. /**
  9509. * The list of attribute names used in the shader
  9510. */
  9511. attributes?: string[];
  9512. /**
  9513. * The list of unifrom names used in the shader
  9514. */
  9515. uniforms?: string[];
  9516. /**
  9517. * The list of sampler names used in the shader
  9518. */
  9519. samplers?: string[];
  9520. /**
  9521. * The list of defines used in the shader
  9522. */
  9523. defines?: string[];
  9524. }
  9525. /**
  9526. * Interface to implement to create a shadow generator compatible with BJS.
  9527. */
  9528. export interface IShadowGenerator {
  9529. /**
  9530. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9531. * @returns The render target texture if present otherwise, null
  9532. */
  9533. getShadowMap(): Nullable<RenderTargetTexture>;
  9534. /**
  9535. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9536. * @returns The render target texture if the shadow map is present otherwise, null
  9537. */
  9538. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9539. /**
  9540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9541. * @param subMesh The submesh we want to render in the shadow map
  9542. * @param useInstances Defines wether will draw in the map using instances
  9543. * @returns true if ready otherwise, false
  9544. */
  9545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9546. /**
  9547. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9548. * @param defines Defines of the material we want to update
  9549. * @param lightIndex Index of the light in the enabled light list of the material
  9550. */
  9551. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9552. /**
  9553. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9554. * defined in the generator but impacting the effect).
  9555. * It implies the unifroms available on the materials are the standard BJS ones.
  9556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9557. * @param effect The effect we are binfing the information for
  9558. */
  9559. bindShadowLight(lightIndex: string, effect: Effect): void;
  9560. /**
  9561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9562. * (eq to shadow prjection matrix * light transform matrix)
  9563. * @returns The transform matrix used to create the shadow map
  9564. */
  9565. getTransformMatrix(): Matrix;
  9566. /**
  9567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9568. * Cube and 2D textures for instance.
  9569. */
  9570. recreateShadowMap(): void;
  9571. /**
  9572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9573. * @param onCompiled Callback triggered at the and of the effects compilation
  9574. * @param options Sets of optional options forcing the compilation with different modes
  9575. */
  9576. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9577. useInstances: boolean;
  9578. }>): void;
  9579. /**
  9580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9581. * @param options Sets of optional options forcing the compilation with different modes
  9582. * @returns A promise that resolves when the compilation completes
  9583. */
  9584. forceCompilationAsync(options?: Partial<{
  9585. useInstances: boolean;
  9586. }>): Promise<void>;
  9587. /**
  9588. * Serializes the shadow generator setup to a json object.
  9589. * @returns The serialized JSON object
  9590. */
  9591. serialize(): any;
  9592. /**
  9593. * Disposes the Shadow map and related Textures and effects.
  9594. */
  9595. dispose(): void;
  9596. }
  9597. /**
  9598. * Default implementation IShadowGenerator.
  9599. * This is the main object responsible of generating shadows in the framework.
  9600. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9601. */
  9602. export class ShadowGenerator implements IShadowGenerator {
  9603. /**
  9604. * Shadow generator mode None: no filtering applied.
  9605. */
  9606. static readonly FILTER_NONE: number;
  9607. /**
  9608. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9609. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9610. */
  9611. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9612. /**
  9613. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9614. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9615. */
  9616. static readonly FILTER_POISSONSAMPLING: number;
  9617. /**
  9618. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9619. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9620. */
  9621. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9622. /**
  9623. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9624. * edge artifacts on steep falloff.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9630. * edge artifacts on steep falloff.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode PCF: Percentage Closer Filtering
  9636. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9637. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9638. */
  9639. static readonly FILTER_PCF: number;
  9640. /**
  9641. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9643. * Contact Hardening
  9644. */
  9645. static readonly FILTER_PCSS: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * Highest Quality.
  9649. *
  9650. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9651. *
  9652. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9653. */
  9654. static readonly QUALITY_HIGH: number;
  9655. /**
  9656. * Reserved for PCF and PCSS
  9657. * Good tradeoff for quality/perf cross devices
  9658. *
  9659. * Execute PCF on a 3*3 kernel.
  9660. *
  9661. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9662. */
  9663. static readonly QUALITY_MEDIUM: number;
  9664. /**
  9665. * Reserved for PCF and PCSS
  9666. * The lowest quality but the fastest.
  9667. *
  9668. * Execute PCF on a 1*1 kernel.
  9669. *
  9670. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9671. */
  9672. static readonly QUALITY_LOW: number;
  9673. /** Gets or sets the custom shader name to use */
  9674. customShaderOptions: ICustomShaderOptions;
  9675. /**
  9676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9677. */
  9678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9679. /**
  9680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9681. */
  9682. onAfterShadowMapRenderObservable: Observable<Effect>;
  9683. /**
  9684. * Observable triggered before a mesh is rendered in the shadow map.
  9685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9686. */
  9687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9688. /**
  9689. * Observable triggered after a mesh is rendered in the shadow map.
  9690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9691. */
  9692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9693. private _bias;
  9694. /**
  9695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9696. */
  9697. get bias(): number;
  9698. /**
  9699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9700. */
  9701. set bias(bias: number);
  9702. private _normalBias;
  9703. /**
  9704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9705. */
  9706. get normalBias(): number;
  9707. /**
  9708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9709. */
  9710. set normalBias(normalBias: number);
  9711. private _blurBoxOffset;
  9712. /**
  9713. * Gets the blur box offset: offset applied during the blur pass.
  9714. * Only useful if useKernelBlur = false
  9715. */
  9716. get blurBoxOffset(): number;
  9717. /**
  9718. * Sets the blur box offset: offset applied during the blur pass.
  9719. * Only useful if useKernelBlur = false
  9720. */
  9721. set blurBoxOffset(value: number);
  9722. private _blurScale;
  9723. /**
  9724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9725. * 2 means half of the size.
  9726. */
  9727. get blurScale(): number;
  9728. /**
  9729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9730. * 2 means half of the size.
  9731. */
  9732. set blurScale(value: number);
  9733. private _blurKernel;
  9734. /**
  9735. * Gets the blur kernel: kernel size of the blur pass.
  9736. * Only useful if useKernelBlur = true
  9737. */
  9738. get blurKernel(): number;
  9739. /**
  9740. * Sets the blur kernel: kernel size of the blur pass.
  9741. * Only useful if useKernelBlur = true
  9742. */
  9743. set blurKernel(value: number);
  9744. private _useKernelBlur;
  9745. /**
  9746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9748. */
  9749. get useKernelBlur(): boolean;
  9750. /**
  9751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9753. */
  9754. set useKernelBlur(value: boolean);
  9755. private _depthScale;
  9756. /**
  9757. * Gets the depth scale used in ESM mode.
  9758. */
  9759. get depthScale(): number;
  9760. /**
  9761. * Sets the depth scale used in ESM mode.
  9762. * This can override the scale stored on the light.
  9763. */
  9764. set depthScale(value: number);
  9765. private _filter;
  9766. /**
  9767. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9768. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9769. */
  9770. get filter(): number;
  9771. /**
  9772. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9773. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9774. */
  9775. set filter(value: number);
  9776. /**
  9777. * Gets if the current filter is set to Poisson Sampling.
  9778. */
  9779. get usePoissonSampling(): boolean;
  9780. /**
  9781. * Sets the current filter to Poisson Sampling.
  9782. */
  9783. set usePoissonSampling(value: boolean);
  9784. /**
  9785. * Gets if the current filter is set to ESM.
  9786. */
  9787. get useExponentialShadowMap(): boolean;
  9788. /**
  9789. * Sets the current filter is to ESM.
  9790. */
  9791. set useExponentialShadowMap(value: boolean);
  9792. /**
  9793. * Gets if the current filter is set to filtered ESM.
  9794. */
  9795. get useBlurExponentialShadowMap(): boolean;
  9796. /**
  9797. * Gets if the current filter is set to filtered ESM.
  9798. */
  9799. set useBlurExponentialShadowMap(value: boolean);
  9800. /**
  9801. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9802. * exponential to prevent steep falloff artifacts).
  9803. */
  9804. get useCloseExponentialShadowMap(): boolean;
  9805. /**
  9806. * Sets the current filter to "close ESM" (using the inverse of the
  9807. * exponential to prevent steep falloff artifacts).
  9808. */
  9809. set useCloseExponentialShadowMap(value: boolean);
  9810. /**
  9811. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9812. * exponential to prevent steep falloff artifacts).
  9813. */
  9814. get useBlurCloseExponentialShadowMap(): boolean;
  9815. /**
  9816. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9817. * exponential to prevent steep falloff artifacts).
  9818. */
  9819. set useBlurCloseExponentialShadowMap(value: boolean);
  9820. /**
  9821. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9822. */
  9823. get usePercentageCloserFiltering(): boolean;
  9824. /**
  9825. * Sets the current filter to "PCF" (percentage closer filtering).
  9826. */
  9827. set usePercentageCloserFiltering(value: boolean);
  9828. private _filteringQuality;
  9829. /**
  9830. * Gets the PCF or PCSS Quality.
  9831. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9832. */
  9833. get filteringQuality(): number;
  9834. /**
  9835. * Sets the PCF or PCSS Quality.
  9836. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9837. */
  9838. set filteringQuality(filteringQuality: number);
  9839. /**
  9840. * Gets if the current filter is set to "PCSS" (contact hardening).
  9841. */
  9842. get useContactHardeningShadow(): boolean;
  9843. /**
  9844. * Sets the current filter to "PCSS" (contact hardening).
  9845. */
  9846. set useContactHardeningShadow(value: boolean);
  9847. private _contactHardeningLightSizeUVRatio;
  9848. /**
  9849. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9850. * Using a ratio helps keeping shape stability independently of the map size.
  9851. *
  9852. * It does not account for the light projection as it was having too much
  9853. * instability during the light setup or during light position changes.
  9854. *
  9855. * Only valid if useContactHardeningShadow is true.
  9856. */
  9857. get contactHardeningLightSizeUVRatio(): number;
  9858. /**
  9859. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9860. * Using a ratio helps keeping shape stability independently of the map size.
  9861. *
  9862. * It does not account for the light projection as it was having too much
  9863. * instability during the light setup or during light position changes.
  9864. *
  9865. * Only valid if useContactHardeningShadow is true.
  9866. */
  9867. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9868. private _darkness;
  9869. /** Gets or sets the actual darkness of a shadow */
  9870. get darkness(): number;
  9871. set darkness(value: number);
  9872. /**
  9873. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9874. * 0 means strongest and 1 would means no shadow.
  9875. * @returns the darkness.
  9876. */
  9877. getDarkness(): number;
  9878. /**
  9879. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9880. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9881. * @returns the shadow generator allowing fluent coding.
  9882. */
  9883. setDarkness(darkness: number): ShadowGenerator;
  9884. private _transparencyShadow;
  9885. /** Gets or sets the ability to have transparent shadow */
  9886. get transparencyShadow(): boolean;
  9887. set transparencyShadow(value: boolean);
  9888. /**
  9889. * Sets the ability to have transparent shadow (boolean).
  9890. * @param transparent True if transparent else False
  9891. * @returns the shadow generator allowing fluent coding
  9892. */
  9893. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9894. private _shadowMap;
  9895. private _shadowMap2;
  9896. /**
  9897. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9898. * @returns The render target texture if present otherwise, null
  9899. */
  9900. getShadowMap(): Nullable<RenderTargetTexture>;
  9901. /**
  9902. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9903. * @returns The render target texture if the shadow map is present otherwise, null
  9904. */
  9905. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9906. /**
  9907. * Gets the class name of that object
  9908. * @returns "ShadowGenerator"
  9909. */
  9910. getClassName(): string;
  9911. /**
  9912. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9913. * @param mesh Mesh to add
  9914. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9915. * @returns the Shadow Generator itself
  9916. */
  9917. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9918. /**
  9919. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9920. * @param mesh Mesh to remove
  9921. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9922. * @returns the Shadow Generator itself
  9923. */
  9924. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9925. /**
  9926. * Controls the extent to which the shadows fade out at the edge of the frustum
  9927. * Used only by directionals and spots
  9928. */
  9929. frustumEdgeFalloff: number;
  9930. private _light;
  9931. /**
  9932. * Returns the associated light object.
  9933. * @returns the light generating the shadow
  9934. */
  9935. getLight(): IShadowLight;
  9936. /**
  9937. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9938. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9939. * It might on the other hand introduce peter panning.
  9940. */
  9941. forceBackFacesOnly: boolean;
  9942. private _scene;
  9943. private _lightDirection;
  9944. private _effect;
  9945. private _viewMatrix;
  9946. private _projectionMatrix;
  9947. private _transformMatrix;
  9948. private _cachedPosition;
  9949. private _cachedDirection;
  9950. private _cachedDefines;
  9951. private _currentRenderID;
  9952. private _boxBlurPostprocess;
  9953. private _kernelBlurXPostprocess;
  9954. private _kernelBlurYPostprocess;
  9955. private _blurPostProcesses;
  9956. private _mapSize;
  9957. private _currentFaceIndex;
  9958. private _currentFaceIndexCache;
  9959. private _textureType;
  9960. private _defaultTextureMatrix;
  9961. private _storedUniqueId;
  9962. /** @hidden */
  9963. static _SceneComponentInitialization: (scene: Scene) => void;
  9964. /**
  9965. * Creates a ShadowGenerator object.
  9966. * A ShadowGenerator is the required tool to use the shadows.
  9967. * Each light casting shadows needs to use its own ShadowGenerator.
  9968. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9969. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9970. * @param light The light object generating the shadows.
  9971. * @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.
  9972. */
  9973. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9974. private _initializeGenerator;
  9975. private _initializeShadowMap;
  9976. private _initializeBlurRTTAndPostProcesses;
  9977. private _renderForShadowMap;
  9978. private _renderSubMeshForShadowMap;
  9979. private _applyFilterValues;
  9980. /**
  9981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9982. * @param onCompiled Callback triggered at the and of the effects compilation
  9983. * @param options Sets of optional options forcing the compilation with different modes
  9984. */
  9985. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9986. useInstances: boolean;
  9987. }>): void;
  9988. /**
  9989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9990. * @param options Sets of optional options forcing the compilation with different modes
  9991. * @returns A promise that resolves when the compilation completes
  9992. */
  9993. forceCompilationAsync(options?: Partial<{
  9994. useInstances: boolean;
  9995. }>): Promise<void>;
  9996. /**
  9997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9998. * @param subMesh The submesh we want to render in the shadow map
  9999. * @param useInstances Defines wether will draw in the map using instances
  10000. * @returns true if ready otherwise, false
  10001. */
  10002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10003. /**
  10004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10005. * @param defines Defines of the material we want to update
  10006. * @param lightIndex Index of the light in the enabled light list of the material
  10007. */
  10008. prepareDefines(defines: any, lightIndex: number): void;
  10009. /**
  10010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10011. * defined in the generator but impacting the effect).
  10012. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10013. * @param effect The effect we are binfing the information for
  10014. */
  10015. bindShadowLight(lightIndex: string, effect: Effect): void;
  10016. /**
  10017. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10018. * (eq to shadow prjection matrix * light transform matrix)
  10019. * @returns The transform matrix used to create the shadow map
  10020. */
  10021. getTransformMatrix(): Matrix;
  10022. /**
  10023. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10024. * Cube and 2D textures for instance.
  10025. */
  10026. recreateShadowMap(): void;
  10027. private _disposeBlurPostProcesses;
  10028. private _disposeRTTandPostProcesses;
  10029. /**
  10030. * Disposes the ShadowGenerator.
  10031. * Returns nothing.
  10032. */
  10033. dispose(): void;
  10034. /**
  10035. * Serializes the shadow generator setup to a json object.
  10036. * @returns The serialized JSON object
  10037. */
  10038. serialize(): any;
  10039. /**
  10040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10041. * @param parsedShadowGenerator The JSON object to parse
  10042. * @param scene The scene to create the shadow map for
  10043. * @returns The parsed shadow generator
  10044. */
  10045. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10046. }
  10047. }
  10048. declare module "babylonjs/Lights/light" {
  10049. import { Nullable } from "babylonjs/types";
  10050. import { Scene } from "babylonjs/scene";
  10051. import { Vector3 } from "babylonjs/Maths/math.vector";
  10052. import { Color3 } from "babylonjs/Maths/math.color";
  10053. import { Node } from "babylonjs/node";
  10054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10055. import { Effect } from "babylonjs/Materials/effect";
  10056. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10057. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10058. /**
  10059. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10060. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10061. * 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.
  10062. */
  10063. export abstract class Light extends Node {
  10064. /**
  10065. * Falloff Default: light is falling off following the material specification:
  10066. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10067. */
  10068. static readonly FALLOFF_DEFAULT: number;
  10069. /**
  10070. * Falloff Physical: light is falling off following the inverse squared distance law.
  10071. */
  10072. static readonly FALLOFF_PHYSICAL: number;
  10073. /**
  10074. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10075. * to enhance interoperability with other engines.
  10076. */
  10077. static readonly FALLOFF_GLTF: number;
  10078. /**
  10079. * Falloff Standard: light is falling off like in the standard material
  10080. * to enhance interoperability with other materials.
  10081. */
  10082. static readonly FALLOFF_STANDARD: number;
  10083. /**
  10084. * If every light affecting the material is in this lightmapMode,
  10085. * material.lightmapTexture adds or multiplies
  10086. * (depends on material.useLightmapAsShadowmap)
  10087. * after every other light calculations.
  10088. */
  10089. static readonly LIGHTMAP_DEFAULT: number;
  10090. /**
  10091. * material.lightmapTexture as only diffuse lighting from this light
  10092. * adds only specular lighting from this light
  10093. * adds dynamic shadows
  10094. */
  10095. static readonly LIGHTMAP_SPECULAR: number;
  10096. /**
  10097. * material.lightmapTexture as only lighting
  10098. * no light calculation from this light
  10099. * only adds dynamic shadows from this light
  10100. */
  10101. static readonly LIGHTMAP_SHADOWSONLY: number;
  10102. /**
  10103. * Each light type uses the default quantity according to its type:
  10104. * point/spot lights use luminous intensity
  10105. * directional lights use illuminance
  10106. */
  10107. static readonly INTENSITYMODE_AUTOMATIC: number;
  10108. /**
  10109. * lumen (lm)
  10110. */
  10111. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10112. /**
  10113. * candela (lm/sr)
  10114. */
  10115. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10116. /**
  10117. * lux (lm/m^2)
  10118. */
  10119. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10120. /**
  10121. * nit (cd/m^2)
  10122. */
  10123. static readonly INTENSITYMODE_LUMINANCE: number;
  10124. /**
  10125. * Light type const id of the point light.
  10126. */
  10127. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10128. /**
  10129. * Light type const id of the directional light.
  10130. */
  10131. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10132. /**
  10133. * Light type const id of the spot light.
  10134. */
  10135. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10136. /**
  10137. * Light type const id of the hemispheric light.
  10138. */
  10139. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10140. /**
  10141. * Diffuse gives the basic color to an object.
  10142. */
  10143. diffuse: Color3;
  10144. /**
  10145. * Specular produces a highlight color on an object.
  10146. * Note: This is note affecting PBR materials.
  10147. */
  10148. specular: Color3;
  10149. /**
  10150. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10151. * falling off base on range or angle.
  10152. * This can be set to any values in Light.FALLOFF_x.
  10153. *
  10154. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10155. * other types of materials.
  10156. */
  10157. falloffType: number;
  10158. /**
  10159. * Strength of the light.
  10160. * Note: By default it is define in the framework own unit.
  10161. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10162. */
  10163. intensity: number;
  10164. private _range;
  10165. protected _inverseSquaredRange: number;
  10166. /**
  10167. * Defines how far from the source the light is impacting in scene units.
  10168. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10169. */
  10170. get range(): number;
  10171. /**
  10172. * Defines how far from the source the light is impacting in scene units.
  10173. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10174. */
  10175. set range(value: number);
  10176. /**
  10177. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10178. * of light.
  10179. */
  10180. private _photometricScale;
  10181. private _intensityMode;
  10182. /**
  10183. * Gets the photometric scale used to interpret the intensity.
  10184. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10185. */
  10186. get intensityMode(): number;
  10187. /**
  10188. * Sets the photometric scale used to interpret the intensity.
  10189. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10190. */
  10191. set intensityMode(value: number);
  10192. private _radius;
  10193. /**
  10194. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10195. */
  10196. get radius(): number;
  10197. /**
  10198. * sets the light radius used by PBR Materials to simulate soft area lights.
  10199. */
  10200. set radius(value: number);
  10201. private _renderPriority;
  10202. /**
  10203. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10204. * exceeding the number allowed of the materials.
  10205. */
  10206. renderPriority: number;
  10207. private _shadowEnabled;
  10208. /**
  10209. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10210. * the current shadow generator.
  10211. */
  10212. get shadowEnabled(): boolean;
  10213. /**
  10214. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10215. * the current shadow generator.
  10216. */
  10217. set shadowEnabled(value: boolean);
  10218. private _includedOnlyMeshes;
  10219. /**
  10220. * Gets the only meshes impacted by this light.
  10221. */
  10222. get includedOnlyMeshes(): AbstractMesh[];
  10223. /**
  10224. * Sets the only meshes impacted by this light.
  10225. */
  10226. set includedOnlyMeshes(value: AbstractMesh[]);
  10227. private _excludedMeshes;
  10228. /**
  10229. * Gets the meshes not impacted by this light.
  10230. */
  10231. get excludedMeshes(): AbstractMesh[];
  10232. /**
  10233. * Sets the meshes not impacted by this light.
  10234. */
  10235. set excludedMeshes(value: AbstractMesh[]);
  10236. private _excludeWithLayerMask;
  10237. /**
  10238. * Gets the layer id use to find what meshes are not impacted by the light.
  10239. * Inactive if 0
  10240. */
  10241. get excludeWithLayerMask(): number;
  10242. /**
  10243. * Sets the layer id use to find what meshes are not impacted by the light.
  10244. * Inactive if 0
  10245. */
  10246. set excludeWithLayerMask(value: number);
  10247. private _includeOnlyWithLayerMask;
  10248. /**
  10249. * Gets the layer id use to find what meshes are impacted by the light.
  10250. * Inactive if 0
  10251. */
  10252. get includeOnlyWithLayerMask(): number;
  10253. /**
  10254. * Sets the layer id use to find what meshes are impacted by the light.
  10255. * Inactive if 0
  10256. */
  10257. set includeOnlyWithLayerMask(value: number);
  10258. private _lightmapMode;
  10259. /**
  10260. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10261. */
  10262. get lightmapMode(): number;
  10263. /**
  10264. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10265. */
  10266. set lightmapMode(value: number);
  10267. /**
  10268. * Shadow generator associted to the light.
  10269. * @hidden Internal use only.
  10270. */
  10271. _shadowGenerator: Nullable<IShadowGenerator>;
  10272. /**
  10273. * @hidden Internal use only.
  10274. */
  10275. _excludedMeshesIds: string[];
  10276. /**
  10277. * @hidden Internal use only.
  10278. */
  10279. _includedOnlyMeshesIds: string[];
  10280. /**
  10281. * The current light unifom buffer.
  10282. * @hidden Internal use only.
  10283. */
  10284. _uniformBuffer: UniformBuffer;
  10285. /** @hidden */
  10286. _renderId: number;
  10287. /**
  10288. * Creates a Light object in the scene.
  10289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10290. * @param name The firendly name of the light
  10291. * @param scene The scene the light belongs too
  10292. */
  10293. constructor(name: string, scene: Scene);
  10294. protected abstract _buildUniformLayout(): void;
  10295. /**
  10296. * Sets the passed Effect "effect" with the Light information.
  10297. * @param effect The effect to update
  10298. * @param lightIndex The index of the light in the effect to update
  10299. * @returns The light
  10300. */
  10301. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10302. /**
  10303. * Sets the passed Effect "effect" with the Light textures.
  10304. * @param effect The effect to update
  10305. * @param lightIndex The index of the light in the effect to update
  10306. * @returns The light
  10307. */
  10308. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10309. /**
  10310. * Binds the lights information from the scene to the effect for the given mesh.
  10311. * @param lightIndex Light index
  10312. * @param scene The scene where the light belongs to
  10313. * @param effect The effect we are binding the data to
  10314. * @param useSpecular Defines if specular is supported
  10315. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10317. */
  10318. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10319. /**
  10320. * Sets the passed Effect "effect" with the Light information.
  10321. * @param effect The effect to update
  10322. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10323. * @returns The light
  10324. */
  10325. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10326. /**
  10327. * Returns the string "Light".
  10328. * @returns the class name
  10329. */
  10330. getClassName(): string;
  10331. /** @hidden */
  10332. readonly _isLight: boolean;
  10333. /**
  10334. * Converts the light information to a readable string for debug purpose.
  10335. * @param fullDetails Supports for multiple levels of logging within scene loading
  10336. * @returns the human readable light info
  10337. */
  10338. toString(fullDetails?: boolean): string;
  10339. /** @hidden */
  10340. protected _syncParentEnabledState(): void;
  10341. /**
  10342. * Set the enabled state of this node.
  10343. * @param value - the new enabled state
  10344. */
  10345. setEnabled(value: boolean): void;
  10346. /**
  10347. * Returns the Light associated shadow generator if any.
  10348. * @return the associated shadow generator.
  10349. */
  10350. getShadowGenerator(): Nullable<IShadowGenerator>;
  10351. /**
  10352. * Returns a Vector3, the absolute light position in the World.
  10353. * @returns the world space position of the light
  10354. */
  10355. getAbsolutePosition(): Vector3;
  10356. /**
  10357. * Specifies if the light will affect the passed mesh.
  10358. * @param mesh The mesh to test against the light
  10359. * @return true the mesh is affected otherwise, false.
  10360. */
  10361. canAffectMesh(mesh: AbstractMesh): boolean;
  10362. /**
  10363. * Sort function to order lights for rendering.
  10364. * @param a First Light object to compare to second.
  10365. * @param b Second Light object to compare first.
  10366. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10367. */
  10368. static CompareLightsPriority(a: Light, b: Light): number;
  10369. /**
  10370. * Releases resources associated with this node.
  10371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10373. */
  10374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10375. /**
  10376. * Returns the light type ID (integer).
  10377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10378. */
  10379. getTypeID(): number;
  10380. /**
  10381. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10382. * @returns the scaled intensity in intensity mode unit
  10383. */
  10384. getScaledIntensity(): number;
  10385. /**
  10386. * Returns a new Light object, named "name", from the current one.
  10387. * @param name The name of the cloned light
  10388. * @returns the new created light
  10389. */
  10390. clone(name: string): Nullable<Light>;
  10391. /**
  10392. * Serializes the current light into a Serialization object.
  10393. * @returns the serialized object.
  10394. */
  10395. serialize(): any;
  10396. /**
  10397. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10398. * This new light is named "name" and added to the passed scene.
  10399. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10400. * @param name The friendly name of the light
  10401. * @param scene The scene the new light will belong to
  10402. * @returns the constructor function
  10403. */
  10404. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10405. /**
  10406. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10407. * @param parsedLight The JSON representation of the light
  10408. * @param scene The scene to create the parsed light in
  10409. * @returns the created light after parsing
  10410. */
  10411. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10412. private _hookArrayForExcluded;
  10413. private _hookArrayForIncludedOnly;
  10414. private _resyncMeshes;
  10415. /**
  10416. * Forces the meshes to update their light related information in their rendering used effects
  10417. * @hidden Internal Use Only
  10418. */
  10419. _markMeshesAsLightDirty(): void;
  10420. /**
  10421. * Recomputes the cached photometric scale if needed.
  10422. */
  10423. private _computePhotometricScale;
  10424. /**
  10425. * Returns the Photometric Scale according to the light type and intensity mode.
  10426. */
  10427. private _getPhotometricScale;
  10428. /**
  10429. * Reorder the light in the scene according to their defined priority.
  10430. * @hidden Internal Use Only
  10431. */
  10432. _reorderLightsInScene(): void;
  10433. /**
  10434. * Prepares the list of defines specific to the light type.
  10435. * @param defines the list of defines
  10436. * @param lightIndex defines the index of the light for the effect
  10437. */
  10438. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10439. }
  10440. }
  10441. declare module "babylonjs/Actions/action" {
  10442. import { Observable } from "babylonjs/Misc/observable";
  10443. import { Condition } from "babylonjs/Actions/condition";
  10444. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10447. /**
  10448. * Interface used to define Action
  10449. */
  10450. export interface IAction {
  10451. /**
  10452. * Trigger for the action
  10453. */
  10454. trigger: number;
  10455. /** Options of the trigger */
  10456. triggerOptions: any;
  10457. /**
  10458. * Gets the trigger parameters
  10459. * @returns the trigger parameters
  10460. */
  10461. getTriggerParameter(): any;
  10462. /**
  10463. * Internal only - executes current action event
  10464. * @hidden
  10465. */
  10466. _executeCurrent(evt?: ActionEvent): void;
  10467. /**
  10468. * Serialize placeholder for child classes
  10469. * @param parent of child
  10470. * @returns the serialized object
  10471. */
  10472. serialize(parent: any): any;
  10473. /**
  10474. * Internal only
  10475. * @hidden
  10476. */
  10477. _prepare(): void;
  10478. /**
  10479. * Internal only - manager for action
  10480. * @hidden
  10481. */
  10482. _actionManager: AbstractActionManager;
  10483. /**
  10484. * Adds action to chain of actions, may be a DoNothingAction
  10485. * @param action defines the next action to execute
  10486. * @returns The action passed in
  10487. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10488. */
  10489. then(action: IAction): IAction;
  10490. }
  10491. /**
  10492. * The action to be carried out following a trigger
  10493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10494. */
  10495. export class Action implements IAction {
  10496. /** the trigger, with or without parameters, for the action */
  10497. triggerOptions: any;
  10498. /**
  10499. * Trigger for the action
  10500. */
  10501. trigger: number;
  10502. /**
  10503. * Internal only - manager for action
  10504. * @hidden
  10505. */
  10506. _actionManager: ActionManager;
  10507. private _nextActiveAction;
  10508. private _child;
  10509. private _condition?;
  10510. private _triggerParameter;
  10511. /**
  10512. * An event triggered prior to action being executed.
  10513. */
  10514. onBeforeExecuteObservable: Observable<Action>;
  10515. /**
  10516. * Creates a new Action
  10517. * @param triggerOptions the trigger, with or without parameters, for the action
  10518. * @param condition an optional determinant of action
  10519. */
  10520. constructor(
  10521. /** the trigger, with or without parameters, for the action */
  10522. triggerOptions: any, condition?: Condition);
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _prepare(): void;
  10528. /**
  10529. * Gets the trigger parameters
  10530. * @returns the trigger parameters
  10531. */
  10532. getTriggerParameter(): any;
  10533. /**
  10534. * Internal only - executes current action event
  10535. * @hidden
  10536. */
  10537. _executeCurrent(evt?: ActionEvent): void;
  10538. /**
  10539. * Execute placeholder for child classes
  10540. * @param evt optional action event
  10541. */
  10542. execute(evt?: ActionEvent): void;
  10543. /**
  10544. * Skips to next active action
  10545. */
  10546. skipToNextActiveAction(): void;
  10547. /**
  10548. * Adds action to chain of actions, may be a DoNothingAction
  10549. * @param action defines the next action to execute
  10550. * @returns The action passed in
  10551. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10552. */
  10553. then(action: Action): Action;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. _getProperty(propertyPath: string): string;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. _getEffectiveTarget(target: any, propertyPath: string): any;
  10564. /**
  10565. * Serialize placeholder for child classes
  10566. * @param parent of child
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. /**
  10571. * Internal only called by serialize
  10572. * @hidden
  10573. */
  10574. protected _serialize(serializedAction: any, parent?: any): any;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. static _SerializeValueAsString: (value: any) => string;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10585. name: string;
  10586. targetType: string;
  10587. value: string;
  10588. };
  10589. }
  10590. }
  10591. declare module "babylonjs/Actions/condition" {
  10592. import { ActionManager } from "babylonjs/Actions/actionManager";
  10593. /**
  10594. * A Condition applied to an Action
  10595. */
  10596. export class Condition {
  10597. /**
  10598. * Internal only - manager for action
  10599. * @hidden
  10600. */
  10601. _actionManager: ActionManager;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. _evaluationId: number;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. _currentResult: boolean;
  10612. /**
  10613. * Creates a new Condition
  10614. * @param actionManager the manager of the action the condition is applied to
  10615. */
  10616. constructor(actionManager: ActionManager);
  10617. /**
  10618. * Check if the current condition is valid
  10619. * @returns a boolean
  10620. */
  10621. isValid(): boolean;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. _getProperty(propertyPath: string): string;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. _getEffectiveTarget(target: any, propertyPath: string): any;
  10632. /**
  10633. * Serialize placeholder for child classes
  10634. * @returns the serialized object
  10635. */
  10636. serialize(): any;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. protected _serialize(serializedCondition: any): any;
  10642. }
  10643. /**
  10644. * Defines specific conditional operators as extensions of Condition
  10645. */
  10646. export class ValueCondition extends Condition {
  10647. /** path to specify the property of the target the conditional operator uses */
  10648. propertyPath: string;
  10649. /** the value compared by the conditional operator against the current value of the property */
  10650. value: any;
  10651. /** the conditional operator, default ValueCondition.IsEqual */
  10652. operator: number;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. private static _IsEqual;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. private static _IsDifferent;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. private static _IsGreater;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. private static _IsLesser;
  10673. /**
  10674. * returns the number for IsEqual
  10675. */
  10676. static get IsEqual(): number;
  10677. /**
  10678. * Returns the number for IsDifferent
  10679. */
  10680. static get IsDifferent(): number;
  10681. /**
  10682. * Returns the number for IsGreater
  10683. */
  10684. static get IsGreater(): number;
  10685. /**
  10686. * Returns the number for IsLesser
  10687. */
  10688. static get IsLesser(): number;
  10689. /**
  10690. * Internal only The action manager for the condition
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private _target;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _effectiveTarget;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private _property;
  10709. /**
  10710. * Creates a new ValueCondition
  10711. * @param actionManager manager for the action the condition applies to
  10712. * @param target for the action
  10713. * @param propertyPath path to specify the property of the target the conditional operator uses
  10714. * @param value the value compared by the conditional operator against the current value of the property
  10715. * @param operator the conditional operator, default ValueCondition.IsEqual
  10716. */
  10717. constructor(actionManager: ActionManager, target: any,
  10718. /** path to specify the property of the target the conditional operator uses */
  10719. propertyPath: string,
  10720. /** the value compared by the conditional operator against the current value of the property */
  10721. value: any,
  10722. /** the conditional operator, default ValueCondition.IsEqual */
  10723. operator?: number);
  10724. /**
  10725. * Compares the given value with the property value for the specified conditional operator
  10726. * @returns the result of the comparison
  10727. */
  10728. isValid(): boolean;
  10729. /**
  10730. * Serialize the ValueCondition into a JSON compatible object
  10731. * @returns serialization object
  10732. */
  10733. serialize(): any;
  10734. /**
  10735. * Gets the name of the conditional operator for the ValueCondition
  10736. * @param operator the conditional operator
  10737. * @returns the name
  10738. */
  10739. static GetOperatorName(operator: number): string;
  10740. }
  10741. /**
  10742. * Defines a predicate condition as an extension of Condition
  10743. */
  10744. export class PredicateCondition extends Condition {
  10745. /** defines the predicate function used to validate the condition */
  10746. predicate: () => boolean;
  10747. /**
  10748. * Internal only - manager for action
  10749. * @hidden
  10750. */
  10751. _actionManager: ActionManager;
  10752. /**
  10753. * Creates a new PredicateCondition
  10754. * @param actionManager manager for the action the condition applies to
  10755. * @param predicate defines the predicate function used to validate the condition
  10756. */
  10757. constructor(actionManager: ActionManager,
  10758. /** defines the predicate function used to validate the condition */
  10759. predicate: () => boolean);
  10760. /**
  10761. * @returns the validity of the predicate condition
  10762. */
  10763. isValid(): boolean;
  10764. }
  10765. /**
  10766. * Defines a state condition as an extension of Condition
  10767. */
  10768. export class StateCondition extends Condition {
  10769. /** Value to compare with target state */
  10770. value: string;
  10771. /**
  10772. * Internal only - manager for action
  10773. * @hidden
  10774. */
  10775. _actionManager: ActionManager;
  10776. /**
  10777. * Internal only
  10778. * @hidden
  10779. */
  10780. private _target;
  10781. /**
  10782. * Creates a new StateCondition
  10783. * @param actionManager manager for the action the condition applies to
  10784. * @param target of the condition
  10785. * @param value to compare with target state
  10786. */
  10787. constructor(actionManager: ActionManager, target: any,
  10788. /** Value to compare with target state */
  10789. value: string);
  10790. /**
  10791. * Gets a boolean indicating if the current condition is met
  10792. * @returns the validity of the state
  10793. */
  10794. isValid(): boolean;
  10795. /**
  10796. * Serialize the StateCondition into a JSON compatible object
  10797. * @returns serialization object
  10798. */
  10799. serialize(): any;
  10800. }
  10801. }
  10802. declare module "babylonjs/Actions/directActions" {
  10803. import { Action } from "babylonjs/Actions/action";
  10804. import { Condition } from "babylonjs/Actions/condition";
  10805. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10806. /**
  10807. * This defines an action responsible to toggle a boolean once triggered.
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10809. */
  10810. export class SwitchBooleanAction extends Action {
  10811. /**
  10812. * The path to the boolean property in the target object
  10813. */
  10814. propertyPath: string;
  10815. private _target;
  10816. private _effectiveTarget;
  10817. private _property;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the object containing the boolean
  10822. * @param propertyPath defines the path to the boolean property in the target object
  10823. * @param condition defines the trigger related conditions
  10824. */
  10825. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10826. /** @hidden */
  10827. _prepare(): void;
  10828. /**
  10829. * Execute the action toggle the boolean value.
  10830. */
  10831. execute(): void;
  10832. /**
  10833. * Serializes the actions and its related information.
  10834. * @param parent defines the object to serialize in
  10835. * @returns the serialized object
  10836. */
  10837. serialize(parent: any): any;
  10838. }
  10839. /**
  10840. * This defines an action responsible to set a the state field of the target
  10841. * to a desired value once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class SetStateAction extends Action {
  10845. /**
  10846. * The value to store in the state field.
  10847. */
  10848. value: string;
  10849. private _target;
  10850. /**
  10851. * Instantiate the action
  10852. * @param triggerOptions defines the trigger options
  10853. * @param target defines the object containing the state property
  10854. * @param value defines the value to store in the state field
  10855. * @param condition defines the trigger related conditions
  10856. */
  10857. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10858. /**
  10859. * Execute the action and store the value on the target state property.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible to set a property of the target
  10871. * to a desired value once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class SetValueAction extends Action {
  10875. /**
  10876. * The path of the property to set in the target.
  10877. */
  10878. propertyPath: string;
  10879. /**
  10880. * The value to set in the property
  10881. */
  10882. value: any;
  10883. private _target;
  10884. private _effectiveTarget;
  10885. private _property;
  10886. /**
  10887. * Instantiate the action
  10888. * @param triggerOptions defines the trigger options
  10889. * @param target defines the object containing the property
  10890. * @param propertyPath defines the path of the property to set in the target
  10891. * @param value defines the value to set in the property
  10892. * @param condition defines the trigger related conditions
  10893. */
  10894. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10895. /** @hidden */
  10896. _prepare(): void;
  10897. /**
  10898. * Execute the action and set the targetted property to the desired value.
  10899. */
  10900. execute(): void;
  10901. /**
  10902. * Serializes the actions and its related information.
  10903. * @param parent defines the object to serialize in
  10904. * @returns the serialized object
  10905. */
  10906. serialize(parent: any): any;
  10907. }
  10908. /**
  10909. * This defines an action responsible to increment the target value
  10910. * to a desired value once triggered.
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10912. */
  10913. export class IncrementValueAction extends Action {
  10914. /**
  10915. * The path of the property to increment in the target.
  10916. */
  10917. propertyPath: string;
  10918. /**
  10919. * The value we should increment the property by.
  10920. */
  10921. value: any;
  10922. private _target;
  10923. private _effectiveTarget;
  10924. private _property;
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param target defines the object containing the property
  10929. * @param propertyPath defines the path of the property to increment in the target
  10930. * @param value defines the value value we should increment the property by
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10934. /** @hidden */
  10935. _prepare(): void;
  10936. /**
  10937. * Execute the action and increment the target of the value amount.
  10938. */
  10939. execute(): void;
  10940. /**
  10941. * Serializes the actions and its related information.
  10942. * @param parent defines the object to serialize in
  10943. * @returns the serialized object
  10944. */
  10945. serialize(parent: any): any;
  10946. }
  10947. /**
  10948. * This defines an action responsible to start an animation once triggered.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class PlayAnimationAction extends Action {
  10952. /**
  10953. * Where the animation should start (animation frame)
  10954. */
  10955. from: number;
  10956. /**
  10957. * Where the animation should stop (animation frame)
  10958. */
  10959. to: number;
  10960. /**
  10961. * Define if the animation should loop or stop after the first play.
  10962. */
  10963. loop?: boolean;
  10964. private _target;
  10965. /**
  10966. * Instantiate the action
  10967. * @param triggerOptions defines the trigger options
  10968. * @param target defines the target animation or animation name
  10969. * @param from defines from where the animation should start (animation frame)
  10970. * @param end defines where the animation should stop (animation frame)
  10971. * @param loop defines if the animation should loop or stop after the first play
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and play the animation.
  10979. */
  10980. execute(): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to stop an animation once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class StopAnimationAction extends Action {
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target animation or animation name
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and stop the animation.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible that does nothing once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class DoNothingAction extends Action {
  11019. /**
  11020. * Instantiate the action
  11021. * @param triggerOptions defines the trigger options
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions?: any, condition?: Condition);
  11025. /**
  11026. * Execute the action and do nothing.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to trigger several actions once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class CombineAction extends Action {
  11041. /**
  11042. * The list of aggregated animations to run.
  11043. */
  11044. children: Action[];
  11045. /**
  11046. * Instantiate the action
  11047. * @param triggerOptions defines the trigger options
  11048. * @param children defines the list of aggregated animations to run
  11049. * @param condition defines the trigger related conditions
  11050. */
  11051. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11052. /** @hidden */
  11053. _prepare(): void;
  11054. /**
  11055. * Execute the action and executes all the aggregated actions.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. /**
  11059. * Serializes the actions and its related information.
  11060. * @param parent defines the object to serialize in
  11061. * @returns the serialized object
  11062. */
  11063. serialize(parent: any): any;
  11064. }
  11065. /**
  11066. * This defines an action responsible to run code (external event) once triggered.
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11068. */
  11069. export class ExecuteCodeAction extends Action {
  11070. /**
  11071. * The callback function to run.
  11072. */
  11073. func: (evt: ActionEvent) => void;
  11074. /**
  11075. * Instantiate the action
  11076. * @param triggerOptions defines the trigger options
  11077. * @param func defines the callback function to run
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11081. /**
  11082. * Execute the action and run the attached code.
  11083. */
  11084. execute(evt: ActionEvent): void;
  11085. }
  11086. /**
  11087. * This defines an action responsible to set the parent property of the target once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class SetParentAction extends Action {
  11091. private _parent;
  11092. private _target;
  11093. /**
  11094. * Instantiate the action
  11095. * @param triggerOptions defines the trigger options
  11096. * @param target defines the target containing the parent property
  11097. * @param parent defines from where the animation should start (animation frame)
  11098. * @param condition defines the trigger related conditions
  11099. */
  11100. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11101. /** @hidden */
  11102. _prepare(): void;
  11103. /**
  11104. * Execute the action and set the parent property.
  11105. */
  11106. execute(): void;
  11107. /**
  11108. * Serializes the actions and its related information.
  11109. * @param parent defines the object to serialize in
  11110. * @returns the serialized object
  11111. */
  11112. serialize(parent: any): any;
  11113. }
  11114. }
  11115. declare module "babylonjs/Actions/actionManager" {
  11116. import { Nullable } from "babylonjs/types";
  11117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11118. import { Scene } from "babylonjs/scene";
  11119. import { IAction } from "babylonjs/Actions/action";
  11120. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11121. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11122. /**
  11123. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11124. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11126. */
  11127. export class ActionManager extends AbstractActionManager {
  11128. /**
  11129. * Nothing
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly NothingTrigger: number;
  11133. /**
  11134. * On pick
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnPickTrigger: number;
  11138. /**
  11139. * On left pick
  11140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11141. */
  11142. static readonly OnLeftPickTrigger: number;
  11143. /**
  11144. * On right pick
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11146. */
  11147. static readonly OnRightPickTrigger: number;
  11148. /**
  11149. * On center pick
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11151. */
  11152. static readonly OnCenterPickTrigger: number;
  11153. /**
  11154. * On pick down
  11155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11156. */
  11157. static readonly OnPickDownTrigger: number;
  11158. /**
  11159. * On double pick
  11160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11161. */
  11162. static readonly OnDoublePickTrigger: number;
  11163. /**
  11164. * On pick up
  11165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11166. */
  11167. static readonly OnPickUpTrigger: number;
  11168. /**
  11169. * On pick out.
  11170. * This trigger will only be raised if you also declared a OnPickDown
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnPickOutTrigger: number;
  11174. /**
  11175. * On long press
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnLongPressTrigger: number;
  11179. /**
  11180. * On pointer over
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPointerOverTrigger: number;
  11184. /**
  11185. * On pointer out
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnPointerOutTrigger: number;
  11189. /**
  11190. * On every frame
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnEveryFrameTrigger: number;
  11194. /**
  11195. * On intersection enter
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnIntersectionEnterTrigger: number;
  11199. /**
  11200. * On intersection exit
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnIntersectionExitTrigger: number;
  11204. /**
  11205. * On key down
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnKeyDownTrigger: number;
  11209. /**
  11210. * On key up
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnKeyUpTrigger: number;
  11214. private _scene;
  11215. /**
  11216. * Creates a new action manager
  11217. * @param scene defines the hosting scene
  11218. */
  11219. constructor(scene: Scene);
  11220. /**
  11221. * Releases all associated resources
  11222. */
  11223. dispose(): void;
  11224. /**
  11225. * Gets hosting scene
  11226. * @returns the hosting scene
  11227. */
  11228. getScene(): Scene;
  11229. /**
  11230. * Does this action manager handles actions of any of the given triggers
  11231. * @param triggers defines the triggers to be tested
  11232. * @return a boolean indicating whether one (or more) of the triggers is handled
  11233. */
  11234. hasSpecificTriggers(triggers: number[]): boolean;
  11235. /**
  11236. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11237. * speed.
  11238. * @param triggerA defines the trigger to be tested
  11239. * @param triggerB defines the trigger to be tested
  11240. * @return a boolean indicating whether one (or more) of the triggers is handled
  11241. */
  11242. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11243. /**
  11244. * Does this action manager handles actions of a given trigger
  11245. * @param trigger defines the trigger to be tested
  11246. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11247. * @return whether the trigger is handled
  11248. */
  11249. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11250. /**
  11251. * Does this action manager has pointer triggers
  11252. */
  11253. get hasPointerTriggers(): boolean;
  11254. /**
  11255. * Does this action manager has pick triggers
  11256. */
  11257. get hasPickTriggers(): boolean;
  11258. /**
  11259. * Registers an action to this action manager
  11260. * @param action defines the action to be registered
  11261. * @return the action amended (prepared) after registration
  11262. */
  11263. registerAction(action: IAction): Nullable<IAction>;
  11264. /**
  11265. * Unregisters an action to this action manager
  11266. * @param action defines the action to be unregistered
  11267. * @return a boolean indicating whether the action has been unregistered
  11268. */
  11269. unregisterAction(action: IAction): Boolean;
  11270. /**
  11271. * Process a specific trigger
  11272. * @param trigger defines the trigger to process
  11273. * @param evt defines the event details to be processed
  11274. */
  11275. processTrigger(trigger: number, evt?: IActionEvent): void;
  11276. /** @hidden */
  11277. _getEffectiveTarget(target: any, propertyPath: string): any;
  11278. /** @hidden */
  11279. _getProperty(propertyPath: string): string;
  11280. /**
  11281. * Serialize this manager to a JSON object
  11282. * @param name defines the property name to store this manager
  11283. * @returns a JSON representation of this manager
  11284. */
  11285. serialize(name: string): any;
  11286. /**
  11287. * Creates a new ActionManager from a JSON data
  11288. * @param parsedActions defines the JSON data to read from
  11289. * @param object defines the hosting mesh
  11290. * @param scene defines the hosting scene
  11291. */
  11292. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11293. /**
  11294. * Get a trigger name by index
  11295. * @param trigger defines the trigger index
  11296. * @returns a trigger name
  11297. */
  11298. static GetTriggerName(trigger: number): string;
  11299. }
  11300. }
  11301. declare module "babylonjs/Culling/ray" {
  11302. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11307. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11308. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11309. import { Plane } from "babylonjs/Maths/math.plane";
  11310. /**
  11311. * Class representing a ray with position and direction
  11312. */
  11313. export class Ray {
  11314. /** origin point */
  11315. origin: Vector3;
  11316. /** direction */
  11317. direction: Vector3;
  11318. /** length of the ray */
  11319. length: number;
  11320. private static readonly TmpVector3;
  11321. private _tmpRay;
  11322. /**
  11323. * Creates a new ray
  11324. * @param origin origin point
  11325. * @param direction direction
  11326. * @param length length of the ray
  11327. */
  11328. constructor(
  11329. /** origin point */
  11330. origin: Vector3,
  11331. /** direction */
  11332. direction: Vector3,
  11333. /** length of the ray */
  11334. length?: number);
  11335. /**
  11336. * Checks if the ray intersects a box
  11337. * @param minimum bound of the box
  11338. * @param maximum bound of the box
  11339. * @param intersectionTreshold extra extend to be added to the box in all direction
  11340. * @returns if the box was hit
  11341. */
  11342. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11343. /**
  11344. * Checks if the ray intersects a box
  11345. * @param box the bounding box to check
  11346. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11347. * @returns if the box was hit
  11348. */
  11349. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11350. /**
  11351. * If the ray hits a sphere
  11352. * @param sphere the bounding sphere to check
  11353. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11354. * @returns true if it hits the sphere
  11355. */
  11356. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11357. /**
  11358. * If the ray hits a triange
  11359. * @param vertex0 triangle vertex
  11360. * @param vertex1 triangle vertex
  11361. * @param vertex2 triangle vertex
  11362. * @returns intersection information if hit
  11363. */
  11364. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11365. /**
  11366. * Checks if ray intersects a plane
  11367. * @param plane the plane to check
  11368. * @returns the distance away it was hit
  11369. */
  11370. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11371. /**
  11372. * Calculate the intercept of a ray on a given axis
  11373. * @param axis to check 'x' | 'y' | 'z'
  11374. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11375. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11376. */
  11377. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11378. /**
  11379. * Checks if ray intersects a mesh
  11380. * @param mesh the mesh to check
  11381. * @param fastCheck if only the bounding box should checked
  11382. * @returns picking info of the intersecton
  11383. */
  11384. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11385. /**
  11386. * Checks if ray intersects a mesh
  11387. * @param meshes the meshes to check
  11388. * @param fastCheck if only the bounding box should checked
  11389. * @param results array to store result in
  11390. * @returns Array of picking infos
  11391. */
  11392. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11393. private _comparePickingInfo;
  11394. private static smallnum;
  11395. private static rayl;
  11396. /**
  11397. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11398. * @param sega the first point of the segment to test the intersection against
  11399. * @param segb the second point of the segment to test the intersection against
  11400. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11401. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11402. */
  11403. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11404. /**
  11405. * Update the ray from viewport position
  11406. * @param x position
  11407. * @param y y position
  11408. * @param viewportWidth viewport width
  11409. * @param viewportHeight viewport height
  11410. * @param world world matrix
  11411. * @param view view matrix
  11412. * @param projection projection matrix
  11413. * @returns this ray updated
  11414. */
  11415. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11416. /**
  11417. * Creates a ray with origin and direction of 0,0,0
  11418. * @returns the new ray
  11419. */
  11420. static Zero(): Ray;
  11421. /**
  11422. * Creates a new ray from screen space and viewport
  11423. * @param x position
  11424. * @param y y position
  11425. * @param viewportWidth viewport width
  11426. * @param viewportHeight viewport height
  11427. * @param world world matrix
  11428. * @param view view matrix
  11429. * @param projection projection matrix
  11430. * @returns new ray
  11431. */
  11432. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11433. /**
  11434. * 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
  11435. * transformed to the given world matrix.
  11436. * @param origin The origin point
  11437. * @param end The end point
  11438. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11439. * @returns the new ray
  11440. */
  11441. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11442. /**
  11443. * Transforms a ray by a matrix
  11444. * @param ray ray to transform
  11445. * @param matrix matrix to apply
  11446. * @returns the resulting new ray
  11447. */
  11448. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * Transforms a ray by a matrix
  11451. * @param ray ray to transform
  11452. * @param matrix matrix to apply
  11453. * @param result ray to store result in
  11454. */
  11455. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11456. /**
  11457. * Unproject a ray from screen space to object space
  11458. * @param sourceX defines the screen space x coordinate to use
  11459. * @param sourceY defines the screen space y coordinate to use
  11460. * @param viewportWidth defines the current width of the viewport
  11461. * @param viewportHeight defines the current height of the viewport
  11462. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11463. * @param view defines the view matrix to use
  11464. * @param projection defines the projection matrix to use
  11465. */
  11466. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11467. }
  11468. /**
  11469. * Type used to define predicate used to select faces when a mesh intersection is detected
  11470. */
  11471. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11472. module "babylonjs/scene" {
  11473. interface Scene {
  11474. /** @hidden */
  11475. _tempPickingRay: Nullable<Ray>;
  11476. /** @hidden */
  11477. _cachedRayForTransform: Ray;
  11478. /** @hidden */
  11479. _pickWithRayInverseMatrix: Matrix;
  11480. /** @hidden */
  11481. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11482. /** @hidden */
  11483. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11484. }
  11485. }
  11486. }
  11487. declare module "babylonjs/sceneComponent" {
  11488. import { Scene } from "babylonjs/scene";
  11489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11491. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11492. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11493. import { Nullable } from "babylonjs/types";
  11494. import { Camera } from "babylonjs/Cameras/camera";
  11495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11496. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11497. import { AbstractScene } from "babylonjs/abstractScene";
  11498. import { Mesh } from "babylonjs/Meshes/mesh";
  11499. /**
  11500. * Groups all the scene component constants in one place to ease maintenance.
  11501. * @hidden
  11502. */
  11503. export class SceneComponentConstants {
  11504. static readonly NAME_EFFECTLAYER: string;
  11505. static readonly NAME_LAYER: string;
  11506. static readonly NAME_LENSFLARESYSTEM: string;
  11507. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11508. static readonly NAME_PARTICLESYSTEM: string;
  11509. static readonly NAME_GAMEPAD: string;
  11510. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11511. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11512. static readonly NAME_DEPTHRENDERER: string;
  11513. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11514. static readonly NAME_SPRITE: string;
  11515. static readonly NAME_OUTLINERENDERER: string;
  11516. static readonly NAME_PROCEDURALTEXTURE: string;
  11517. static readonly NAME_SHADOWGENERATOR: string;
  11518. static readonly NAME_OCTREE: string;
  11519. static readonly NAME_PHYSICSENGINE: string;
  11520. static readonly NAME_AUDIO: string;
  11521. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11522. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11523. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11524. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11525. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11526. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11527. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11528. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11529. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11530. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11531. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11532. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11533. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11534. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11535. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11536. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11537. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11538. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11540. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11541. static readonly STEP_AFTERRENDER_AUDIO: number;
  11542. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11543. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11544. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11545. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11546. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11547. static readonly STEP_POINTERMOVE_SPRITE: number;
  11548. static readonly STEP_POINTERDOWN_SPRITE: number;
  11549. static readonly STEP_POINTERUP_SPRITE: number;
  11550. }
  11551. /**
  11552. * This represents a scene component.
  11553. *
  11554. * This is used to decouple the dependency the scene is having on the different workloads like
  11555. * layers, post processes...
  11556. */
  11557. export interface ISceneComponent {
  11558. /**
  11559. * The name of the component. Each component must have a unique name.
  11560. */
  11561. name: string;
  11562. /**
  11563. * The scene the component belongs to.
  11564. */
  11565. scene: Scene;
  11566. /**
  11567. * Register the component to one instance of a scene.
  11568. */
  11569. register(): void;
  11570. /**
  11571. * Rebuilds the elements related to this component in case of
  11572. * context lost for instance.
  11573. */
  11574. rebuild(): void;
  11575. /**
  11576. * Disposes the component and the associated ressources.
  11577. */
  11578. dispose(): void;
  11579. }
  11580. /**
  11581. * This represents a SERIALIZABLE scene component.
  11582. *
  11583. * This extends Scene Component to add Serialization methods on top.
  11584. */
  11585. export interface ISceneSerializableComponent extends ISceneComponent {
  11586. /**
  11587. * Adds all the elements from the container to the scene
  11588. * @param container the container holding the elements
  11589. */
  11590. addFromContainer(container: AbstractScene): void;
  11591. /**
  11592. * Removes all the elements in the container from the scene
  11593. * @param container contains the elements to remove
  11594. * @param dispose if the removed element should be disposed (default: false)
  11595. */
  11596. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11597. /**
  11598. * Serializes the component data to the specified json object
  11599. * @param serializationObject The object to serialize to
  11600. */
  11601. serialize(serializationObject: any): void;
  11602. }
  11603. /**
  11604. * Strong typing of a Mesh related stage step action
  11605. */
  11606. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11607. /**
  11608. * Strong typing of a Evaluate Sub Mesh related stage step action
  11609. */
  11610. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11611. /**
  11612. * Strong typing of a Active Mesh related stage step action
  11613. */
  11614. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11615. /**
  11616. * Strong typing of a Camera related stage step action
  11617. */
  11618. export type CameraStageAction = (camera: Camera) => void;
  11619. /**
  11620. * Strong typing of a Camera Frame buffer related stage step action
  11621. */
  11622. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11623. /**
  11624. * Strong typing of a Render Target related stage step action
  11625. */
  11626. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11627. /**
  11628. * Strong typing of a RenderingGroup related stage step action
  11629. */
  11630. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11631. /**
  11632. * Strong typing of a Mesh Render related stage step action
  11633. */
  11634. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11635. /**
  11636. * Strong typing of a simple stage step action
  11637. */
  11638. export type SimpleStageAction = () => void;
  11639. /**
  11640. * Strong typing of a render target action.
  11641. */
  11642. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11643. /**
  11644. * Strong typing of a pointer move action.
  11645. */
  11646. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11647. /**
  11648. * Strong typing of a pointer up/down action.
  11649. */
  11650. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11651. /**
  11652. * Representation of a stage in the scene (Basically a list of ordered steps)
  11653. * @hidden
  11654. */
  11655. export class Stage<T extends Function> extends Array<{
  11656. index: number;
  11657. component: ISceneComponent;
  11658. action: T;
  11659. }> {
  11660. /**
  11661. * Hide ctor from the rest of the world.
  11662. * @param items The items to add.
  11663. */
  11664. private constructor();
  11665. /**
  11666. * Creates a new Stage.
  11667. * @returns A new instance of a Stage
  11668. */
  11669. static Create<T extends Function>(): Stage<T>;
  11670. /**
  11671. * Registers a step in an ordered way in the targeted stage.
  11672. * @param index Defines the position to register the step in
  11673. * @param component Defines the component attached to the step
  11674. * @param action Defines the action to launch during the step
  11675. */
  11676. registerStep(index: number, component: ISceneComponent, action: T): void;
  11677. /**
  11678. * Clears all the steps from the stage.
  11679. */
  11680. clear(): void;
  11681. }
  11682. }
  11683. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11684. import { Nullable } from "babylonjs/types";
  11685. import { Observable } from "babylonjs/Misc/observable";
  11686. import { Scene } from "babylonjs/scene";
  11687. import { Sprite } from "babylonjs/Sprites/sprite";
  11688. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11689. import { Ray } from "babylonjs/Culling/ray";
  11690. import { Camera } from "babylonjs/Cameras/camera";
  11691. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11692. import { ISceneComponent } from "babylonjs/sceneComponent";
  11693. module "babylonjs/scene" {
  11694. interface Scene {
  11695. /** @hidden */
  11696. _pointerOverSprite: Nullable<Sprite>;
  11697. /** @hidden */
  11698. _pickedDownSprite: Nullable<Sprite>;
  11699. /** @hidden */
  11700. _tempSpritePickingRay: Nullable<Ray>;
  11701. /**
  11702. * All of the sprite managers added to this scene
  11703. * @see http://doc.babylonjs.com/babylon101/sprites
  11704. */
  11705. spriteManagers: Array<ISpriteManager>;
  11706. /**
  11707. * An event triggered when sprites rendering is about to start
  11708. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11709. */
  11710. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11711. /**
  11712. * An event triggered when sprites rendering is done
  11713. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11714. */
  11715. onAfterSpritesRenderingObservable: Observable<Scene>;
  11716. /** @hidden */
  11717. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11718. /** Launch a ray to try to pick a sprite in the scene
  11719. * @param x position on screen
  11720. * @param y position on screen
  11721. * @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
  11722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11723. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11724. * @returns a PickingInfo
  11725. */
  11726. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11727. /** Use the given ray to pick a sprite in the scene
  11728. * @param ray The ray (in world space) to use to pick meshes
  11729. * @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
  11730. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11731. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11732. * @returns a PickingInfo
  11733. */
  11734. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11735. /** @hidden */
  11736. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11737. /** Launch a ray to try to pick sprites in the scene
  11738. * @param x position on screen
  11739. * @param y position on screen
  11740. * @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
  11741. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11742. * @returns a PickingInfo array
  11743. */
  11744. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11745. /** Use the given ray to pick sprites in the scene
  11746. * @param ray The ray (in world space) to use to pick meshes
  11747. * @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
  11748. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11749. * @returns a PickingInfo array
  11750. */
  11751. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11752. /**
  11753. * Force the sprite under the pointer
  11754. * @param sprite defines the sprite to use
  11755. */
  11756. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11757. /**
  11758. * Gets the sprite under the pointer
  11759. * @returns a Sprite or null if no sprite is under the pointer
  11760. */
  11761. getPointerOverSprite(): Nullable<Sprite>;
  11762. }
  11763. }
  11764. /**
  11765. * Defines the sprite scene component responsible to manage sprites
  11766. * in a given scene.
  11767. */
  11768. export class SpriteSceneComponent implements ISceneComponent {
  11769. /**
  11770. * The component name helpfull to identify the component in the list of scene components.
  11771. */
  11772. readonly name: string;
  11773. /**
  11774. * The scene the component belongs to.
  11775. */
  11776. scene: Scene;
  11777. /** @hidden */
  11778. private _spritePredicate;
  11779. /**
  11780. * Creates a new instance of the component for the given scene
  11781. * @param scene Defines the scene to register the component in
  11782. */
  11783. constructor(scene: Scene);
  11784. /**
  11785. * Registers the component in a given scene
  11786. */
  11787. register(): void;
  11788. /**
  11789. * Rebuilds the elements related to this component in case of
  11790. * context lost for instance.
  11791. */
  11792. rebuild(): void;
  11793. /**
  11794. * Disposes the component and the associated ressources.
  11795. */
  11796. dispose(): void;
  11797. private _pickSpriteButKeepRay;
  11798. private _pointerMove;
  11799. private _pointerDown;
  11800. private _pointerUp;
  11801. }
  11802. }
  11803. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11804. /** @hidden */
  11805. export var fogFragmentDeclaration: {
  11806. name: string;
  11807. shader: string;
  11808. };
  11809. }
  11810. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11811. /** @hidden */
  11812. export var fogFragment: {
  11813. name: string;
  11814. shader: string;
  11815. };
  11816. }
  11817. declare module "babylonjs/Shaders/sprites.fragment" {
  11818. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11819. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11820. /** @hidden */
  11821. export var spritesPixelShader: {
  11822. name: string;
  11823. shader: string;
  11824. };
  11825. }
  11826. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11827. /** @hidden */
  11828. export var fogVertexDeclaration: {
  11829. name: string;
  11830. shader: string;
  11831. };
  11832. }
  11833. declare module "babylonjs/Shaders/sprites.vertex" {
  11834. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11835. /** @hidden */
  11836. export var spritesVertexShader: {
  11837. name: string;
  11838. shader: string;
  11839. };
  11840. }
  11841. declare module "babylonjs/Sprites/spriteManager" {
  11842. import { IDisposable, Scene } from "babylonjs/scene";
  11843. import { Nullable } from "babylonjs/types";
  11844. import { Observable } from "babylonjs/Misc/observable";
  11845. import { Sprite } from "babylonjs/Sprites/sprite";
  11846. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11847. import { Camera } from "babylonjs/Cameras/camera";
  11848. import { Texture } from "babylonjs/Materials/Textures/texture";
  11849. import "babylonjs/Shaders/sprites.fragment";
  11850. import "babylonjs/Shaders/sprites.vertex";
  11851. import { Ray } from "babylonjs/Culling/ray";
  11852. /**
  11853. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11854. */
  11855. export interface ISpriteManager extends IDisposable {
  11856. /**
  11857. * Restricts the camera to viewing objects with the same layerMask.
  11858. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11859. */
  11860. layerMask: number;
  11861. /**
  11862. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11863. */
  11864. isPickable: boolean;
  11865. /**
  11866. * Specifies the rendering group id for this mesh (0 by default)
  11867. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11868. */
  11869. renderingGroupId: number;
  11870. /**
  11871. * Defines the list of sprites managed by the manager.
  11872. */
  11873. sprites: Array<Sprite>;
  11874. /**
  11875. * Tests the intersection of a sprite with a specific ray.
  11876. * @param ray The ray we are sending to test the collision
  11877. * @param camera The camera space we are sending rays in
  11878. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11879. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11880. * @returns picking info or null.
  11881. */
  11882. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11883. /**
  11884. * Intersects the sprites with a ray
  11885. * @param ray defines the ray to intersect with
  11886. * @param camera defines the current active camera
  11887. * @param predicate defines a predicate used to select candidate sprites
  11888. * @returns null if no hit or a PickingInfo array
  11889. */
  11890. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11891. /**
  11892. * Renders the list of sprites on screen.
  11893. */
  11894. render(): void;
  11895. }
  11896. /**
  11897. * Class used to manage multiple sprites on the same spritesheet
  11898. * @see http://doc.babylonjs.com/babylon101/sprites
  11899. */
  11900. export class SpriteManager implements ISpriteManager {
  11901. /** defines the manager's name */
  11902. name: string;
  11903. /** Gets the list of sprites */
  11904. sprites: Sprite[];
  11905. /** Gets or sets the rendering group id (0 by default) */
  11906. renderingGroupId: number;
  11907. /** Gets or sets camera layer mask */
  11908. layerMask: number;
  11909. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11910. fogEnabled: boolean;
  11911. /** Gets or sets a boolean indicating if the sprites are pickable */
  11912. isPickable: boolean;
  11913. /** Defines the default width of a cell in the spritesheet */
  11914. cellWidth: number;
  11915. /** Defines the default height of a cell in the spritesheet */
  11916. cellHeight: number;
  11917. /** Associative array from JSON sprite data file */
  11918. private _cellData;
  11919. /** Array of sprite names from JSON sprite data file */
  11920. private _spriteMap;
  11921. /** True when packed cell data from JSON file is ready*/
  11922. private _packedAndReady;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. set onDispose(callback: () => void);
  11932. private _capacity;
  11933. private _fromPacked;
  11934. private _spriteTexture;
  11935. private _epsilon;
  11936. private _scene;
  11937. private _vertexData;
  11938. private _buffer;
  11939. private _vertexBuffers;
  11940. private _indexBuffer;
  11941. private _effectBase;
  11942. private _effectFog;
  11943. /**
  11944. * Gets or sets the spritesheet texture
  11945. */
  11946. get texture(): Texture;
  11947. set texture(value: Texture);
  11948. /**
  11949. * Creates a new sprite manager
  11950. * @param name defines the manager's name
  11951. * @param imgUrl defines the sprite sheet url
  11952. * @param capacity defines the maximum allowed number of sprites
  11953. * @param cellSize defines the size of a sprite cell
  11954. * @param scene defines the hosting scene
  11955. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11956. * @param samplingMode defines the smapling mode to use with spritesheet
  11957. * @param fromPacked set to false; do not alter
  11958. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11959. */
  11960. constructor(
  11961. /** defines the manager's name */
  11962. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11963. private _makePacked;
  11964. private _appendSpriteVertex;
  11965. /**
  11966. * Intersects the sprites with a ray
  11967. * @param ray defines the ray to intersect with
  11968. * @param camera defines the current active camera
  11969. * @param predicate defines a predicate used to select candidate sprites
  11970. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11971. * @returns null if no hit or a PickingInfo
  11972. */
  11973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11974. /**
  11975. * Intersects the sprites with a ray
  11976. * @param ray defines the ray to intersect with
  11977. * @param camera defines the current active camera
  11978. * @param predicate defines a predicate used to select candidate sprites
  11979. * @returns null if no hit or a PickingInfo array
  11980. */
  11981. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11982. /**
  11983. * Render all child sprites
  11984. */
  11985. render(): void;
  11986. /**
  11987. * Release associated resources
  11988. */
  11989. dispose(): void;
  11990. }
  11991. }
  11992. declare module "babylonjs/Sprites/sprite" {
  11993. import { Vector3 } from "babylonjs/Maths/math.vector";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { ActionManager } from "babylonjs/Actions/actionManager";
  11996. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11997. import { Color4 } from "babylonjs/Maths/math.color";
  11998. /**
  11999. * Class used to represent a sprite
  12000. * @see http://doc.babylonjs.com/babylon101/sprites
  12001. */
  12002. export class Sprite {
  12003. /** defines the name */
  12004. name: string;
  12005. /** Gets or sets the current world position */
  12006. position: Vector3;
  12007. /** Gets or sets the main color */
  12008. color: Color4;
  12009. /** Gets or sets the width */
  12010. width: number;
  12011. /** Gets or sets the height */
  12012. height: number;
  12013. /** Gets or sets rotation angle */
  12014. angle: number;
  12015. /** Gets or sets the cell index in the sprite sheet */
  12016. cellIndex: number;
  12017. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12018. cellRef: string;
  12019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12020. invertU: number;
  12021. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12022. invertV: number;
  12023. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12024. disposeWhenFinishedAnimating: boolean;
  12025. /** Gets the list of attached animations */
  12026. animations: Animation[];
  12027. /** Gets or sets a boolean indicating if the sprite can be picked */
  12028. isPickable: boolean;
  12029. /**
  12030. * Gets or sets the associated action manager
  12031. */
  12032. actionManager: Nullable<ActionManager>;
  12033. private _animationStarted;
  12034. private _loopAnimation;
  12035. private _fromIndex;
  12036. private _toIndex;
  12037. private _delay;
  12038. private _direction;
  12039. private _manager;
  12040. private _time;
  12041. private _onAnimationEnd;
  12042. /**
  12043. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12044. */
  12045. isVisible: boolean;
  12046. /**
  12047. * Gets or sets the sprite size
  12048. */
  12049. get size(): number;
  12050. set size(value: number);
  12051. /**
  12052. * Creates a new Sprite
  12053. * @param name defines the name
  12054. * @param manager defines the manager
  12055. */
  12056. constructor(
  12057. /** defines the name */
  12058. name: string, manager: ISpriteManager);
  12059. /**
  12060. * Starts an animation
  12061. * @param from defines the initial key
  12062. * @param to defines the end key
  12063. * @param loop defines if the animation must loop
  12064. * @param delay defines the start delay (in ms)
  12065. * @param onAnimationEnd defines a callback to call when animation ends
  12066. */
  12067. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12068. /** Stops current animation (if any) */
  12069. stopAnimation(): void;
  12070. /** @hidden */
  12071. _animate(deltaTime: number): void;
  12072. /** Release associated resources */
  12073. dispose(): void;
  12074. }
  12075. }
  12076. declare module "babylonjs/Collisions/pickingInfo" {
  12077. import { Nullable } from "babylonjs/types";
  12078. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12080. import { Sprite } from "babylonjs/Sprites/sprite";
  12081. import { Ray } from "babylonjs/Culling/ray";
  12082. /**
  12083. * Information about the result of picking within a scene
  12084. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12085. */
  12086. export class PickingInfo {
  12087. /** @hidden */
  12088. _pickingUnavailable: boolean;
  12089. /**
  12090. * If the pick collided with an object
  12091. */
  12092. hit: boolean;
  12093. /**
  12094. * Distance away where the pick collided
  12095. */
  12096. distance: number;
  12097. /**
  12098. * The location of pick collision
  12099. */
  12100. pickedPoint: Nullable<Vector3>;
  12101. /**
  12102. * The mesh corresponding the the pick collision
  12103. */
  12104. pickedMesh: Nullable<AbstractMesh>;
  12105. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12106. bu: number;
  12107. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12108. bv: number;
  12109. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12110. faceId: number;
  12111. /** Id of the the submesh that was picked */
  12112. subMeshId: number;
  12113. /** If a sprite was picked, this will be the sprite the pick collided with */
  12114. pickedSprite: Nullable<Sprite>;
  12115. /**
  12116. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12117. */
  12118. originMesh: Nullable<AbstractMesh>;
  12119. /**
  12120. * The ray that was used to perform the picking.
  12121. */
  12122. ray: Nullable<Ray>;
  12123. /**
  12124. * Gets the normal correspodning to the face the pick collided with
  12125. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12126. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12127. * @returns The normal correspodning to the face the pick collided with
  12128. */
  12129. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12130. /**
  12131. * Gets the texture coordinates of where the pick occured
  12132. * @returns the vector containing the coordnates of the texture
  12133. */
  12134. getTextureCoordinates(): Nullable<Vector2>;
  12135. }
  12136. }
  12137. declare module "babylonjs/Events/pointerEvents" {
  12138. import { Nullable } from "babylonjs/types";
  12139. import { Vector2 } from "babylonjs/Maths/math.vector";
  12140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12141. import { Ray } from "babylonjs/Culling/ray";
  12142. /**
  12143. * Gather the list of pointer event types as constants.
  12144. */
  12145. export class PointerEventTypes {
  12146. /**
  12147. * 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.
  12148. */
  12149. static readonly POINTERDOWN: number;
  12150. /**
  12151. * The pointerup event is fired when a pointer is no longer active.
  12152. */
  12153. static readonly POINTERUP: number;
  12154. /**
  12155. * The pointermove event is fired when a pointer changes coordinates.
  12156. */
  12157. static readonly POINTERMOVE: number;
  12158. /**
  12159. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12160. */
  12161. static readonly POINTERWHEEL: number;
  12162. /**
  12163. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12164. */
  12165. static readonly POINTERPICK: number;
  12166. /**
  12167. * The pointertap event is fired when a the object has been touched and released without drag.
  12168. */
  12169. static readonly POINTERTAP: number;
  12170. /**
  12171. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12172. */
  12173. static readonly POINTERDOUBLETAP: number;
  12174. }
  12175. /**
  12176. * Base class of pointer info types.
  12177. */
  12178. export class PointerInfoBase {
  12179. /**
  12180. * Defines the type of event (PointerEventTypes)
  12181. */
  12182. type: number;
  12183. /**
  12184. * Defines the related dom event
  12185. */
  12186. event: PointerEvent | MouseWheelEvent;
  12187. /**
  12188. * Instantiates the base class of pointers info.
  12189. * @param type Defines the type of event (PointerEventTypes)
  12190. * @param event Defines the related dom event
  12191. */
  12192. constructor(
  12193. /**
  12194. * Defines the type of event (PointerEventTypes)
  12195. */
  12196. type: number,
  12197. /**
  12198. * Defines the related dom event
  12199. */
  12200. event: PointerEvent | MouseWheelEvent);
  12201. }
  12202. /**
  12203. * This class is used to store pointer related info for the onPrePointerObservable event.
  12204. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12205. */
  12206. export class PointerInfoPre extends PointerInfoBase {
  12207. /**
  12208. * Ray from a pointer if availible (eg. 6dof controller)
  12209. */
  12210. ray: Nullable<Ray>;
  12211. /**
  12212. * Defines the local position of the pointer on the canvas.
  12213. */
  12214. localPosition: Vector2;
  12215. /**
  12216. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12217. */
  12218. skipOnPointerObservable: boolean;
  12219. /**
  12220. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12221. * @param type Defines the type of event (PointerEventTypes)
  12222. * @param event Defines the related dom event
  12223. * @param localX Defines the local x coordinates of the pointer when the event occured
  12224. * @param localY Defines the local y coordinates of the pointer when the event occured
  12225. */
  12226. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12227. }
  12228. /**
  12229. * This type contains all the data related to a pointer event in Babylon.js.
  12230. * 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.
  12231. */
  12232. export class PointerInfo extends PointerInfoBase {
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>;
  12237. /**
  12238. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12239. * @param type Defines the type of event (PointerEventTypes)
  12240. * @param event Defines the related dom event
  12241. * @param pickInfo Defines the picking info associated to the info (if any)\
  12242. */
  12243. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12244. /**
  12245. * Defines the picking info associated to the info (if any)\
  12246. */
  12247. pickInfo: Nullable<PickingInfo>);
  12248. }
  12249. /**
  12250. * Data relating to a touch event on the screen.
  12251. */
  12252. export interface PointerTouch {
  12253. /**
  12254. * X coordinate of touch.
  12255. */
  12256. x: number;
  12257. /**
  12258. * Y coordinate of touch.
  12259. */
  12260. y: number;
  12261. /**
  12262. * Id of touch. Unique for each finger.
  12263. */
  12264. pointerId: number;
  12265. /**
  12266. * Event type passed from DOM.
  12267. */
  12268. type: any;
  12269. }
  12270. }
  12271. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12272. import { Observable } from "babylonjs/Misc/observable";
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the mouse inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Define if touch is enabled in the mouse input
  12283. */
  12284. touchEnabled: boolean;
  12285. /**
  12286. * Defines the camera the input is attached to.
  12287. */
  12288. camera: FreeCamera;
  12289. /**
  12290. * Defines the buttons associated with the input to handle camera move.
  12291. */
  12292. buttons: number[];
  12293. /**
  12294. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12295. */
  12296. angularSensibility: number;
  12297. private _pointerInput;
  12298. private _onMouseMove;
  12299. private _observer;
  12300. private previousPosition;
  12301. /**
  12302. * Observable for when a pointer move event occurs containing the move offset
  12303. */
  12304. onPointerMovedObservable: Observable<{
  12305. offsetX: number;
  12306. offsetY: number;
  12307. }>;
  12308. /**
  12309. * @hidden
  12310. * If the camera should be rotated automatically based on pointer movement
  12311. */
  12312. _allowCameraRotation: boolean;
  12313. /**
  12314. * Manage the mouse inputs to control the movement of a free camera.
  12315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12316. * @param touchEnabled Defines if touch is enabled or not
  12317. */
  12318. constructor(
  12319. /**
  12320. * Define if touch is enabled in the mouse input
  12321. */
  12322. touchEnabled?: boolean);
  12323. /**
  12324. * Attach the input controls to a specific dom element to get the input from.
  12325. * @param element Defines the element the controls should be listened from
  12326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12327. */
  12328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12329. /**
  12330. * Called on JS contextmenu event.
  12331. * Override this method to provide functionality.
  12332. */
  12333. protected onContextMenu(evt: PointerEvent): void;
  12334. /**
  12335. * Detach the current controls from the specified dom element.
  12336. * @param element Defines the element to stop listening the inputs from
  12337. */
  12338. detachControl(element: Nullable<HTMLElement>): void;
  12339. /**
  12340. * Gets the class name of the current intput.
  12341. * @returns the class name
  12342. */
  12343. getClassName(): string;
  12344. /**
  12345. * Get the friendly name associated with the input class.
  12346. * @returns the input friendly name
  12347. */
  12348. getSimpleName(): string;
  12349. }
  12350. }
  12351. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12352. import { Nullable } from "babylonjs/types";
  12353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12354. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12355. /**
  12356. * Manage the touch inputs to control the movement of a free camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12360. /**
  12361. * Defines the camera the input is attached to.
  12362. */
  12363. camera: FreeCamera;
  12364. /**
  12365. * Defines the touch sensibility for rotation.
  12366. * The higher the faster.
  12367. */
  12368. touchAngularSensibility: number;
  12369. /**
  12370. * Defines the touch sensibility for move.
  12371. * The higher the faster.
  12372. */
  12373. touchMoveSensibility: number;
  12374. private _offsetX;
  12375. private _offsetY;
  12376. private _pointerPressed;
  12377. private _pointerInput;
  12378. private _observer;
  12379. private _onLostFocus;
  12380. /**
  12381. * Attach the input controls to a specific dom element to get the input from.
  12382. * @param element Defines the element the controls should be listened from
  12383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12384. */
  12385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12386. /**
  12387. * Detach the current controls from the specified dom element.
  12388. * @param element Defines the element to stop listening the inputs from
  12389. */
  12390. detachControl(element: Nullable<HTMLElement>): void;
  12391. /**
  12392. * Update the current camera state depending on the inputs that have been used this frame.
  12393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12394. */
  12395. checkInputs(): void;
  12396. /**
  12397. * Gets the class name of the current intput.
  12398. * @returns the class name
  12399. */
  12400. getClassName(): string;
  12401. /**
  12402. * Get the friendly name associated with the input class.
  12403. * @returns the input friendly name
  12404. */
  12405. getSimpleName(): string;
  12406. }
  12407. }
  12408. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12411. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12412. import { Nullable } from "babylonjs/types";
  12413. /**
  12414. * Default Inputs manager for the FreeCamera.
  12415. * It groups all the default supported inputs for ease of use.
  12416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12417. */
  12418. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12419. /**
  12420. * @hidden
  12421. */
  12422. _mouseInput: Nullable<FreeCameraMouseInput>;
  12423. /**
  12424. * Instantiates a new FreeCameraInputsManager.
  12425. * @param camera Defines the camera the inputs belong to
  12426. */
  12427. constructor(camera: FreeCamera);
  12428. /**
  12429. * Add keyboard input support to the input manager.
  12430. * @returns the current input manager
  12431. */
  12432. addKeyboard(): FreeCameraInputsManager;
  12433. /**
  12434. * Add mouse input support to the input manager.
  12435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12436. * @returns the current input manager
  12437. */
  12438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12439. /**
  12440. * Removes the mouse input support from the manager
  12441. * @returns the current input manager
  12442. */
  12443. removeMouse(): FreeCameraInputsManager;
  12444. /**
  12445. * Add touch input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addTouch(): FreeCameraInputsManager;
  12449. /**
  12450. * Remove all attached input methods from a camera
  12451. */
  12452. clear(): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Cameras/freeCamera" {
  12456. import { Vector3 } from "babylonjs/Maths/math.vector";
  12457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12458. import { Scene } from "babylonjs/scene";
  12459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12460. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12461. /**
  12462. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12463. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12465. */
  12466. export class FreeCamera extends TargetCamera {
  12467. /**
  12468. * Define the collision ellipsoid of the camera.
  12469. * This is helpful to simulate a camera body like the player body around the camera
  12470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12471. */
  12472. ellipsoid: Vector3;
  12473. /**
  12474. * Define an offset for the position of the ellipsoid around the camera.
  12475. * This can be helpful to determine the center of the body near the gravity center of the body
  12476. * instead of its head.
  12477. */
  12478. ellipsoidOffset: Vector3;
  12479. /**
  12480. * Enable or disable collisions of the camera with the rest of the scene objects.
  12481. */
  12482. checkCollisions: boolean;
  12483. /**
  12484. * Enable or disable gravity on the camera.
  12485. */
  12486. applyGravity: boolean;
  12487. /**
  12488. * Define the input manager associated to the camera.
  12489. */
  12490. inputs: FreeCameraInputsManager;
  12491. /**
  12492. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12493. * Higher values reduce sensitivity.
  12494. */
  12495. get angularSensibility(): number;
  12496. /**
  12497. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12498. * Higher values reduce sensitivity.
  12499. */
  12500. set angularSensibility(value: number);
  12501. /**
  12502. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12503. */
  12504. get keysUp(): number[];
  12505. set keysUp(value: number[]);
  12506. /**
  12507. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12508. */
  12509. get keysDown(): number[];
  12510. set keysDown(value: number[]);
  12511. /**
  12512. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12513. */
  12514. get keysLeft(): number[];
  12515. set keysLeft(value: number[]);
  12516. /**
  12517. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12518. */
  12519. get keysRight(): number[];
  12520. set keysRight(value: number[]);
  12521. /**
  12522. * Event raised when the camera collide with a mesh in the scene.
  12523. */
  12524. onCollide: (collidedMesh: AbstractMesh) => void;
  12525. private _collider;
  12526. private _needMoveForGravity;
  12527. private _oldPosition;
  12528. private _diffPosition;
  12529. private _newPosition;
  12530. /** @hidden */
  12531. _localDirection: Vector3;
  12532. /** @hidden */
  12533. _transformedDirection: Vector3;
  12534. /**
  12535. * Instantiates a Free Camera.
  12536. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12537. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12538. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12539. * @param name Define the name of the camera in the scene
  12540. * @param position Define the start position of the camera in the scene
  12541. * @param scene Define the scene the camera belongs to
  12542. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12543. */
  12544. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12545. /**
  12546. * Attached controls to the current camera.
  12547. * @param element Defines the element the controls should be listened from
  12548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12549. */
  12550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12551. /**
  12552. * Detach the current controls from the camera.
  12553. * The camera will stop reacting to inputs.
  12554. * @param element Defines the element to stop listening the inputs from
  12555. */
  12556. detachControl(element: HTMLElement): void;
  12557. private _collisionMask;
  12558. /**
  12559. * Define a collision mask to limit the list of object the camera can collide with
  12560. */
  12561. get collisionMask(): number;
  12562. set collisionMask(mask: number);
  12563. /** @hidden */
  12564. _collideWithWorld(displacement: Vector3): void;
  12565. private _onCollisionPositionChange;
  12566. /** @hidden */
  12567. _checkInputs(): void;
  12568. /** @hidden */
  12569. _decideIfNeedsToMove(): boolean;
  12570. /** @hidden */
  12571. _updatePosition(): void;
  12572. /**
  12573. * Destroy the camera and release the current resources hold by it.
  12574. */
  12575. dispose(): void;
  12576. /**
  12577. * Gets the current object class name.
  12578. * @return the class name
  12579. */
  12580. getClassName(): string;
  12581. }
  12582. }
  12583. declare module "babylonjs/Gamepads/gamepad" {
  12584. import { Observable } from "babylonjs/Misc/observable";
  12585. /**
  12586. * Represents a gamepad control stick position
  12587. */
  12588. export class StickValues {
  12589. /**
  12590. * The x component of the control stick
  12591. */
  12592. x: number;
  12593. /**
  12594. * The y component of the control stick
  12595. */
  12596. y: number;
  12597. /**
  12598. * Initializes the gamepad x and y control stick values
  12599. * @param x The x component of the gamepad control stick value
  12600. * @param y The y component of the gamepad control stick value
  12601. */
  12602. constructor(
  12603. /**
  12604. * The x component of the control stick
  12605. */
  12606. x: number,
  12607. /**
  12608. * The y component of the control stick
  12609. */
  12610. y: number);
  12611. }
  12612. /**
  12613. * An interface which manages callbacks for gamepad button changes
  12614. */
  12615. export interface GamepadButtonChanges {
  12616. /**
  12617. * Called when a gamepad has been changed
  12618. */
  12619. changed: boolean;
  12620. /**
  12621. * Called when a gamepad press event has been triggered
  12622. */
  12623. pressChanged: boolean;
  12624. /**
  12625. * Called when a touch event has been triggered
  12626. */
  12627. touchChanged: boolean;
  12628. /**
  12629. * Called when a value has changed
  12630. */
  12631. valueChanged: boolean;
  12632. }
  12633. /**
  12634. * Represents a gamepad
  12635. */
  12636. export class Gamepad {
  12637. /**
  12638. * The id of the gamepad
  12639. */
  12640. id: string;
  12641. /**
  12642. * The index of the gamepad
  12643. */
  12644. index: number;
  12645. /**
  12646. * The browser gamepad
  12647. */
  12648. browserGamepad: any;
  12649. /**
  12650. * Specifies what type of gamepad this represents
  12651. */
  12652. type: number;
  12653. private _leftStick;
  12654. private _rightStick;
  12655. /** @hidden */
  12656. _isConnected: boolean;
  12657. private _leftStickAxisX;
  12658. private _leftStickAxisY;
  12659. private _rightStickAxisX;
  12660. private _rightStickAxisY;
  12661. /**
  12662. * Triggered when the left control stick has been changed
  12663. */
  12664. private _onleftstickchanged;
  12665. /**
  12666. * Triggered when the right control stick has been changed
  12667. */
  12668. private _onrightstickchanged;
  12669. /**
  12670. * Represents a gamepad controller
  12671. */
  12672. static GAMEPAD: number;
  12673. /**
  12674. * Represents a generic controller
  12675. */
  12676. static GENERIC: number;
  12677. /**
  12678. * Represents an XBox controller
  12679. */
  12680. static XBOX: number;
  12681. /**
  12682. * Represents a pose-enabled controller
  12683. */
  12684. static POSE_ENABLED: number;
  12685. /**
  12686. * Represents an Dual Shock controller
  12687. */
  12688. static DUALSHOCK: number;
  12689. /**
  12690. * Specifies whether the left control stick should be Y-inverted
  12691. */
  12692. protected _invertLeftStickY: boolean;
  12693. /**
  12694. * Specifies if the gamepad has been connected
  12695. */
  12696. get isConnected(): boolean;
  12697. /**
  12698. * Initializes the gamepad
  12699. * @param id The id of the gamepad
  12700. * @param index The index of the gamepad
  12701. * @param browserGamepad The browser gamepad
  12702. * @param leftStickX The x component of the left joystick
  12703. * @param leftStickY The y component of the left joystick
  12704. * @param rightStickX The x component of the right joystick
  12705. * @param rightStickY The y component of the right joystick
  12706. */
  12707. constructor(
  12708. /**
  12709. * The id of the gamepad
  12710. */
  12711. id: string,
  12712. /**
  12713. * The index of the gamepad
  12714. */
  12715. index: number,
  12716. /**
  12717. * The browser gamepad
  12718. */
  12719. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12720. /**
  12721. * Callback triggered when the left joystick has changed
  12722. * @param callback
  12723. */
  12724. onleftstickchanged(callback: (values: StickValues) => void): void;
  12725. /**
  12726. * Callback triggered when the right joystick has changed
  12727. * @param callback
  12728. */
  12729. onrightstickchanged(callback: (values: StickValues) => void): void;
  12730. /**
  12731. * Gets the left joystick
  12732. */
  12733. get leftStick(): StickValues;
  12734. /**
  12735. * Sets the left joystick values
  12736. */
  12737. set leftStick(newValues: StickValues);
  12738. /**
  12739. * Gets the right joystick
  12740. */
  12741. get rightStick(): StickValues;
  12742. /**
  12743. * Sets the right joystick value
  12744. */
  12745. set rightStick(newValues: StickValues);
  12746. /**
  12747. * Updates the gamepad joystick positions
  12748. */
  12749. update(): void;
  12750. /**
  12751. * Disposes the gamepad
  12752. */
  12753. dispose(): void;
  12754. }
  12755. /**
  12756. * Represents a generic gamepad
  12757. */
  12758. export class GenericPad extends Gamepad {
  12759. private _buttons;
  12760. private _onbuttondown;
  12761. private _onbuttonup;
  12762. /**
  12763. * Observable triggered when a button has been pressed
  12764. */
  12765. onButtonDownObservable: Observable<number>;
  12766. /**
  12767. * Observable triggered when a button has been released
  12768. */
  12769. onButtonUpObservable: Observable<number>;
  12770. /**
  12771. * Callback triggered when a button has been pressed
  12772. * @param callback Called when a button has been pressed
  12773. */
  12774. onbuttondown(callback: (buttonPressed: number) => void): void;
  12775. /**
  12776. * Callback triggered when a button has been released
  12777. * @param callback Called when a button has been released
  12778. */
  12779. onbuttonup(callback: (buttonReleased: number) => void): void;
  12780. /**
  12781. * Initializes the generic gamepad
  12782. * @param id The id of the generic gamepad
  12783. * @param index The index of the generic gamepad
  12784. * @param browserGamepad The browser gamepad
  12785. */
  12786. constructor(id: string, index: number, browserGamepad: any);
  12787. private _setButtonValue;
  12788. /**
  12789. * Updates the generic gamepad
  12790. */
  12791. update(): void;
  12792. /**
  12793. * Disposes the generic gamepad
  12794. */
  12795. dispose(): void;
  12796. }
  12797. }
  12798. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12799. import { Nullable } from "babylonjs/types";
  12800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12801. import { Scene } from "babylonjs/scene";
  12802. module "babylonjs/Engines/engine" {
  12803. interface Engine {
  12804. /**
  12805. * Creates a raw texture
  12806. * @param data defines the data to store in the texture
  12807. * @param width defines the width of the texture
  12808. * @param height defines the height of the texture
  12809. * @param format defines the format of the data
  12810. * @param generateMipMaps defines if the engine should generate the mip levels
  12811. * @param invertY defines if data must be stored with Y axis inverted
  12812. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12813. * @param compression defines the compression used (null by default)
  12814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12815. * @returns the raw texture inside an InternalTexture
  12816. */
  12817. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12818. /**
  12819. * Update a raw texture
  12820. * @param texture defines the texture to update
  12821. * @param data defines the data to store in the texture
  12822. * @param format defines the format of the data
  12823. * @param invertY defines if data must be stored with Y axis inverted
  12824. */
  12825. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12826. /**
  12827. * Update a raw texture
  12828. * @param texture defines the texture to update
  12829. * @param data defines the data to store in the texture
  12830. * @param format defines the format of the data
  12831. * @param invertY defines if data must be stored with Y axis inverted
  12832. * @param compression defines the compression used (null by default)
  12833. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12834. */
  12835. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12836. /**
  12837. * Creates a new raw cube texture
  12838. * @param data defines the array of data to use to create each face
  12839. * @param size defines the size of the textures
  12840. * @param format defines the format of the data
  12841. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12842. * @param generateMipMaps defines if the engine should generate the mip levels
  12843. * @param invertY defines if data must be stored with Y axis inverted
  12844. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12845. * @param compression defines the compression used (null by default)
  12846. * @returns the cube texture as an InternalTexture
  12847. */
  12848. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12849. /**
  12850. * Update a raw cube texture
  12851. * @param texture defines the texture to udpdate
  12852. * @param data defines the data to store
  12853. * @param format defines the data format
  12854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12855. * @param invertY defines if data must be stored with Y axis inverted
  12856. */
  12857. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12858. /**
  12859. * Update a raw cube texture
  12860. * @param texture defines the texture to udpdate
  12861. * @param data defines the data to store
  12862. * @param format defines the data format
  12863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12864. * @param invertY defines if data must be stored with Y axis inverted
  12865. * @param compression defines the compression used (null by default)
  12866. */
  12867. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12868. /**
  12869. * Update a raw cube texture
  12870. * @param texture defines the texture to udpdate
  12871. * @param data defines the data to store
  12872. * @param format defines the data format
  12873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12874. * @param invertY defines if data must be stored with Y axis inverted
  12875. * @param compression defines the compression used (null by default)
  12876. * @param level defines which level of the texture to update
  12877. */
  12878. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12879. /**
  12880. * Creates a new raw cube texture from a specified url
  12881. * @param url defines the url where the data is located
  12882. * @param scene defines the current scene
  12883. * @param size defines the size of the textures
  12884. * @param format defines the format of the data
  12885. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12886. * @param noMipmap defines if the engine should avoid generating the mip levels
  12887. * @param callback defines a callback used to extract texture data from loaded data
  12888. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12889. * @param onLoad defines a callback called when texture is loaded
  12890. * @param onError defines a callback called if there is an error
  12891. * @returns the cube texture as an InternalTexture
  12892. */
  12893. 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;
  12894. /**
  12895. * Creates a new raw cube texture from a specified url
  12896. * @param url defines the url where the data is located
  12897. * @param scene defines the current scene
  12898. * @param size defines the size of the textures
  12899. * @param format defines the format of the data
  12900. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12901. * @param noMipmap defines if the engine should avoid generating the mip levels
  12902. * @param callback defines a callback used to extract texture data from loaded data
  12903. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12904. * @param onLoad defines a callback called when texture is loaded
  12905. * @param onError defines a callback called if there is an error
  12906. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12907. * @param invertY defines if data must be stored with Y axis inverted
  12908. * @returns the cube texture as an InternalTexture
  12909. */
  12910. 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;
  12911. /**
  12912. * Creates a new raw 3D texture
  12913. * @param data defines the data used to create the texture
  12914. * @param width defines the width of the texture
  12915. * @param height defines the height of the texture
  12916. * @param depth defines the depth of the texture
  12917. * @param format defines the format of the texture
  12918. * @param generateMipMaps defines if the engine must generate mip levels
  12919. * @param invertY defines if data must be stored with Y axis inverted
  12920. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12921. * @param compression defines the compressed used (can be null)
  12922. * @param textureType defines the compressed used (can be null)
  12923. * @returns a new raw 3D texture (stored in an InternalTexture)
  12924. */
  12925. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12926. /**
  12927. * Update a raw 3D texture
  12928. * @param texture defines the texture to update
  12929. * @param data defines the data to store
  12930. * @param format defines the data format
  12931. * @param invertY defines if data must be stored with Y axis inverted
  12932. */
  12933. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12934. /**
  12935. * Update a raw 3D texture
  12936. * @param texture defines the texture to update
  12937. * @param data defines the data to store
  12938. * @param format defines the data format
  12939. * @param invertY defines if data must be stored with Y axis inverted
  12940. * @param compression defines the used compression (can be null)
  12941. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12942. */
  12943. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12944. /**
  12945. * Creates a new raw 2D array texture
  12946. * @param data defines the data used to create the texture
  12947. * @param width defines the width of the texture
  12948. * @param height defines the height of the texture
  12949. * @param depth defines the number of layers of the texture
  12950. * @param format defines the format of the texture
  12951. * @param generateMipMaps defines if the engine must generate mip levels
  12952. * @param invertY defines if data must be stored with Y axis inverted
  12953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12954. * @param compression defines the compressed used (can be null)
  12955. * @param textureType defines the compressed used (can be null)
  12956. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12957. */
  12958. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12959. /**
  12960. * Update a raw 2D array texture
  12961. * @param texture defines the texture to update
  12962. * @param data defines the data to store
  12963. * @param format defines the data format
  12964. * @param invertY defines if data must be stored with Y axis inverted
  12965. */
  12966. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12967. /**
  12968. * Update a raw 2D array texture
  12969. * @param texture defines the texture to update
  12970. * @param data defines the data to store
  12971. * @param format defines the data format
  12972. * @param invertY defines if data must be stored with Y axis inverted
  12973. * @param compression defines the used compression (can be null)
  12974. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12975. */
  12976. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12977. }
  12978. }
  12979. }
  12980. declare module "babylonjs/Materials/Textures/rawTexture" {
  12981. import { Scene } from "babylonjs/scene";
  12982. import { Texture } from "babylonjs/Materials/Textures/texture";
  12983. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12984. /**
  12985. * Raw texture can help creating a texture directly from an array of data.
  12986. * This can be super useful if you either get the data from an uncompressed source or
  12987. * if you wish to create your texture pixel by pixel.
  12988. */
  12989. export class RawTexture extends Texture {
  12990. /**
  12991. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12992. */
  12993. format: number;
  12994. private _engine;
  12995. /**
  12996. * Instantiates a new RawTexture.
  12997. * Raw texture can help creating a texture directly from an array of data.
  12998. * This can be super useful if you either get the data from an uncompressed source or
  12999. * if you wish to create your texture pixel by pixel.
  13000. * @param data define the array of data to use to create the texture
  13001. * @param width define the width of the texture
  13002. * @param height define the height of the texture
  13003. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13004. * @param scene define the scene the texture belongs to
  13005. * @param generateMipMaps define whether mip maps should be generated or not
  13006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13008. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13009. */
  13010. constructor(data: ArrayBufferView, width: number, height: number,
  13011. /**
  13012. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13013. */
  13014. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13015. /**
  13016. * Updates the texture underlying data.
  13017. * @param data Define the new data of the texture
  13018. */
  13019. update(data: ArrayBufferView): void;
  13020. /**
  13021. * Creates a luminance texture from some data.
  13022. * @param data Define the texture data
  13023. * @param width Define the width of the texture
  13024. * @param height Define the height of the texture
  13025. * @param scene Define the scene the texture belongs to
  13026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13029. * @returns the luminance texture
  13030. */
  13031. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13032. /**
  13033. * Creates a luminance alpha texture from some data.
  13034. * @param data Define the texture data
  13035. * @param width Define the width of the texture
  13036. * @param height Define the height of the texture
  13037. * @param scene Define the scene the texture belongs to
  13038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13041. * @returns the luminance alpha texture
  13042. */
  13043. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13044. /**
  13045. * Creates an alpha texture from some data.
  13046. * @param data Define the texture data
  13047. * @param width Define the width of the texture
  13048. * @param height Define the height of the texture
  13049. * @param scene Define the scene the texture belongs to
  13050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13053. * @returns the alpha texture
  13054. */
  13055. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13056. /**
  13057. * Creates a RGB texture from some data.
  13058. * @param data Define the texture data
  13059. * @param width Define the width of the texture
  13060. * @param height Define the height of the texture
  13061. * @param scene Define the scene the texture belongs to
  13062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13065. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13066. * @returns the RGB alpha texture
  13067. */
  13068. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13069. /**
  13070. * Creates a RGBA texture from some data.
  13071. * @param data Define the texture data
  13072. * @param width Define the width of the texture
  13073. * @param height Define the height of the texture
  13074. * @param scene Define the scene the texture belongs to
  13075. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13076. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13077. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13078. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13079. * @returns the RGBA texture
  13080. */
  13081. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13082. /**
  13083. * Creates a R texture from some data.
  13084. * @param data Define the texture data
  13085. * @param width Define the width of the texture
  13086. * @param height Define the height of the texture
  13087. * @param scene Define the scene the texture belongs to
  13088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13091. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13092. * @returns the R texture
  13093. */
  13094. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13095. }
  13096. }
  13097. declare module "babylonjs/Maths/math.size" {
  13098. /**
  13099. * Interface for the size containing width and height
  13100. */
  13101. export interface ISize {
  13102. /**
  13103. * Width
  13104. */
  13105. width: number;
  13106. /**
  13107. * Heighht
  13108. */
  13109. height: number;
  13110. }
  13111. /**
  13112. * Size containing widht and height
  13113. */
  13114. export class Size implements ISize {
  13115. /**
  13116. * Width
  13117. */
  13118. width: number;
  13119. /**
  13120. * Height
  13121. */
  13122. height: number;
  13123. /**
  13124. * Creates a Size object from the given width and height (floats).
  13125. * @param width width of the new size
  13126. * @param height height of the new size
  13127. */
  13128. constructor(width: number, height: number);
  13129. /**
  13130. * Returns a string with the Size width and height
  13131. * @returns a string with the Size width and height
  13132. */
  13133. toString(): string;
  13134. /**
  13135. * "Size"
  13136. * @returns the string "Size"
  13137. */
  13138. getClassName(): string;
  13139. /**
  13140. * Returns the Size hash code.
  13141. * @returns a hash code for a unique width and height
  13142. */
  13143. getHashCode(): number;
  13144. /**
  13145. * Updates the current size from the given one.
  13146. * @param src the given size
  13147. */
  13148. copyFrom(src: Size): void;
  13149. /**
  13150. * Updates in place the current Size from the given floats.
  13151. * @param width width of the new size
  13152. * @param height height of the new size
  13153. * @returns the updated Size.
  13154. */
  13155. copyFromFloats(width: number, height: number): Size;
  13156. /**
  13157. * Updates in place the current Size from the given floats.
  13158. * @param width width to set
  13159. * @param height height to set
  13160. * @returns the updated Size.
  13161. */
  13162. set(width: number, height: number): Size;
  13163. /**
  13164. * Multiplies the width and height by numbers
  13165. * @param w factor to multiple the width by
  13166. * @param h factor to multiple the height by
  13167. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13168. */
  13169. multiplyByFloats(w: number, h: number): Size;
  13170. /**
  13171. * Clones the size
  13172. * @returns a new Size copied from the given one.
  13173. */
  13174. clone(): Size;
  13175. /**
  13176. * True if the current Size and the given one width and height are strictly equal.
  13177. * @param other the other size to compare against
  13178. * @returns True if the current Size and the given one width and height are strictly equal.
  13179. */
  13180. equals(other: Size): boolean;
  13181. /**
  13182. * The surface of the Size : width * height (float).
  13183. */
  13184. get surface(): number;
  13185. /**
  13186. * Create a new size of zero
  13187. * @returns a new Size set to (0.0, 0.0)
  13188. */
  13189. static Zero(): Size;
  13190. /**
  13191. * Sums the width and height of two sizes
  13192. * @param otherSize size to add to this size
  13193. * @returns a new Size set as the addition result of the current Size and the given one.
  13194. */
  13195. add(otherSize: Size): Size;
  13196. /**
  13197. * Subtracts the width and height of two
  13198. * @param otherSize size to subtract to this size
  13199. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13200. */
  13201. subtract(otherSize: Size): Size;
  13202. /**
  13203. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13204. * @param start starting size to lerp between
  13205. * @param end end size to lerp between
  13206. * @param amount amount to lerp between the start and end values
  13207. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13208. */
  13209. static Lerp(start: Size, end: Size, amount: number): Size;
  13210. }
  13211. }
  13212. declare module "babylonjs/Animations/runtimeAnimation" {
  13213. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13214. import { Animatable } from "babylonjs/Animations/animatable";
  13215. import { Scene } from "babylonjs/scene";
  13216. /**
  13217. * Defines a runtime animation
  13218. */
  13219. export class RuntimeAnimation {
  13220. private _events;
  13221. /**
  13222. * The current frame of the runtime animation
  13223. */
  13224. private _currentFrame;
  13225. /**
  13226. * The animation used by the runtime animation
  13227. */
  13228. private _animation;
  13229. /**
  13230. * The target of the runtime animation
  13231. */
  13232. private _target;
  13233. /**
  13234. * The initiating animatable
  13235. */
  13236. private _host;
  13237. /**
  13238. * The original value of the runtime animation
  13239. */
  13240. private _originalValue;
  13241. /**
  13242. * The original blend value of the runtime animation
  13243. */
  13244. private _originalBlendValue;
  13245. /**
  13246. * The offsets cache of the runtime animation
  13247. */
  13248. private _offsetsCache;
  13249. /**
  13250. * The high limits cache of the runtime animation
  13251. */
  13252. private _highLimitsCache;
  13253. /**
  13254. * Specifies if the runtime animation has been stopped
  13255. */
  13256. private _stopped;
  13257. /**
  13258. * The blending factor of the runtime animation
  13259. */
  13260. private _blendingFactor;
  13261. /**
  13262. * The BabylonJS scene
  13263. */
  13264. private _scene;
  13265. /**
  13266. * The current value of the runtime animation
  13267. */
  13268. private _currentValue;
  13269. /** @hidden */
  13270. _animationState: _IAnimationState;
  13271. /**
  13272. * The active target of the runtime animation
  13273. */
  13274. private _activeTargets;
  13275. private _currentActiveTarget;
  13276. private _directTarget;
  13277. /**
  13278. * The target path of the runtime animation
  13279. */
  13280. private _targetPath;
  13281. /**
  13282. * The weight of the runtime animation
  13283. */
  13284. private _weight;
  13285. /**
  13286. * The ratio offset of the runtime animation
  13287. */
  13288. private _ratioOffset;
  13289. /**
  13290. * The previous delay of the runtime animation
  13291. */
  13292. private _previousDelay;
  13293. /**
  13294. * The previous ratio of the runtime animation
  13295. */
  13296. private _previousRatio;
  13297. private _enableBlending;
  13298. private _keys;
  13299. private _minFrame;
  13300. private _maxFrame;
  13301. private _minValue;
  13302. private _maxValue;
  13303. private _targetIsArray;
  13304. /**
  13305. * Gets the current frame of the runtime animation
  13306. */
  13307. get currentFrame(): number;
  13308. /**
  13309. * Gets the weight of the runtime animation
  13310. */
  13311. get weight(): number;
  13312. /**
  13313. * Gets the current value of the runtime animation
  13314. */
  13315. get currentValue(): any;
  13316. /**
  13317. * Gets the target path of the runtime animation
  13318. */
  13319. get targetPath(): string;
  13320. /**
  13321. * Gets the actual target of the runtime animation
  13322. */
  13323. get target(): any;
  13324. /** @hidden */
  13325. _onLoop: () => void;
  13326. /**
  13327. * Create a new RuntimeAnimation object
  13328. * @param target defines the target of the animation
  13329. * @param animation defines the source animation object
  13330. * @param scene defines the hosting scene
  13331. * @param host defines the initiating Animatable
  13332. */
  13333. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13334. private _preparePath;
  13335. /**
  13336. * Gets the animation from the runtime animation
  13337. */
  13338. get animation(): Animation;
  13339. /**
  13340. * Resets the runtime animation to the beginning
  13341. * @param restoreOriginal defines whether to restore the target property to the original value
  13342. */
  13343. reset(restoreOriginal?: boolean): void;
  13344. /**
  13345. * Specifies if the runtime animation is stopped
  13346. * @returns Boolean specifying if the runtime animation is stopped
  13347. */
  13348. isStopped(): boolean;
  13349. /**
  13350. * Disposes of the runtime animation
  13351. */
  13352. dispose(): void;
  13353. /**
  13354. * Apply the interpolated value to the target
  13355. * @param currentValue defines the value computed by the animation
  13356. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13357. */
  13358. setValue(currentValue: any, weight: number): void;
  13359. private _getOriginalValues;
  13360. private _setValue;
  13361. /**
  13362. * Gets the loop pmode of the runtime animation
  13363. * @returns Loop Mode
  13364. */
  13365. private _getCorrectLoopMode;
  13366. /**
  13367. * Move the current animation to a given frame
  13368. * @param frame defines the frame to move to
  13369. */
  13370. goToFrame(frame: number): void;
  13371. /**
  13372. * @hidden Internal use only
  13373. */
  13374. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13375. /**
  13376. * Execute the current animation
  13377. * @param delay defines the delay to add to the current frame
  13378. * @param from defines the lower bound of the animation range
  13379. * @param to defines the upper bound of the animation range
  13380. * @param loop defines if the current animation must loop
  13381. * @param speedRatio defines the current speed ratio
  13382. * @param weight defines the weight of the animation (default is -1 so no weight)
  13383. * @param onLoop optional callback called when animation loops
  13384. * @returns a boolean indicating if the animation is running
  13385. */
  13386. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13387. }
  13388. }
  13389. declare module "babylonjs/Animations/animatable" {
  13390. import { Animation } from "babylonjs/Animations/animation";
  13391. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13392. import { Nullable } from "babylonjs/types";
  13393. import { Observable } from "babylonjs/Misc/observable";
  13394. import { Scene } from "babylonjs/scene";
  13395. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13396. import { Node } from "babylonjs/node";
  13397. /**
  13398. * Class used to store an actual running animation
  13399. */
  13400. export class Animatable {
  13401. /** defines the target object */
  13402. target: any;
  13403. /** defines the starting frame number (default is 0) */
  13404. fromFrame: number;
  13405. /** defines the ending frame number (default is 100) */
  13406. toFrame: number;
  13407. /** defines if the animation must loop (default is false) */
  13408. loopAnimation: boolean;
  13409. /** defines a callback to call when animation ends if it is not looping */
  13410. onAnimationEnd?: (() => void) | null | undefined;
  13411. /** defines a callback to call when animation loops */
  13412. onAnimationLoop?: (() => void) | null | undefined;
  13413. private _localDelayOffset;
  13414. private _pausedDelay;
  13415. private _runtimeAnimations;
  13416. private _paused;
  13417. private _scene;
  13418. private _speedRatio;
  13419. private _weight;
  13420. private _syncRoot;
  13421. /**
  13422. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13423. * This will only apply for non looping animation (default is true)
  13424. */
  13425. disposeOnEnd: boolean;
  13426. /**
  13427. * Gets a boolean indicating if the animation has started
  13428. */
  13429. animationStarted: boolean;
  13430. /**
  13431. * Observer raised when the animation ends
  13432. */
  13433. onAnimationEndObservable: Observable<Animatable>;
  13434. /**
  13435. * Observer raised when the animation loops
  13436. */
  13437. onAnimationLoopObservable: Observable<Animatable>;
  13438. /**
  13439. * Gets the root Animatable used to synchronize and normalize animations
  13440. */
  13441. get syncRoot(): Nullable<Animatable>;
  13442. /**
  13443. * Gets the current frame of the first RuntimeAnimation
  13444. * Used to synchronize Animatables
  13445. */
  13446. get masterFrame(): number;
  13447. /**
  13448. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13449. */
  13450. get weight(): number;
  13451. set weight(value: number);
  13452. /**
  13453. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13454. */
  13455. get speedRatio(): number;
  13456. set speedRatio(value: number);
  13457. /**
  13458. * Creates a new Animatable
  13459. * @param scene defines the hosting scene
  13460. * @param target defines the target object
  13461. * @param fromFrame defines the starting frame number (default is 0)
  13462. * @param toFrame defines the ending frame number (default is 100)
  13463. * @param loopAnimation defines if the animation must loop (default is false)
  13464. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13465. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13466. * @param animations defines a group of animation to add to the new Animatable
  13467. * @param onAnimationLoop defines a callback to call when animation loops
  13468. */
  13469. constructor(scene: Scene,
  13470. /** defines the target object */
  13471. target: any,
  13472. /** defines the starting frame number (default is 0) */
  13473. fromFrame?: number,
  13474. /** defines the ending frame number (default is 100) */
  13475. toFrame?: number,
  13476. /** defines if the animation must loop (default is false) */
  13477. loopAnimation?: boolean, speedRatio?: number,
  13478. /** defines a callback to call when animation ends if it is not looping */
  13479. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13480. /** defines a callback to call when animation loops */
  13481. onAnimationLoop?: (() => void) | null | undefined);
  13482. /**
  13483. * Synchronize and normalize current Animatable with a source Animatable
  13484. * This is useful when using animation weights and when animations are not of the same length
  13485. * @param root defines the root Animatable to synchronize with
  13486. * @returns the current Animatable
  13487. */
  13488. syncWith(root: Animatable): Animatable;
  13489. /**
  13490. * Gets the list of runtime animations
  13491. * @returns an array of RuntimeAnimation
  13492. */
  13493. getAnimations(): RuntimeAnimation[];
  13494. /**
  13495. * Adds more animations to the current animatable
  13496. * @param target defines the target of the animations
  13497. * @param animations defines the new animations to add
  13498. */
  13499. appendAnimations(target: any, animations: Animation[]): void;
  13500. /**
  13501. * Gets the source animation for a specific property
  13502. * @param property defines the propertyu to look for
  13503. * @returns null or the source animation for the given property
  13504. */
  13505. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13506. /**
  13507. * Gets the runtime animation for a specific property
  13508. * @param property defines the propertyu to look for
  13509. * @returns null or the runtime animation for the given property
  13510. */
  13511. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13512. /**
  13513. * Resets the animatable to its original state
  13514. */
  13515. reset(): void;
  13516. /**
  13517. * Allows the animatable to blend with current running animations
  13518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13519. * @param blendingSpeed defines the blending speed to use
  13520. */
  13521. enableBlending(blendingSpeed: number): void;
  13522. /**
  13523. * Disable animation blending
  13524. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13525. */
  13526. disableBlending(): void;
  13527. /**
  13528. * Jump directly to a given frame
  13529. * @param frame defines the frame to jump to
  13530. */
  13531. goToFrame(frame: number): void;
  13532. /**
  13533. * Pause the animation
  13534. */
  13535. pause(): void;
  13536. /**
  13537. * Restart the animation
  13538. */
  13539. restart(): void;
  13540. private _raiseOnAnimationEnd;
  13541. /**
  13542. * Stop and delete the current animation
  13543. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13544. * @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)
  13545. */
  13546. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13547. /**
  13548. * Wait asynchronously for the animation to end
  13549. * @returns a promise which will be fullfilled when the animation ends
  13550. */
  13551. waitAsync(): Promise<Animatable>;
  13552. /** @hidden */
  13553. _animate(delay: number): boolean;
  13554. }
  13555. module "babylonjs/scene" {
  13556. interface Scene {
  13557. /** @hidden */
  13558. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13559. /** @hidden */
  13560. _processLateAnimationBindingsForMatrices(holder: {
  13561. totalWeight: number;
  13562. animations: RuntimeAnimation[];
  13563. originalValue: Matrix;
  13564. }): any;
  13565. /** @hidden */
  13566. _processLateAnimationBindingsForQuaternions(holder: {
  13567. totalWeight: number;
  13568. animations: RuntimeAnimation[];
  13569. originalValue: Quaternion;
  13570. }, refQuaternion: Quaternion): Quaternion;
  13571. /** @hidden */
  13572. _processLateAnimationBindings(): void;
  13573. /**
  13574. * Will start the animation sequence of a given target
  13575. * @param target defines the target
  13576. * @param from defines from which frame should animation start
  13577. * @param to defines until which frame should animation run.
  13578. * @param weight defines the weight to apply to the animation (1.0 by default)
  13579. * @param loop defines if the animation loops
  13580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13581. * @param onAnimationEnd defines the function to be executed when the animation ends
  13582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13583. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13584. * @param onAnimationLoop defines the callback to call when an animation loops
  13585. * @returns the animatable object created for this animation
  13586. */
  13587. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13588. /**
  13589. * Will start the animation sequence of a given target
  13590. * @param target defines the target
  13591. * @param from defines from which frame should animation start
  13592. * @param to defines until which frame should animation run.
  13593. * @param loop defines if the animation loops
  13594. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13595. * @param onAnimationEnd defines the function to be executed when the animation ends
  13596. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13597. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13598. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13599. * @param onAnimationLoop defines the callback to call when an animation loops
  13600. * @returns the animatable object created for this animation
  13601. */
  13602. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13603. /**
  13604. * Will start the animation sequence of a given target and its hierarchy
  13605. * @param target defines the target
  13606. * @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.
  13607. * @param from defines from which frame should animation start
  13608. * @param to defines until which frame should animation run.
  13609. * @param loop defines if the animation loops
  13610. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13611. * @param onAnimationEnd defines the function to be executed when the animation ends
  13612. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13613. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13614. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13615. * @param onAnimationLoop defines the callback to call when an animation loops
  13616. * @returns the list of created animatables
  13617. */
  13618. 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[];
  13619. /**
  13620. * Begin a new animation on a given node
  13621. * @param target defines the target where the animation will take place
  13622. * @param animations defines the list of animations to start
  13623. * @param from defines the initial value
  13624. * @param to defines the final value
  13625. * @param loop defines if you want animation to loop (off by default)
  13626. * @param speedRatio defines the speed ratio to apply to all animations
  13627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13628. * @param onAnimationLoop defines the callback to call when an animation loops
  13629. * @returns the list of created animatables
  13630. */
  13631. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13632. /**
  13633. * Begin a new animation on a given node and its hierarchy
  13634. * @param target defines the root node where the animation will take place
  13635. * @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.
  13636. * @param animations defines the list of animations to start
  13637. * @param from defines the initial value
  13638. * @param to defines the final value
  13639. * @param loop defines if you want animation to loop (off by default)
  13640. * @param speedRatio defines the speed ratio to apply to all animations
  13641. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13642. * @param onAnimationLoop defines the callback to call when an animation loops
  13643. * @returns the list of animatables created for all nodes
  13644. */
  13645. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13646. /**
  13647. * Gets the animatable associated with a specific target
  13648. * @param target defines the target of the animatable
  13649. * @returns the required animatable if found
  13650. */
  13651. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13652. /**
  13653. * Gets all animatables associated with a given target
  13654. * @param target defines the target to look animatables for
  13655. * @returns an array of Animatables
  13656. */
  13657. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13658. /**
  13659. * Stops and removes all animations that have been applied to the scene
  13660. */
  13661. stopAllAnimations(): void;
  13662. /**
  13663. * Gets the current delta time used by animation engine
  13664. */
  13665. deltaTime: number;
  13666. }
  13667. }
  13668. module "babylonjs/Bones/bone" {
  13669. interface Bone {
  13670. /**
  13671. * Copy an animation range from another bone
  13672. * @param source defines the source bone
  13673. * @param rangeName defines the range name to copy
  13674. * @param frameOffset defines the frame offset
  13675. * @param rescaleAsRequired defines if rescaling must be applied if required
  13676. * @param skelDimensionsRatio defines the scaling ratio
  13677. * @returns true if operation was successful
  13678. */
  13679. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13680. }
  13681. }
  13682. }
  13683. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13684. /**
  13685. * Class used to override all child animations of a given target
  13686. */
  13687. export class AnimationPropertiesOverride {
  13688. /**
  13689. * Gets or sets a value indicating if animation blending must be used
  13690. */
  13691. enableBlending: boolean;
  13692. /**
  13693. * Gets or sets the blending speed to use when enableBlending is true
  13694. */
  13695. blendingSpeed: number;
  13696. /**
  13697. * Gets or sets the default loop mode to use
  13698. */
  13699. loopMode: number;
  13700. }
  13701. }
  13702. declare module "babylonjs/Bones/skeleton" {
  13703. import { Bone } from "babylonjs/Bones/bone";
  13704. import { Observable } from "babylonjs/Misc/observable";
  13705. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13706. import { Scene } from "babylonjs/scene";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13710. import { Animatable } from "babylonjs/Animations/animatable";
  13711. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13712. import { Animation } from "babylonjs/Animations/animation";
  13713. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13714. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13715. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13716. /**
  13717. * Class used to handle skinning animations
  13718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13719. */
  13720. export class Skeleton implements IAnimatable {
  13721. /** defines the skeleton name */
  13722. name: string;
  13723. /** defines the skeleton Id */
  13724. id: string;
  13725. /**
  13726. * Defines the list of child bones
  13727. */
  13728. bones: Bone[];
  13729. /**
  13730. * Defines an estimate of the dimension of the skeleton at rest
  13731. */
  13732. dimensionsAtRest: Vector3;
  13733. /**
  13734. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13735. */
  13736. needInitialSkinMatrix: boolean;
  13737. /**
  13738. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13739. */
  13740. overrideMesh: Nullable<AbstractMesh>;
  13741. /**
  13742. * Gets the list of animations attached to this skeleton
  13743. */
  13744. animations: Array<Animation>;
  13745. private _scene;
  13746. private _isDirty;
  13747. private _transformMatrices;
  13748. private _transformMatrixTexture;
  13749. private _meshesWithPoseMatrix;
  13750. private _animatables;
  13751. private _identity;
  13752. private _synchronizedWithMesh;
  13753. private _ranges;
  13754. private _lastAbsoluteTransformsUpdateId;
  13755. private _canUseTextureForBones;
  13756. private _uniqueId;
  13757. /** @hidden */
  13758. _numBonesWithLinkedTransformNode: number;
  13759. /** @hidden */
  13760. _hasWaitingData: Nullable<boolean>;
  13761. /**
  13762. * Specifies if the skeleton should be serialized
  13763. */
  13764. doNotSerialize: boolean;
  13765. private _useTextureToStoreBoneMatrices;
  13766. /**
  13767. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13768. * Please note that this option is not available if the hardware does not support it
  13769. */
  13770. get useTextureToStoreBoneMatrices(): boolean;
  13771. set useTextureToStoreBoneMatrices(value: boolean);
  13772. private _animationPropertiesOverride;
  13773. /**
  13774. * Gets or sets the animation properties override
  13775. */
  13776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13778. /**
  13779. * List of inspectable custom properties (used by the Inspector)
  13780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13781. */
  13782. inspectableCustomProperties: IInspectable[];
  13783. /**
  13784. * An observable triggered before computing the skeleton's matrices
  13785. */
  13786. onBeforeComputeObservable: Observable<Skeleton>;
  13787. /**
  13788. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13789. */
  13790. get isUsingTextureForMatrices(): boolean;
  13791. /**
  13792. * Gets the unique ID of this skeleton
  13793. */
  13794. get uniqueId(): number;
  13795. /**
  13796. * Creates a new skeleton
  13797. * @param name defines the skeleton name
  13798. * @param id defines the skeleton Id
  13799. * @param scene defines the hosting scene
  13800. */
  13801. constructor(
  13802. /** defines the skeleton name */
  13803. name: string,
  13804. /** defines the skeleton Id */
  13805. id: string, scene: Scene);
  13806. /**
  13807. * Gets the current object class name.
  13808. * @return the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Returns an array containing the root bones
  13813. * @returns an array containing the root bones
  13814. */
  13815. getChildren(): Array<Bone>;
  13816. /**
  13817. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13818. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13819. * @returns a Float32Array containing matrices data
  13820. */
  13821. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13822. /**
  13823. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13824. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13825. * @returns a raw texture containing the data
  13826. */
  13827. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13828. /**
  13829. * Gets the current hosting scene
  13830. * @returns a scene object
  13831. */
  13832. getScene(): Scene;
  13833. /**
  13834. * Gets a string representing the current skeleton data
  13835. * @param fullDetails defines a boolean indicating if we want a verbose version
  13836. * @returns a string representing the current skeleton data
  13837. */
  13838. toString(fullDetails?: boolean): string;
  13839. /**
  13840. * Get bone's index searching by name
  13841. * @param name defines bone's name to search for
  13842. * @return the indice of the bone. Returns -1 if not found
  13843. */
  13844. getBoneIndexByName(name: string): number;
  13845. /**
  13846. * Creater a new animation range
  13847. * @param name defines the name of the range
  13848. * @param from defines the start key
  13849. * @param to defines the end key
  13850. */
  13851. createAnimationRange(name: string, from: number, to: number): void;
  13852. /**
  13853. * Delete a specific animation range
  13854. * @param name defines the name of the range
  13855. * @param deleteFrames defines if frames must be removed as well
  13856. */
  13857. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13858. /**
  13859. * Gets a specific animation range
  13860. * @param name defines the name of the range to look for
  13861. * @returns the requested animation range or null if not found
  13862. */
  13863. getAnimationRange(name: string): Nullable<AnimationRange>;
  13864. /**
  13865. * Gets the list of all animation ranges defined on this skeleton
  13866. * @returns an array
  13867. */
  13868. getAnimationRanges(): Nullable<AnimationRange>[];
  13869. /**
  13870. * Copy animation range from a source skeleton.
  13871. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13872. * @param source defines the source skeleton
  13873. * @param name defines the name of the range to copy
  13874. * @param rescaleAsRequired defines if rescaling must be applied if required
  13875. * @returns true if operation was successful
  13876. */
  13877. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13878. /**
  13879. * Forces the skeleton to go to rest pose
  13880. */
  13881. returnToRest(): void;
  13882. private _getHighestAnimationFrame;
  13883. /**
  13884. * Begin a specific animation range
  13885. * @param name defines the name of the range to start
  13886. * @param loop defines if looping must be turned on (false by default)
  13887. * @param speedRatio defines the speed ratio to apply (1 by default)
  13888. * @param onAnimationEnd defines a callback which will be called when animation will end
  13889. * @returns a new animatable
  13890. */
  13891. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13892. /** @hidden */
  13893. _markAsDirty(): void;
  13894. /** @hidden */
  13895. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13896. /** @hidden */
  13897. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13898. private _computeTransformMatrices;
  13899. /**
  13900. * Build all resources required to render a skeleton
  13901. */
  13902. prepare(): void;
  13903. /**
  13904. * Gets the list of animatables currently running for this skeleton
  13905. * @returns an array of animatables
  13906. */
  13907. getAnimatables(): IAnimatable[];
  13908. /**
  13909. * Clone the current skeleton
  13910. * @param name defines the name of the new skeleton
  13911. * @param id defines the id of the new skeleton
  13912. * @returns the new skeleton
  13913. */
  13914. clone(name: string, id?: string): Skeleton;
  13915. /**
  13916. * Enable animation blending for this skeleton
  13917. * @param blendingSpeed defines the blending speed to apply
  13918. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13919. */
  13920. enableBlending(blendingSpeed?: number): void;
  13921. /**
  13922. * Releases all resources associated with the current skeleton
  13923. */
  13924. dispose(): void;
  13925. /**
  13926. * Serialize the skeleton in a JSON object
  13927. * @returns a JSON object
  13928. */
  13929. serialize(): any;
  13930. /**
  13931. * Creates a new skeleton from serialized data
  13932. * @param parsedSkeleton defines the serialized data
  13933. * @param scene defines the hosting scene
  13934. * @returns a new skeleton
  13935. */
  13936. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13937. /**
  13938. * Compute all node absolute transforms
  13939. * @param forceUpdate defines if computation must be done even if cache is up to date
  13940. */
  13941. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13942. /**
  13943. * Gets the root pose matrix
  13944. * @returns a matrix
  13945. */
  13946. getPoseMatrix(): Nullable<Matrix>;
  13947. /**
  13948. * Sorts bones per internal index
  13949. */
  13950. sortBones(): void;
  13951. private _sortBones;
  13952. }
  13953. }
  13954. declare module "babylonjs/Bones/bone" {
  13955. import { Skeleton } from "babylonjs/Bones/skeleton";
  13956. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13957. import { Nullable } from "babylonjs/types";
  13958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13960. import { Node } from "babylonjs/node";
  13961. import { Space } from "babylonjs/Maths/math.axis";
  13962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13963. /**
  13964. * Class used to store bone information
  13965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13966. */
  13967. export class Bone extends Node {
  13968. /**
  13969. * defines the bone name
  13970. */
  13971. name: string;
  13972. private static _tmpVecs;
  13973. private static _tmpQuat;
  13974. private static _tmpMats;
  13975. /**
  13976. * Gets the list of child bones
  13977. */
  13978. children: Bone[];
  13979. /** Gets the animations associated with this bone */
  13980. animations: import("babylonjs/Animations/animation").Animation[];
  13981. /**
  13982. * Gets or sets bone length
  13983. */
  13984. length: number;
  13985. /**
  13986. * @hidden Internal only
  13987. * Set this value to map this bone to a different index in the transform matrices
  13988. * Set this value to -1 to exclude the bone from the transform matrices
  13989. */
  13990. _index: Nullable<number>;
  13991. private _skeleton;
  13992. private _localMatrix;
  13993. private _restPose;
  13994. private _baseMatrix;
  13995. private _absoluteTransform;
  13996. private _invertedAbsoluteTransform;
  13997. private _parent;
  13998. private _scalingDeterminant;
  13999. private _worldTransform;
  14000. private _localScaling;
  14001. private _localRotation;
  14002. private _localPosition;
  14003. private _needToDecompose;
  14004. private _needToCompose;
  14005. /** @hidden */
  14006. _linkedTransformNode: Nullable<TransformNode>;
  14007. /** @hidden */
  14008. _waitingTransformNodeId: Nullable<string>;
  14009. /** @hidden */
  14010. get _matrix(): Matrix;
  14011. /** @hidden */
  14012. set _matrix(value: Matrix);
  14013. /**
  14014. * Create a new bone
  14015. * @param name defines the bone name
  14016. * @param skeleton defines the parent skeleton
  14017. * @param parentBone defines the parent (can be null if the bone is the root)
  14018. * @param localMatrix defines the local matrix
  14019. * @param restPose defines the rest pose matrix
  14020. * @param baseMatrix defines the base matrix
  14021. * @param index defines index of the bone in the hiearchy
  14022. */
  14023. constructor(
  14024. /**
  14025. * defines the bone name
  14026. */
  14027. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14028. /**
  14029. * Gets the current object class name.
  14030. * @return the class name
  14031. */
  14032. getClassName(): string;
  14033. /**
  14034. * Gets the parent skeleton
  14035. * @returns a skeleton
  14036. */
  14037. getSkeleton(): Skeleton;
  14038. /**
  14039. * Gets parent bone
  14040. * @returns a bone or null if the bone is the root of the bone hierarchy
  14041. */
  14042. getParent(): Nullable<Bone>;
  14043. /**
  14044. * Returns an array containing the root bones
  14045. * @returns an array containing the root bones
  14046. */
  14047. getChildren(): Array<Bone>;
  14048. /**
  14049. * Gets the node index in matrix array generated for rendering
  14050. * @returns the node index
  14051. */
  14052. getIndex(): number;
  14053. /**
  14054. * Sets the parent bone
  14055. * @param parent defines the parent (can be null if the bone is the root)
  14056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14057. */
  14058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14059. /**
  14060. * Gets the local matrix
  14061. * @returns a matrix
  14062. */
  14063. getLocalMatrix(): Matrix;
  14064. /**
  14065. * Gets the base matrix (initial matrix which remains unchanged)
  14066. * @returns a matrix
  14067. */
  14068. getBaseMatrix(): Matrix;
  14069. /**
  14070. * Gets the rest pose matrix
  14071. * @returns a matrix
  14072. */
  14073. getRestPose(): Matrix;
  14074. /**
  14075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14076. */
  14077. getWorldMatrix(): Matrix;
  14078. /**
  14079. * Sets the local matrix to rest pose matrix
  14080. */
  14081. returnToRest(): void;
  14082. /**
  14083. * Gets the inverse of the absolute transform matrix.
  14084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14085. * @returns a matrix
  14086. */
  14087. getInvertedAbsoluteTransform(): Matrix;
  14088. /**
  14089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14090. * @returns a matrix
  14091. */
  14092. getAbsoluteTransform(): Matrix;
  14093. /**
  14094. * Links with the given transform node.
  14095. * The local matrix of this bone is copied from the transform node every frame.
  14096. * @param transformNode defines the transform node to link to
  14097. */
  14098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14099. /**
  14100. * Gets the node used to drive the bone's transformation
  14101. * @returns a transform node or null
  14102. */
  14103. getTransformNode(): Nullable<TransformNode>;
  14104. /** Gets or sets current position (in local space) */
  14105. get position(): Vector3;
  14106. set position(newPosition: Vector3);
  14107. /** Gets or sets current rotation (in local space) */
  14108. get rotation(): Vector3;
  14109. set rotation(newRotation: Vector3);
  14110. /** Gets or sets current rotation quaternion (in local space) */
  14111. get rotationQuaternion(): Quaternion;
  14112. set rotationQuaternion(newRotation: Quaternion);
  14113. /** Gets or sets current scaling (in local space) */
  14114. get scaling(): Vector3;
  14115. set scaling(newScaling: Vector3);
  14116. /**
  14117. * Gets the animation properties override
  14118. */
  14119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14120. private _decompose;
  14121. private _compose;
  14122. /**
  14123. * Update the base and local matrices
  14124. * @param matrix defines the new base or local matrix
  14125. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14126. * @param updateLocalMatrix defines if the local matrix should be updated
  14127. */
  14128. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14129. /** @hidden */
  14130. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14131. /**
  14132. * Flag the bone as dirty (Forcing it to update everything)
  14133. */
  14134. markAsDirty(): void;
  14135. /** @hidden */
  14136. _markAsDirtyAndCompose(): void;
  14137. private _markAsDirtyAndDecompose;
  14138. /**
  14139. * Translate the bone in local or world space
  14140. * @param vec The amount to translate the bone
  14141. * @param space The space that the translation is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the postion of the bone in local or world space
  14147. * @param position The position to set the bone
  14148. * @param space The space that the position is in
  14149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14150. */
  14151. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14152. /**
  14153. * Set the absolute position of the bone (world space)
  14154. * @param position The position to set the bone
  14155. * @param mesh The mesh that this bone is attached to
  14156. */
  14157. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14158. /**
  14159. * Scale the bone on the x, y and z axes (in local space)
  14160. * @param x The amount to scale the bone on the x axis
  14161. * @param y The amount to scale the bone on the y axis
  14162. * @param z The amount to scale the bone on the z axis
  14163. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14164. */
  14165. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14166. /**
  14167. * Set the bone scaling in local space
  14168. * @param scale defines the scaling vector
  14169. */
  14170. setScale(scale: Vector3): void;
  14171. /**
  14172. * Gets the current scaling in local space
  14173. * @returns the current scaling vector
  14174. */
  14175. getScale(): Vector3;
  14176. /**
  14177. * Gets the current scaling in local space and stores it in a target vector
  14178. * @param result defines the target vector
  14179. */
  14180. getScaleToRef(result: Vector3): void;
  14181. /**
  14182. * Set the yaw, pitch, and roll of the bone in local or world space
  14183. * @param yaw The rotation of the bone on the y axis
  14184. * @param pitch The rotation of the bone on the x axis
  14185. * @param roll The rotation of the bone on the z axis
  14186. * @param space The space that the axes of rotation are in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. */
  14189. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14190. /**
  14191. * Add a rotation to the bone on an axis in local or world space
  14192. * @param axis The axis to rotate the bone on
  14193. * @param amount The amount to rotate the bone
  14194. * @param space The space that the axis is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14198. /**
  14199. * Set the rotation of the bone to a particular axis angle in local or world space
  14200. * @param axis The axis to rotate the bone on
  14201. * @param angle The angle that the bone should be rotated to
  14202. * @param space The space that the axis is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the euler rotation of the bone in local of world space
  14208. * @param rotation The euler rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the quaternion rotation of the bone in local of world space
  14215. * @param quat The quaternion rotation that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14220. /**
  14221. * Set the rotation matrix of the bone in local of world space
  14222. * @param rotMat The rotation matrix that the bone should be set to
  14223. * @param space The space that the rotation is in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. */
  14226. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14227. private _rotateWithMatrix;
  14228. private _getNegativeRotationToRef;
  14229. /**
  14230. * Get the position of the bone in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @returns The position of the bone
  14234. */
  14235. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14236. /**
  14237. * Copy the position of the bone to a vector3 in local or world space
  14238. * @param space The space that the returned position is in
  14239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14240. * @param result The vector3 to copy the position to
  14241. */
  14242. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14243. /**
  14244. * Get the absolute position of the bone (world space)
  14245. * @param mesh The mesh that this bone is attached to
  14246. * @returns The absolute position of the bone
  14247. */
  14248. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14249. /**
  14250. * Copy the absolute position of the bone (world space) to the result param
  14251. * @param mesh The mesh that this bone is attached to
  14252. * @param result The vector3 to copy the absolute position to
  14253. */
  14254. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14255. /**
  14256. * Compute the absolute transforms of this bone and its children
  14257. */
  14258. computeAbsoluteTransforms(): void;
  14259. /**
  14260. * Get the world direction from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @returns The world direction
  14264. */
  14265. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14266. /**
  14267. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14268. * @param localAxis The local direction that is used to compute the world direction
  14269. * @param mesh The mesh that this bone is attached to
  14270. * @param result The vector3 that the world direction will be copied to
  14271. */
  14272. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14273. /**
  14274. * Get the euler rotation of the bone in local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @returns The euler rotation
  14278. */
  14279. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14280. /**
  14281. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @param result The vector3 that the rotation should be copied to
  14285. */
  14286. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14287. /**
  14288. * Get the quaternion rotation of the bone in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @returns The quaternion rotation
  14292. */
  14293. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14294. /**
  14295. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @param result The quaternion that the rotation should be copied to
  14299. */
  14300. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14301. /**
  14302. * Get the rotation matrix of the bone in local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @returns The rotation matrix
  14306. */
  14307. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14308. /**
  14309. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @param result The quaternion that the rotation should be copied to
  14313. */
  14314. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @returns The world position
  14320. */
  14321. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14322. /**
  14323. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14324. * @param position The local position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @param result The vector3 that the world position should be copied to
  14327. */
  14328. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14329. /**
  14330. * Get the local position of a point that is in world space
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @returns The local position
  14334. */
  14335. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14336. /**
  14337. * Get the local position of a point that is in world space and copy it to the result param
  14338. * @param position The world position
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @param result The vector3 that the local position should be copied to
  14341. */
  14342. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14343. }
  14344. }
  14345. declare module "babylonjs/Meshes/transformNode" {
  14346. import { DeepImmutable } from "babylonjs/types";
  14347. import { Observable } from "babylonjs/Misc/observable";
  14348. import { Nullable } from "babylonjs/types";
  14349. import { Camera } from "babylonjs/Cameras/camera";
  14350. import { Scene } from "babylonjs/scene";
  14351. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14352. import { Node } from "babylonjs/node";
  14353. import { Bone } from "babylonjs/Bones/bone";
  14354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14355. import { Space } from "babylonjs/Maths/math.axis";
  14356. /**
  14357. * 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.
  14358. * @see https://doc.babylonjs.com/how_to/transformnode
  14359. */
  14360. export class TransformNode extends Node {
  14361. /**
  14362. * Object will not rotate to face the camera
  14363. */
  14364. static BILLBOARDMODE_NONE: number;
  14365. /**
  14366. * Object will rotate to face the camera but only on the x axis
  14367. */
  14368. static BILLBOARDMODE_X: number;
  14369. /**
  14370. * Object will rotate to face the camera but only on the y axis
  14371. */
  14372. static BILLBOARDMODE_Y: number;
  14373. /**
  14374. * Object will rotate to face the camera but only on the z axis
  14375. */
  14376. static BILLBOARDMODE_Z: number;
  14377. /**
  14378. * Object will rotate to face the camera
  14379. */
  14380. static BILLBOARDMODE_ALL: number;
  14381. /**
  14382. * Object will rotate to face the camera's position instead of orientation
  14383. */
  14384. static BILLBOARDMODE_USE_POSITION: number;
  14385. private _forward;
  14386. private _forwardInverted;
  14387. private _up;
  14388. private _right;
  14389. private _rightInverted;
  14390. private _position;
  14391. private _rotation;
  14392. private _rotationQuaternion;
  14393. protected _scaling: Vector3;
  14394. protected _isDirty: boolean;
  14395. private _transformToBoneReferal;
  14396. private _isAbsoluteSynced;
  14397. private _billboardMode;
  14398. /**
  14399. * Gets or sets the billboard mode. Default is 0.
  14400. *
  14401. * | Value | Type | Description |
  14402. * | --- | --- | --- |
  14403. * | 0 | BILLBOARDMODE_NONE | |
  14404. * | 1 | BILLBOARDMODE_X | |
  14405. * | 2 | BILLBOARDMODE_Y | |
  14406. * | 4 | BILLBOARDMODE_Z | |
  14407. * | 7 | BILLBOARDMODE_ALL | |
  14408. *
  14409. */
  14410. get billboardMode(): number;
  14411. set billboardMode(value: number);
  14412. private _preserveParentRotationForBillboard;
  14413. /**
  14414. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14415. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14416. */
  14417. get preserveParentRotationForBillboard(): boolean;
  14418. set preserveParentRotationForBillboard(value: boolean);
  14419. /**
  14420. * 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
  14421. */
  14422. scalingDeterminant: number;
  14423. private _infiniteDistance;
  14424. /**
  14425. * Gets or sets the distance of the object to max, often used by skybox
  14426. */
  14427. get infiniteDistance(): boolean;
  14428. set infiniteDistance(value: boolean);
  14429. /**
  14430. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14431. * By default the system will update normals to compensate
  14432. */
  14433. ignoreNonUniformScaling: boolean;
  14434. /**
  14435. * 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
  14436. */
  14437. reIntegrateRotationIntoRotationQuaternion: boolean;
  14438. /** @hidden */
  14439. _poseMatrix: Nullable<Matrix>;
  14440. /** @hidden */
  14441. _localMatrix: Matrix;
  14442. private _usePivotMatrix;
  14443. private _absolutePosition;
  14444. private _absoluteScaling;
  14445. private _absoluteRotationQuaternion;
  14446. private _pivotMatrix;
  14447. private _pivotMatrixInverse;
  14448. protected _postMultiplyPivotMatrix: boolean;
  14449. protected _isWorldMatrixFrozen: boolean;
  14450. /** @hidden */
  14451. _indexInSceneTransformNodesArray: number;
  14452. /**
  14453. * An event triggered after the world matrix is updated
  14454. */
  14455. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14456. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14457. /**
  14458. * Gets a string identifying the name of the class
  14459. * @returns "TransformNode" string
  14460. */
  14461. getClassName(): string;
  14462. /**
  14463. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14464. */
  14465. get position(): Vector3;
  14466. set position(newPosition: Vector3);
  14467. /**
  14468. * 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)).
  14469. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14470. */
  14471. get rotation(): Vector3;
  14472. set rotation(newRotation: Vector3);
  14473. /**
  14474. * 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)).
  14475. */
  14476. get scaling(): Vector3;
  14477. set scaling(newScaling: Vector3);
  14478. /**
  14479. * 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).
  14480. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14481. */
  14482. get rotationQuaternion(): Nullable<Quaternion>;
  14483. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14484. /**
  14485. * The forward direction of that transform in world space.
  14486. */
  14487. get forward(): Vector3;
  14488. /**
  14489. * The up direction of that transform in world space.
  14490. */
  14491. get up(): Vector3;
  14492. /**
  14493. * The right direction of that transform in world space.
  14494. */
  14495. get right(): Vector3;
  14496. /**
  14497. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14498. * @param matrix the matrix to copy the pose from
  14499. * @returns this TransformNode.
  14500. */
  14501. updatePoseMatrix(matrix: Matrix): TransformNode;
  14502. /**
  14503. * Returns the mesh Pose matrix.
  14504. * @returns the pose matrix
  14505. */
  14506. getPoseMatrix(): Matrix;
  14507. /** @hidden */
  14508. _isSynchronized(): boolean;
  14509. /** @hidden */
  14510. _initCache(): void;
  14511. /**
  14512. * Flag the transform node as dirty (Forcing it to update everything)
  14513. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14514. * @returns this transform node
  14515. */
  14516. markAsDirty(property: string): TransformNode;
  14517. /**
  14518. * Returns the current mesh absolute position.
  14519. * Returns a Vector3.
  14520. */
  14521. get absolutePosition(): Vector3;
  14522. /**
  14523. * Returns the current mesh absolute scaling.
  14524. * Returns a Vector3.
  14525. */
  14526. get absoluteScaling(): Vector3;
  14527. /**
  14528. * Returns the current mesh absolute rotation.
  14529. * Returns a Quaternion.
  14530. */
  14531. get absoluteRotationQuaternion(): Quaternion;
  14532. /**
  14533. * Sets a new matrix to apply before all other transformation
  14534. * @param matrix defines the transform matrix
  14535. * @returns the current TransformNode
  14536. */
  14537. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14538. /**
  14539. * Sets a new pivot matrix to the current node
  14540. * @param matrix defines the new pivot matrix to use
  14541. * @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
  14542. * @returns the current TransformNode
  14543. */
  14544. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14545. /**
  14546. * Returns the mesh pivot matrix.
  14547. * Default : Identity.
  14548. * @returns the matrix
  14549. */
  14550. getPivotMatrix(): Matrix;
  14551. /**
  14552. * Instantiate (when possible) or clone that node with its hierarchy
  14553. * @param newParent defines the new parent to use for the instance (or clone)
  14554. * @param options defines options to configure how copy is done
  14555. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14556. * @returns an instance (or a clone) of the current node with its hiearchy
  14557. */
  14558. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14559. doNotInstantiate: boolean;
  14560. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14561. /**
  14562. * Prevents the World matrix to be computed any longer
  14563. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14564. * @returns the TransformNode.
  14565. */
  14566. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14567. /**
  14568. * Allows back the World matrix computation.
  14569. * @returns the TransformNode.
  14570. */
  14571. unfreezeWorldMatrix(): this;
  14572. /**
  14573. * True if the World matrix has been frozen.
  14574. */
  14575. get isWorldMatrixFrozen(): boolean;
  14576. /**
  14577. * Retuns the mesh absolute position in the World.
  14578. * @returns a Vector3.
  14579. */
  14580. getAbsolutePosition(): Vector3;
  14581. /**
  14582. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14583. * @param absolutePosition the absolute position to set
  14584. * @returns the TransformNode.
  14585. */
  14586. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14587. /**
  14588. * Sets the mesh position in its local space.
  14589. * @param vector3 the position to set in localspace
  14590. * @returns the TransformNode.
  14591. */
  14592. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14593. /**
  14594. * Returns the mesh position in the local space from the current World matrix values.
  14595. * @returns a new Vector3.
  14596. */
  14597. getPositionExpressedInLocalSpace(): Vector3;
  14598. /**
  14599. * Translates the mesh along the passed Vector3 in its local space.
  14600. * @param vector3 the distance to translate in localspace
  14601. * @returns the TransformNode.
  14602. */
  14603. locallyTranslate(vector3: Vector3): TransformNode;
  14604. private static _lookAtVectorCache;
  14605. /**
  14606. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14607. * @param targetPoint the position (must be in same space as current mesh) to look at
  14608. * @param yawCor optional yaw (y-axis) correction in radians
  14609. * @param pitchCor optional pitch (x-axis) correction in radians
  14610. * @param rollCor optional roll (z-axis) correction in radians
  14611. * @param space the choosen space of the target
  14612. * @returns the TransformNode.
  14613. */
  14614. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14615. /**
  14616. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14617. * This Vector3 is expressed in the World space.
  14618. * @param localAxis axis to rotate
  14619. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14620. */
  14621. getDirection(localAxis: Vector3): Vector3;
  14622. /**
  14623. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14624. * localAxis is expressed in the mesh local space.
  14625. * result is computed in the Wordl space from the mesh World matrix.
  14626. * @param localAxis axis to rotate
  14627. * @param result the resulting transformnode
  14628. * @returns this TransformNode.
  14629. */
  14630. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14631. /**
  14632. * Sets this transform node rotation to the given local axis.
  14633. * @param localAxis the axis in local space
  14634. * @param yawCor optional yaw (y-axis) correction in radians
  14635. * @param pitchCor optional pitch (x-axis) correction in radians
  14636. * @param rollCor optional roll (z-axis) correction in radians
  14637. * @returns this TransformNode
  14638. */
  14639. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14640. /**
  14641. * Sets a new pivot point to the current node
  14642. * @param point defines the new pivot point to use
  14643. * @param space defines if the point is in world or local space (local by default)
  14644. * @returns the current TransformNode
  14645. */
  14646. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14647. /**
  14648. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14649. * @returns the pivot point
  14650. */
  14651. getPivotPoint(): Vector3;
  14652. /**
  14653. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14654. * @param result the vector3 to store the result
  14655. * @returns this TransformNode.
  14656. */
  14657. getPivotPointToRef(result: Vector3): TransformNode;
  14658. /**
  14659. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14660. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14661. */
  14662. getAbsolutePivotPoint(): Vector3;
  14663. /**
  14664. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14665. * @param result vector3 to store the result
  14666. * @returns this TransformNode.
  14667. */
  14668. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14669. /**
  14670. * Defines the passed node as the parent of the current node.
  14671. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14672. * @see https://doc.babylonjs.com/how_to/parenting
  14673. * @param node the node ot set as the parent
  14674. * @returns this TransformNode.
  14675. */
  14676. setParent(node: Nullable<Node>): TransformNode;
  14677. private _nonUniformScaling;
  14678. /**
  14679. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14680. */
  14681. get nonUniformScaling(): boolean;
  14682. /** @hidden */
  14683. _updateNonUniformScalingState(value: boolean): boolean;
  14684. /**
  14685. * Attach the current TransformNode to another TransformNode associated with a bone
  14686. * @param bone Bone affecting the TransformNode
  14687. * @param affectedTransformNode TransformNode associated with the bone
  14688. * @returns this object
  14689. */
  14690. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14691. /**
  14692. * Detach the transform node if its associated with a bone
  14693. * @returns this object
  14694. */
  14695. detachFromBone(): TransformNode;
  14696. private static _rotationAxisCache;
  14697. /**
  14698. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14699. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14700. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14701. * The passed axis is also normalized.
  14702. * @param axis the axis to rotate around
  14703. * @param amount the amount to rotate in radians
  14704. * @param space Space to rotate in (Default: local)
  14705. * @returns the TransformNode.
  14706. */
  14707. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14708. /**
  14709. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14710. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14711. * The passed axis is also normalized. .
  14712. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14713. * @param point the point to rotate around
  14714. * @param axis the axis to rotate around
  14715. * @param amount the amount to rotate in radians
  14716. * @returns the TransformNode
  14717. */
  14718. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14719. /**
  14720. * Translates the mesh along the axis vector for the passed distance in the given space.
  14721. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14722. * @param axis the axis to translate in
  14723. * @param distance the distance to translate
  14724. * @param space Space to rotate in (Default: local)
  14725. * @returns the TransformNode.
  14726. */
  14727. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14728. /**
  14729. * Adds a rotation step to the mesh current rotation.
  14730. * x, y, z are Euler angles expressed in radians.
  14731. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14732. * This means this rotation is made in the mesh local space only.
  14733. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14734. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14735. * ```javascript
  14736. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14737. * ```
  14738. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14739. * 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.
  14740. * @param x Rotation to add
  14741. * @param y Rotation to add
  14742. * @param z Rotation to add
  14743. * @returns the TransformNode.
  14744. */
  14745. addRotation(x: number, y: number, z: number): TransformNode;
  14746. /**
  14747. * @hidden
  14748. */
  14749. protected _getEffectiveParent(): Nullable<Node>;
  14750. /**
  14751. * Computes the world matrix of the node
  14752. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14753. * @returns the world matrix
  14754. */
  14755. computeWorldMatrix(force?: boolean): Matrix;
  14756. protected _afterComputeWorldMatrix(): void;
  14757. /**
  14758. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14759. * @param func callback function to add
  14760. *
  14761. * @returns the TransformNode.
  14762. */
  14763. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14764. /**
  14765. * Removes a registered callback function.
  14766. * @param func callback function to remove
  14767. * @returns the TransformNode.
  14768. */
  14769. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14770. /**
  14771. * Gets the position of the current mesh in camera space
  14772. * @param camera defines the camera to use
  14773. * @returns a position
  14774. */
  14775. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14776. /**
  14777. * Returns the distance from the mesh to the active camera
  14778. * @param camera defines the camera to use
  14779. * @returns the distance
  14780. */
  14781. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14782. /**
  14783. * Clone the current transform node
  14784. * @param name Name of the new clone
  14785. * @param newParent New parent for the clone
  14786. * @param doNotCloneChildren Do not clone children hierarchy
  14787. * @returns the new transform node
  14788. */
  14789. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14790. /**
  14791. * Serializes the objects information.
  14792. * @param currentSerializationObject defines the object to serialize in
  14793. * @returns the serialized object
  14794. */
  14795. serialize(currentSerializationObject?: any): any;
  14796. /**
  14797. * Returns a new TransformNode object parsed from the source provided.
  14798. * @param parsedTransformNode is the source.
  14799. * @param scene the scne the object belongs to
  14800. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14801. * @returns a new TransformNode object parsed from the source provided.
  14802. */
  14803. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14804. /**
  14805. * Get all child-transformNodes of this node
  14806. * @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
  14807. * @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
  14808. * @returns an array of TransformNode
  14809. */
  14810. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14811. /**
  14812. * Releases resources associated with this transform node.
  14813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14815. */
  14816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14817. /**
  14818. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14819. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14820. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14821. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14822. * @returns the current mesh
  14823. */
  14824. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14825. private _syncAbsoluteScalingAndRotation;
  14826. }
  14827. }
  14828. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14829. import { Observable } from "babylonjs/Misc/observable";
  14830. import { Nullable } from "babylonjs/types";
  14831. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14834. import { Ray } from "babylonjs/Culling/ray";
  14835. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14836. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14837. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14838. /**
  14839. * Defines the types of pose enabled controllers that are supported
  14840. */
  14841. export enum PoseEnabledControllerType {
  14842. /**
  14843. * HTC Vive
  14844. */
  14845. VIVE = 0,
  14846. /**
  14847. * Oculus Rift
  14848. */
  14849. OCULUS = 1,
  14850. /**
  14851. * Windows mixed reality
  14852. */
  14853. WINDOWS = 2,
  14854. /**
  14855. * Samsung gear VR
  14856. */
  14857. GEAR_VR = 3,
  14858. /**
  14859. * Google Daydream
  14860. */
  14861. DAYDREAM = 4,
  14862. /**
  14863. * Generic
  14864. */
  14865. GENERIC = 5
  14866. }
  14867. /**
  14868. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14869. */
  14870. export interface MutableGamepadButton {
  14871. /**
  14872. * Value of the button/trigger
  14873. */
  14874. value: number;
  14875. /**
  14876. * If the button/trigger is currently touched
  14877. */
  14878. touched: boolean;
  14879. /**
  14880. * If the button/trigger is currently pressed
  14881. */
  14882. pressed: boolean;
  14883. }
  14884. /**
  14885. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14886. * @hidden
  14887. */
  14888. export interface ExtendedGamepadButton extends GamepadButton {
  14889. /**
  14890. * If the button/trigger is currently pressed
  14891. */
  14892. readonly pressed: boolean;
  14893. /**
  14894. * If the button/trigger is currently touched
  14895. */
  14896. readonly touched: boolean;
  14897. /**
  14898. * Value of the button/trigger
  14899. */
  14900. readonly value: number;
  14901. }
  14902. /** @hidden */
  14903. export interface _GamePadFactory {
  14904. /**
  14905. * Returns wether or not the current gamepad can be created for this type of controller.
  14906. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14907. * @returns true if it can be created, otherwise false
  14908. */
  14909. canCreate(gamepadInfo: any): boolean;
  14910. /**
  14911. * Creates a new instance of the Gamepad.
  14912. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14913. * @returns the new gamepad instance
  14914. */
  14915. create(gamepadInfo: any): Gamepad;
  14916. }
  14917. /**
  14918. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14919. */
  14920. export class PoseEnabledControllerHelper {
  14921. /** @hidden */
  14922. static _ControllerFactories: _GamePadFactory[];
  14923. /** @hidden */
  14924. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14925. /**
  14926. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14927. * @param vrGamepad the gamepad to initialized
  14928. * @returns a vr controller of the type the gamepad identified as
  14929. */
  14930. static InitiateController(vrGamepad: any): Gamepad;
  14931. }
  14932. /**
  14933. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14934. */
  14935. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14936. /**
  14937. * If the controller is used in a webXR session
  14938. */
  14939. isXR: boolean;
  14940. private _deviceRoomPosition;
  14941. private _deviceRoomRotationQuaternion;
  14942. /**
  14943. * The device position in babylon space
  14944. */
  14945. devicePosition: Vector3;
  14946. /**
  14947. * The device rotation in babylon space
  14948. */
  14949. deviceRotationQuaternion: Quaternion;
  14950. /**
  14951. * The scale factor of the device in babylon space
  14952. */
  14953. deviceScaleFactor: number;
  14954. /**
  14955. * (Likely devicePosition should be used instead) The device position in its room space
  14956. */
  14957. position: Vector3;
  14958. /**
  14959. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14960. */
  14961. rotationQuaternion: Quaternion;
  14962. /**
  14963. * The type of controller (Eg. Windows mixed reality)
  14964. */
  14965. controllerType: PoseEnabledControllerType;
  14966. protected _calculatedPosition: Vector3;
  14967. private _calculatedRotation;
  14968. /**
  14969. * The raw pose from the device
  14970. */
  14971. rawPose: DevicePose;
  14972. private _trackPosition;
  14973. private _maxRotationDistFromHeadset;
  14974. private _draggedRoomRotation;
  14975. /**
  14976. * @hidden
  14977. */
  14978. _disableTrackPosition(fixedPosition: Vector3): void;
  14979. /**
  14980. * Internal, the mesh attached to the controller
  14981. * @hidden
  14982. */
  14983. _mesh: Nullable<AbstractMesh>;
  14984. private _poseControlledCamera;
  14985. private _leftHandSystemQuaternion;
  14986. /**
  14987. * Internal, matrix used to convert room space to babylon space
  14988. * @hidden
  14989. */
  14990. _deviceToWorld: Matrix;
  14991. /**
  14992. * Node to be used when casting a ray from the controller
  14993. * @hidden
  14994. */
  14995. _pointingPoseNode: Nullable<TransformNode>;
  14996. /**
  14997. * Name of the child mesh that can be used to cast a ray from the controller
  14998. */
  14999. static readonly POINTING_POSE: string;
  15000. /**
  15001. * Creates a new PoseEnabledController from a gamepad
  15002. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15003. */
  15004. constructor(browserGamepad: any);
  15005. private _workingMatrix;
  15006. /**
  15007. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15008. */
  15009. update(): void;
  15010. /**
  15011. * Updates only the pose device and mesh without doing any button event checking
  15012. */
  15013. protected _updatePoseAndMesh(): void;
  15014. /**
  15015. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15016. * @param poseData raw pose fromthe device
  15017. */
  15018. updateFromDevice(poseData: DevicePose): void;
  15019. /**
  15020. * @hidden
  15021. */
  15022. _meshAttachedObservable: Observable<AbstractMesh>;
  15023. /**
  15024. * Attaches a mesh to the controller
  15025. * @param mesh the mesh to be attached
  15026. */
  15027. attachToMesh(mesh: AbstractMesh): void;
  15028. /**
  15029. * Attaches the controllers mesh to a camera
  15030. * @param camera the camera the mesh should be attached to
  15031. */
  15032. attachToPoseControlledCamera(camera: TargetCamera): void;
  15033. /**
  15034. * Disposes of the controller
  15035. */
  15036. dispose(): void;
  15037. /**
  15038. * The mesh that is attached to the controller
  15039. */
  15040. get mesh(): Nullable<AbstractMesh>;
  15041. /**
  15042. * Gets the ray of the controller in the direction the controller is pointing
  15043. * @param length the length the resulting ray should be
  15044. * @returns a ray in the direction the controller is pointing
  15045. */
  15046. getForwardRay(length?: number): Ray;
  15047. }
  15048. }
  15049. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Scene } from "babylonjs/scene";
  15052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15053. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15054. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15055. import { Nullable } from "babylonjs/types";
  15056. /**
  15057. * Defines the WebVRController object that represents controllers tracked in 3D space
  15058. */
  15059. export abstract class WebVRController extends PoseEnabledController {
  15060. /**
  15061. * Internal, the default controller model for the controller
  15062. */
  15063. protected _defaultModel: Nullable<AbstractMesh>;
  15064. /**
  15065. * Fired when the trigger state has changed
  15066. */
  15067. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15068. /**
  15069. * Fired when the main button state has changed
  15070. */
  15071. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15072. /**
  15073. * Fired when the secondary button state has changed
  15074. */
  15075. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15076. /**
  15077. * Fired when the pad state has changed
  15078. */
  15079. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15080. /**
  15081. * Fired when controllers stick values have changed
  15082. */
  15083. onPadValuesChangedObservable: Observable<StickValues>;
  15084. /**
  15085. * Array of button availible on the controller
  15086. */
  15087. protected _buttons: Array<MutableGamepadButton>;
  15088. private _onButtonStateChange;
  15089. /**
  15090. * Fired when a controller button's state has changed
  15091. * @param callback the callback containing the button that was modified
  15092. */
  15093. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15094. /**
  15095. * X and Y axis corresponding to the controllers joystick
  15096. */
  15097. pad: StickValues;
  15098. /**
  15099. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15100. */
  15101. hand: string;
  15102. /**
  15103. * The default controller model for the controller
  15104. */
  15105. get defaultModel(): Nullable<AbstractMesh>;
  15106. /**
  15107. * Creates a new WebVRController from a gamepad
  15108. * @param vrGamepad the gamepad that the WebVRController should be created from
  15109. */
  15110. constructor(vrGamepad: any);
  15111. /**
  15112. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15113. */
  15114. update(): void;
  15115. /**
  15116. * Function to be called when a button is modified
  15117. */
  15118. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15119. /**
  15120. * Loads a mesh and attaches it to the controller
  15121. * @param scene the scene the mesh should be added to
  15122. * @param meshLoaded callback for when the mesh has been loaded
  15123. */
  15124. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15125. private _setButtonValue;
  15126. private _changes;
  15127. private _checkChanges;
  15128. /**
  15129. * Disposes of th webVRCOntroller
  15130. */
  15131. dispose(): void;
  15132. }
  15133. }
  15134. declare module "babylonjs/Lights/hemisphericLight" {
  15135. import { Nullable } from "babylonjs/types";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15138. import { Color3 } from "babylonjs/Maths/math.color";
  15139. import { Effect } from "babylonjs/Materials/effect";
  15140. import { Light } from "babylonjs/Lights/light";
  15141. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15142. /**
  15143. * The HemisphericLight simulates the ambient environment light,
  15144. * so the passed direction is the light reflection direction, not the incoming direction.
  15145. */
  15146. export class HemisphericLight extends Light {
  15147. /**
  15148. * The groundColor is the light in the opposite direction to the one specified during creation.
  15149. * 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.
  15150. */
  15151. groundColor: Color3;
  15152. /**
  15153. * The light reflection direction, not the incoming direction.
  15154. */
  15155. direction: Vector3;
  15156. /**
  15157. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15158. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15159. * The HemisphericLight can't cast shadows.
  15160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15161. * @param name The friendly name of the light
  15162. * @param direction The direction of the light reflection
  15163. * @param scene The scene the light belongs to
  15164. */
  15165. constructor(name: string, direction: Vector3, scene: Scene);
  15166. protected _buildUniformLayout(): void;
  15167. /**
  15168. * Returns the string "HemisphericLight".
  15169. * @return The class name
  15170. */
  15171. getClassName(): string;
  15172. /**
  15173. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15174. * Returns the updated direction.
  15175. * @param target The target the direction should point to
  15176. * @return The computed direction
  15177. */
  15178. setDirectionToTarget(target: Vector3): Vector3;
  15179. /**
  15180. * Returns the shadow generator associated to the light.
  15181. * @returns Always null for hemispheric lights because it does not support shadows.
  15182. */
  15183. getShadowGenerator(): Nullable<IShadowGenerator>;
  15184. /**
  15185. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15186. * @param effect The effect to update
  15187. * @param lightIndex The index of the light in the effect to update
  15188. * @returns The hemispheric light
  15189. */
  15190. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15192. /**
  15193. * Computes the world matrix of the node
  15194. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15195. * @param useWasUpdatedFlag defines a reserved property
  15196. * @returns the world matrix
  15197. */
  15198. computeWorldMatrix(): Matrix;
  15199. /**
  15200. * Returns the integer 3.
  15201. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15202. */
  15203. getTypeID(): number;
  15204. /**
  15205. * Prepares the list of defines specific to the light type.
  15206. * @param defines the list of defines
  15207. * @param lightIndex defines the index of the light for the effect
  15208. */
  15209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15210. }
  15211. }
  15212. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15213. /** @hidden */
  15214. export var vrMultiviewToSingleviewPixelShader: {
  15215. name: string;
  15216. shader: string;
  15217. };
  15218. }
  15219. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15220. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15221. import { Scene } from "babylonjs/scene";
  15222. /**
  15223. * Renders to multiple views with a single draw call
  15224. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15225. */
  15226. export class MultiviewRenderTarget extends RenderTargetTexture {
  15227. /**
  15228. * Creates a multiview render target
  15229. * @param scene scene used with the render target
  15230. * @param size the size of the render target (used for each view)
  15231. */
  15232. constructor(scene: Scene, size?: number | {
  15233. width: number;
  15234. height: number;
  15235. } | {
  15236. ratio: number;
  15237. });
  15238. /**
  15239. * @hidden
  15240. * @param faceIndex the face index, if its a cube texture
  15241. */
  15242. _bindFrameBuffer(faceIndex?: number): void;
  15243. /**
  15244. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15245. * @returns the view count
  15246. */
  15247. getViewCount(): number;
  15248. }
  15249. }
  15250. declare module "babylonjs/Maths/math.frustum" {
  15251. import { Matrix } from "babylonjs/Maths/math.vector";
  15252. import { DeepImmutable } from "babylonjs/types";
  15253. import { Plane } from "babylonjs/Maths/math.plane";
  15254. /**
  15255. * Represents a camera frustum
  15256. */
  15257. export class Frustum {
  15258. /**
  15259. * Gets the planes representing the frustum
  15260. * @param transform matrix to be applied to the returned planes
  15261. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15262. */
  15263. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15264. /**
  15265. * Gets the near frustum plane transformed by the transform matrix
  15266. * @param transform transformation matrix to be applied to the resulting frustum plane
  15267. * @param frustumPlane the resuling frustum plane
  15268. */
  15269. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15270. /**
  15271. * Gets the far frustum plane transformed by the transform matrix
  15272. * @param transform transformation matrix to be applied to the resulting frustum plane
  15273. * @param frustumPlane the resuling frustum plane
  15274. */
  15275. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15276. /**
  15277. * Gets the left frustum plane transformed by the transform matrix
  15278. * @param transform transformation matrix to be applied to the resulting frustum plane
  15279. * @param frustumPlane the resuling frustum plane
  15280. */
  15281. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15282. /**
  15283. * Gets the right frustum plane transformed by the transform matrix
  15284. * @param transform transformation matrix to be applied to the resulting frustum plane
  15285. * @param frustumPlane the resuling frustum plane
  15286. */
  15287. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15288. /**
  15289. * Gets the top frustum plane transformed by the transform matrix
  15290. * @param transform transformation matrix to be applied to the resulting frustum plane
  15291. * @param frustumPlane the resuling frustum plane
  15292. */
  15293. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15294. /**
  15295. * Gets the bottom frustum plane transformed by the transform matrix
  15296. * @param transform transformation matrix to be applied to the resulting frustum plane
  15297. * @param frustumPlane the resuling frustum plane
  15298. */
  15299. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15300. /**
  15301. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15302. * @param transform transformation matrix to be applied to the resulting frustum planes
  15303. * @param frustumPlanes the resuling frustum planes
  15304. */
  15305. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15306. }
  15307. }
  15308. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15309. import { Camera } from "babylonjs/Cameras/camera";
  15310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15311. import { Nullable } from "babylonjs/types";
  15312. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15313. import { Matrix } from "babylonjs/Maths/math.vector";
  15314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15315. module "babylonjs/Engines/engine" {
  15316. interface Engine {
  15317. /**
  15318. * Creates a new multiview render target
  15319. * @param width defines the width of the texture
  15320. * @param height defines the height of the texture
  15321. * @returns the created multiview texture
  15322. */
  15323. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15324. /**
  15325. * Binds a multiview framebuffer to be drawn to
  15326. * @param multiviewTexture texture to bind
  15327. */
  15328. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15329. }
  15330. }
  15331. module "babylonjs/Cameras/camera" {
  15332. interface Camera {
  15333. /**
  15334. * @hidden
  15335. * 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)
  15336. */
  15337. _useMultiviewToSingleView: boolean;
  15338. /**
  15339. * @hidden
  15340. * 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)
  15341. */
  15342. _multiviewTexture: Nullable<RenderTargetTexture>;
  15343. /**
  15344. * @hidden
  15345. * ensures the multiview texture of the camera exists and has the specified width/height
  15346. * @param width height to set on the multiview texture
  15347. * @param height width to set on the multiview texture
  15348. */
  15349. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15350. }
  15351. }
  15352. module "babylonjs/scene" {
  15353. interface Scene {
  15354. /** @hidden */
  15355. _transformMatrixR: Matrix;
  15356. /** @hidden */
  15357. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15358. /** @hidden */
  15359. _createMultiviewUbo(): void;
  15360. /** @hidden */
  15361. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15362. /** @hidden */
  15363. _renderMultiviewToSingleView(camera: Camera): void;
  15364. }
  15365. }
  15366. }
  15367. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15368. import { Camera } from "babylonjs/Cameras/camera";
  15369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15370. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15371. import "babylonjs/Engines/Extensions/engine.multiview";
  15372. /**
  15373. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15374. * This will not be used for webXR as it supports displaying texture arrays directly
  15375. */
  15376. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15377. /**
  15378. * Initializes a VRMultiviewToSingleview
  15379. * @param name name of the post process
  15380. * @param camera camera to be applied to
  15381. * @param scaleFactor scaling factor to the size of the output texture
  15382. */
  15383. constructor(name: string, camera: Camera, scaleFactor: number);
  15384. }
  15385. }
  15386. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15387. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15388. import { Nullable } from "babylonjs/types";
  15389. import { Size } from "babylonjs/Maths/math.size";
  15390. import { Observable } from "babylonjs/Misc/observable";
  15391. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15392. /**
  15393. * Interface used to define additional presentation attributes
  15394. */
  15395. export interface IVRPresentationAttributes {
  15396. /**
  15397. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15398. */
  15399. highRefreshRate: boolean;
  15400. /**
  15401. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15402. */
  15403. foveationLevel: number;
  15404. }
  15405. module "babylonjs/Engines/engine" {
  15406. interface Engine {
  15407. /** @hidden */
  15408. _vrDisplay: any;
  15409. /** @hidden */
  15410. _vrSupported: boolean;
  15411. /** @hidden */
  15412. _oldSize: Size;
  15413. /** @hidden */
  15414. _oldHardwareScaleFactor: number;
  15415. /** @hidden */
  15416. _vrExclusivePointerMode: boolean;
  15417. /** @hidden */
  15418. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15419. /** @hidden */
  15420. _onVRDisplayPointerRestricted: () => void;
  15421. /** @hidden */
  15422. _onVRDisplayPointerUnrestricted: () => void;
  15423. /** @hidden */
  15424. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15425. /** @hidden */
  15426. _onVrDisplayDisconnect: Nullable<() => void>;
  15427. /** @hidden */
  15428. _onVrDisplayPresentChange: Nullable<() => void>;
  15429. /**
  15430. * Observable signaled when VR display mode changes
  15431. */
  15432. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15433. /**
  15434. * Observable signaled when VR request present is complete
  15435. */
  15436. onVRRequestPresentComplete: Observable<boolean>;
  15437. /**
  15438. * Observable signaled when VR request present starts
  15439. */
  15440. onVRRequestPresentStart: Observable<Engine>;
  15441. /**
  15442. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15443. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15444. */
  15445. isInVRExclusivePointerMode: boolean;
  15446. /**
  15447. * Gets a boolean indicating if a webVR device was detected
  15448. * @returns true if a webVR device was detected
  15449. */
  15450. isVRDevicePresent(): boolean;
  15451. /**
  15452. * Gets the current webVR device
  15453. * @returns the current webVR device (or null)
  15454. */
  15455. getVRDevice(): any;
  15456. /**
  15457. * Initializes a webVR display and starts listening to display change events
  15458. * The onVRDisplayChangedObservable will be notified upon these changes
  15459. * @returns A promise containing a VRDisplay and if vr is supported
  15460. */
  15461. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15462. /** @hidden */
  15463. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15464. /**
  15465. * Gets or sets the presentation attributes used to configure VR rendering
  15466. */
  15467. vrPresentationAttributes?: IVRPresentationAttributes;
  15468. /**
  15469. * Call this function to switch to webVR mode
  15470. * Will do nothing if webVR is not supported or if there is no webVR device
  15471. * @param options the webvr options provided to the camera. mainly used for multiview
  15472. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15473. */
  15474. enableVR(options: WebVROptions): void;
  15475. /** @hidden */
  15476. _onVRFullScreenTriggered(): void;
  15477. }
  15478. }
  15479. }
  15480. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15481. import { Nullable } from "babylonjs/types";
  15482. import { Observable } from "babylonjs/Misc/observable";
  15483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15484. import { Scene } from "babylonjs/scene";
  15485. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15486. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15487. import { Node } from "babylonjs/node";
  15488. import { Ray } from "babylonjs/Culling/ray";
  15489. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15490. import "babylonjs/Engines/Extensions/engine.webVR";
  15491. /**
  15492. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15493. * IMPORTANT!! The data is right-hand data.
  15494. * @export
  15495. * @interface DevicePose
  15496. */
  15497. export interface DevicePose {
  15498. /**
  15499. * The position of the device, values in array are [x,y,z].
  15500. */
  15501. readonly position: Nullable<Float32Array>;
  15502. /**
  15503. * The linearVelocity of the device, values in array are [x,y,z].
  15504. */
  15505. readonly linearVelocity: Nullable<Float32Array>;
  15506. /**
  15507. * The linearAcceleration of the device, values in array are [x,y,z].
  15508. */
  15509. readonly linearAcceleration: Nullable<Float32Array>;
  15510. /**
  15511. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15512. */
  15513. readonly orientation: Nullable<Float32Array>;
  15514. /**
  15515. * The angularVelocity of the device, values in array are [x,y,z].
  15516. */
  15517. readonly angularVelocity: Nullable<Float32Array>;
  15518. /**
  15519. * The angularAcceleration of the device, values in array are [x,y,z].
  15520. */
  15521. readonly angularAcceleration: Nullable<Float32Array>;
  15522. }
  15523. /**
  15524. * Interface representing a pose controlled object in Babylon.
  15525. * A pose controlled object has both regular pose values as well as pose values
  15526. * from an external device such as a VR head mounted display
  15527. */
  15528. export interface PoseControlled {
  15529. /**
  15530. * The position of the object in babylon space.
  15531. */
  15532. position: Vector3;
  15533. /**
  15534. * The rotation quaternion of the object in babylon space.
  15535. */
  15536. rotationQuaternion: Quaternion;
  15537. /**
  15538. * The position of the device in babylon space.
  15539. */
  15540. devicePosition?: Vector3;
  15541. /**
  15542. * The rotation quaternion of the device in babylon space.
  15543. */
  15544. deviceRotationQuaternion: Quaternion;
  15545. /**
  15546. * The raw pose coming from the device.
  15547. */
  15548. rawPose: Nullable<DevicePose>;
  15549. /**
  15550. * The scale of the device to be used when translating from device space to babylon space.
  15551. */
  15552. deviceScaleFactor: number;
  15553. /**
  15554. * Updates the poseControlled values based on the input device pose.
  15555. * @param poseData the pose data to update the object with
  15556. */
  15557. updateFromDevice(poseData: DevicePose): void;
  15558. }
  15559. /**
  15560. * Set of options to customize the webVRCamera
  15561. */
  15562. export interface WebVROptions {
  15563. /**
  15564. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15565. */
  15566. trackPosition?: boolean;
  15567. /**
  15568. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15569. */
  15570. positionScale?: number;
  15571. /**
  15572. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15573. */
  15574. displayName?: string;
  15575. /**
  15576. * Should the native controller meshes be initialized. (default: true)
  15577. */
  15578. controllerMeshes?: boolean;
  15579. /**
  15580. * Creating a default HemiLight only on controllers. (default: true)
  15581. */
  15582. defaultLightingOnControllers?: boolean;
  15583. /**
  15584. * If you don't want to use the default VR button of the helper. (default: false)
  15585. */
  15586. useCustomVRButton?: boolean;
  15587. /**
  15588. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15589. */
  15590. customVRButton?: HTMLButtonElement;
  15591. /**
  15592. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15593. */
  15594. rayLength?: number;
  15595. /**
  15596. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15597. */
  15598. defaultHeight?: number;
  15599. /**
  15600. * If multiview should be used if availible (default: false)
  15601. */
  15602. useMultiview?: boolean;
  15603. }
  15604. /**
  15605. * This represents a WebVR camera.
  15606. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15607. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15608. */
  15609. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15610. private webVROptions;
  15611. /**
  15612. * @hidden
  15613. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15614. */
  15615. _vrDevice: any;
  15616. /**
  15617. * The rawPose of the vrDevice.
  15618. */
  15619. rawPose: Nullable<DevicePose>;
  15620. private _onVREnabled;
  15621. private _specsVersion;
  15622. private _attached;
  15623. private _frameData;
  15624. protected _descendants: Array<Node>;
  15625. private _deviceRoomPosition;
  15626. /** @hidden */
  15627. _deviceRoomRotationQuaternion: Quaternion;
  15628. private _standingMatrix;
  15629. /**
  15630. * Represents device position in babylon space.
  15631. */
  15632. devicePosition: Vector3;
  15633. /**
  15634. * Represents device rotation in babylon space.
  15635. */
  15636. deviceRotationQuaternion: Quaternion;
  15637. /**
  15638. * The scale of the device to be used when translating from device space to babylon space.
  15639. */
  15640. deviceScaleFactor: number;
  15641. private _deviceToWorld;
  15642. private _worldToDevice;
  15643. /**
  15644. * References to the webVR controllers for the vrDevice.
  15645. */
  15646. controllers: Array<WebVRController>;
  15647. /**
  15648. * Emits an event when a controller is attached.
  15649. */
  15650. onControllersAttachedObservable: Observable<WebVRController[]>;
  15651. /**
  15652. * Emits an event when a controller's mesh has been loaded;
  15653. */
  15654. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15655. /**
  15656. * Emits an event when the HMD's pose has been updated.
  15657. */
  15658. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15659. private _poseSet;
  15660. /**
  15661. * If the rig cameras be used as parent instead of this camera.
  15662. */
  15663. rigParenting: boolean;
  15664. private _lightOnControllers;
  15665. private _defaultHeight?;
  15666. /**
  15667. * Instantiates a WebVRFreeCamera.
  15668. * @param name The name of the WebVRFreeCamera
  15669. * @param position The starting anchor position for the camera
  15670. * @param scene The scene the camera belongs to
  15671. * @param webVROptions a set of customizable options for the webVRCamera
  15672. */
  15673. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15674. /**
  15675. * Gets the device distance from the ground in meters.
  15676. * @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.
  15677. */
  15678. deviceDistanceToRoomGround(): number;
  15679. /**
  15680. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15681. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15682. */
  15683. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15684. /**
  15685. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15686. * @returns A promise with a boolean set to if the standing matrix is supported.
  15687. */
  15688. useStandingMatrixAsync(): Promise<boolean>;
  15689. /**
  15690. * Disposes the camera
  15691. */
  15692. dispose(): void;
  15693. /**
  15694. * Gets a vrController by name.
  15695. * @param name The name of the controller to retreive
  15696. * @returns the controller matching the name specified or null if not found
  15697. */
  15698. getControllerByName(name: string): Nullable<WebVRController>;
  15699. private _leftController;
  15700. /**
  15701. * The controller corresponding to the users left hand.
  15702. */
  15703. get leftController(): Nullable<WebVRController>;
  15704. private _rightController;
  15705. /**
  15706. * The controller corresponding to the users right hand.
  15707. */
  15708. get rightController(): Nullable<WebVRController>;
  15709. /**
  15710. * Casts a ray forward from the vrCamera's gaze.
  15711. * @param length Length of the ray (default: 100)
  15712. * @returns the ray corresponding to the gaze
  15713. */
  15714. getForwardRay(length?: number): Ray;
  15715. /**
  15716. * @hidden
  15717. * Updates the camera based on device's frame data
  15718. */
  15719. _checkInputs(): void;
  15720. /**
  15721. * Updates the poseControlled values based on the input device pose.
  15722. * @param poseData Pose coming from the device
  15723. */
  15724. updateFromDevice(poseData: DevicePose): void;
  15725. private _htmlElementAttached;
  15726. private _detachIfAttached;
  15727. /**
  15728. * WebVR's attach control will start broadcasting frames to the device.
  15729. * Note that in certain browsers (chrome for example) this function must be called
  15730. * within a user-interaction callback. Example:
  15731. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15732. *
  15733. * @param element html element to attach the vrDevice to
  15734. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15735. */
  15736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15737. /**
  15738. * Detaches the camera from the html element and disables VR
  15739. *
  15740. * @param element html element to detach from
  15741. */
  15742. detachControl(element: HTMLElement): void;
  15743. /**
  15744. * @returns the name of this class
  15745. */
  15746. getClassName(): string;
  15747. /**
  15748. * Calls resetPose on the vrDisplay
  15749. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15750. */
  15751. resetToCurrentRotation(): void;
  15752. /**
  15753. * @hidden
  15754. * Updates the rig cameras (left and right eye)
  15755. */
  15756. _updateRigCameras(): void;
  15757. private _workingVector;
  15758. private _oneVector;
  15759. private _workingMatrix;
  15760. private updateCacheCalled;
  15761. private _correctPositionIfNotTrackPosition;
  15762. /**
  15763. * @hidden
  15764. * Updates the cached values of the camera
  15765. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15766. */
  15767. _updateCache(ignoreParentClass?: boolean): void;
  15768. /**
  15769. * @hidden
  15770. * Get current device position in babylon world
  15771. */
  15772. _computeDevicePosition(): void;
  15773. /**
  15774. * Updates the current device position and rotation in the babylon world
  15775. */
  15776. update(): void;
  15777. /**
  15778. * @hidden
  15779. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15780. * @returns an identity matrix
  15781. */
  15782. _getViewMatrix(): Matrix;
  15783. private _tmpMatrix;
  15784. /**
  15785. * This function is called by the two RIG cameras.
  15786. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15787. * @hidden
  15788. */
  15789. _getWebVRViewMatrix(): Matrix;
  15790. /** @hidden */
  15791. _getWebVRProjectionMatrix(): Matrix;
  15792. private _onGamepadConnectedObserver;
  15793. private _onGamepadDisconnectedObserver;
  15794. private _updateCacheWhenTrackingDisabledObserver;
  15795. /**
  15796. * Initializes the controllers and their meshes
  15797. */
  15798. initControllers(): void;
  15799. }
  15800. }
  15801. declare module "babylonjs/PostProcesses/postProcess" {
  15802. import { Nullable } from "babylonjs/types";
  15803. import { SmartArray } from "babylonjs/Misc/smartArray";
  15804. import { Observable } from "babylonjs/Misc/observable";
  15805. import { Vector2 } from "babylonjs/Maths/math.vector";
  15806. import { Camera } from "babylonjs/Cameras/camera";
  15807. import { Effect } from "babylonjs/Materials/effect";
  15808. import "babylonjs/Shaders/postprocess.vertex";
  15809. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15810. import { Engine } from "babylonjs/Engines/engine";
  15811. import { Color4 } from "babylonjs/Maths/math.color";
  15812. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15814. /**
  15815. * Size options for a post process
  15816. */
  15817. export type PostProcessOptions = {
  15818. width: number;
  15819. height: number;
  15820. };
  15821. /**
  15822. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15823. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15824. */
  15825. export class PostProcess {
  15826. /** Name of the PostProcess. */
  15827. name: string;
  15828. /**
  15829. * Gets or sets the unique id of the post process
  15830. */
  15831. uniqueId: number;
  15832. /**
  15833. * Width of the texture to apply the post process on
  15834. */
  15835. width: number;
  15836. /**
  15837. * Height of the texture to apply the post process on
  15838. */
  15839. height: number;
  15840. /**
  15841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15842. * @hidden
  15843. */
  15844. _outputTexture: Nullable<InternalTexture>;
  15845. /**
  15846. * Sampling mode used by the shader
  15847. * See https://doc.babylonjs.com/classes/3.1/texture
  15848. */
  15849. renderTargetSamplingMode: number;
  15850. /**
  15851. * Clear color to use when screen clearing
  15852. */
  15853. clearColor: Color4;
  15854. /**
  15855. * If the buffer needs to be cleared before applying the post process. (default: true)
  15856. * Should be set to false if shader will overwrite all previous pixels.
  15857. */
  15858. autoClear: boolean;
  15859. /**
  15860. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15861. */
  15862. alphaMode: number;
  15863. /**
  15864. * Sets the setAlphaBlendConstants of the babylon engine
  15865. */
  15866. alphaConstants: Color4;
  15867. /**
  15868. * Animations to be used for the post processing
  15869. */
  15870. animations: import("babylonjs/Animations/animation").Animation[];
  15871. /**
  15872. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15873. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15874. */
  15875. enablePixelPerfectMode: boolean;
  15876. /**
  15877. * Force the postprocess to be applied without taking in account viewport
  15878. */
  15879. forceFullscreenViewport: boolean;
  15880. /**
  15881. * List of inspectable custom properties (used by the Inspector)
  15882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15883. */
  15884. inspectableCustomProperties: IInspectable[];
  15885. /**
  15886. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15887. *
  15888. * | Value | Type | Description |
  15889. * | ----- | ----------------------------------- | ----------- |
  15890. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15891. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15892. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15893. *
  15894. */
  15895. scaleMode: number;
  15896. /**
  15897. * Force textures to be a power of two (default: false)
  15898. */
  15899. alwaysForcePOT: boolean;
  15900. private _samples;
  15901. /**
  15902. * Number of sample textures (default: 1)
  15903. */
  15904. get samples(): number;
  15905. set samples(n: number);
  15906. /**
  15907. * Modify the scale of the post process to be the same as the viewport (default: false)
  15908. */
  15909. adaptScaleToCurrentViewport: boolean;
  15910. private _camera;
  15911. private _scene;
  15912. private _engine;
  15913. private _options;
  15914. private _reusable;
  15915. private _textureType;
  15916. /**
  15917. * Smart array of input and output textures for the post process.
  15918. * @hidden
  15919. */
  15920. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15921. /**
  15922. * The index in _textures that corresponds to the output texture.
  15923. * @hidden
  15924. */
  15925. _currentRenderTextureInd: number;
  15926. private _effect;
  15927. private _samplers;
  15928. private _fragmentUrl;
  15929. private _vertexUrl;
  15930. private _parameters;
  15931. private _scaleRatio;
  15932. protected _indexParameters: any;
  15933. private _shareOutputWithPostProcess;
  15934. private _texelSize;
  15935. private _forcedOutputTexture;
  15936. /**
  15937. * Returns the fragment url or shader name used in the post process.
  15938. * @returns the fragment url or name in the shader store.
  15939. */
  15940. getEffectName(): string;
  15941. /**
  15942. * An event triggered when the postprocess is activated.
  15943. */
  15944. onActivateObservable: Observable<Camera>;
  15945. private _onActivateObserver;
  15946. /**
  15947. * A function that is added to the onActivateObservable
  15948. */
  15949. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15950. /**
  15951. * An event triggered when the postprocess changes its size.
  15952. */
  15953. onSizeChangedObservable: Observable<PostProcess>;
  15954. private _onSizeChangedObserver;
  15955. /**
  15956. * A function that is added to the onSizeChangedObservable
  15957. */
  15958. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15959. /**
  15960. * An event triggered when the postprocess applies its effect.
  15961. */
  15962. onApplyObservable: Observable<Effect>;
  15963. private _onApplyObserver;
  15964. /**
  15965. * A function that is added to the onApplyObservable
  15966. */
  15967. set onApply(callback: (effect: Effect) => void);
  15968. /**
  15969. * An event triggered before rendering the postprocess
  15970. */
  15971. onBeforeRenderObservable: Observable<Effect>;
  15972. private _onBeforeRenderObserver;
  15973. /**
  15974. * A function that is added to the onBeforeRenderObservable
  15975. */
  15976. set onBeforeRender(callback: (effect: Effect) => void);
  15977. /**
  15978. * An event triggered after rendering the postprocess
  15979. */
  15980. onAfterRenderObservable: Observable<Effect>;
  15981. private _onAfterRenderObserver;
  15982. /**
  15983. * A function that is added to the onAfterRenderObservable
  15984. */
  15985. set onAfterRender(callback: (efect: Effect) => void);
  15986. /**
  15987. * 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
  15988. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15989. */
  15990. get inputTexture(): InternalTexture;
  15991. set inputTexture(value: InternalTexture);
  15992. /**
  15993. * Gets the camera which post process is applied to.
  15994. * @returns The camera the post process is applied to.
  15995. */
  15996. getCamera(): Camera;
  15997. /**
  15998. * Gets the texel size of the postprocess.
  15999. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16000. */
  16001. get texelSize(): Vector2;
  16002. /**
  16003. * Creates a new instance PostProcess
  16004. * @param name The name of the PostProcess.
  16005. * @param fragmentUrl The url of the fragment shader to be used.
  16006. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16007. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16008. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16009. * @param camera The camera to apply the render pass to.
  16010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16011. * @param engine The engine which the post process will be applied. (default: current engine)
  16012. * @param reusable If the post process can be reused on the same frame. (default: false)
  16013. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16014. * @param textureType Type of textures used when performing the post process. (default: 0)
  16015. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16016. * @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
  16017. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16018. */
  16019. constructor(
  16020. /** Name of the PostProcess. */
  16021. 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);
  16022. /**
  16023. * Gets a string idenfifying the name of the class
  16024. * @returns "PostProcess" string
  16025. */
  16026. getClassName(): string;
  16027. /**
  16028. * Gets the engine which this post process belongs to.
  16029. * @returns The engine the post process was enabled with.
  16030. */
  16031. getEngine(): Engine;
  16032. /**
  16033. * The effect that is created when initializing the post process.
  16034. * @returns The created effect corresponding the the postprocess.
  16035. */
  16036. getEffect(): Effect;
  16037. /**
  16038. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16039. * @param postProcess The post process to share the output with.
  16040. * @returns This post process.
  16041. */
  16042. shareOutputWith(postProcess: PostProcess): PostProcess;
  16043. /**
  16044. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16045. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16046. */
  16047. useOwnOutput(): void;
  16048. /**
  16049. * Updates the effect with the current post process compile time values and recompiles the shader.
  16050. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16051. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16052. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16053. * @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
  16054. * @param onCompiled Called when the shader has been compiled.
  16055. * @param onError Called if there is an error when compiling a shader.
  16056. */
  16057. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16058. /**
  16059. * The post process is reusable if it can be used multiple times within one frame.
  16060. * @returns If the post process is reusable
  16061. */
  16062. isReusable(): boolean;
  16063. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16064. markTextureDirty(): void;
  16065. /**
  16066. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16067. * 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.
  16068. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16069. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16070. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16071. * @returns The target texture that was bound to be written to.
  16072. */
  16073. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16074. /**
  16075. * If the post process is supported.
  16076. */
  16077. get isSupported(): boolean;
  16078. /**
  16079. * The aspect ratio of the output texture.
  16080. */
  16081. get aspectRatio(): number;
  16082. /**
  16083. * Get a value indicating if the post-process is ready to be used
  16084. * @returns true if the post-process is ready (shader is compiled)
  16085. */
  16086. isReady(): boolean;
  16087. /**
  16088. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16089. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16090. */
  16091. apply(): Nullable<Effect>;
  16092. private _disposeTextures;
  16093. /**
  16094. * Disposes the post process.
  16095. * @param camera The camera to dispose the post process on.
  16096. */
  16097. dispose(camera?: Camera): void;
  16098. }
  16099. }
  16100. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16101. /** @hidden */
  16102. export var kernelBlurVaryingDeclaration: {
  16103. name: string;
  16104. shader: string;
  16105. };
  16106. }
  16107. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16108. /** @hidden */
  16109. export var kernelBlurFragment: {
  16110. name: string;
  16111. shader: string;
  16112. };
  16113. }
  16114. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16115. /** @hidden */
  16116. export var kernelBlurFragment2: {
  16117. name: string;
  16118. shader: string;
  16119. };
  16120. }
  16121. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16122. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16123. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16124. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16125. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16126. /** @hidden */
  16127. export var kernelBlurPixelShader: {
  16128. name: string;
  16129. shader: string;
  16130. };
  16131. }
  16132. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16133. /** @hidden */
  16134. export var kernelBlurVertex: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16140. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16141. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16142. /** @hidden */
  16143. export var kernelBlurVertexShader: {
  16144. name: string;
  16145. shader: string;
  16146. };
  16147. }
  16148. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16149. import { Vector2 } from "babylonjs/Maths/math.vector";
  16150. import { Nullable } from "babylonjs/types";
  16151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16152. import { Camera } from "babylonjs/Cameras/camera";
  16153. import { Effect } from "babylonjs/Materials/effect";
  16154. import { Engine } from "babylonjs/Engines/engine";
  16155. import "babylonjs/Shaders/kernelBlur.fragment";
  16156. import "babylonjs/Shaders/kernelBlur.vertex";
  16157. /**
  16158. * The Blur Post Process which blurs an image based on a kernel and direction.
  16159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16160. */
  16161. export class BlurPostProcess extends PostProcess {
  16162. /** The direction in which to blur the image. */
  16163. direction: Vector2;
  16164. private blockCompilation;
  16165. protected _kernel: number;
  16166. protected _idealKernel: number;
  16167. protected _packedFloat: boolean;
  16168. private _staticDefines;
  16169. /**
  16170. * Sets the length in pixels of the blur sample region
  16171. */
  16172. set kernel(v: number);
  16173. /**
  16174. * Gets the length in pixels of the blur sample region
  16175. */
  16176. get kernel(): number;
  16177. /**
  16178. * Sets wether or not the blur needs to unpack/repack floats
  16179. */
  16180. set packedFloat(v: boolean);
  16181. /**
  16182. * Gets wether or not the blur is unpacking/repacking floats
  16183. */
  16184. get packedFloat(): boolean;
  16185. /**
  16186. * Creates a new instance BlurPostProcess
  16187. * @param name The name of the effect.
  16188. * @param direction The direction in which to blur the image.
  16189. * @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.
  16190. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16191. * @param camera The camera to apply the render pass to.
  16192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16193. * @param engine The engine which the post process will be applied. (default: current engine)
  16194. * @param reusable If the post process can be reused on the same frame. (default: false)
  16195. * @param textureType Type of textures used when performing the post process. (default: 0)
  16196. * @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)
  16197. */
  16198. constructor(name: string,
  16199. /** The direction in which to blur the image. */
  16200. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16201. /**
  16202. * Updates the effect with the current post process compile time values and recompiles the shader.
  16203. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16204. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16205. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16206. * @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
  16207. * @param onCompiled Called when the shader has been compiled.
  16208. * @param onError Called if there is an error when compiling a shader.
  16209. */
  16210. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16211. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16212. /**
  16213. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16214. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16215. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16216. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16217. * The gaps between physical kernels are compensated for in the weighting of the samples
  16218. * @param idealKernel Ideal blur kernel.
  16219. * @return Nearest best kernel.
  16220. */
  16221. protected _nearestBestKernel(idealKernel: number): number;
  16222. /**
  16223. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16224. * @param x The point on the Gaussian distribution to sample.
  16225. * @return the value of the Gaussian function at x.
  16226. */
  16227. protected _gaussianWeight(x: number): number;
  16228. /**
  16229. * Generates a string that can be used as a floating point number in GLSL.
  16230. * @param x Value to print.
  16231. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16232. * @return GLSL float string.
  16233. */
  16234. protected _glslFloat(x: number, decimalFigures?: number): string;
  16235. }
  16236. }
  16237. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16238. import { Scene } from "babylonjs/scene";
  16239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16240. import { Plane } from "babylonjs/Maths/math.plane";
  16241. /**
  16242. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16243. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16244. * You can then easily use it as a reflectionTexture on a flat surface.
  16245. * In case the surface is not a plane, please consider relying on reflection probes.
  16246. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16247. */
  16248. export class MirrorTexture extends RenderTargetTexture {
  16249. private scene;
  16250. /**
  16251. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16252. * 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.
  16253. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16254. */
  16255. mirrorPlane: Plane;
  16256. /**
  16257. * Define the blur ratio used to blur the reflection if needed.
  16258. */
  16259. set blurRatio(value: number);
  16260. get blurRatio(): number;
  16261. /**
  16262. * Define the adaptive blur kernel used to blur the reflection if needed.
  16263. * This will autocompute the closest best match for the `blurKernel`
  16264. */
  16265. set adaptiveBlurKernel(value: number);
  16266. /**
  16267. * Define the blur kernel used to blur the reflection if needed.
  16268. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16269. */
  16270. set blurKernel(value: number);
  16271. /**
  16272. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16273. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16274. */
  16275. set blurKernelX(value: number);
  16276. get blurKernelX(): number;
  16277. /**
  16278. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16279. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16280. */
  16281. set blurKernelY(value: number);
  16282. get blurKernelY(): number;
  16283. private _autoComputeBlurKernel;
  16284. protected _onRatioRescale(): void;
  16285. private _updateGammaSpace;
  16286. private _imageProcessingConfigChangeObserver;
  16287. private _transformMatrix;
  16288. private _mirrorMatrix;
  16289. private _savedViewMatrix;
  16290. private _blurX;
  16291. private _blurY;
  16292. private _adaptiveBlurKernel;
  16293. private _blurKernelX;
  16294. private _blurKernelY;
  16295. private _blurRatio;
  16296. /**
  16297. * Instantiates a Mirror Texture.
  16298. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16299. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16300. * You can then easily use it as a reflectionTexture on a flat surface.
  16301. * In case the surface is not a plane, please consider relying on reflection probes.
  16302. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16303. * @param name
  16304. * @param size
  16305. * @param scene
  16306. * @param generateMipMaps
  16307. * @param type
  16308. * @param samplingMode
  16309. * @param generateDepthBuffer
  16310. */
  16311. constructor(name: string, size: number | {
  16312. width: number;
  16313. height: number;
  16314. } | {
  16315. ratio: number;
  16316. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16317. private _preparePostProcesses;
  16318. /**
  16319. * Clone the mirror texture.
  16320. * @returns the cloned texture
  16321. */
  16322. clone(): MirrorTexture;
  16323. /**
  16324. * Serialize the texture to a JSON representation you could use in Parse later on
  16325. * @returns the serialized JSON representation
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Dispose the texture and release its associated resources.
  16330. */
  16331. dispose(): void;
  16332. }
  16333. }
  16334. declare module "babylonjs/Materials/Textures/texture" {
  16335. import { Observable } from "babylonjs/Misc/observable";
  16336. import { Nullable } from "babylonjs/types";
  16337. import { Matrix } from "babylonjs/Maths/math.vector";
  16338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16339. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16340. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16341. import { Scene } from "babylonjs/scene";
  16342. /**
  16343. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16344. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16345. */
  16346. export class Texture extends BaseTexture {
  16347. /**
  16348. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16349. */
  16350. static SerializeBuffers: boolean;
  16351. /** @hidden */
  16352. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16353. /** @hidden */
  16354. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16355. /** @hidden */
  16356. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16357. /** nearest is mag = nearest and min = nearest and mip = linear */
  16358. static readonly NEAREST_SAMPLINGMODE: number;
  16359. /** nearest is mag = nearest and min = nearest and mip = linear */
  16360. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16362. static readonly BILINEAR_SAMPLINGMODE: number;
  16363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16364. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16365. /** Trilinear is mag = linear and min = linear and mip = linear */
  16366. static readonly TRILINEAR_SAMPLINGMODE: number;
  16367. /** Trilinear is mag = linear and min = linear and mip = linear */
  16368. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16369. /** mag = nearest and min = nearest and mip = nearest */
  16370. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16371. /** mag = nearest and min = linear and mip = nearest */
  16372. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16373. /** mag = nearest and min = linear and mip = linear */
  16374. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16375. /** mag = nearest and min = linear and mip = none */
  16376. static readonly NEAREST_LINEAR: number;
  16377. /** mag = nearest and min = nearest and mip = none */
  16378. static readonly NEAREST_NEAREST: number;
  16379. /** mag = linear and min = nearest and mip = nearest */
  16380. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16381. /** mag = linear and min = nearest and mip = linear */
  16382. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16383. /** mag = linear and min = linear and mip = none */
  16384. static readonly LINEAR_LINEAR: number;
  16385. /** mag = linear and min = nearest and mip = none */
  16386. static readonly LINEAR_NEAREST: number;
  16387. /** Explicit coordinates mode */
  16388. static readonly EXPLICIT_MODE: number;
  16389. /** Spherical coordinates mode */
  16390. static readonly SPHERICAL_MODE: number;
  16391. /** Planar coordinates mode */
  16392. static readonly PLANAR_MODE: number;
  16393. /** Cubic coordinates mode */
  16394. static readonly CUBIC_MODE: number;
  16395. /** Projection coordinates mode */
  16396. static readonly PROJECTION_MODE: number;
  16397. /** Inverse Cubic coordinates mode */
  16398. static readonly SKYBOX_MODE: number;
  16399. /** Inverse Cubic coordinates mode */
  16400. static readonly INVCUBIC_MODE: number;
  16401. /** Equirectangular coordinates mode */
  16402. static readonly EQUIRECTANGULAR_MODE: number;
  16403. /** Equirectangular Fixed coordinates mode */
  16404. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16405. /** Equirectangular Fixed Mirrored coordinates mode */
  16406. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16407. /** Texture is not repeating outside of 0..1 UVs */
  16408. static readonly CLAMP_ADDRESSMODE: number;
  16409. /** Texture is repeating outside of 0..1 UVs */
  16410. static readonly WRAP_ADDRESSMODE: number;
  16411. /** Texture is repeating and mirrored */
  16412. static readonly MIRROR_ADDRESSMODE: number;
  16413. /**
  16414. * 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
  16415. */
  16416. static UseSerializedUrlIfAny: boolean;
  16417. /**
  16418. * Define the url of the texture.
  16419. */
  16420. url: Nullable<string>;
  16421. /**
  16422. * Define an offset on the texture to offset the u coordinates of the UVs
  16423. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16424. */
  16425. uOffset: number;
  16426. /**
  16427. * Define an offset on the texture to offset the v coordinates of the UVs
  16428. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16429. */
  16430. vOffset: number;
  16431. /**
  16432. * Define an offset on the texture to scale the u coordinates of the UVs
  16433. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16434. */
  16435. uScale: number;
  16436. /**
  16437. * Define an offset on the texture to scale the v coordinates of the UVs
  16438. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16439. */
  16440. vScale: number;
  16441. /**
  16442. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16443. * @see http://doc.babylonjs.com/how_to/more_materials
  16444. */
  16445. uAng: number;
  16446. /**
  16447. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16448. * @see http://doc.babylonjs.com/how_to/more_materials
  16449. */
  16450. vAng: number;
  16451. /**
  16452. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16453. * @see http://doc.babylonjs.com/how_to/more_materials
  16454. */
  16455. wAng: number;
  16456. /**
  16457. * Defines the center of rotation (U)
  16458. */
  16459. uRotationCenter: number;
  16460. /**
  16461. * Defines the center of rotation (V)
  16462. */
  16463. vRotationCenter: number;
  16464. /**
  16465. * Defines the center of rotation (W)
  16466. */
  16467. wRotationCenter: number;
  16468. /**
  16469. * Are mip maps generated for this texture or not.
  16470. */
  16471. get noMipmap(): boolean;
  16472. /**
  16473. * List of inspectable custom properties (used by the Inspector)
  16474. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16475. */
  16476. inspectableCustomProperties: Nullable<IInspectable[]>;
  16477. private _noMipmap;
  16478. /** @hidden */
  16479. _invertY: boolean;
  16480. private _rowGenerationMatrix;
  16481. private _cachedTextureMatrix;
  16482. private _projectionModeMatrix;
  16483. private _t0;
  16484. private _t1;
  16485. private _t2;
  16486. private _cachedUOffset;
  16487. private _cachedVOffset;
  16488. private _cachedUScale;
  16489. private _cachedVScale;
  16490. private _cachedUAng;
  16491. private _cachedVAng;
  16492. private _cachedWAng;
  16493. private _cachedProjectionMatrixId;
  16494. private _cachedCoordinatesMode;
  16495. /** @hidden */
  16496. protected _initialSamplingMode: number;
  16497. /** @hidden */
  16498. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16499. private _deleteBuffer;
  16500. protected _format: Nullable<number>;
  16501. private _delayedOnLoad;
  16502. private _delayedOnError;
  16503. private _mimeType?;
  16504. /**
  16505. * Observable triggered once the texture has been loaded.
  16506. */
  16507. onLoadObservable: Observable<Texture>;
  16508. protected _isBlocking: boolean;
  16509. /**
  16510. * Is the texture preventing material to render while loading.
  16511. * If false, a default texture will be used instead of the loading one during the preparation step.
  16512. */
  16513. set isBlocking(value: boolean);
  16514. get isBlocking(): boolean;
  16515. /**
  16516. * Get the current sampling mode associated with the texture.
  16517. */
  16518. get samplingMode(): number;
  16519. /**
  16520. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16521. */
  16522. get invertY(): boolean;
  16523. /**
  16524. * Instantiates a new texture.
  16525. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16526. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16527. * @param url defines the url of the picture to load as a texture
  16528. * @param scene defines the scene or engine the texture will belong to
  16529. * @param noMipmap defines if the texture will require mip maps or not
  16530. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16531. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16532. * @param onLoad defines a callback triggered when the texture has been loaded
  16533. * @param onError defines a callback triggered when an error occurred during the loading session
  16534. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16535. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16536. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16537. * @param mimeType defines an optional mime type information
  16538. */
  16539. 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);
  16540. /**
  16541. * Update the url (and optional buffer) of this texture if url was null during construction.
  16542. * @param url the url of the texture
  16543. * @param buffer the buffer of the texture (defaults to null)
  16544. * @param onLoad callback called when the texture is loaded (defaults to null)
  16545. */
  16546. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16547. /**
  16548. * Finish the loading sequence of a texture flagged as delayed load.
  16549. * @hidden
  16550. */
  16551. delayLoad(): void;
  16552. private _prepareRowForTextureGeneration;
  16553. /**
  16554. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16555. * @returns the transform matrix of the texture.
  16556. */
  16557. getTextureMatrix(uBase?: number): Matrix;
  16558. /**
  16559. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16560. * @returns The reflection texture transform
  16561. */
  16562. getReflectionTextureMatrix(): Matrix;
  16563. /**
  16564. * Clones the texture.
  16565. * @returns the cloned texture
  16566. */
  16567. clone(): Texture;
  16568. /**
  16569. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16570. * @returns The JSON representation of the texture
  16571. */
  16572. serialize(): any;
  16573. /**
  16574. * Get the current class name of the texture useful for serialization or dynamic coding.
  16575. * @returns "Texture"
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Dispose the texture and release its associated resources.
  16580. */
  16581. dispose(): void;
  16582. /**
  16583. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16584. * @param parsedTexture Define the JSON representation of the texture
  16585. * @param scene Define the scene the parsed texture should be instantiated in
  16586. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16587. * @returns The parsed texture if successful
  16588. */
  16589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16590. /**
  16591. * Creates a texture from its base 64 representation.
  16592. * @param data Define the base64 payload without the data: prefix
  16593. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16594. * @param scene Define the scene the texture should belong to
  16595. * @param noMipmap Forces the texture to not create mip map information if true
  16596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16598. * @param onLoad define a callback triggered when the texture has been loaded
  16599. * @param onError define a callback triggered when an error occurred during the loading session
  16600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16601. * @returns the created texture
  16602. */
  16603. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16604. /**
  16605. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16606. * @param data Define the base64 payload without the data: prefix
  16607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16609. * @param scene Define the scene the texture should belong to
  16610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16611. * @param noMipmap Forces the texture to not create mip map information if true
  16612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16614. * @param onLoad define a callback triggered when the texture has been loaded
  16615. * @param onError define a callback triggered when an error occurred during the loading session
  16616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16617. * @returns the created texture
  16618. */
  16619. 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;
  16620. }
  16621. }
  16622. declare module "babylonjs/PostProcesses/postProcessManager" {
  16623. import { Nullable } from "babylonjs/types";
  16624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16626. import { Scene } from "babylonjs/scene";
  16627. /**
  16628. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16630. */
  16631. export class PostProcessManager {
  16632. private _scene;
  16633. private _indexBuffer;
  16634. private _vertexBuffers;
  16635. /**
  16636. * Creates a new instance PostProcess
  16637. * @param scene The scene that the post process is associated with.
  16638. */
  16639. constructor(scene: Scene);
  16640. private _prepareBuffers;
  16641. private _buildIndexBuffer;
  16642. /**
  16643. * Rebuilds the vertex buffers of the manager.
  16644. * @hidden
  16645. */
  16646. _rebuild(): void;
  16647. /**
  16648. * Prepares a frame to be run through a post process.
  16649. * @param sourceTexture The input texture to the post procesess. (default: null)
  16650. * @param postProcesses An array of post processes to be run. (default: null)
  16651. * @returns True if the post processes were able to be run.
  16652. * @hidden
  16653. */
  16654. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16655. /**
  16656. * Manually render a set of post processes to a texture.
  16657. * @param postProcesses An array of post processes to be run.
  16658. * @param targetTexture The target texture to render to.
  16659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16660. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16661. * @param lodLevel defines which lod of the texture to render to
  16662. */
  16663. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16664. /**
  16665. * Finalize the result of the output of the postprocesses.
  16666. * @param doNotPresent If true the result will not be displayed to the screen.
  16667. * @param targetTexture The target texture to render to.
  16668. * @param faceIndex The index of the face to bind the target texture to.
  16669. * @param postProcesses The array of post processes to render.
  16670. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16671. * @hidden
  16672. */
  16673. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16674. /**
  16675. * Disposes of the post process manager.
  16676. */
  16677. dispose(): void;
  16678. }
  16679. }
  16680. declare module "babylonjs/Misc/gradients" {
  16681. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16682. /** Interface used by value gradients (color, factor, ...) */
  16683. export interface IValueGradient {
  16684. /**
  16685. * Gets or sets the gradient value (between 0 and 1)
  16686. */
  16687. gradient: number;
  16688. }
  16689. /** Class used to store color4 gradient */
  16690. export class ColorGradient implements IValueGradient {
  16691. /**
  16692. * Gets or sets the gradient value (between 0 and 1)
  16693. */
  16694. gradient: number;
  16695. /**
  16696. * Gets or sets first associated color
  16697. */
  16698. color1: Color4;
  16699. /**
  16700. * Gets or sets second associated color
  16701. */
  16702. color2?: Color4;
  16703. /**
  16704. * Will get a color picked randomly between color1 and color2.
  16705. * If color2 is undefined then color1 will be used
  16706. * @param result defines the target Color4 to store the result in
  16707. */
  16708. getColorToRef(result: Color4): void;
  16709. }
  16710. /** Class used to store color 3 gradient */
  16711. export class Color3Gradient implements IValueGradient {
  16712. /**
  16713. * Gets or sets the gradient value (between 0 and 1)
  16714. */
  16715. gradient: number;
  16716. /**
  16717. * Gets or sets the associated color
  16718. */
  16719. color: Color3;
  16720. }
  16721. /** Class used to store factor gradient */
  16722. export class FactorGradient implements IValueGradient {
  16723. /**
  16724. * Gets or sets the gradient value (between 0 and 1)
  16725. */
  16726. gradient: number;
  16727. /**
  16728. * Gets or sets first associated factor
  16729. */
  16730. factor1: number;
  16731. /**
  16732. * Gets or sets second associated factor
  16733. */
  16734. factor2?: number;
  16735. /**
  16736. * Will get a number picked randomly between factor1 and factor2.
  16737. * If factor2 is undefined then factor1 will be used
  16738. * @returns the picked number
  16739. */
  16740. getFactor(): number;
  16741. }
  16742. /**
  16743. * Helper used to simplify some generic gradient tasks
  16744. */
  16745. export class GradientHelper {
  16746. /**
  16747. * Gets the current gradient from an array of IValueGradient
  16748. * @param ratio defines the current ratio to get
  16749. * @param gradients defines the array of IValueGradient
  16750. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16751. */
  16752. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16753. }
  16754. }
  16755. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16757. import { Nullable } from "babylonjs/types";
  16758. module "babylonjs/Engines/thinEngine" {
  16759. interface ThinEngine {
  16760. /**
  16761. * Creates a dynamic texture
  16762. * @param width defines the width of the texture
  16763. * @param height defines the height of the texture
  16764. * @param generateMipMaps defines if the engine should generate the mip levels
  16765. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16766. * @returns the dynamic texture inside an InternalTexture
  16767. */
  16768. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16769. /**
  16770. * Update the content of a dynamic texture
  16771. * @param texture defines the texture to update
  16772. * @param canvas defines the canvas containing the source
  16773. * @param invertY defines if data must be stored with Y axis inverted
  16774. * @param premulAlpha defines if alpha is stored as premultiplied
  16775. * @param format defines the format of the data
  16776. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16777. */
  16778. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16779. }
  16780. }
  16781. }
  16782. declare module "babylonjs/Misc/canvasGenerator" {
  16783. /**
  16784. * Helper class used to generate a canvas to manipulate images
  16785. */
  16786. export class CanvasGenerator {
  16787. /**
  16788. * Create a new canvas (or offscreen canvas depending on the context)
  16789. * @param width defines the expected width
  16790. * @param height defines the expected height
  16791. * @return a new canvas or offscreen canvas
  16792. */
  16793. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16794. }
  16795. }
  16796. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16797. import { Scene } from "babylonjs/scene";
  16798. import { Texture } from "babylonjs/Materials/Textures/texture";
  16799. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16800. /**
  16801. * A class extending Texture allowing drawing on a texture
  16802. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16803. */
  16804. export class DynamicTexture extends Texture {
  16805. private _generateMipMaps;
  16806. private _canvas;
  16807. private _context;
  16808. private _engine;
  16809. /**
  16810. * Creates a DynamicTexture
  16811. * @param name defines the name of the texture
  16812. * @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
  16813. * @param scene defines the scene where you want the texture
  16814. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16815. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16816. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16817. */
  16818. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16819. /**
  16820. * Get the current class name of the texture useful for serialization or dynamic coding.
  16821. * @returns "DynamicTexture"
  16822. */
  16823. getClassName(): string;
  16824. /**
  16825. * Gets the current state of canRescale
  16826. */
  16827. get canRescale(): boolean;
  16828. private _recreate;
  16829. /**
  16830. * Scales the texture
  16831. * @param ratio the scale factor to apply to both width and height
  16832. */
  16833. scale(ratio: number): void;
  16834. /**
  16835. * Resizes the texture
  16836. * @param width the new width
  16837. * @param height the new height
  16838. */
  16839. scaleTo(width: number, height: number): void;
  16840. /**
  16841. * Gets the context of the canvas used by the texture
  16842. * @returns the canvas context of the dynamic texture
  16843. */
  16844. getContext(): CanvasRenderingContext2D;
  16845. /**
  16846. * Clears the texture
  16847. */
  16848. clear(): void;
  16849. /**
  16850. * Updates the texture
  16851. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16852. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16853. */
  16854. update(invertY?: boolean, premulAlpha?: boolean): void;
  16855. /**
  16856. * Draws text onto the texture
  16857. * @param text defines the text to be drawn
  16858. * @param x defines the placement of the text from the left
  16859. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16860. * @param font defines the font to be used with font-style, font-size, font-name
  16861. * @param color defines the color used for the text
  16862. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16863. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16864. * @param update defines whether texture is immediately update (default is true)
  16865. */
  16866. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16867. /**
  16868. * Clones the texture
  16869. * @returns the clone of the texture.
  16870. */
  16871. clone(): DynamicTexture;
  16872. /**
  16873. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16874. * @returns a serialized dynamic texture object
  16875. */
  16876. serialize(): any;
  16877. /** @hidden */
  16878. _rebuild(): void;
  16879. }
  16880. }
  16881. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16882. import { Scene } from "babylonjs/scene";
  16883. import { ISceneComponent } from "babylonjs/sceneComponent";
  16884. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16885. module "babylonjs/abstractScene" {
  16886. interface AbstractScene {
  16887. /**
  16888. * The list of procedural textures added to the scene
  16889. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16890. */
  16891. proceduralTextures: Array<ProceduralTexture>;
  16892. }
  16893. }
  16894. /**
  16895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16896. * in a given scene.
  16897. */
  16898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16899. /**
  16900. * The component name helpfull to identify the component in the list of scene components.
  16901. */
  16902. readonly name: string;
  16903. /**
  16904. * The scene the component belongs to.
  16905. */
  16906. scene: Scene;
  16907. /**
  16908. * Creates a new instance of the component for the given scene
  16909. * @param scene Defines the scene to register the component in
  16910. */
  16911. constructor(scene: Scene);
  16912. /**
  16913. * Registers the component in a given scene
  16914. */
  16915. register(): void;
  16916. /**
  16917. * Rebuilds the elements related to this component in case of
  16918. * context lost for instance.
  16919. */
  16920. rebuild(): void;
  16921. /**
  16922. * Disposes the component and the associated ressources.
  16923. */
  16924. dispose(): void;
  16925. private _beforeClear;
  16926. }
  16927. }
  16928. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16930. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16931. module "babylonjs/Engines/thinEngine" {
  16932. interface ThinEngine {
  16933. /**
  16934. * Creates a new render target cube texture
  16935. * @param size defines the size of the texture
  16936. * @param options defines the options used to create the texture
  16937. * @returns a new render target cube texture stored in an InternalTexture
  16938. */
  16939. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16940. }
  16941. }
  16942. }
  16943. declare module "babylonjs/Shaders/procedural.vertex" {
  16944. /** @hidden */
  16945. export var proceduralVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16951. import { Observable } from "babylonjs/Misc/observable";
  16952. import { Nullable } from "babylonjs/types";
  16953. import { Scene } from "babylonjs/scene";
  16954. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16955. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16956. import { Effect } from "babylonjs/Materials/effect";
  16957. import { Texture } from "babylonjs/Materials/Textures/texture";
  16958. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16959. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16960. import "babylonjs/Shaders/procedural.vertex";
  16961. /**
  16962. * 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.
  16963. * This is the base class of any Procedural texture and contains most of the shareable code.
  16964. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16965. */
  16966. export class ProceduralTexture extends Texture {
  16967. isCube: boolean;
  16968. /**
  16969. * Define if the texture is enabled or not (disabled texture will not render)
  16970. */
  16971. isEnabled: boolean;
  16972. /**
  16973. * Define if the texture must be cleared before rendering (default is true)
  16974. */
  16975. autoClear: boolean;
  16976. /**
  16977. * Callback called when the texture is generated
  16978. */
  16979. onGenerated: () => void;
  16980. /**
  16981. * Event raised when the texture is generated
  16982. */
  16983. onGeneratedObservable: Observable<ProceduralTexture>;
  16984. /** @hidden */
  16985. _generateMipMaps: boolean;
  16986. /** @hidden **/
  16987. _effect: Effect;
  16988. /** @hidden */
  16989. _textures: {
  16990. [key: string]: Texture;
  16991. };
  16992. private _size;
  16993. private _currentRefreshId;
  16994. private _refreshRate;
  16995. private _vertexBuffers;
  16996. private _indexBuffer;
  16997. private _uniforms;
  16998. private _samplers;
  16999. private _fragment;
  17000. private _floats;
  17001. private _ints;
  17002. private _floatsArrays;
  17003. private _colors3;
  17004. private _colors4;
  17005. private _vectors2;
  17006. private _vectors3;
  17007. private _matrices;
  17008. private _fallbackTexture;
  17009. private _fallbackTextureUsed;
  17010. private _engine;
  17011. private _cachedDefines;
  17012. private _contentUpdateId;
  17013. private _contentData;
  17014. /**
  17015. * Instantiates a new procedural texture.
  17016. * 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.
  17017. * This is the base class of any Procedural texture and contains most of the shareable code.
  17018. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17019. * @param name Define the name of the texture
  17020. * @param size Define the size of the texture to create
  17021. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17022. * @param scene Define the scene the texture belongs to
  17023. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17024. * @param generateMipMaps Define if the texture should creates mip maps or not
  17025. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17026. */
  17027. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17028. /**
  17029. * The effect that is created when initializing the post process.
  17030. * @returns The created effect corresponding the the postprocess.
  17031. */
  17032. getEffect(): Effect;
  17033. /**
  17034. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17035. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17036. */
  17037. getContent(): Nullable<ArrayBufferView>;
  17038. private _createIndexBuffer;
  17039. /** @hidden */
  17040. _rebuild(): void;
  17041. /**
  17042. * Resets the texture in order to recreate its associated resources.
  17043. * This can be called in case of context loss
  17044. */
  17045. reset(): void;
  17046. protected _getDefines(): string;
  17047. /**
  17048. * Is the texture ready to be used ? (rendered at least once)
  17049. * @returns true if ready, otherwise, false.
  17050. */
  17051. isReady(): boolean;
  17052. /**
  17053. * Resets the refresh counter of the texture and start bak from scratch.
  17054. * Could be useful to regenerate the texture if it is setup to render only once.
  17055. */
  17056. resetRefreshCounter(): void;
  17057. /**
  17058. * Set the fragment shader to use in order to render the texture.
  17059. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17060. */
  17061. setFragment(fragment: any): void;
  17062. /**
  17063. * Define the refresh rate of the texture or the rendering frequency.
  17064. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17065. */
  17066. get refreshRate(): number;
  17067. set refreshRate(value: number);
  17068. /** @hidden */
  17069. _shouldRender(): boolean;
  17070. /**
  17071. * Get the size the texture is rendering at.
  17072. * @returns the size (texture is always squared)
  17073. */
  17074. getRenderSize(): number;
  17075. /**
  17076. * Resize the texture to new value.
  17077. * @param size Define the new size the texture should have
  17078. * @param generateMipMaps Define whether the new texture should create mip maps
  17079. */
  17080. resize(size: number, generateMipMaps: boolean): void;
  17081. private _checkUniform;
  17082. /**
  17083. * Set a texture in the shader program used to render.
  17084. * @param name Define the name of the uniform samplers as defined in the shader
  17085. * @param texture Define the texture to bind to this sampler
  17086. * @return the texture itself allowing "fluent" like uniform updates
  17087. */
  17088. setTexture(name: string, texture: Texture): ProceduralTexture;
  17089. /**
  17090. * Set a float in the shader.
  17091. * @param name Define the name of the uniform as defined in the shader
  17092. * @param value Define the value to give to the uniform
  17093. * @return the texture itself allowing "fluent" like uniform updates
  17094. */
  17095. setFloat(name: string, value: number): ProceduralTexture;
  17096. /**
  17097. * Set a int in the shader.
  17098. * @param name Define the name of the uniform as defined in the shader
  17099. * @param value Define the value to give to the uniform
  17100. * @return the texture itself allowing "fluent" like uniform updates
  17101. */
  17102. setInt(name: string, value: number): ProceduralTexture;
  17103. /**
  17104. * Set an array of floats in the shader.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the texture itself allowing "fluent" like uniform updates
  17108. */
  17109. setFloats(name: string, value: number[]): ProceduralTexture;
  17110. /**
  17111. * Set a vec3 in the shader from a Color3.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the texture itself allowing "fluent" like uniform updates
  17115. */
  17116. setColor3(name: string, value: Color3): ProceduralTexture;
  17117. /**
  17118. * Set a vec4 in the shader from a Color4.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the texture itself allowing "fluent" like uniform updates
  17122. */
  17123. setColor4(name: string, value: Color4): ProceduralTexture;
  17124. /**
  17125. * Set a vec2 in the shader from a Vector2.
  17126. * @param name Define the name of the uniform as defined in the shader
  17127. * @param value Define the value to give to the uniform
  17128. * @return the texture itself allowing "fluent" like uniform updates
  17129. */
  17130. setVector2(name: string, value: Vector2): ProceduralTexture;
  17131. /**
  17132. * Set a vec3 in the shader from a Vector3.
  17133. * @param name Define the name of the uniform as defined in the shader
  17134. * @param value Define the value to give to the uniform
  17135. * @return the texture itself allowing "fluent" like uniform updates
  17136. */
  17137. setVector3(name: string, value: Vector3): ProceduralTexture;
  17138. /**
  17139. * Set a mat4 in the shader from a MAtrix.
  17140. * @param name Define the name of the uniform as defined in the shader
  17141. * @param value Define the value to give to the uniform
  17142. * @return the texture itself allowing "fluent" like uniform updates
  17143. */
  17144. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17145. /**
  17146. * Render the texture to its associated render target.
  17147. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17148. */
  17149. render(useCameraPostProcess?: boolean): void;
  17150. /**
  17151. * Clone the texture.
  17152. * @returns the cloned texture
  17153. */
  17154. clone(): ProceduralTexture;
  17155. /**
  17156. * Dispose the texture and release its asoociated resources.
  17157. */
  17158. dispose(): void;
  17159. }
  17160. }
  17161. declare module "babylonjs/Particles/baseParticleSystem" {
  17162. import { Nullable } from "babylonjs/types";
  17163. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17165. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17166. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17167. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17168. import { Scene } from "babylonjs/scene";
  17169. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17170. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17171. import { Texture } from "babylonjs/Materials/Textures/texture";
  17172. import { Color4 } from "babylonjs/Maths/math.color";
  17173. import { Animation } from "babylonjs/Animations/animation";
  17174. /**
  17175. * This represents the base class for particle system in Babylon.
  17176. * 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.
  17177. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17178. * @example https://doc.babylonjs.com/babylon101/particles
  17179. */
  17180. export class BaseParticleSystem {
  17181. /**
  17182. * Source color is added to the destination color without alpha affecting the result
  17183. */
  17184. static BLENDMODE_ONEONE: number;
  17185. /**
  17186. * Blend current color and particle color using particle’s alpha
  17187. */
  17188. static BLENDMODE_STANDARD: number;
  17189. /**
  17190. * Add current color and particle color multiplied by particle’s alpha
  17191. */
  17192. static BLENDMODE_ADD: number;
  17193. /**
  17194. * Multiply current color with particle color
  17195. */
  17196. static BLENDMODE_MULTIPLY: number;
  17197. /**
  17198. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17199. */
  17200. static BLENDMODE_MULTIPLYADD: number;
  17201. /**
  17202. * List of animations used by the particle system.
  17203. */
  17204. animations: Animation[];
  17205. /**
  17206. * The id of the Particle system.
  17207. */
  17208. id: string;
  17209. /**
  17210. * The friendly name of the Particle system.
  17211. */
  17212. name: string;
  17213. /**
  17214. * The rendering group used by the Particle system to chose when to render.
  17215. */
  17216. renderingGroupId: number;
  17217. /**
  17218. * The emitter represents the Mesh or position we are attaching the particle system to.
  17219. */
  17220. emitter: Nullable<AbstractMesh | Vector3>;
  17221. /**
  17222. * The maximum number of particles to emit per frame
  17223. */
  17224. emitRate: number;
  17225. /**
  17226. * If you want to launch only a few particles at once, that can be done, as well.
  17227. */
  17228. manualEmitCount: number;
  17229. /**
  17230. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17231. */
  17232. updateSpeed: number;
  17233. /**
  17234. * The amount of time the particle system is running (depends of the overall update speed).
  17235. */
  17236. targetStopDuration: number;
  17237. /**
  17238. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17239. */
  17240. disposeOnStop: boolean;
  17241. /**
  17242. * Minimum power of emitting particles.
  17243. */
  17244. minEmitPower: number;
  17245. /**
  17246. * Maximum power of emitting particles.
  17247. */
  17248. maxEmitPower: number;
  17249. /**
  17250. * Minimum life time of emitting particles.
  17251. */
  17252. minLifeTime: number;
  17253. /**
  17254. * Maximum life time of emitting particles.
  17255. */
  17256. maxLifeTime: number;
  17257. /**
  17258. * Minimum Size of emitting particles.
  17259. */
  17260. minSize: number;
  17261. /**
  17262. * Maximum Size of emitting particles.
  17263. */
  17264. maxSize: number;
  17265. /**
  17266. * Minimum scale of emitting particles on X axis.
  17267. */
  17268. minScaleX: number;
  17269. /**
  17270. * Maximum scale of emitting particles on X axis.
  17271. */
  17272. maxScaleX: number;
  17273. /**
  17274. * Minimum scale of emitting particles on Y axis.
  17275. */
  17276. minScaleY: number;
  17277. /**
  17278. * Maximum scale of emitting particles on Y axis.
  17279. */
  17280. maxScaleY: number;
  17281. /**
  17282. * Gets or sets the minimal initial rotation in radians.
  17283. */
  17284. minInitialRotation: number;
  17285. /**
  17286. * Gets or sets the maximal initial rotation in radians.
  17287. */
  17288. maxInitialRotation: number;
  17289. /**
  17290. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17291. */
  17292. minAngularSpeed: number;
  17293. /**
  17294. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17295. */
  17296. maxAngularSpeed: number;
  17297. /**
  17298. * The texture used to render each particle. (this can be a spritesheet)
  17299. */
  17300. particleTexture: Nullable<Texture>;
  17301. /**
  17302. * The layer mask we are rendering the particles through.
  17303. */
  17304. layerMask: number;
  17305. /**
  17306. * This can help using your own shader to render the particle system.
  17307. * The according effect will be created
  17308. */
  17309. customShader: any;
  17310. /**
  17311. * By default particle system starts as soon as they are created. This prevents the
  17312. * automatic start to happen and let you decide when to start emitting particles.
  17313. */
  17314. preventAutoStart: boolean;
  17315. private _noiseTexture;
  17316. /**
  17317. * Gets or sets a texture used to add random noise to particle positions
  17318. */
  17319. get noiseTexture(): Nullable<ProceduralTexture>;
  17320. set noiseTexture(value: Nullable<ProceduralTexture>);
  17321. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17322. noiseStrength: Vector3;
  17323. /**
  17324. * Callback triggered when the particle animation is ending.
  17325. */
  17326. onAnimationEnd: Nullable<() => void>;
  17327. /**
  17328. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17329. */
  17330. blendMode: number;
  17331. /**
  17332. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17333. * to override the particles.
  17334. */
  17335. forceDepthWrite: boolean;
  17336. /** 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 */
  17337. preWarmCycles: number;
  17338. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17339. preWarmStepOffset: number;
  17340. /**
  17341. * 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)
  17342. */
  17343. spriteCellChangeSpeed: number;
  17344. /**
  17345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17346. */
  17347. startSpriteCellID: number;
  17348. /**
  17349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17350. */
  17351. endSpriteCellID: number;
  17352. /**
  17353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17354. */
  17355. spriteCellWidth: number;
  17356. /**
  17357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17358. */
  17359. spriteCellHeight: number;
  17360. /**
  17361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17362. */
  17363. spriteRandomStartCell: boolean;
  17364. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17365. translationPivot: Vector2;
  17366. /** @hidden */
  17367. protected _isAnimationSheetEnabled: boolean;
  17368. /**
  17369. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17370. */
  17371. beginAnimationOnStart: boolean;
  17372. /**
  17373. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17374. */
  17375. beginAnimationFrom: number;
  17376. /**
  17377. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17378. */
  17379. beginAnimationTo: number;
  17380. /**
  17381. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17382. */
  17383. beginAnimationLoop: boolean;
  17384. /**
  17385. * Gets or sets a world offset applied to all particles
  17386. */
  17387. worldOffset: Vector3;
  17388. /**
  17389. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17390. */
  17391. get isAnimationSheetEnabled(): boolean;
  17392. set isAnimationSheetEnabled(value: boolean);
  17393. /**
  17394. * Get hosting scene
  17395. * @returns the scene
  17396. */
  17397. getScene(): Scene;
  17398. /**
  17399. * You can use gravity if you want to give an orientation to your particles.
  17400. */
  17401. gravity: Vector3;
  17402. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17403. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17404. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17405. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17406. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17407. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17408. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17409. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17410. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17411. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17412. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17413. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17414. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17415. /**
  17416. * Defines the delay in milliseconds before starting the system (0 by default)
  17417. */
  17418. startDelay: number;
  17419. /**
  17420. * Gets the current list of drag gradients.
  17421. * You must use addDragGradient and removeDragGradient to udpate this list
  17422. * @returns the list of drag gradients
  17423. */
  17424. getDragGradients(): Nullable<Array<FactorGradient>>;
  17425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17426. limitVelocityDamping: number;
  17427. /**
  17428. * Gets the current list of limit velocity gradients.
  17429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17430. * @returns the list of limit velocity gradients
  17431. */
  17432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17433. /**
  17434. * Gets the current list of color gradients.
  17435. * You must use addColorGradient and removeColorGradient to udpate this list
  17436. * @returns the list of color gradients
  17437. */
  17438. getColorGradients(): Nullable<Array<ColorGradient>>;
  17439. /**
  17440. * Gets the current list of size gradients.
  17441. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17442. * @returns the list of size gradients
  17443. */
  17444. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17445. /**
  17446. * Gets the current list of color remap gradients.
  17447. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17448. * @returns the list of color remap gradients
  17449. */
  17450. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17451. /**
  17452. * Gets the current list of alpha remap gradients.
  17453. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17454. * @returns the list of alpha remap gradients
  17455. */
  17456. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17457. /**
  17458. * Gets the current list of life time gradients.
  17459. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17460. * @returns the list of life time gradients
  17461. */
  17462. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17463. /**
  17464. * Gets the current list of angular speed gradients.
  17465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17466. * @returns the list of angular speed gradients
  17467. */
  17468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17469. /**
  17470. * Gets the current list of velocity gradients.
  17471. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17472. * @returns the list of velocity gradients
  17473. */
  17474. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17475. /**
  17476. * Gets the current list of start size gradients.
  17477. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17478. * @returns the list of start size gradients
  17479. */
  17480. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17481. /**
  17482. * Gets the current list of emit rate gradients.
  17483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17484. * @returns the list of emit rate gradients
  17485. */
  17486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17487. /**
  17488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17490. */
  17491. get direction1(): Vector3;
  17492. set direction1(value: Vector3);
  17493. /**
  17494. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17496. */
  17497. get direction2(): Vector3;
  17498. set direction2(value: Vector3);
  17499. /**
  17500. * 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.
  17501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17502. */
  17503. get minEmitBox(): Vector3;
  17504. set minEmitBox(value: Vector3);
  17505. /**
  17506. * 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.
  17507. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17508. */
  17509. get maxEmitBox(): Vector3;
  17510. set maxEmitBox(value: Vector3);
  17511. /**
  17512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17513. */
  17514. color1: Color4;
  17515. /**
  17516. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17517. */
  17518. color2: Color4;
  17519. /**
  17520. * Color the particle will have at the end of its lifetime
  17521. */
  17522. colorDead: Color4;
  17523. /**
  17524. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17525. */
  17526. textureMask: Color4;
  17527. /**
  17528. * The particle emitter type defines the emitter used by the particle system.
  17529. * It can be for example box, sphere, or cone...
  17530. */
  17531. particleEmitterType: IParticleEmitterType;
  17532. /** @hidden */
  17533. _isSubEmitter: boolean;
  17534. /**
  17535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17537. */
  17538. billboardMode: number;
  17539. protected _isBillboardBased: boolean;
  17540. /**
  17541. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17542. */
  17543. get isBillboardBased(): boolean;
  17544. set isBillboardBased(value: boolean);
  17545. /**
  17546. * The scene the particle system belongs to.
  17547. */
  17548. protected _scene: Scene;
  17549. /**
  17550. * Local cache of defines for image processing.
  17551. */
  17552. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17553. /**
  17554. * Default configuration related to image processing available in the standard Material.
  17555. */
  17556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17557. /**
  17558. * Gets the image processing configuration used either in this material.
  17559. */
  17560. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17561. /**
  17562. * Sets the Default image processing configuration used either in the this material.
  17563. *
  17564. * If sets to null, the scene one is in use.
  17565. */
  17566. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17567. /**
  17568. * Attaches a new image processing configuration to the Standard Material.
  17569. * @param configuration
  17570. */
  17571. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17572. /** @hidden */
  17573. protected _reset(): void;
  17574. /** @hidden */
  17575. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17576. /**
  17577. * Instantiates a particle system.
  17578. * 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.
  17579. * @param name The name of the particle system
  17580. */
  17581. constructor(name: string);
  17582. /**
  17583. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17586. * @returns the emitter
  17587. */
  17588. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17589. /**
  17590. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17591. * @param radius The radius of the hemisphere to emit from
  17592. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17593. * @returns the emitter
  17594. */
  17595. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17596. /**
  17597. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17598. * @param radius The radius of the sphere to emit from
  17599. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17600. * @returns the emitter
  17601. */
  17602. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17603. /**
  17604. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17605. * @param radius The radius of the sphere to emit from
  17606. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17607. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17608. * @returns the emitter
  17609. */
  17610. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17611. /**
  17612. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17613. * @param radius The radius of the emission cylinder
  17614. * @param height The height of the emission cylinder
  17615. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17616. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17617. * @returns the emitter
  17618. */
  17619. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17620. /**
  17621. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17622. * @param radius The radius of the cylinder to emit from
  17623. * @param height The height of the emission cylinder
  17624. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17627. * @returns the emitter
  17628. */
  17629. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17630. /**
  17631. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17632. * @param radius The radius of the cone to emit from
  17633. * @param angle The base angle of the cone
  17634. * @returns the emitter
  17635. */
  17636. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17637. /**
  17638. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17641. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17642. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17643. * @returns the emitter
  17644. */
  17645. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17646. }
  17647. }
  17648. declare module "babylonjs/Particles/subEmitter" {
  17649. import { Scene } from "babylonjs/scene";
  17650. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17651. /**
  17652. * Type of sub emitter
  17653. */
  17654. export enum SubEmitterType {
  17655. /**
  17656. * Attached to the particle over it's lifetime
  17657. */
  17658. ATTACHED = 0,
  17659. /**
  17660. * Created when the particle dies
  17661. */
  17662. END = 1
  17663. }
  17664. /**
  17665. * Sub emitter class used to emit particles from an existing particle
  17666. */
  17667. export class SubEmitter {
  17668. /**
  17669. * the particle system to be used by the sub emitter
  17670. */
  17671. particleSystem: ParticleSystem;
  17672. /**
  17673. * Type of the submitter (Default: END)
  17674. */
  17675. type: SubEmitterType;
  17676. /**
  17677. * 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)
  17678. * Note: This only is supported when using an emitter of type Mesh
  17679. */
  17680. inheritDirection: boolean;
  17681. /**
  17682. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17683. */
  17684. inheritedVelocityAmount: number;
  17685. /**
  17686. * Creates a sub emitter
  17687. * @param particleSystem the particle system to be used by the sub emitter
  17688. */
  17689. constructor(
  17690. /**
  17691. * the particle system to be used by the sub emitter
  17692. */
  17693. particleSystem: ParticleSystem);
  17694. /**
  17695. * Clones the sub emitter
  17696. * @returns the cloned sub emitter
  17697. */
  17698. clone(): SubEmitter;
  17699. /**
  17700. * Serialize current object to a JSON object
  17701. * @returns the serialized object
  17702. */
  17703. serialize(): any;
  17704. /** @hidden */
  17705. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17706. /**
  17707. * Creates a new SubEmitter from a serialized JSON version
  17708. * @param serializationObject defines the JSON object to read from
  17709. * @param scene defines the hosting scene
  17710. * @param rootUrl defines the rootUrl for data loading
  17711. * @returns a new SubEmitter
  17712. */
  17713. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17714. /** Release associated resources */
  17715. dispose(): void;
  17716. }
  17717. }
  17718. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17719. /** @hidden */
  17720. export var clipPlaneFragmentDeclaration: {
  17721. name: string;
  17722. shader: string;
  17723. };
  17724. }
  17725. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17726. /** @hidden */
  17727. export var imageProcessingDeclaration: {
  17728. name: string;
  17729. shader: string;
  17730. };
  17731. }
  17732. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17733. /** @hidden */
  17734. export var imageProcessingFunctions: {
  17735. name: string;
  17736. shader: string;
  17737. };
  17738. }
  17739. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17740. /** @hidden */
  17741. export var clipPlaneFragment: {
  17742. name: string;
  17743. shader: string;
  17744. };
  17745. }
  17746. declare module "babylonjs/Shaders/particles.fragment" {
  17747. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17748. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17749. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17750. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17751. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17752. /** @hidden */
  17753. export var particlesPixelShader: {
  17754. name: string;
  17755. shader: string;
  17756. };
  17757. }
  17758. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17759. /** @hidden */
  17760. export var clipPlaneVertexDeclaration: {
  17761. name: string;
  17762. shader: string;
  17763. };
  17764. }
  17765. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17766. /** @hidden */
  17767. export var clipPlaneVertex: {
  17768. name: string;
  17769. shader: string;
  17770. };
  17771. }
  17772. declare module "babylonjs/Shaders/particles.vertex" {
  17773. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17775. /** @hidden */
  17776. export var particlesVertexShader: {
  17777. name: string;
  17778. shader: string;
  17779. };
  17780. }
  17781. declare module "babylonjs/Particles/particleSystem" {
  17782. import { Nullable } from "babylonjs/types";
  17783. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17784. import { Observable } from "babylonjs/Misc/observable";
  17785. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17786. import { Effect } from "babylonjs/Materials/effect";
  17787. import { Scene, IDisposable } from "babylonjs/scene";
  17788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17789. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17790. import { Particle } from "babylonjs/Particles/particle";
  17791. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17792. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17793. import "babylonjs/Shaders/particles.fragment";
  17794. import "babylonjs/Shaders/particles.vertex";
  17795. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17796. /**
  17797. * This represents a particle system in Babylon.
  17798. * 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.
  17799. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17800. * @example https://doc.babylonjs.com/babylon101/particles
  17801. */
  17802. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17803. /**
  17804. * Billboard mode will only apply to Y axis
  17805. */
  17806. static readonly BILLBOARDMODE_Y: number;
  17807. /**
  17808. * Billboard mode will apply to all axes
  17809. */
  17810. static readonly BILLBOARDMODE_ALL: number;
  17811. /**
  17812. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17813. */
  17814. static readonly BILLBOARDMODE_STRETCHED: number;
  17815. /**
  17816. * This function can be defined to provide custom update for active particles.
  17817. * This function will be called instead of regular update (age, position, color, etc.).
  17818. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17819. */
  17820. updateFunction: (particles: Particle[]) => void;
  17821. private _emitterWorldMatrix;
  17822. /**
  17823. * This function can be defined to specify initial direction for every new particle.
  17824. * It by default use the emitterType defined function
  17825. */
  17826. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17827. /**
  17828. * This function can be defined to specify initial position for every new particle.
  17829. * It by default use the emitterType defined function
  17830. */
  17831. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17832. /**
  17833. * @hidden
  17834. */
  17835. _inheritedVelocityOffset: Vector3;
  17836. /**
  17837. * An event triggered when the system is disposed
  17838. */
  17839. onDisposeObservable: Observable<ParticleSystem>;
  17840. private _onDisposeObserver;
  17841. /**
  17842. * Sets a callback that will be triggered when the system is disposed
  17843. */
  17844. set onDispose(callback: () => void);
  17845. private _particles;
  17846. private _epsilon;
  17847. private _capacity;
  17848. private _stockParticles;
  17849. private _newPartsExcess;
  17850. private _vertexData;
  17851. private _vertexBuffer;
  17852. private _vertexBuffers;
  17853. private _spriteBuffer;
  17854. private _indexBuffer;
  17855. private _effect;
  17856. private _customEffect;
  17857. private _cachedDefines;
  17858. private _scaledColorStep;
  17859. private _colorDiff;
  17860. private _scaledDirection;
  17861. private _scaledGravity;
  17862. private _currentRenderId;
  17863. private _alive;
  17864. private _useInstancing;
  17865. private _started;
  17866. private _stopped;
  17867. private _actualFrame;
  17868. private _scaledUpdateSpeed;
  17869. private _vertexBufferSize;
  17870. /** @hidden */
  17871. _currentEmitRateGradient: Nullable<FactorGradient>;
  17872. /** @hidden */
  17873. _currentEmitRate1: number;
  17874. /** @hidden */
  17875. _currentEmitRate2: number;
  17876. /** @hidden */
  17877. _currentStartSizeGradient: Nullable<FactorGradient>;
  17878. /** @hidden */
  17879. _currentStartSize1: number;
  17880. /** @hidden */
  17881. _currentStartSize2: number;
  17882. private readonly _rawTextureWidth;
  17883. private _rampGradientsTexture;
  17884. private _useRampGradients;
  17885. /** Gets or sets a boolean indicating that ramp gradients must be used
  17886. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17887. */
  17888. get useRampGradients(): boolean;
  17889. set useRampGradients(value: boolean);
  17890. /**
  17891. * 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.
  17892. * 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: [])
  17893. */
  17894. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17895. private _subEmitters;
  17896. /**
  17897. * @hidden
  17898. * If the particle systems emitter should be disposed when the particle system is disposed
  17899. */
  17900. _disposeEmitterOnDispose: boolean;
  17901. /**
  17902. * The current active Sub-systems, this property is used by the root particle system only.
  17903. */
  17904. activeSubSystems: Array<ParticleSystem>;
  17905. private _rootParticleSystem;
  17906. /**
  17907. * Gets the current list of active particles
  17908. */
  17909. get particles(): Particle[];
  17910. /**
  17911. * Returns the string "ParticleSystem"
  17912. * @returns a string containing the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Instantiates a particle system.
  17917. * 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.
  17918. * @param name The name of the particle system
  17919. * @param capacity The max number of particles alive at the same time
  17920. * @param scene The scene the particle system belongs to
  17921. * @param customEffect a custom effect used to change the way particles are rendered by default
  17922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17923. * @param epsilon Offset used to render the particles
  17924. */
  17925. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17926. private _addFactorGradient;
  17927. private _removeFactorGradient;
  17928. /**
  17929. * Adds a new life time gradient
  17930. * @param gradient defines the gradient to use (between 0 and 1)
  17931. * @param factor defines the life time factor to affect to the specified gradient
  17932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17933. * @returns the current particle system
  17934. */
  17935. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17936. /**
  17937. * Remove a specific life time gradient
  17938. * @param gradient defines the gradient to remove
  17939. * @returns the current particle system
  17940. */
  17941. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17942. /**
  17943. * Adds a new size gradient
  17944. * @param gradient defines the gradient to use (between 0 and 1)
  17945. * @param factor defines the size factor to affect to the specified gradient
  17946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17947. * @returns the current particle system
  17948. */
  17949. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17950. /**
  17951. * Remove a specific size gradient
  17952. * @param gradient defines the gradient to remove
  17953. * @returns the current particle system
  17954. */
  17955. removeSizeGradient(gradient: number): IParticleSystem;
  17956. /**
  17957. * Adds a new color remap gradient
  17958. * @param gradient defines the gradient to use (between 0 and 1)
  17959. * @param min defines the color remap minimal range
  17960. * @param max defines the color remap maximal range
  17961. * @returns the current particle system
  17962. */
  17963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17964. /**
  17965. * Remove a specific color remap gradient
  17966. * @param gradient defines the gradient to remove
  17967. * @returns the current particle system
  17968. */
  17969. removeColorRemapGradient(gradient: number): IParticleSystem;
  17970. /**
  17971. * Adds a new alpha remap gradient
  17972. * @param gradient defines the gradient to use (between 0 and 1)
  17973. * @param min defines the alpha remap minimal range
  17974. * @param max defines the alpha remap maximal range
  17975. * @returns the current particle system
  17976. */
  17977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17978. /**
  17979. * Remove a specific alpha remap gradient
  17980. * @param gradient defines the gradient to remove
  17981. * @returns the current particle system
  17982. */
  17983. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17984. /**
  17985. * Adds a new angular speed gradient
  17986. * @param gradient defines the gradient to use (between 0 and 1)
  17987. * @param factor defines the angular speed to affect to the specified gradient
  17988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17989. * @returns the current particle system
  17990. */
  17991. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17992. /**
  17993. * Remove a specific angular speed gradient
  17994. * @param gradient defines the gradient to remove
  17995. * @returns the current particle system
  17996. */
  17997. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17998. /**
  17999. * Adds a new velocity gradient
  18000. * @param gradient defines the gradient to use (between 0 and 1)
  18001. * @param factor defines the velocity to affect to the specified gradient
  18002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18003. * @returns the current particle system
  18004. */
  18005. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18006. /**
  18007. * Remove a specific velocity gradient
  18008. * @param gradient defines the gradient to remove
  18009. * @returns the current particle system
  18010. */
  18011. removeVelocityGradient(gradient: number): IParticleSystem;
  18012. /**
  18013. * Adds a new limit velocity gradient
  18014. * @param gradient defines the gradient to use (between 0 and 1)
  18015. * @param factor defines the limit velocity value to affect to the specified gradient
  18016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18017. * @returns the current particle system
  18018. */
  18019. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18020. /**
  18021. * Remove a specific limit velocity gradient
  18022. * @param gradient defines the gradient to remove
  18023. * @returns the current particle system
  18024. */
  18025. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18026. /**
  18027. * Adds a new drag gradient
  18028. * @param gradient defines the gradient to use (between 0 and 1)
  18029. * @param factor defines the drag value to affect to the specified gradient
  18030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18031. * @returns the current particle system
  18032. */
  18033. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18034. /**
  18035. * Remove a specific drag gradient
  18036. * @param gradient defines the gradient to remove
  18037. * @returns the current particle system
  18038. */
  18039. removeDragGradient(gradient: number): IParticleSystem;
  18040. /**
  18041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18042. * @param gradient defines the gradient to use (between 0 and 1)
  18043. * @param factor defines the emit rate value to affect to the specified gradient
  18044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18045. * @returns the current particle system
  18046. */
  18047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18048. /**
  18049. * Remove a specific emit rate gradient
  18050. * @param gradient defines the gradient to remove
  18051. * @returns the current particle system
  18052. */
  18053. removeEmitRateGradient(gradient: number): IParticleSystem;
  18054. /**
  18055. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18056. * @param gradient defines the gradient to use (between 0 and 1)
  18057. * @param factor defines the start size value to affect to the specified gradient
  18058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18059. * @returns the current particle system
  18060. */
  18061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18062. /**
  18063. * Remove a specific start size gradient
  18064. * @param gradient defines the gradient to remove
  18065. * @returns the current particle system
  18066. */
  18067. removeStartSizeGradient(gradient: number): IParticleSystem;
  18068. private _createRampGradientTexture;
  18069. /**
  18070. * Gets the current list of ramp gradients.
  18071. * You must use addRampGradient and removeRampGradient to udpate this list
  18072. * @returns the list of ramp gradients
  18073. */
  18074. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18075. /**
  18076. * Adds a new ramp gradient used to remap particle colors
  18077. * @param gradient defines the gradient to use (between 0 and 1)
  18078. * @param color defines the color to affect to the specified gradient
  18079. * @returns the current particle system
  18080. */
  18081. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18082. /**
  18083. * Remove a specific ramp gradient
  18084. * @param gradient defines the gradient to remove
  18085. * @returns the current particle system
  18086. */
  18087. removeRampGradient(gradient: number): ParticleSystem;
  18088. /**
  18089. * Adds a new color gradient
  18090. * @param gradient defines the gradient to use (between 0 and 1)
  18091. * @param color1 defines the color to affect to the specified gradient
  18092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18093. * @returns this particle system
  18094. */
  18095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18096. /**
  18097. * Remove a specific color gradient
  18098. * @param gradient defines the gradient to remove
  18099. * @returns this particle system
  18100. */
  18101. removeColorGradient(gradient: number): IParticleSystem;
  18102. private _fetchR;
  18103. protected _reset(): void;
  18104. private _resetEffect;
  18105. private _createVertexBuffers;
  18106. private _createIndexBuffer;
  18107. /**
  18108. * Gets the maximum number of particles active at the same time.
  18109. * @returns The max number of active particles.
  18110. */
  18111. getCapacity(): number;
  18112. /**
  18113. * Gets whether there are still active particles in the system.
  18114. * @returns True if it is alive, otherwise false.
  18115. */
  18116. isAlive(): boolean;
  18117. /**
  18118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18119. * @returns True if it has been started, otherwise false.
  18120. */
  18121. isStarted(): boolean;
  18122. private _prepareSubEmitterInternalArray;
  18123. /**
  18124. * Starts the particle system and begins to emit
  18125. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18126. */
  18127. start(delay?: number): void;
  18128. /**
  18129. * Stops the particle system.
  18130. * @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.
  18131. */
  18132. stop(stopSubEmitters?: boolean): void;
  18133. /**
  18134. * Remove all active particles
  18135. */
  18136. reset(): void;
  18137. /**
  18138. * @hidden (for internal use only)
  18139. */
  18140. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18141. /**
  18142. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18143. * Its lifetime will start back at 0.
  18144. */
  18145. recycleParticle: (particle: Particle) => void;
  18146. private _stopSubEmitters;
  18147. private _createParticle;
  18148. private _removeFromRoot;
  18149. private _emitFromParticle;
  18150. private _update;
  18151. /** @hidden */
  18152. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18153. /** @hidden */
  18154. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18155. /** @hidden */
  18156. private _getEffect;
  18157. /**
  18158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18159. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18160. */
  18161. animate(preWarmOnly?: boolean): void;
  18162. private _appendParticleVertices;
  18163. /**
  18164. * Rebuilds the particle system.
  18165. */
  18166. rebuild(): void;
  18167. /**
  18168. * Is this system ready to be used/rendered
  18169. * @return true if the system is ready
  18170. */
  18171. isReady(): boolean;
  18172. private _render;
  18173. /**
  18174. * Renders the particle system in its current state.
  18175. * @returns the current number of particles
  18176. */
  18177. render(): number;
  18178. /**
  18179. * Disposes the particle system and free the associated resources
  18180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18181. */
  18182. dispose(disposeTexture?: boolean): void;
  18183. /**
  18184. * Clones the particle system.
  18185. * @param name The name of the cloned object
  18186. * @param newEmitter The new emitter to use
  18187. * @returns the cloned particle system
  18188. */
  18189. clone(name: string, newEmitter: any): ParticleSystem;
  18190. /**
  18191. * Serializes the particle system to a JSON object.
  18192. * @returns the JSON object
  18193. */
  18194. serialize(): any;
  18195. /** @hidden */
  18196. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18197. /** @hidden */
  18198. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18199. /**
  18200. * Parses a JSON object to create a particle system.
  18201. * @param parsedParticleSystem The JSON object to parse
  18202. * @param scene The scene to create the particle system in
  18203. * @param rootUrl The root url to use to load external dependencies like texture
  18204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18205. * @returns the Parsed particle system
  18206. */
  18207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18208. }
  18209. }
  18210. declare module "babylonjs/Particles/particle" {
  18211. import { Nullable } from "babylonjs/types";
  18212. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18213. import { Color4 } from "babylonjs/Maths/math.color";
  18214. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18215. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18216. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18217. /**
  18218. * A particle represents one of the element emitted by a particle system.
  18219. * This is mainly define by its coordinates, direction, velocity and age.
  18220. */
  18221. export class Particle {
  18222. /**
  18223. * The particle system the particle belongs to.
  18224. */
  18225. particleSystem: ParticleSystem;
  18226. private static _Count;
  18227. /**
  18228. * Unique ID of the particle
  18229. */
  18230. id: number;
  18231. /**
  18232. * The world position of the particle in the scene.
  18233. */
  18234. position: Vector3;
  18235. /**
  18236. * The world direction of the particle in the scene.
  18237. */
  18238. direction: Vector3;
  18239. /**
  18240. * The color of the particle.
  18241. */
  18242. color: Color4;
  18243. /**
  18244. * The color change of the particle per step.
  18245. */
  18246. colorStep: Color4;
  18247. /**
  18248. * Defines how long will the life of the particle be.
  18249. */
  18250. lifeTime: number;
  18251. /**
  18252. * The current age of the particle.
  18253. */
  18254. age: number;
  18255. /**
  18256. * The current size of the particle.
  18257. */
  18258. size: number;
  18259. /**
  18260. * The current scale of the particle.
  18261. */
  18262. scale: Vector2;
  18263. /**
  18264. * The current angle of the particle.
  18265. */
  18266. angle: number;
  18267. /**
  18268. * Defines how fast is the angle changing.
  18269. */
  18270. angularSpeed: number;
  18271. /**
  18272. * Defines the cell index used by the particle to be rendered from a sprite.
  18273. */
  18274. cellIndex: number;
  18275. /**
  18276. * The information required to support color remapping
  18277. */
  18278. remapData: Vector4;
  18279. /** @hidden */
  18280. _randomCellOffset?: number;
  18281. /** @hidden */
  18282. _initialDirection: Nullable<Vector3>;
  18283. /** @hidden */
  18284. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18285. /** @hidden */
  18286. _initialStartSpriteCellID: number;
  18287. /** @hidden */
  18288. _initialEndSpriteCellID: number;
  18289. /** @hidden */
  18290. _currentColorGradient: Nullable<ColorGradient>;
  18291. /** @hidden */
  18292. _currentColor1: Color4;
  18293. /** @hidden */
  18294. _currentColor2: Color4;
  18295. /** @hidden */
  18296. _currentSizeGradient: Nullable<FactorGradient>;
  18297. /** @hidden */
  18298. _currentSize1: number;
  18299. /** @hidden */
  18300. _currentSize2: number;
  18301. /** @hidden */
  18302. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18303. /** @hidden */
  18304. _currentAngularSpeed1: number;
  18305. /** @hidden */
  18306. _currentAngularSpeed2: number;
  18307. /** @hidden */
  18308. _currentVelocityGradient: Nullable<FactorGradient>;
  18309. /** @hidden */
  18310. _currentVelocity1: number;
  18311. /** @hidden */
  18312. _currentVelocity2: number;
  18313. /** @hidden */
  18314. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18315. /** @hidden */
  18316. _currentLimitVelocity1: number;
  18317. /** @hidden */
  18318. _currentLimitVelocity2: number;
  18319. /** @hidden */
  18320. _currentDragGradient: Nullable<FactorGradient>;
  18321. /** @hidden */
  18322. _currentDrag1: number;
  18323. /** @hidden */
  18324. _currentDrag2: number;
  18325. /** @hidden */
  18326. _randomNoiseCoordinates1: Vector3;
  18327. /** @hidden */
  18328. _randomNoiseCoordinates2: Vector3;
  18329. /**
  18330. * Creates a new instance Particle
  18331. * @param particleSystem the particle system the particle belongs to
  18332. */
  18333. constructor(
  18334. /**
  18335. * The particle system the particle belongs to.
  18336. */
  18337. particleSystem: ParticleSystem);
  18338. private updateCellInfoFromSystem;
  18339. /**
  18340. * Defines how the sprite cell index is updated for the particle
  18341. */
  18342. updateCellIndex(): void;
  18343. /** @hidden */
  18344. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18345. /** @hidden */
  18346. _inheritParticleInfoToSubEmitters(): void;
  18347. /** @hidden */
  18348. _reset(): void;
  18349. /**
  18350. * Copy the properties of particle to another one.
  18351. * @param other the particle to copy the information to.
  18352. */
  18353. copyTo(other: Particle): void;
  18354. }
  18355. }
  18356. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18358. import { Effect } from "babylonjs/Materials/effect";
  18359. import { Particle } from "babylonjs/Particles/particle";
  18360. /**
  18361. * Particle emitter represents a volume emitting particles.
  18362. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18363. */
  18364. export interface IParticleEmitterType {
  18365. /**
  18366. * Called by the particle System when the direction is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param directionToUpdate is the direction vector to update with the result
  18369. * @param particle is the particle we are computed the direction for
  18370. */
  18371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Called by the particle System when the position is computed for the created particle.
  18374. * @param worldMatrix is the world matrix of the particle system
  18375. * @param positionToUpdate is the position vector to update with the result
  18376. * @param particle is the particle we are computed the position for
  18377. */
  18378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18379. /**
  18380. * Clones the current emitter and returns a copy of it
  18381. * @returns the new emitter
  18382. */
  18383. clone(): IParticleEmitterType;
  18384. /**
  18385. * Called by the GPUParticleSystem to setup the update shader
  18386. * @param effect defines the update shader
  18387. */
  18388. applyToShader(effect: Effect): void;
  18389. /**
  18390. * Returns a string to use to update the GPU particles update shader
  18391. * @returns the effect defines string
  18392. */
  18393. getEffectDefines(): string;
  18394. /**
  18395. * Returns a string representing the class name
  18396. * @returns a string containing the class name
  18397. */
  18398. getClassName(): string;
  18399. /**
  18400. * Serializes the particle system to a JSON object.
  18401. * @returns the JSON object
  18402. */
  18403. serialize(): any;
  18404. /**
  18405. * Parse properties from a JSON object
  18406. * @param serializationObject defines the JSON object
  18407. */
  18408. parse(serializationObject: any): void;
  18409. }
  18410. }
  18411. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18412. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18413. import { Effect } from "babylonjs/Materials/effect";
  18414. import { Particle } from "babylonjs/Particles/particle";
  18415. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18416. /**
  18417. * Particle emitter emitting particles from the inside of a box.
  18418. * It emits the particles randomly between 2 given directions.
  18419. */
  18420. export class BoxParticleEmitter implements IParticleEmitterType {
  18421. /**
  18422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18423. */
  18424. direction1: Vector3;
  18425. /**
  18426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18427. */
  18428. direction2: Vector3;
  18429. /**
  18430. * 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.
  18431. */
  18432. minEmitBox: Vector3;
  18433. /**
  18434. * 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.
  18435. */
  18436. maxEmitBox: Vector3;
  18437. /**
  18438. * Creates a new instance BoxParticleEmitter
  18439. */
  18440. constructor();
  18441. /**
  18442. * Called by the particle System when the direction is computed for the created particle.
  18443. * @param worldMatrix is the world matrix of the particle system
  18444. * @param directionToUpdate is the direction vector to update with the result
  18445. * @param particle is the particle we are computed the direction for
  18446. */
  18447. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18448. /**
  18449. * Called by the particle System when the position is computed for the created particle.
  18450. * @param worldMatrix is the world matrix of the particle system
  18451. * @param positionToUpdate is the position vector to update with the result
  18452. * @param particle is the particle we are computed the position for
  18453. */
  18454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18455. /**
  18456. * Clones the current emitter and returns a copy of it
  18457. * @returns the new emitter
  18458. */
  18459. clone(): BoxParticleEmitter;
  18460. /**
  18461. * Called by the GPUParticleSystem to setup the update shader
  18462. * @param effect defines the update shader
  18463. */
  18464. applyToShader(effect: Effect): void;
  18465. /**
  18466. * Returns a string to use to update the GPU particles update shader
  18467. * @returns a string containng the defines string
  18468. */
  18469. getEffectDefines(): string;
  18470. /**
  18471. * Returns the string "BoxParticleEmitter"
  18472. * @returns a string containing the class name
  18473. */
  18474. getClassName(): string;
  18475. /**
  18476. * Serializes the particle system to a JSON object.
  18477. * @returns the JSON object
  18478. */
  18479. serialize(): any;
  18480. /**
  18481. * Parse properties from a JSON object
  18482. * @param serializationObject defines the JSON object
  18483. */
  18484. parse(serializationObject: any): void;
  18485. }
  18486. }
  18487. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18488. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18489. import { Effect } from "babylonjs/Materials/effect";
  18490. import { Particle } from "babylonjs/Particles/particle";
  18491. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18492. /**
  18493. * Particle emitter emitting particles from the inside of a cone.
  18494. * It emits the particles alongside the cone volume from the base to the particle.
  18495. * The emission direction might be randomized.
  18496. */
  18497. export class ConeParticleEmitter implements IParticleEmitterType {
  18498. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18499. directionRandomizer: number;
  18500. private _radius;
  18501. private _angle;
  18502. private _height;
  18503. /**
  18504. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18505. */
  18506. radiusRange: number;
  18507. /**
  18508. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18509. */
  18510. heightRange: number;
  18511. /**
  18512. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18513. */
  18514. emitFromSpawnPointOnly: boolean;
  18515. /**
  18516. * Gets or sets the radius of the emission cone
  18517. */
  18518. get radius(): number;
  18519. set radius(value: number);
  18520. /**
  18521. * Gets or sets the angle of the emission cone
  18522. */
  18523. get angle(): number;
  18524. set angle(value: number);
  18525. private _buildHeight;
  18526. /**
  18527. * Creates a new instance ConeParticleEmitter
  18528. * @param radius the radius of the emission cone (1 by default)
  18529. * @param angle the cone base angle (PI by default)
  18530. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18531. */
  18532. constructor(radius?: number, angle?: number,
  18533. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18534. directionRandomizer?: number);
  18535. /**
  18536. * Called by the particle System when the direction is computed for the created particle.
  18537. * @param worldMatrix is the world matrix of the particle system
  18538. * @param directionToUpdate is the direction vector to update with the result
  18539. * @param particle is the particle we are computed the direction for
  18540. */
  18541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18542. /**
  18543. * Called by the particle System when the position is computed for the created particle.
  18544. * @param worldMatrix is the world matrix of the particle system
  18545. * @param positionToUpdate is the position vector to update with the result
  18546. * @param particle is the particle we are computed the position for
  18547. */
  18548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18549. /**
  18550. * Clones the current emitter and returns a copy of it
  18551. * @returns the new emitter
  18552. */
  18553. clone(): ConeParticleEmitter;
  18554. /**
  18555. * Called by the GPUParticleSystem to setup the update shader
  18556. * @param effect defines the update shader
  18557. */
  18558. applyToShader(effect: Effect): void;
  18559. /**
  18560. * Returns a string to use to update the GPU particles update shader
  18561. * @returns a string containng the defines string
  18562. */
  18563. getEffectDefines(): string;
  18564. /**
  18565. * Returns the string "ConeParticleEmitter"
  18566. * @returns a string containing the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Serializes the particle system to a JSON object.
  18571. * @returns the JSON object
  18572. */
  18573. serialize(): any;
  18574. /**
  18575. * Parse properties from a JSON object
  18576. * @param serializationObject defines the JSON object
  18577. */
  18578. parse(serializationObject: any): void;
  18579. }
  18580. }
  18581. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18583. import { Effect } from "babylonjs/Materials/effect";
  18584. import { Particle } from "babylonjs/Particles/particle";
  18585. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18586. /**
  18587. * Particle emitter emitting particles from the inside of a cylinder.
  18588. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18589. */
  18590. export class CylinderParticleEmitter implements IParticleEmitterType {
  18591. /**
  18592. * The radius of the emission cylinder.
  18593. */
  18594. radius: number;
  18595. /**
  18596. * The height of the emission cylinder.
  18597. */
  18598. height: number;
  18599. /**
  18600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18601. */
  18602. radiusRange: number;
  18603. /**
  18604. * How much to randomize the particle direction [0-1].
  18605. */
  18606. directionRandomizer: number;
  18607. /**
  18608. * Creates a new instance CylinderParticleEmitter
  18609. * @param radius the radius of the emission cylinder (1 by default)
  18610. * @param height the height of the emission cylinder (1 by default)
  18611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18612. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18613. */
  18614. constructor(
  18615. /**
  18616. * The radius of the emission cylinder.
  18617. */
  18618. radius?: number,
  18619. /**
  18620. * The height of the emission cylinder.
  18621. */
  18622. height?: number,
  18623. /**
  18624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18625. */
  18626. radiusRange?: number,
  18627. /**
  18628. * How much to randomize the particle direction [0-1].
  18629. */
  18630. directionRandomizer?: number);
  18631. /**
  18632. * Called by the particle System when the direction is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param directionToUpdate is the direction vector to update with the result
  18635. * @param particle is the particle we are computed the direction for
  18636. */
  18637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Called by the particle System when the position is computed for the created particle.
  18640. * @param worldMatrix is the world matrix of the particle system
  18641. * @param positionToUpdate is the position vector to update with the result
  18642. * @param particle is the particle we are computed the position for
  18643. */
  18644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18645. /**
  18646. * Clones the current emitter and returns a copy of it
  18647. * @returns the new emitter
  18648. */
  18649. clone(): CylinderParticleEmitter;
  18650. /**
  18651. * Called by the GPUParticleSystem to setup the update shader
  18652. * @param effect defines the update shader
  18653. */
  18654. applyToShader(effect: Effect): void;
  18655. /**
  18656. * Returns a string to use to update the GPU particles update shader
  18657. * @returns a string containng the defines string
  18658. */
  18659. getEffectDefines(): string;
  18660. /**
  18661. * Returns the string "CylinderParticleEmitter"
  18662. * @returns a string containing the class name
  18663. */
  18664. getClassName(): string;
  18665. /**
  18666. * Serializes the particle system to a JSON object.
  18667. * @returns the JSON object
  18668. */
  18669. serialize(): any;
  18670. /**
  18671. * Parse properties from a JSON object
  18672. * @param serializationObject defines the JSON object
  18673. */
  18674. parse(serializationObject: any): void;
  18675. }
  18676. /**
  18677. * Particle emitter emitting particles from the inside of a cylinder.
  18678. * It emits the particles randomly between two vectors.
  18679. */
  18680. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18681. /**
  18682. * The min limit of the emission direction.
  18683. */
  18684. direction1: Vector3;
  18685. /**
  18686. * The max limit of the emission direction.
  18687. */
  18688. direction2: Vector3;
  18689. /**
  18690. * Creates a new instance CylinderDirectedParticleEmitter
  18691. * @param radius the radius of the emission cylinder (1 by default)
  18692. * @param height the height of the emission cylinder (1 by default)
  18693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18694. * @param direction1 the min limit of the emission direction (up vector by default)
  18695. * @param direction2 the max limit of the emission direction (up vector by default)
  18696. */
  18697. constructor(radius?: number, height?: number, radiusRange?: number,
  18698. /**
  18699. * The min limit of the emission direction.
  18700. */
  18701. direction1?: Vector3,
  18702. /**
  18703. * The max limit of the emission direction.
  18704. */
  18705. direction2?: Vector3);
  18706. /**
  18707. * Called by the particle System when the direction is computed for the created particle.
  18708. * @param worldMatrix is the world matrix of the particle system
  18709. * @param directionToUpdate is the direction vector to update with the result
  18710. * @param particle is the particle we are computed the direction for
  18711. */
  18712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18713. /**
  18714. * Clones the current emitter and returns a copy of it
  18715. * @returns the new emitter
  18716. */
  18717. clone(): CylinderDirectedParticleEmitter;
  18718. /**
  18719. * Called by the GPUParticleSystem to setup the update shader
  18720. * @param effect defines the update shader
  18721. */
  18722. applyToShader(effect: Effect): void;
  18723. /**
  18724. * Returns a string to use to update the GPU particles update shader
  18725. * @returns a string containng the defines string
  18726. */
  18727. getEffectDefines(): string;
  18728. /**
  18729. * Returns the string "CylinderDirectedParticleEmitter"
  18730. * @returns a string containing the class name
  18731. */
  18732. getClassName(): string;
  18733. /**
  18734. * Serializes the particle system to a JSON object.
  18735. * @returns the JSON object
  18736. */
  18737. serialize(): any;
  18738. /**
  18739. * Parse properties from a JSON object
  18740. * @param serializationObject defines the JSON object
  18741. */
  18742. parse(serializationObject: any): void;
  18743. }
  18744. }
  18745. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18746. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18747. import { Effect } from "babylonjs/Materials/effect";
  18748. import { Particle } from "babylonjs/Particles/particle";
  18749. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18750. /**
  18751. * Particle emitter emitting particles from the inside of a hemisphere.
  18752. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18753. */
  18754. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18755. /**
  18756. * The radius of the emission hemisphere.
  18757. */
  18758. radius: number;
  18759. /**
  18760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18761. */
  18762. radiusRange: number;
  18763. /**
  18764. * How much to randomize the particle direction [0-1].
  18765. */
  18766. directionRandomizer: number;
  18767. /**
  18768. * Creates a new instance HemisphericParticleEmitter
  18769. * @param radius the radius of the emission hemisphere (1 by default)
  18770. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18771. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18772. */
  18773. constructor(
  18774. /**
  18775. * The radius of the emission hemisphere.
  18776. */
  18777. radius?: number,
  18778. /**
  18779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18780. */
  18781. radiusRange?: number,
  18782. /**
  18783. * How much to randomize the particle direction [0-1].
  18784. */
  18785. directionRandomizer?: number);
  18786. /**
  18787. * Called by the particle System when the direction is computed for the created particle.
  18788. * @param worldMatrix is the world matrix of the particle system
  18789. * @param directionToUpdate is the direction vector to update with the result
  18790. * @param particle is the particle we are computed the direction for
  18791. */
  18792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18793. /**
  18794. * Called by the particle System when the position is computed for the created particle.
  18795. * @param worldMatrix is the world matrix of the particle system
  18796. * @param positionToUpdate is the position vector to update with the result
  18797. * @param particle is the particle we are computed the position for
  18798. */
  18799. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18800. /**
  18801. * Clones the current emitter and returns a copy of it
  18802. * @returns the new emitter
  18803. */
  18804. clone(): HemisphericParticleEmitter;
  18805. /**
  18806. * Called by the GPUParticleSystem to setup the update shader
  18807. * @param effect defines the update shader
  18808. */
  18809. applyToShader(effect: Effect): void;
  18810. /**
  18811. * Returns a string to use to update the GPU particles update shader
  18812. * @returns a string containng the defines string
  18813. */
  18814. getEffectDefines(): string;
  18815. /**
  18816. * Returns the string "HemisphericParticleEmitter"
  18817. * @returns a string containing the class name
  18818. */
  18819. getClassName(): string;
  18820. /**
  18821. * Serializes the particle system to a JSON object.
  18822. * @returns the JSON object
  18823. */
  18824. serialize(): any;
  18825. /**
  18826. * Parse properties from a JSON object
  18827. * @param serializationObject defines the JSON object
  18828. */
  18829. parse(serializationObject: any): void;
  18830. }
  18831. }
  18832. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18833. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18834. import { Effect } from "babylonjs/Materials/effect";
  18835. import { Particle } from "babylonjs/Particles/particle";
  18836. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18837. /**
  18838. * Particle emitter emitting particles from a point.
  18839. * It emits the particles randomly between 2 given directions.
  18840. */
  18841. export class PointParticleEmitter implements IParticleEmitterType {
  18842. /**
  18843. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18844. */
  18845. direction1: Vector3;
  18846. /**
  18847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18848. */
  18849. direction2: Vector3;
  18850. /**
  18851. * Creates a new instance PointParticleEmitter
  18852. */
  18853. constructor();
  18854. /**
  18855. * Called by the particle System when the direction is computed for the created particle.
  18856. * @param worldMatrix is the world matrix of the particle system
  18857. * @param directionToUpdate is the direction vector to update with the result
  18858. * @param particle is the particle we are computed the direction for
  18859. */
  18860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18861. /**
  18862. * Called by the particle System when the position is computed for the created particle.
  18863. * @param worldMatrix is the world matrix of the particle system
  18864. * @param positionToUpdate is the position vector to update with the result
  18865. * @param particle is the particle we are computed the position for
  18866. */
  18867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18868. /**
  18869. * Clones the current emitter and returns a copy of it
  18870. * @returns the new emitter
  18871. */
  18872. clone(): PointParticleEmitter;
  18873. /**
  18874. * Called by the GPUParticleSystem to setup the update shader
  18875. * @param effect defines the update shader
  18876. */
  18877. applyToShader(effect: Effect): void;
  18878. /**
  18879. * Returns a string to use to update the GPU particles update shader
  18880. * @returns a string containng the defines string
  18881. */
  18882. getEffectDefines(): string;
  18883. /**
  18884. * Returns the string "PointParticleEmitter"
  18885. * @returns a string containing the class name
  18886. */
  18887. getClassName(): string;
  18888. /**
  18889. * Serializes the particle system to a JSON object.
  18890. * @returns the JSON object
  18891. */
  18892. serialize(): any;
  18893. /**
  18894. * Parse properties from a JSON object
  18895. * @param serializationObject defines the JSON object
  18896. */
  18897. parse(serializationObject: any): void;
  18898. }
  18899. }
  18900. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18901. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18902. import { Effect } from "babylonjs/Materials/effect";
  18903. import { Particle } from "babylonjs/Particles/particle";
  18904. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18905. /**
  18906. * Particle emitter emitting particles from the inside of a sphere.
  18907. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18908. */
  18909. export class SphereParticleEmitter implements IParticleEmitterType {
  18910. /**
  18911. * The radius of the emission sphere.
  18912. */
  18913. radius: number;
  18914. /**
  18915. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18916. */
  18917. radiusRange: number;
  18918. /**
  18919. * How much to randomize the particle direction [0-1].
  18920. */
  18921. directionRandomizer: number;
  18922. /**
  18923. * Creates a new instance SphereParticleEmitter
  18924. * @param radius the radius of the emission sphere (1 by default)
  18925. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18926. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18927. */
  18928. constructor(
  18929. /**
  18930. * The radius of the emission sphere.
  18931. */
  18932. radius?: number,
  18933. /**
  18934. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18935. */
  18936. radiusRange?: number,
  18937. /**
  18938. * How much to randomize the particle direction [0-1].
  18939. */
  18940. directionRandomizer?: number);
  18941. /**
  18942. * Called by the particle System when the direction is computed for the created particle.
  18943. * @param worldMatrix is the world matrix of the particle system
  18944. * @param directionToUpdate is the direction vector to update with the result
  18945. * @param particle is the particle we are computed the direction for
  18946. */
  18947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18948. /**
  18949. * Called by the particle System when the position is computed for the created particle.
  18950. * @param worldMatrix is the world matrix of the particle system
  18951. * @param positionToUpdate is the position vector to update with the result
  18952. * @param particle is the particle we are computed the position for
  18953. */
  18954. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18955. /**
  18956. * Clones the current emitter and returns a copy of it
  18957. * @returns the new emitter
  18958. */
  18959. clone(): SphereParticleEmitter;
  18960. /**
  18961. * Called by the GPUParticleSystem to setup the update shader
  18962. * @param effect defines the update shader
  18963. */
  18964. applyToShader(effect: Effect): void;
  18965. /**
  18966. * Returns a string to use to update the GPU particles update shader
  18967. * @returns a string containng the defines string
  18968. */
  18969. getEffectDefines(): string;
  18970. /**
  18971. * Returns the string "SphereParticleEmitter"
  18972. * @returns a string containing the class name
  18973. */
  18974. getClassName(): string;
  18975. /**
  18976. * Serializes the particle system to a JSON object.
  18977. * @returns the JSON object
  18978. */
  18979. serialize(): any;
  18980. /**
  18981. * Parse properties from a JSON object
  18982. * @param serializationObject defines the JSON object
  18983. */
  18984. parse(serializationObject: any): void;
  18985. }
  18986. /**
  18987. * Particle emitter emitting particles from the inside of a sphere.
  18988. * It emits the particles randomly between two vectors.
  18989. */
  18990. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18991. /**
  18992. * The min limit of the emission direction.
  18993. */
  18994. direction1: Vector3;
  18995. /**
  18996. * The max limit of the emission direction.
  18997. */
  18998. direction2: Vector3;
  18999. /**
  19000. * Creates a new instance SphereDirectedParticleEmitter
  19001. * @param radius the radius of the emission sphere (1 by default)
  19002. * @param direction1 the min limit of the emission direction (up vector by default)
  19003. * @param direction2 the max limit of the emission direction (up vector by default)
  19004. */
  19005. constructor(radius?: number,
  19006. /**
  19007. * The min limit of the emission direction.
  19008. */
  19009. direction1?: Vector3,
  19010. /**
  19011. * The max limit of the emission direction.
  19012. */
  19013. direction2?: Vector3);
  19014. /**
  19015. * Called by the particle System when the direction is computed for the created particle.
  19016. * @param worldMatrix is the world matrix of the particle system
  19017. * @param directionToUpdate is the direction vector to update with the result
  19018. * @param particle is the particle we are computed the direction for
  19019. */
  19020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19021. /**
  19022. * Clones the current emitter and returns a copy of it
  19023. * @returns the new emitter
  19024. */
  19025. clone(): SphereDirectedParticleEmitter;
  19026. /**
  19027. * Called by the GPUParticleSystem to setup the update shader
  19028. * @param effect defines the update shader
  19029. */
  19030. applyToShader(effect: Effect): void;
  19031. /**
  19032. * Returns a string to use to update the GPU particles update shader
  19033. * @returns a string containng the defines string
  19034. */
  19035. getEffectDefines(): string;
  19036. /**
  19037. * Returns the string "SphereDirectedParticleEmitter"
  19038. * @returns a string containing the class name
  19039. */
  19040. getClassName(): string;
  19041. /**
  19042. * Serializes the particle system to a JSON object.
  19043. * @returns the JSON object
  19044. */
  19045. serialize(): any;
  19046. /**
  19047. * Parse properties from a JSON object
  19048. * @param serializationObject defines the JSON object
  19049. */
  19050. parse(serializationObject: any): void;
  19051. }
  19052. }
  19053. declare module "babylonjs/Particles/EmitterTypes/index" {
  19054. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19055. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19056. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19057. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19058. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19059. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19060. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19061. }
  19062. declare module "babylonjs/Particles/IParticleSystem" {
  19063. import { Nullable } from "babylonjs/types";
  19064. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19065. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19068. import { Texture } from "babylonjs/Materials/Textures/texture";
  19069. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19070. import { Scene } from "babylonjs/scene";
  19071. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19072. import { Animation } from "babylonjs/Animations/animation";
  19073. /**
  19074. * Interface representing a particle system in Babylon.js.
  19075. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19076. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19077. */
  19078. export interface IParticleSystem {
  19079. /**
  19080. * List of animations used by the particle system.
  19081. */
  19082. animations: Animation[];
  19083. /**
  19084. * The id of the Particle system.
  19085. */
  19086. id: string;
  19087. /**
  19088. * The name of the Particle system.
  19089. */
  19090. name: string;
  19091. /**
  19092. * The emitter represents the Mesh or position we are attaching the particle system to.
  19093. */
  19094. emitter: Nullable<AbstractMesh | Vector3>;
  19095. /**
  19096. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19097. */
  19098. isBillboardBased: boolean;
  19099. /**
  19100. * The rendering group used by the Particle system to chose when to render.
  19101. */
  19102. renderingGroupId: number;
  19103. /**
  19104. * The layer mask we are rendering the particles through.
  19105. */
  19106. layerMask: number;
  19107. /**
  19108. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19109. */
  19110. updateSpeed: number;
  19111. /**
  19112. * The amount of time the particle system is running (depends of the overall update speed).
  19113. */
  19114. targetStopDuration: number;
  19115. /**
  19116. * The texture used to render each particle. (this can be a spritesheet)
  19117. */
  19118. particleTexture: Nullable<Texture>;
  19119. /**
  19120. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19121. */
  19122. blendMode: number;
  19123. /**
  19124. * Minimum life time of emitting particles.
  19125. */
  19126. minLifeTime: number;
  19127. /**
  19128. * Maximum life time of emitting particles.
  19129. */
  19130. maxLifeTime: number;
  19131. /**
  19132. * Minimum Size of emitting particles.
  19133. */
  19134. minSize: number;
  19135. /**
  19136. * Maximum Size of emitting particles.
  19137. */
  19138. maxSize: number;
  19139. /**
  19140. * Minimum scale of emitting particles on X axis.
  19141. */
  19142. minScaleX: number;
  19143. /**
  19144. * Maximum scale of emitting particles on X axis.
  19145. */
  19146. maxScaleX: number;
  19147. /**
  19148. * Minimum scale of emitting particles on Y axis.
  19149. */
  19150. minScaleY: number;
  19151. /**
  19152. * Maximum scale of emitting particles on Y axis.
  19153. */
  19154. maxScaleY: number;
  19155. /**
  19156. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19157. */
  19158. color1: Color4;
  19159. /**
  19160. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19161. */
  19162. color2: Color4;
  19163. /**
  19164. * Color the particle will have at the end of its lifetime.
  19165. */
  19166. colorDead: Color4;
  19167. /**
  19168. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19169. */
  19170. emitRate: number;
  19171. /**
  19172. * You can use gravity if you want to give an orientation to your particles.
  19173. */
  19174. gravity: Vector3;
  19175. /**
  19176. * Minimum power of emitting particles.
  19177. */
  19178. minEmitPower: number;
  19179. /**
  19180. * Maximum power of emitting particles.
  19181. */
  19182. maxEmitPower: number;
  19183. /**
  19184. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19185. */
  19186. minAngularSpeed: number;
  19187. /**
  19188. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19189. */
  19190. maxAngularSpeed: number;
  19191. /**
  19192. * Gets or sets the minimal initial rotation in radians.
  19193. */
  19194. minInitialRotation: number;
  19195. /**
  19196. * Gets or sets the maximal initial rotation in radians.
  19197. */
  19198. maxInitialRotation: number;
  19199. /**
  19200. * The particle emitter type defines the emitter used by the particle system.
  19201. * It can be for example box, sphere, or cone...
  19202. */
  19203. particleEmitterType: Nullable<IParticleEmitterType>;
  19204. /**
  19205. * Defines the delay in milliseconds before starting the system (0 by default)
  19206. */
  19207. startDelay: number;
  19208. /**
  19209. * 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
  19210. */
  19211. preWarmCycles: number;
  19212. /**
  19213. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19214. */
  19215. preWarmStepOffset: number;
  19216. /**
  19217. * 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)
  19218. */
  19219. spriteCellChangeSpeed: number;
  19220. /**
  19221. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19222. */
  19223. startSpriteCellID: number;
  19224. /**
  19225. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19226. */
  19227. endSpriteCellID: number;
  19228. /**
  19229. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19230. */
  19231. spriteCellWidth: number;
  19232. /**
  19233. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19234. */
  19235. spriteCellHeight: number;
  19236. /**
  19237. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19238. */
  19239. spriteRandomStartCell: boolean;
  19240. /**
  19241. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19242. */
  19243. isAnimationSheetEnabled: boolean;
  19244. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19245. translationPivot: Vector2;
  19246. /**
  19247. * Gets or sets a texture used to add random noise to particle positions
  19248. */
  19249. noiseTexture: Nullable<BaseTexture>;
  19250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19251. noiseStrength: Vector3;
  19252. /**
  19253. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19254. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19255. */
  19256. billboardMode: number;
  19257. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19258. limitVelocityDamping: number;
  19259. /**
  19260. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19261. */
  19262. beginAnimationOnStart: boolean;
  19263. /**
  19264. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19265. */
  19266. beginAnimationFrom: number;
  19267. /**
  19268. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19269. */
  19270. beginAnimationTo: number;
  19271. /**
  19272. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19273. */
  19274. beginAnimationLoop: boolean;
  19275. /**
  19276. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19277. */
  19278. disposeOnStop: boolean;
  19279. /**
  19280. * Gets the maximum number of particles active at the same time.
  19281. * @returns The max number of active particles.
  19282. */
  19283. getCapacity(): number;
  19284. /**
  19285. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19286. * @returns True if it has been started, otherwise false.
  19287. */
  19288. isStarted(): boolean;
  19289. /**
  19290. * Animates the particle system for this frame.
  19291. */
  19292. animate(): void;
  19293. /**
  19294. * Renders the particle system in its current state.
  19295. * @returns the current number of particles
  19296. */
  19297. render(): number;
  19298. /**
  19299. * Dispose the particle system and frees its associated resources.
  19300. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19301. */
  19302. dispose(disposeTexture?: boolean): void;
  19303. /**
  19304. * Clones the particle system.
  19305. * @param name The name of the cloned object
  19306. * @param newEmitter The new emitter to use
  19307. * @returns the cloned particle system
  19308. */
  19309. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19310. /**
  19311. * Serializes the particle system to a JSON object.
  19312. * @returns the JSON object
  19313. */
  19314. serialize(): any;
  19315. /**
  19316. * Rebuild the particle system
  19317. */
  19318. rebuild(): void;
  19319. /**
  19320. * Starts the particle system and begins to emit
  19321. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19322. */
  19323. start(delay?: number): void;
  19324. /**
  19325. * Stops the particle system.
  19326. */
  19327. stop(): void;
  19328. /**
  19329. * Remove all active particles
  19330. */
  19331. reset(): void;
  19332. /**
  19333. * Is this system ready to be used/rendered
  19334. * @return true if the system is ready
  19335. */
  19336. isReady(): boolean;
  19337. /**
  19338. * Adds a new color gradient
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param color1 defines the color to affect to the specified gradient
  19341. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19342. * @returns the current particle system
  19343. */
  19344. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19345. /**
  19346. * Remove a specific color gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeColorGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Adds a new size gradient
  19353. * @param gradient defines the gradient to use (between 0 and 1)
  19354. * @param factor defines the size factor to affect to the specified gradient
  19355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19356. * @returns the current particle system
  19357. */
  19358. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19359. /**
  19360. * Remove a specific size gradient
  19361. * @param gradient defines the gradient to remove
  19362. * @returns the current particle system
  19363. */
  19364. removeSizeGradient(gradient: number): IParticleSystem;
  19365. /**
  19366. * Gets the current list of color gradients.
  19367. * You must use addColorGradient and removeColorGradient to udpate this list
  19368. * @returns the list of color gradients
  19369. */
  19370. getColorGradients(): Nullable<Array<ColorGradient>>;
  19371. /**
  19372. * Gets the current list of size gradients.
  19373. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19374. * @returns the list of size gradients
  19375. */
  19376. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19377. /**
  19378. * Gets the current list of angular speed gradients.
  19379. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19380. * @returns the list of angular speed gradients
  19381. */
  19382. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19383. /**
  19384. * Adds a new angular speed gradient
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param factor defines the angular speed to affect to the specified gradient
  19387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19388. * @returns the current particle system
  19389. */
  19390. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19391. /**
  19392. * Remove a specific angular speed gradient
  19393. * @param gradient defines the gradient to remove
  19394. * @returns the current particle system
  19395. */
  19396. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19397. /**
  19398. * Gets the current list of velocity gradients.
  19399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19400. * @returns the list of velocity gradients
  19401. */
  19402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19403. /**
  19404. * Adds a new velocity gradient
  19405. * @param gradient defines the gradient to use (between 0 and 1)
  19406. * @param factor defines the velocity to affect to the specified gradient
  19407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19408. * @returns the current particle system
  19409. */
  19410. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19411. /**
  19412. * Remove a specific velocity gradient
  19413. * @param gradient defines the gradient to remove
  19414. * @returns the current particle system
  19415. */
  19416. removeVelocityGradient(gradient: number): IParticleSystem;
  19417. /**
  19418. * Gets the current list of limit velocity gradients.
  19419. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19420. * @returns the list of limit velocity gradients
  19421. */
  19422. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19423. /**
  19424. * Adds a new limit velocity gradient
  19425. * @param gradient defines the gradient to use (between 0 and 1)
  19426. * @param factor defines the limit velocity to affect to the specified gradient
  19427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19428. * @returns the current particle system
  19429. */
  19430. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19431. /**
  19432. * Remove a specific limit velocity gradient
  19433. * @param gradient defines the gradient to remove
  19434. * @returns the current particle system
  19435. */
  19436. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19437. /**
  19438. * Adds a new drag gradient
  19439. * @param gradient defines the gradient to use (between 0 and 1)
  19440. * @param factor defines the drag to affect to the specified gradient
  19441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19442. * @returns the current particle system
  19443. */
  19444. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19445. /**
  19446. * Remove a specific drag gradient
  19447. * @param gradient defines the gradient to remove
  19448. * @returns the current particle system
  19449. */
  19450. removeDragGradient(gradient: number): IParticleSystem;
  19451. /**
  19452. * Gets the current list of drag gradients.
  19453. * You must use addDragGradient and removeDragGradient to udpate this list
  19454. * @returns the list of drag gradients
  19455. */
  19456. getDragGradients(): Nullable<Array<FactorGradient>>;
  19457. /**
  19458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19459. * @param gradient defines the gradient to use (between 0 and 1)
  19460. * @param factor defines the emit rate to affect to the specified gradient
  19461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19462. * @returns the current particle system
  19463. */
  19464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19465. /**
  19466. * Remove a specific emit rate gradient
  19467. * @param gradient defines the gradient to remove
  19468. * @returns the current particle system
  19469. */
  19470. removeEmitRateGradient(gradient: number): IParticleSystem;
  19471. /**
  19472. * Gets the current list of emit rate gradients.
  19473. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19474. * @returns the list of emit rate gradients
  19475. */
  19476. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19477. /**
  19478. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19479. * @param gradient defines the gradient to use (between 0 and 1)
  19480. * @param factor defines the start size to affect to the specified gradient
  19481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19482. * @returns the current particle system
  19483. */
  19484. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19485. /**
  19486. * Remove a specific start size gradient
  19487. * @param gradient defines the gradient to remove
  19488. * @returns the current particle system
  19489. */
  19490. removeStartSizeGradient(gradient: number): IParticleSystem;
  19491. /**
  19492. * Gets the current list of start size gradients.
  19493. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19494. * @returns the list of start size gradients
  19495. */
  19496. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19497. /**
  19498. * Adds a new life time gradient
  19499. * @param gradient defines the gradient to use (between 0 and 1)
  19500. * @param factor defines the life time factor to affect to the specified gradient
  19501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19502. * @returns the current particle system
  19503. */
  19504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19505. /**
  19506. * Remove a specific life time gradient
  19507. * @param gradient defines the gradient to remove
  19508. * @returns the current particle system
  19509. */
  19510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19511. /**
  19512. * Gets the current list of life time gradients.
  19513. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19514. * @returns the list of life time gradients
  19515. */
  19516. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19517. /**
  19518. * Gets the current list of color gradients.
  19519. * You must use addColorGradient and removeColorGradient to udpate this list
  19520. * @returns the list of color gradients
  19521. */
  19522. getColorGradients(): Nullable<Array<ColorGradient>>;
  19523. /**
  19524. * Adds a new ramp gradient used to remap particle colors
  19525. * @param gradient defines the gradient to use (between 0 and 1)
  19526. * @param color defines the color to affect to the specified gradient
  19527. * @returns the current particle system
  19528. */
  19529. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19530. /**
  19531. * Gets the current list of ramp gradients.
  19532. * You must use addRampGradient and removeRampGradient to udpate this list
  19533. * @returns the list of ramp gradients
  19534. */
  19535. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19536. /** Gets or sets a boolean indicating that ramp gradients must be used
  19537. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19538. */
  19539. useRampGradients: boolean;
  19540. /**
  19541. * Adds a new color remap gradient
  19542. * @param gradient defines the gradient to use (between 0 and 1)
  19543. * @param min defines the color remap minimal range
  19544. * @param max defines the color remap maximal range
  19545. * @returns the current particle system
  19546. */
  19547. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19548. /**
  19549. * Gets the current list of color remap gradients.
  19550. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19551. * @returns the list of color remap gradients
  19552. */
  19553. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19554. /**
  19555. * Adds a new alpha remap gradient
  19556. * @param gradient defines the gradient to use (between 0 and 1)
  19557. * @param min defines the alpha remap minimal range
  19558. * @param max defines the alpha remap maximal range
  19559. * @returns the current particle system
  19560. */
  19561. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19562. /**
  19563. * Gets the current list of alpha remap gradients.
  19564. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19565. * @returns the list of alpha remap gradients
  19566. */
  19567. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19568. /**
  19569. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19572. * @returns the emitter
  19573. */
  19574. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19575. /**
  19576. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19577. * @param radius The radius of the hemisphere to emit from
  19578. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19579. * @returns the emitter
  19580. */
  19581. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19582. /**
  19583. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19584. * @param radius The radius of the sphere to emit from
  19585. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19586. * @returns the emitter
  19587. */
  19588. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19589. /**
  19590. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19591. * @param radius The radius of the sphere to emit from
  19592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19594. * @returns the emitter
  19595. */
  19596. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19597. /**
  19598. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19599. * @param radius The radius of the emission cylinder
  19600. * @param height The height of the emission cylinder
  19601. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19602. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19603. * @returns the emitter
  19604. */
  19605. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19606. /**
  19607. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19608. * @param radius The radius of the cylinder to emit from
  19609. * @param height The height of the emission cylinder
  19610. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19613. * @returns the emitter
  19614. */
  19615. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19616. /**
  19617. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19618. * @param radius The radius of the cone to emit from
  19619. * @param angle The base angle of the cone
  19620. * @returns the emitter
  19621. */
  19622. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19623. /**
  19624. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19627. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19628. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19629. * @returns the emitter
  19630. */
  19631. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19632. /**
  19633. * Get hosting scene
  19634. * @returns the scene
  19635. */
  19636. getScene(): Scene;
  19637. }
  19638. }
  19639. declare module "babylonjs/Meshes/instancedMesh" {
  19640. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19641. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19642. import { Camera } from "babylonjs/Cameras/camera";
  19643. import { Node } from "babylonjs/node";
  19644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19645. import { Mesh } from "babylonjs/Meshes/mesh";
  19646. import { Material } from "babylonjs/Materials/material";
  19647. import { Skeleton } from "babylonjs/Bones/skeleton";
  19648. import { Light } from "babylonjs/Lights/light";
  19649. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19650. /**
  19651. * Creates an instance based on a source mesh.
  19652. */
  19653. export class InstancedMesh extends AbstractMesh {
  19654. private _sourceMesh;
  19655. private _currentLOD;
  19656. /** @hidden */
  19657. _indexInSourceMeshInstanceArray: number;
  19658. constructor(name: string, source: Mesh);
  19659. /**
  19660. * Returns the string "InstancedMesh".
  19661. */
  19662. getClassName(): string;
  19663. /** Gets the list of lights affecting that mesh */
  19664. get lightSources(): Light[];
  19665. _resyncLightSources(): void;
  19666. _resyncLightSource(light: Light): void;
  19667. _removeLightSource(light: Light, dispose: boolean): void;
  19668. /**
  19669. * If the source mesh receives shadows
  19670. */
  19671. get receiveShadows(): boolean;
  19672. /**
  19673. * The material of the source mesh
  19674. */
  19675. get material(): Nullable<Material>;
  19676. /**
  19677. * Visibility of the source mesh
  19678. */
  19679. get visibility(): number;
  19680. /**
  19681. * Skeleton of the source mesh
  19682. */
  19683. get skeleton(): Nullable<Skeleton>;
  19684. /**
  19685. * Rendering ground id of the source mesh
  19686. */
  19687. get renderingGroupId(): number;
  19688. set renderingGroupId(value: number);
  19689. /**
  19690. * Returns the total number of vertices (integer).
  19691. */
  19692. getTotalVertices(): number;
  19693. /**
  19694. * Returns a positive integer : the total number of indices in this mesh geometry.
  19695. * @returns the numner of indices or zero if the mesh has no geometry.
  19696. */
  19697. getTotalIndices(): number;
  19698. /**
  19699. * The source mesh of the instance
  19700. */
  19701. get sourceMesh(): Mesh;
  19702. /**
  19703. * Is this node ready to be used/rendered
  19704. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19705. * @return {boolean} is it ready
  19706. */
  19707. isReady(completeCheck?: boolean): boolean;
  19708. /**
  19709. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19710. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19711. * @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.
  19712. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19713. */
  19714. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19715. /**
  19716. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19717. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19718. * The `data` are either a numeric array either a Float32Array.
  19719. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19720. * 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).
  19721. * Note that a new underlying VertexBuffer object is created each call.
  19722. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19723. *
  19724. * Possible `kind` values :
  19725. * - VertexBuffer.PositionKind
  19726. * - VertexBuffer.UVKind
  19727. * - VertexBuffer.UV2Kind
  19728. * - VertexBuffer.UV3Kind
  19729. * - VertexBuffer.UV4Kind
  19730. * - VertexBuffer.UV5Kind
  19731. * - VertexBuffer.UV6Kind
  19732. * - VertexBuffer.ColorKind
  19733. * - VertexBuffer.MatricesIndicesKind
  19734. * - VertexBuffer.MatricesIndicesExtraKind
  19735. * - VertexBuffer.MatricesWeightsKind
  19736. * - VertexBuffer.MatricesWeightsExtraKind
  19737. *
  19738. * Returns the Mesh.
  19739. */
  19740. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19741. /**
  19742. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19743. * If the mesh has no geometry, it is simply returned as it is.
  19744. * The `data` are either a numeric array either a Float32Array.
  19745. * No new underlying VertexBuffer object is created.
  19746. * 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.
  19747. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19748. *
  19749. * Possible `kind` values :
  19750. * - VertexBuffer.PositionKind
  19751. * - VertexBuffer.UVKind
  19752. * - VertexBuffer.UV2Kind
  19753. * - VertexBuffer.UV3Kind
  19754. * - VertexBuffer.UV4Kind
  19755. * - VertexBuffer.UV5Kind
  19756. * - VertexBuffer.UV6Kind
  19757. * - VertexBuffer.ColorKind
  19758. * - VertexBuffer.MatricesIndicesKind
  19759. * - VertexBuffer.MatricesIndicesExtraKind
  19760. * - VertexBuffer.MatricesWeightsKind
  19761. * - VertexBuffer.MatricesWeightsExtraKind
  19762. *
  19763. * Returns the Mesh.
  19764. */
  19765. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19766. /**
  19767. * Sets the mesh indices.
  19768. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19769. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19770. * This method creates a new index buffer each call.
  19771. * Returns the Mesh.
  19772. */
  19773. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19774. /**
  19775. * Boolean : True if the mesh owns the requested kind of data.
  19776. */
  19777. isVerticesDataPresent(kind: string): boolean;
  19778. /**
  19779. * Returns an array of indices (IndicesArray).
  19780. */
  19781. getIndices(): Nullable<IndicesArray>;
  19782. get _positions(): Nullable<Vector3[]>;
  19783. /**
  19784. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19785. * This means the mesh underlying bounding box and sphere are recomputed.
  19786. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19787. * @returns the current mesh
  19788. */
  19789. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19790. /** @hidden */
  19791. _preActivate(): InstancedMesh;
  19792. /** @hidden */
  19793. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19794. /** @hidden */
  19795. _postActivate(): void;
  19796. getWorldMatrix(): Matrix;
  19797. get isAnInstance(): boolean;
  19798. /**
  19799. * Returns the current associated LOD AbstractMesh.
  19800. */
  19801. getLOD(camera: Camera): AbstractMesh;
  19802. /** @hidden */
  19803. _syncSubMeshes(): InstancedMesh;
  19804. /** @hidden */
  19805. _generatePointsArray(): boolean;
  19806. /**
  19807. * Creates a new InstancedMesh from the current mesh.
  19808. * - name (string) : the cloned mesh name
  19809. * - newParent (optional Node) : the optional Node to parent the clone to.
  19810. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19811. *
  19812. * Returns the clone.
  19813. */
  19814. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19815. /**
  19816. * Disposes the InstancedMesh.
  19817. * Returns nothing.
  19818. */
  19819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19820. }
  19821. module "babylonjs/Meshes/mesh" {
  19822. interface Mesh {
  19823. /**
  19824. * Register a custom buffer that will be instanced
  19825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19826. * @param kind defines the buffer kind
  19827. * @param stride defines the stride in floats
  19828. */
  19829. registerInstancedBuffer(kind: string, stride: number): void;
  19830. /** @hidden */
  19831. _userInstancedBuffersStorage: {
  19832. data: {
  19833. [key: string]: Float32Array;
  19834. };
  19835. sizes: {
  19836. [key: string]: number;
  19837. };
  19838. vertexBuffers: {
  19839. [key: string]: Nullable<VertexBuffer>;
  19840. };
  19841. strides: {
  19842. [key: string]: number;
  19843. };
  19844. };
  19845. }
  19846. }
  19847. module "babylonjs/Meshes/abstractMesh" {
  19848. interface AbstractMesh {
  19849. /**
  19850. * Object used to store instanced buffers defined by user
  19851. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19852. */
  19853. instancedBuffers: {
  19854. [key: string]: any;
  19855. };
  19856. }
  19857. }
  19858. }
  19859. declare module "babylonjs/Materials/shaderMaterial" {
  19860. import { Scene } from "babylonjs/scene";
  19861. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19863. import { Mesh } from "babylonjs/Meshes/mesh";
  19864. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19866. import { Texture } from "babylonjs/Materials/Textures/texture";
  19867. import { Material } from "babylonjs/Materials/material";
  19868. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19869. /**
  19870. * Defines the options associated with the creation of a shader material.
  19871. */
  19872. export interface IShaderMaterialOptions {
  19873. /**
  19874. * Does the material work in alpha blend mode
  19875. */
  19876. needAlphaBlending: boolean;
  19877. /**
  19878. * Does the material work in alpha test mode
  19879. */
  19880. needAlphaTesting: boolean;
  19881. /**
  19882. * The list of attribute names used in the shader
  19883. */
  19884. attributes: string[];
  19885. /**
  19886. * The list of unifrom names used in the shader
  19887. */
  19888. uniforms: string[];
  19889. /**
  19890. * The list of UBO names used in the shader
  19891. */
  19892. uniformBuffers: string[];
  19893. /**
  19894. * The list of sampler names used in the shader
  19895. */
  19896. samplers: string[];
  19897. /**
  19898. * The list of defines used in the shader
  19899. */
  19900. defines: string[];
  19901. }
  19902. /**
  19903. * 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.
  19904. *
  19905. * This returned material effects how the mesh will look based on the code in the shaders.
  19906. *
  19907. * @see http://doc.babylonjs.com/how_to/shader_material
  19908. */
  19909. export class ShaderMaterial extends Material {
  19910. private _shaderPath;
  19911. private _options;
  19912. private _textures;
  19913. private _textureArrays;
  19914. private _floats;
  19915. private _ints;
  19916. private _floatsArrays;
  19917. private _colors3;
  19918. private _colors3Arrays;
  19919. private _colors4;
  19920. private _colors4Arrays;
  19921. private _vectors2;
  19922. private _vectors3;
  19923. private _vectors4;
  19924. private _matrices;
  19925. private _matrixArrays;
  19926. private _matrices3x3;
  19927. private _matrices2x2;
  19928. private _vectors2Arrays;
  19929. private _vectors3Arrays;
  19930. private _vectors4Arrays;
  19931. private _cachedWorldViewMatrix;
  19932. private _cachedWorldViewProjectionMatrix;
  19933. private _renderId;
  19934. private _multiview;
  19935. /**
  19936. * Instantiate a new shader material.
  19937. * 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.
  19938. * This returned material effects how the mesh will look based on the code in the shaders.
  19939. * @see http://doc.babylonjs.com/how_to/shader_material
  19940. * @param name Define the name of the material in the scene
  19941. * @param scene Define the scene the material belongs to
  19942. * @param shaderPath Defines the route to the shader code in one of three ways:
  19943. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19944. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19945. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19946. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19947. * @param options Define the options used to create the shader
  19948. */
  19949. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19950. /**
  19951. * Gets the shader path used to define the shader code
  19952. * It can be modified to trigger a new compilation
  19953. */
  19954. get shaderPath(): any;
  19955. /**
  19956. * Sets the shader path used to define the shader code
  19957. * It can be modified to trigger a new compilation
  19958. */
  19959. set shaderPath(shaderPath: any);
  19960. /**
  19961. * Gets the options used to compile the shader.
  19962. * They can be modified to trigger a new compilation
  19963. */
  19964. get options(): IShaderMaterialOptions;
  19965. /**
  19966. * Gets the current class name of the material e.g. "ShaderMaterial"
  19967. * Mainly use in serialization.
  19968. * @returns the class name
  19969. */
  19970. getClassName(): string;
  19971. /**
  19972. * Specifies if the material will require alpha blending
  19973. * @returns a boolean specifying if alpha blending is needed
  19974. */
  19975. needAlphaBlending(): boolean;
  19976. /**
  19977. * Specifies if this material should be rendered in alpha test mode
  19978. * @returns a boolean specifying if an alpha test is needed.
  19979. */
  19980. needAlphaTesting(): boolean;
  19981. private _checkUniform;
  19982. /**
  19983. * Set a texture in the shader.
  19984. * @param name Define the name of the uniform samplers as defined in the shader
  19985. * @param texture Define the texture to bind to this sampler
  19986. * @return the material itself allowing "fluent" like uniform updates
  19987. */
  19988. setTexture(name: string, texture: Texture): ShaderMaterial;
  19989. /**
  19990. * Set a texture array in the shader.
  19991. * @param name Define the name of the uniform sampler array as defined in the shader
  19992. * @param textures Define the list of textures to bind to this sampler
  19993. * @return the material itself allowing "fluent" like uniform updates
  19994. */
  19995. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19996. /**
  19997. * Set a float in the shader.
  19998. * @param name Define the name of the uniform as defined in the shader
  19999. * @param value Define the value to give to the uniform
  20000. * @return the material itself allowing "fluent" like uniform updates
  20001. */
  20002. setFloat(name: string, value: number): ShaderMaterial;
  20003. /**
  20004. * Set a int in the shader.
  20005. * @param name Define the name of the uniform as defined in the shader
  20006. * @param value Define the value to give to the uniform
  20007. * @return the material itself allowing "fluent" like uniform updates
  20008. */
  20009. setInt(name: string, value: number): ShaderMaterial;
  20010. /**
  20011. * Set an array of floats in the shader.
  20012. * @param name Define the name of the uniform as defined in the shader
  20013. * @param value Define the value to give to the uniform
  20014. * @return the material itself allowing "fluent" like uniform updates
  20015. */
  20016. setFloats(name: string, value: number[]): ShaderMaterial;
  20017. /**
  20018. * Set a vec3 in the shader from a Color3.
  20019. * @param name Define the name of the uniform as defined in the shader
  20020. * @param value Define the value to give to the uniform
  20021. * @return the material itself allowing "fluent" like uniform updates
  20022. */
  20023. setColor3(name: string, value: Color3): ShaderMaterial;
  20024. /**
  20025. * Set a vec3 array in the shader from a Color3 array.
  20026. * @param name Define the name of the uniform as defined in the shader
  20027. * @param value Define the value to give to the uniform
  20028. * @return the material itself allowing "fluent" like uniform updates
  20029. */
  20030. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20031. /**
  20032. * Set a vec4 in the shader from a Color4.
  20033. * @param name Define the name of the uniform as defined in the shader
  20034. * @param value Define the value to give to the uniform
  20035. * @return the material itself allowing "fluent" like uniform updates
  20036. */
  20037. setColor4(name: string, value: Color4): ShaderMaterial;
  20038. /**
  20039. * Set a vec4 array in the shader from a Color4 array.
  20040. * @param name Define the name of the uniform as defined in the shader
  20041. * @param value Define the value to give to the uniform
  20042. * @return the material itself allowing "fluent" like uniform updates
  20043. */
  20044. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20045. /**
  20046. * Set a vec2 in the shader from a Vector2.
  20047. * @param name Define the name of the uniform as defined in the shader
  20048. * @param value Define the value to give to the uniform
  20049. * @return the material itself allowing "fluent" like uniform updates
  20050. */
  20051. setVector2(name: string, value: Vector2): ShaderMaterial;
  20052. /**
  20053. * Set a vec3 in the shader from a Vector3.
  20054. * @param name Define the name of the uniform as defined in the shader
  20055. * @param value Define the value to give to the uniform
  20056. * @return the material itself allowing "fluent" like uniform updates
  20057. */
  20058. setVector3(name: string, value: Vector3): ShaderMaterial;
  20059. /**
  20060. * Set a vec4 in the shader from a Vector4.
  20061. * @param name Define the name of the uniform as defined in the shader
  20062. * @param value Define the value to give to the uniform
  20063. * @return the material itself allowing "fluent" like uniform updates
  20064. */
  20065. setVector4(name: string, value: Vector4): ShaderMaterial;
  20066. /**
  20067. * Set a mat4 in the shader from a Matrix.
  20068. * @param name Define the name of the uniform as defined in the shader
  20069. * @param value Define the value to give to the uniform
  20070. * @return the material itself allowing "fluent" like uniform updates
  20071. */
  20072. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20073. /**
  20074. * Set a float32Array in the shader from a matrix array.
  20075. * @param name Define the name of the uniform as defined in the shader
  20076. * @param value Define the value to give to the uniform
  20077. * @return the material itself allowing "fluent" like uniform updates
  20078. */
  20079. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20080. /**
  20081. * Set a mat3 in the shader from a Float32Array.
  20082. * @param name Define the name of the uniform as defined in the shader
  20083. * @param value Define the value to give to the uniform
  20084. * @return the material itself allowing "fluent" like uniform updates
  20085. */
  20086. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20087. /**
  20088. * Set a mat2 in the shader from a Float32Array.
  20089. * @param name Define the name of the uniform as defined in the shader
  20090. * @param value Define the value to give to the uniform
  20091. * @return the material itself allowing "fluent" like uniform updates
  20092. */
  20093. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20094. /**
  20095. * Set a vec2 array in the shader from a number array.
  20096. * @param name Define the name of the uniform as defined in the shader
  20097. * @param value Define the value to give to the uniform
  20098. * @return the material itself allowing "fluent" like uniform updates
  20099. */
  20100. setArray2(name: string, value: number[]): ShaderMaterial;
  20101. /**
  20102. * Set a vec3 array in the shader from a number array.
  20103. * @param name Define the name of the uniform as defined in the shader
  20104. * @param value Define the value to give to the uniform
  20105. * @return the material itself allowing "fluent" like uniform updates
  20106. */
  20107. setArray3(name: string, value: number[]): ShaderMaterial;
  20108. /**
  20109. * Set a vec4 array in the shader from a number array.
  20110. * @param name Define the name of the uniform as defined in the shader
  20111. * @param value Define the value to give to the uniform
  20112. * @return the material itself allowing "fluent" like uniform updates
  20113. */
  20114. setArray4(name: string, value: number[]): ShaderMaterial;
  20115. private _checkCache;
  20116. /**
  20117. * Specifies that the submesh is ready to be used
  20118. * @param mesh defines the mesh to check
  20119. * @param subMesh defines which submesh to check
  20120. * @param useInstances specifies that instances should be used
  20121. * @returns a boolean indicating that the submesh is ready or not
  20122. */
  20123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20124. /**
  20125. * Checks if the material is ready to render the requested mesh
  20126. * @param mesh Define the mesh to render
  20127. * @param useInstances Define whether or not the material is used with instances
  20128. * @returns true if ready, otherwise false
  20129. */
  20130. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20131. /**
  20132. * Binds the world matrix to the material
  20133. * @param world defines the world transformation matrix
  20134. */
  20135. bindOnlyWorldMatrix(world: Matrix): void;
  20136. /**
  20137. * Binds the material to the mesh
  20138. * @param world defines the world transformation matrix
  20139. * @param mesh defines the mesh to bind the material to
  20140. */
  20141. bind(world: Matrix, mesh?: Mesh): void;
  20142. /**
  20143. * Gets the active textures from the material
  20144. * @returns an array of textures
  20145. */
  20146. getActiveTextures(): BaseTexture[];
  20147. /**
  20148. * Specifies if the material uses a texture
  20149. * @param texture defines the texture to check against the material
  20150. * @returns a boolean specifying if the material uses the texture
  20151. */
  20152. hasTexture(texture: BaseTexture): boolean;
  20153. /**
  20154. * Makes a duplicate of the material, and gives it a new name
  20155. * @param name defines the new name for the duplicated material
  20156. * @returns the cloned material
  20157. */
  20158. clone(name: string): ShaderMaterial;
  20159. /**
  20160. * Disposes the material
  20161. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20162. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20163. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20164. */
  20165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20166. /**
  20167. * Serializes this material in a JSON representation
  20168. * @returns the serialized material object
  20169. */
  20170. serialize(): any;
  20171. /**
  20172. * Creates a shader material from parsed shader material data
  20173. * @param source defines the JSON represnetation of the material
  20174. * @param scene defines the hosting scene
  20175. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20176. * @returns a new material
  20177. */
  20178. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20179. }
  20180. }
  20181. declare module "babylonjs/Shaders/color.fragment" {
  20182. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20183. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20184. /** @hidden */
  20185. export var colorPixelShader: {
  20186. name: string;
  20187. shader: string;
  20188. };
  20189. }
  20190. declare module "babylonjs/Shaders/color.vertex" {
  20191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20192. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20193. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20194. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20195. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20196. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20197. /** @hidden */
  20198. export var colorVertexShader: {
  20199. name: string;
  20200. shader: string;
  20201. };
  20202. }
  20203. declare module "babylonjs/Meshes/linesMesh" {
  20204. import { Nullable } from "babylonjs/types";
  20205. import { Scene } from "babylonjs/scene";
  20206. import { Color3 } from "babylonjs/Maths/math.color";
  20207. import { Node } from "babylonjs/node";
  20208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20209. import { Mesh } from "babylonjs/Meshes/mesh";
  20210. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20211. import { Effect } from "babylonjs/Materials/effect";
  20212. import { Material } from "babylonjs/Materials/material";
  20213. import "babylonjs/Shaders/color.fragment";
  20214. import "babylonjs/Shaders/color.vertex";
  20215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20216. /**
  20217. * Line mesh
  20218. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20219. */
  20220. export class LinesMesh extends Mesh {
  20221. /**
  20222. * If vertex color should be applied to the mesh
  20223. */
  20224. readonly useVertexColor?: boolean | undefined;
  20225. /**
  20226. * If vertex alpha should be applied to the mesh
  20227. */
  20228. readonly useVertexAlpha?: boolean | undefined;
  20229. /**
  20230. * Color of the line (Default: White)
  20231. */
  20232. color: Color3;
  20233. /**
  20234. * Alpha of the line (Default: 1)
  20235. */
  20236. alpha: number;
  20237. /**
  20238. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20239. * This margin is expressed in world space coordinates, so its value may vary.
  20240. * Default value is 0.1
  20241. */
  20242. intersectionThreshold: number;
  20243. private _colorShader;
  20244. private color4;
  20245. /**
  20246. * Creates a new LinesMesh
  20247. * @param name defines the name
  20248. * @param scene defines the hosting scene
  20249. * @param parent defines the parent mesh if any
  20250. * @param source defines the optional source LinesMesh used to clone data from
  20251. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20252. * When false, achieved by calling a clone(), also passing False.
  20253. * This will make creation of children, recursive.
  20254. * @param useVertexColor defines if this LinesMesh supports vertex color
  20255. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20256. */
  20257. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20258. /**
  20259. * If vertex color should be applied to the mesh
  20260. */
  20261. useVertexColor?: boolean | undefined,
  20262. /**
  20263. * If vertex alpha should be applied to the mesh
  20264. */
  20265. useVertexAlpha?: boolean | undefined);
  20266. private _addClipPlaneDefine;
  20267. private _removeClipPlaneDefine;
  20268. isReady(): boolean;
  20269. /**
  20270. * Returns the string "LineMesh"
  20271. */
  20272. getClassName(): string;
  20273. /**
  20274. * @hidden
  20275. */
  20276. get material(): Material;
  20277. /**
  20278. * @hidden
  20279. */
  20280. set material(value: Material);
  20281. /**
  20282. * @hidden
  20283. */
  20284. get checkCollisions(): boolean;
  20285. /** @hidden */
  20286. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20287. /** @hidden */
  20288. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20289. /**
  20290. * Disposes of the line mesh
  20291. * @param doNotRecurse If children should be disposed
  20292. */
  20293. dispose(doNotRecurse?: boolean): void;
  20294. /**
  20295. * Returns a new LineMesh object cloned from the current one.
  20296. */
  20297. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20298. /**
  20299. * Creates a new InstancedLinesMesh object from the mesh model.
  20300. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20301. * @param name defines the name of the new instance
  20302. * @returns a new InstancedLinesMesh
  20303. */
  20304. createInstance(name: string): InstancedLinesMesh;
  20305. }
  20306. /**
  20307. * Creates an instance based on a source LinesMesh
  20308. */
  20309. export class InstancedLinesMesh extends InstancedMesh {
  20310. /**
  20311. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20312. * This margin is expressed in world space coordinates, so its value may vary.
  20313. * Initilized with the intersectionThreshold value of the source LinesMesh
  20314. */
  20315. intersectionThreshold: number;
  20316. constructor(name: string, source: LinesMesh);
  20317. /**
  20318. * Returns the string "InstancedLinesMesh".
  20319. */
  20320. getClassName(): string;
  20321. }
  20322. }
  20323. declare module "babylonjs/Shaders/line.fragment" {
  20324. /** @hidden */
  20325. export var linePixelShader: {
  20326. name: string;
  20327. shader: string;
  20328. };
  20329. }
  20330. declare module "babylonjs/Shaders/line.vertex" {
  20331. /** @hidden */
  20332. export var lineVertexShader: {
  20333. name: string;
  20334. shader: string;
  20335. };
  20336. }
  20337. declare module "babylonjs/Rendering/edgesRenderer" {
  20338. import { Nullable } from "babylonjs/types";
  20339. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20341. import { Vector3 } from "babylonjs/Maths/math.vector";
  20342. import { IDisposable } from "babylonjs/scene";
  20343. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20344. import "babylonjs/Shaders/line.fragment";
  20345. import "babylonjs/Shaders/line.vertex";
  20346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20347. module "babylonjs/Meshes/abstractMesh" {
  20348. interface AbstractMesh {
  20349. /**
  20350. * Gets the edgesRenderer associated with the mesh
  20351. */
  20352. edgesRenderer: Nullable<EdgesRenderer>;
  20353. }
  20354. }
  20355. module "babylonjs/Meshes/linesMesh" {
  20356. interface LinesMesh {
  20357. /**
  20358. * Enables the edge rendering mode on the mesh.
  20359. * This mode makes the mesh edges visible
  20360. * @param epsilon defines the maximal distance between two angles to detect a face
  20361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20362. * @returns the currentAbstractMesh
  20363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20364. */
  20365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20366. }
  20367. }
  20368. module "babylonjs/Meshes/linesMesh" {
  20369. interface InstancedLinesMesh {
  20370. /**
  20371. * Enables the edge rendering mode on the mesh.
  20372. * This mode makes the mesh edges visible
  20373. * @param epsilon defines the maximal distance between two angles to detect a face
  20374. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20375. * @returns the current InstancedLinesMesh
  20376. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20377. */
  20378. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20379. }
  20380. }
  20381. /**
  20382. * Defines the minimum contract an Edges renderer should follow.
  20383. */
  20384. export interface IEdgesRenderer extends IDisposable {
  20385. /**
  20386. * Gets or sets a boolean indicating if the edgesRenderer is active
  20387. */
  20388. isEnabled: boolean;
  20389. /**
  20390. * Renders the edges of the attached mesh,
  20391. */
  20392. render(): void;
  20393. /**
  20394. * Checks wether or not the edges renderer is ready to render.
  20395. * @return true if ready, otherwise false.
  20396. */
  20397. isReady(): boolean;
  20398. }
  20399. /**
  20400. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20401. */
  20402. export class EdgesRenderer implements IEdgesRenderer {
  20403. /**
  20404. * Define the size of the edges with an orthographic camera
  20405. */
  20406. edgesWidthScalerForOrthographic: number;
  20407. /**
  20408. * Define the size of the edges with a perspective camera
  20409. */
  20410. edgesWidthScalerForPerspective: number;
  20411. protected _source: AbstractMesh;
  20412. protected _linesPositions: number[];
  20413. protected _linesNormals: number[];
  20414. protected _linesIndices: number[];
  20415. protected _epsilon: number;
  20416. protected _indicesCount: number;
  20417. protected _lineShader: ShaderMaterial;
  20418. protected _ib: DataBuffer;
  20419. protected _buffers: {
  20420. [key: string]: Nullable<VertexBuffer>;
  20421. };
  20422. protected _checkVerticesInsteadOfIndices: boolean;
  20423. private _meshRebuildObserver;
  20424. private _meshDisposeObserver;
  20425. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20426. isEnabled: boolean;
  20427. /**
  20428. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20429. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20430. * @param source Mesh used to create edges
  20431. * @param epsilon sum of angles in adjacency to check for edge
  20432. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20433. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20434. */
  20435. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20436. protected _prepareRessources(): void;
  20437. /** @hidden */
  20438. _rebuild(): void;
  20439. /**
  20440. * Releases the required resources for the edges renderer
  20441. */
  20442. dispose(): void;
  20443. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20444. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20445. /**
  20446. * Checks if the pair of p0 and p1 is en edge
  20447. * @param faceIndex
  20448. * @param edge
  20449. * @param faceNormals
  20450. * @param p0
  20451. * @param p1
  20452. * @private
  20453. */
  20454. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20455. /**
  20456. * push line into the position, normal and index buffer
  20457. * @protected
  20458. */
  20459. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20460. /**
  20461. * Generates lines edges from adjacencjes
  20462. * @private
  20463. */
  20464. _generateEdgesLines(): void;
  20465. /**
  20466. * Checks wether or not the edges renderer is ready to render.
  20467. * @return true if ready, otherwise false.
  20468. */
  20469. isReady(): boolean;
  20470. /**
  20471. * Renders the edges of the attached mesh,
  20472. */
  20473. render(): void;
  20474. }
  20475. /**
  20476. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20477. */
  20478. export class LineEdgesRenderer extends EdgesRenderer {
  20479. /**
  20480. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20481. * @param source LineMesh used to generate edges
  20482. * @param epsilon not important (specified angle for edge detection)
  20483. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20484. */
  20485. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20486. /**
  20487. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20488. */
  20489. _generateEdgesLines(): void;
  20490. }
  20491. }
  20492. declare module "babylonjs/Rendering/renderingGroup" {
  20493. import { SmartArray } from "babylonjs/Misc/smartArray";
  20494. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20496. import { Nullable } from "babylonjs/types";
  20497. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20498. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20499. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20500. import { Material } from "babylonjs/Materials/material";
  20501. import { Scene } from "babylonjs/scene";
  20502. /**
  20503. * This represents the object necessary to create a rendering group.
  20504. * This is exclusively used and created by the rendering manager.
  20505. * To modify the behavior, you use the available helpers in your scene or meshes.
  20506. * @hidden
  20507. */
  20508. export class RenderingGroup {
  20509. index: number;
  20510. private static _zeroVector;
  20511. private _scene;
  20512. private _opaqueSubMeshes;
  20513. private _transparentSubMeshes;
  20514. private _alphaTestSubMeshes;
  20515. private _depthOnlySubMeshes;
  20516. private _particleSystems;
  20517. private _spriteManagers;
  20518. private _opaqueSortCompareFn;
  20519. private _alphaTestSortCompareFn;
  20520. private _transparentSortCompareFn;
  20521. private _renderOpaque;
  20522. private _renderAlphaTest;
  20523. private _renderTransparent;
  20524. /** @hidden */
  20525. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20526. onBeforeTransparentRendering: () => void;
  20527. /**
  20528. * Set the opaque sort comparison function.
  20529. * If null the sub meshes will be render in the order they were created
  20530. */
  20531. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20532. /**
  20533. * Set the alpha test sort comparison function.
  20534. * If null the sub meshes will be render in the order they were created
  20535. */
  20536. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20537. /**
  20538. * Set the transparent sort comparison function.
  20539. * If null the sub meshes will be render in the order they were created
  20540. */
  20541. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20542. /**
  20543. * Creates a new rendering group.
  20544. * @param index The rendering group index
  20545. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20546. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20547. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20548. */
  20549. 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>);
  20550. /**
  20551. * Render all the sub meshes contained in the group.
  20552. * @param customRenderFunction Used to override the default render behaviour of the group.
  20553. * @returns true if rendered some submeshes.
  20554. */
  20555. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20556. /**
  20557. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20558. * @param subMeshes The submeshes to render
  20559. */
  20560. private renderOpaqueSorted;
  20561. /**
  20562. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20563. * @param subMeshes The submeshes to render
  20564. */
  20565. private renderAlphaTestSorted;
  20566. /**
  20567. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20568. * @param subMeshes The submeshes to render
  20569. */
  20570. private renderTransparentSorted;
  20571. /**
  20572. * Renders the submeshes in a specified order.
  20573. * @param subMeshes The submeshes to sort before render
  20574. * @param sortCompareFn The comparison function use to sort
  20575. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20576. * @param transparent Specifies to activate blending if true
  20577. */
  20578. private static renderSorted;
  20579. /**
  20580. * Renders the submeshes in the order they were dispatched (no sort applied).
  20581. * @param subMeshes The submeshes to render
  20582. */
  20583. private static renderUnsorted;
  20584. /**
  20585. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20586. * are rendered back to front if in the same alpha index.
  20587. *
  20588. * @param a The first submesh
  20589. * @param b The second submesh
  20590. * @returns The result of the comparison
  20591. */
  20592. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20593. /**
  20594. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20595. * are rendered back to front.
  20596. *
  20597. * @param a The first submesh
  20598. * @param b The second submesh
  20599. * @returns The result of the comparison
  20600. */
  20601. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20602. /**
  20603. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20604. * are rendered front to back (prevent overdraw).
  20605. *
  20606. * @param a The first submesh
  20607. * @param b The second submesh
  20608. * @returns The result of the comparison
  20609. */
  20610. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20611. /**
  20612. * Resets the different lists of submeshes to prepare a new frame.
  20613. */
  20614. prepare(): void;
  20615. dispose(): void;
  20616. /**
  20617. * Inserts the submesh in its correct queue depending on its material.
  20618. * @param subMesh The submesh to dispatch
  20619. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20620. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20621. */
  20622. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20623. dispatchSprites(spriteManager: ISpriteManager): void;
  20624. dispatchParticles(particleSystem: IParticleSystem): void;
  20625. private _renderParticles;
  20626. private _renderSprites;
  20627. }
  20628. }
  20629. declare module "babylonjs/Rendering/renderingManager" {
  20630. import { Nullable } from "babylonjs/types";
  20631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20633. import { SmartArray } from "babylonjs/Misc/smartArray";
  20634. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20635. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20636. import { Material } from "babylonjs/Materials/material";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Camera } from "babylonjs/Cameras/camera";
  20639. /**
  20640. * Interface describing the different options available in the rendering manager
  20641. * regarding Auto Clear between groups.
  20642. */
  20643. export interface IRenderingManagerAutoClearSetup {
  20644. /**
  20645. * Defines whether or not autoclear is enable.
  20646. */
  20647. autoClear: boolean;
  20648. /**
  20649. * Defines whether or not to autoclear the depth buffer.
  20650. */
  20651. depth: boolean;
  20652. /**
  20653. * Defines whether or not to autoclear the stencil buffer.
  20654. */
  20655. stencil: boolean;
  20656. }
  20657. /**
  20658. * This class is used by the onRenderingGroupObservable
  20659. */
  20660. export class RenderingGroupInfo {
  20661. /**
  20662. * The Scene that being rendered
  20663. */
  20664. scene: Scene;
  20665. /**
  20666. * The camera currently used for the rendering pass
  20667. */
  20668. camera: Nullable<Camera>;
  20669. /**
  20670. * The ID of the renderingGroup being processed
  20671. */
  20672. renderingGroupId: number;
  20673. }
  20674. /**
  20675. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20676. * It is enable to manage the different groups as well as the different necessary sort functions.
  20677. * This should not be used directly aside of the few static configurations
  20678. */
  20679. export class RenderingManager {
  20680. /**
  20681. * The max id used for rendering groups (not included)
  20682. */
  20683. static MAX_RENDERINGGROUPS: number;
  20684. /**
  20685. * The min id used for rendering groups (included)
  20686. */
  20687. static MIN_RENDERINGGROUPS: number;
  20688. /**
  20689. * Used to globally prevent autoclearing scenes.
  20690. */
  20691. static AUTOCLEAR: boolean;
  20692. /**
  20693. * @hidden
  20694. */
  20695. _useSceneAutoClearSetup: boolean;
  20696. private _scene;
  20697. private _renderingGroups;
  20698. private _depthStencilBufferAlreadyCleaned;
  20699. private _autoClearDepthStencil;
  20700. private _customOpaqueSortCompareFn;
  20701. private _customAlphaTestSortCompareFn;
  20702. private _customTransparentSortCompareFn;
  20703. private _renderingGroupInfo;
  20704. /**
  20705. * Instantiates a new rendering group for a particular scene
  20706. * @param scene Defines the scene the groups belongs to
  20707. */
  20708. constructor(scene: Scene);
  20709. private _clearDepthStencilBuffer;
  20710. /**
  20711. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20712. * @hidden
  20713. */
  20714. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20715. /**
  20716. * Resets the different information of the group to prepare a new frame
  20717. * @hidden
  20718. */
  20719. reset(): void;
  20720. /**
  20721. * Dispose and release the group and its associated resources.
  20722. * @hidden
  20723. */
  20724. dispose(): void;
  20725. /**
  20726. * Clear the info related to rendering groups preventing retention points during dispose.
  20727. */
  20728. freeRenderingGroups(): void;
  20729. private _prepareRenderingGroup;
  20730. /**
  20731. * Add a sprite manager to the rendering manager in order to render it this frame.
  20732. * @param spriteManager Define the sprite manager to render
  20733. */
  20734. dispatchSprites(spriteManager: ISpriteManager): void;
  20735. /**
  20736. * Add a particle system to the rendering manager in order to render it this frame.
  20737. * @param particleSystem Define the particle system to render
  20738. */
  20739. dispatchParticles(particleSystem: IParticleSystem): void;
  20740. /**
  20741. * Add a submesh to the manager in order to render it this frame
  20742. * @param subMesh The submesh to dispatch
  20743. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20744. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20745. */
  20746. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20747. /**
  20748. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20749. * This allowed control for front to back rendering or reversly depending of the special needs.
  20750. *
  20751. * @param renderingGroupId The rendering group id corresponding to its index
  20752. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20753. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20754. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20755. */
  20756. 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;
  20757. /**
  20758. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20759. *
  20760. * @param renderingGroupId The rendering group id corresponding to its index
  20761. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20762. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20763. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20764. */
  20765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20766. /**
  20767. * Gets the current auto clear configuration for one rendering group of the rendering
  20768. * manager.
  20769. * @param index the rendering group index to get the information for
  20770. * @returns The auto clear setup for the requested rendering group
  20771. */
  20772. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20773. }
  20774. }
  20775. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20776. import { Observable } from "babylonjs/Misc/observable";
  20777. import { SmartArray } from "babylonjs/Misc/smartArray";
  20778. import { Nullable } from "babylonjs/types";
  20779. import { Camera } from "babylonjs/Cameras/camera";
  20780. import { Scene } from "babylonjs/scene";
  20781. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20782. import { Color4 } from "babylonjs/Maths/math.color";
  20783. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20785. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20786. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20787. import { Texture } from "babylonjs/Materials/Textures/texture";
  20788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20789. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20790. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20791. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20792. import { Engine } from "babylonjs/Engines/engine";
  20793. /**
  20794. * This Helps creating a texture that will be created from a camera in your scene.
  20795. * It is basically a dynamic texture that could be used to create special effects for instance.
  20796. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20797. */
  20798. export class RenderTargetTexture extends Texture {
  20799. isCube: boolean;
  20800. /**
  20801. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20802. */
  20803. static readonly REFRESHRATE_RENDER_ONCE: number;
  20804. /**
  20805. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20806. */
  20807. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20808. /**
  20809. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20810. * the central point of your effect and can save a lot of performances.
  20811. */
  20812. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20813. /**
  20814. * Use this predicate to dynamically define the list of mesh you want to render.
  20815. * If set, the renderList property will be overwritten.
  20816. */
  20817. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20818. private _renderList;
  20819. /**
  20820. * Use this list to define the list of mesh you want to render.
  20821. */
  20822. get renderList(): Nullable<Array<AbstractMesh>>;
  20823. set renderList(value: Nullable<Array<AbstractMesh>>);
  20824. private _hookArray;
  20825. /**
  20826. * Define if particles should be rendered in your texture.
  20827. */
  20828. renderParticles: boolean;
  20829. /**
  20830. * Define if sprites should be rendered in your texture.
  20831. */
  20832. renderSprites: boolean;
  20833. /**
  20834. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20835. */
  20836. coordinatesMode: number;
  20837. /**
  20838. * Define the camera used to render the texture.
  20839. */
  20840. activeCamera: Nullable<Camera>;
  20841. /**
  20842. * Override the render function of the texture with your own one.
  20843. */
  20844. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20845. /**
  20846. * Define if camera post processes should be use while rendering the texture.
  20847. */
  20848. useCameraPostProcesses: boolean;
  20849. /**
  20850. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20851. */
  20852. ignoreCameraViewport: boolean;
  20853. private _postProcessManager;
  20854. private _postProcesses;
  20855. private _resizeObserver;
  20856. /**
  20857. * An event triggered when the texture is unbind.
  20858. */
  20859. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20860. /**
  20861. * An event triggered when the texture is unbind.
  20862. */
  20863. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20864. private _onAfterUnbindObserver;
  20865. /**
  20866. * Set a after unbind callback in the texture.
  20867. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20868. */
  20869. set onAfterUnbind(callback: () => void);
  20870. /**
  20871. * An event triggered before rendering the texture
  20872. */
  20873. onBeforeRenderObservable: Observable<number>;
  20874. private _onBeforeRenderObserver;
  20875. /**
  20876. * Set a before render callback in the texture.
  20877. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20878. */
  20879. set onBeforeRender(callback: (faceIndex: number) => void);
  20880. /**
  20881. * An event triggered after rendering the texture
  20882. */
  20883. onAfterRenderObservable: Observable<number>;
  20884. private _onAfterRenderObserver;
  20885. /**
  20886. * Set a after render callback in the texture.
  20887. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20888. */
  20889. set onAfterRender(callback: (faceIndex: number) => void);
  20890. /**
  20891. * An event triggered after the texture clear
  20892. */
  20893. onClearObservable: Observable<Engine>;
  20894. private _onClearObserver;
  20895. /**
  20896. * Set a clear callback in the texture.
  20897. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20898. */
  20899. set onClear(callback: (Engine: Engine) => void);
  20900. /**
  20901. * An event triggered when the texture is resized.
  20902. */
  20903. onResizeObservable: Observable<RenderTargetTexture>;
  20904. /**
  20905. * Define the clear color of the Render Target if it should be different from the scene.
  20906. */
  20907. clearColor: Color4;
  20908. protected _size: number | {
  20909. width: number;
  20910. height: number;
  20911. };
  20912. protected _initialSizeParameter: number | {
  20913. width: number;
  20914. height: number;
  20915. } | {
  20916. ratio: number;
  20917. };
  20918. protected _sizeRatio: Nullable<number>;
  20919. /** @hidden */
  20920. _generateMipMaps: boolean;
  20921. protected _renderingManager: RenderingManager;
  20922. /** @hidden */
  20923. _waitingRenderList: string[];
  20924. protected _doNotChangeAspectRatio: boolean;
  20925. protected _currentRefreshId: number;
  20926. protected _refreshRate: number;
  20927. protected _textureMatrix: Matrix;
  20928. protected _samples: number;
  20929. protected _renderTargetOptions: RenderTargetCreationOptions;
  20930. /**
  20931. * Gets render target creation options that were used.
  20932. */
  20933. get renderTargetOptions(): RenderTargetCreationOptions;
  20934. protected _engine: Engine;
  20935. protected _onRatioRescale(): void;
  20936. /**
  20937. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20938. * It must define where the camera used to render the texture is set
  20939. */
  20940. boundingBoxPosition: Vector3;
  20941. private _boundingBoxSize;
  20942. /**
  20943. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20944. * When defined, the cubemap will switch to local mode
  20945. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20946. * @example https://www.babylonjs-playground.com/#RNASML
  20947. */
  20948. set boundingBoxSize(value: Vector3);
  20949. get boundingBoxSize(): Vector3;
  20950. /**
  20951. * In case the RTT has been created with a depth texture, get the associated
  20952. * depth texture.
  20953. * Otherwise, return null.
  20954. */
  20955. depthStencilTexture: Nullable<InternalTexture>;
  20956. /**
  20957. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20958. * or used a shadow, depth texture...
  20959. * @param name The friendly name of the texture
  20960. * @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)
  20961. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20962. * @param generateMipMaps True if mip maps need to be generated after render.
  20963. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20964. * @param type The type of the buffer in the RTT (int, half float, float...)
  20965. * @param isCube True if a cube texture needs to be created
  20966. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20967. * @param generateDepthBuffer True to generate a depth buffer
  20968. * @param generateStencilBuffer True to generate a stencil buffer
  20969. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20970. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20971. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20972. */
  20973. constructor(name: string, size: number | {
  20974. width: number;
  20975. height: number;
  20976. } | {
  20977. ratio: number;
  20978. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20979. /**
  20980. * Creates a depth stencil texture.
  20981. * This is only available in WebGL 2 or with the depth texture extension available.
  20982. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20983. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20984. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20985. */
  20986. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20987. private _processSizeParameter;
  20988. /**
  20989. * Define the number of samples to use in case of MSAA.
  20990. * It defaults to one meaning no MSAA has been enabled.
  20991. */
  20992. get samples(): number;
  20993. set samples(value: number);
  20994. /**
  20995. * Resets the refresh counter of the texture and start bak from scratch.
  20996. * Could be useful to regenerate the texture if it is setup to render only once.
  20997. */
  20998. resetRefreshCounter(): void;
  20999. /**
  21000. * Define the refresh rate of the texture or the rendering frequency.
  21001. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21002. */
  21003. get refreshRate(): number;
  21004. set refreshRate(value: number);
  21005. /**
  21006. * Adds a post process to the render target rendering passes.
  21007. * @param postProcess define the post process to add
  21008. */
  21009. addPostProcess(postProcess: PostProcess): void;
  21010. /**
  21011. * Clear all the post processes attached to the render target
  21012. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21013. */
  21014. clearPostProcesses(dispose?: boolean): void;
  21015. /**
  21016. * Remove one of the post process from the list of attached post processes to the texture
  21017. * @param postProcess define the post process to remove from the list
  21018. */
  21019. removePostProcess(postProcess: PostProcess): void;
  21020. /** @hidden */
  21021. _shouldRender(): boolean;
  21022. /**
  21023. * Gets the actual render size of the texture.
  21024. * @returns the width of the render size
  21025. */
  21026. getRenderSize(): number;
  21027. /**
  21028. * Gets the actual render width of the texture.
  21029. * @returns the width of the render size
  21030. */
  21031. getRenderWidth(): number;
  21032. /**
  21033. * Gets the actual render height of the texture.
  21034. * @returns the height of the render size
  21035. */
  21036. getRenderHeight(): number;
  21037. /**
  21038. * Get if the texture can be rescaled or not.
  21039. */
  21040. get canRescale(): boolean;
  21041. /**
  21042. * Resize the texture using a ratio.
  21043. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21044. */
  21045. scale(ratio: number): void;
  21046. /**
  21047. * Get the texture reflection matrix used to rotate/transform the reflection.
  21048. * @returns the reflection matrix
  21049. */
  21050. getReflectionTextureMatrix(): Matrix;
  21051. /**
  21052. * Resize the texture to a new desired size.
  21053. * Be carrefull as it will recreate all the data in the new texture.
  21054. * @param size Define the new size. It can be:
  21055. * - a number for squared texture,
  21056. * - an object containing { width: number, height: number }
  21057. * - or an object containing a ratio { ratio: number }
  21058. */
  21059. resize(size: number | {
  21060. width: number;
  21061. height: number;
  21062. } | {
  21063. ratio: number;
  21064. }): void;
  21065. /**
  21066. * Renders all the objects from the render list into the texture.
  21067. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21068. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21069. */
  21070. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21071. private _bestReflectionRenderTargetDimension;
  21072. /**
  21073. * @hidden
  21074. * @param faceIndex face index to bind to if this is a cubetexture
  21075. */
  21076. _bindFrameBuffer(faceIndex?: number): void;
  21077. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21078. private renderToTarget;
  21079. /**
  21080. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21081. * This allowed control for front to back rendering or reversly depending of the special needs.
  21082. *
  21083. * @param renderingGroupId The rendering group id corresponding to its index
  21084. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21085. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21086. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21087. */
  21088. 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;
  21089. /**
  21090. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21091. *
  21092. * @param renderingGroupId The rendering group id corresponding to its index
  21093. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21094. */
  21095. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21096. /**
  21097. * Clones the texture.
  21098. * @returns the cloned texture
  21099. */
  21100. clone(): RenderTargetTexture;
  21101. /**
  21102. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21103. * @returns The JSON representation of the texture
  21104. */
  21105. serialize(): any;
  21106. /**
  21107. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21108. */
  21109. disposeFramebufferObjects(): void;
  21110. /**
  21111. * Dispose the texture and release its associated resources.
  21112. */
  21113. dispose(): void;
  21114. /** @hidden */
  21115. _rebuild(): void;
  21116. /**
  21117. * Clear the info related to rendering groups preventing retention point in material dispose.
  21118. */
  21119. freeRenderingGroups(): void;
  21120. /**
  21121. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21122. * @returns the view count
  21123. */
  21124. getViewCount(): number;
  21125. }
  21126. }
  21127. declare module "babylonjs/Materials/material" {
  21128. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21129. import { SmartArray } from "babylonjs/Misc/smartArray";
  21130. import { Observable } from "babylonjs/Misc/observable";
  21131. import { Nullable } from "babylonjs/types";
  21132. import { Scene } from "babylonjs/scene";
  21133. import { Matrix } from "babylonjs/Maths/math.vector";
  21134. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21136. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21137. import { Effect } from "babylonjs/Materials/effect";
  21138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21140. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21141. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21142. import { Mesh } from "babylonjs/Meshes/mesh";
  21143. import { Animation } from "babylonjs/Animations/animation";
  21144. /**
  21145. * Options for compiling materials.
  21146. */
  21147. export interface IMaterialCompilationOptions {
  21148. /**
  21149. * Defines whether clip planes are enabled.
  21150. */
  21151. clipPlane: boolean;
  21152. /**
  21153. * Defines whether instances are enabled.
  21154. */
  21155. useInstances: boolean;
  21156. }
  21157. /**
  21158. * Base class for the main features of a material in Babylon.js
  21159. */
  21160. export class Material implements IAnimatable {
  21161. /**
  21162. * Returns the triangle fill mode
  21163. */
  21164. static readonly TriangleFillMode: number;
  21165. /**
  21166. * Returns the wireframe mode
  21167. */
  21168. static readonly WireFrameFillMode: number;
  21169. /**
  21170. * Returns the point fill mode
  21171. */
  21172. static readonly PointFillMode: number;
  21173. /**
  21174. * Returns the point list draw mode
  21175. */
  21176. static readonly PointListDrawMode: number;
  21177. /**
  21178. * Returns the line list draw mode
  21179. */
  21180. static readonly LineListDrawMode: number;
  21181. /**
  21182. * Returns the line loop draw mode
  21183. */
  21184. static readonly LineLoopDrawMode: number;
  21185. /**
  21186. * Returns the line strip draw mode
  21187. */
  21188. static readonly LineStripDrawMode: number;
  21189. /**
  21190. * Returns the triangle strip draw mode
  21191. */
  21192. static readonly TriangleStripDrawMode: number;
  21193. /**
  21194. * Returns the triangle fan draw mode
  21195. */
  21196. static readonly TriangleFanDrawMode: number;
  21197. /**
  21198. * Stores the clock-wise side orientation
  21199. */
  21200. static readonly ClockWiseSideOrientation: number;
  21201. /**
  21202. * Stores the counter clock-wise side orientation
  21203. */
  21204. static readonly CounterClockWiseSideOrientation: number;
  21205. /**
  21206. * The dirty texture flag value
  21207. */
  21208. static readonly TextureDirtyFlag: number;
  21209. /**
  21210. * The dirty light flag value
  21211. */
  21212. static readonly LightDirtyFlag: number;
  21213. /**
  21214. * The dirty fresnel flag value
  21215. */
  21216. static readonly FresnelDirtyFlag: number;
  21217. /**
  21218. * The dirty attribute flag value
  21219. */
  21220. static readonly AttributesDirtyFlag: number;
  21221. /**
  21222. * The dirty misc flag value
  21223. */
  21224. static readonly MiscDirtyFlag: number;
  21225. /**
  21226. * The all dirty flag value
  21227. */
  21228. static readonly AllDirtyFlag: number;
  21229. /**
  21230. * The ID of the material
  21231. */
  21232. id: string;
  21233. /**
  21234. * Gets or sets the unique id of the material
  21235. */
  21236. uniqueId: number;
  21237. /**
  21238. * The name of the material
  21239. */
  21240. name: string;
  21241. /**
  21242. * Gets or sets user defined metadata
  21243. */
  21244. metadata: any;
  21245. /**
  21246. * For internal use only. Please do not use.
  21247. */
  21248. reservedDataStore: any;
  21249. /**
  21250. * Specifies if the ready state should be checked on each call
  21251. */
  21252. checkReadyOnEveryCall: boolean;
  21253. /**
  21254. * Specifies if the ready state should be checked once
  21255. */
  21256. checkReadyOnlyOnce: boolean;
  21257. /**
  21258. * The state of the material
  21259. */
  21260. state: string;
  21261. /**
  21262. * The alpha value of the material
  21263. */
  21264. protected _alpha: number;
  21265. /**
  21266. * List of inspectable custom properties (used by the Inspector)
  21267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21268. */
  21269. inspectableCustomProperties: IInspectable[];
  21270. /**
  21271. * Sets the alpha value of the material
  21272. */
  21273. set alpha(value: number);
  21274. /**
  21275. * Gets the alpha value of the material
  21276. */
  21277. get alpha(): number;
  21278. /**
  21279. * Specifies if back face culling is enabled
  21280. */
  21281. protected _backFaceCulling: boolean;
  21282. /**
  21283. * Sets the back-face culling state
  21284. */
  21285. set backFaceCulling(value: boolean);
  21286. /**
  21287. * Gets the back-face culling state
  21288. */
  21289. get backFaceCulling(): boolean;
  21290. /**
  21291. * Stores the value for side orientation
  21292. */
  21293. sideOrientation: number;
  21294. /**
  21295. * Callback triggered when the material is compiled
  21296. */
  21297. onCompiled: Nullable<(effect: Effect) => void>;
  21298. /**
  21299. * Callback triggered when an error occurs
  21300. */
  21301. onError: Nullable<(effect: Effect, errors: string) => void>;
  21302. /**
  21303. * Callback triggered to get the render target textures
  21304. */
  21305. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21306. /**
  21307. * Gets a boolean indicating that current material needs to register RTT
  21308. */
  21309. get hasRenderTargetTextures(): boolean;
  21310. /**
  21311. * Specifies if the material should be serialized
  21312. */
  21313. doNotSerialize: boolean;
  21314. /**
  21315. * @hidden
  21316. */
  21317. _storeEffectOnSubMeshes: boolean;
  21318. /**
  21319. * Stores the animations for the material
  21320. */
  21321. animations: Nullable<Array<Animation>>;
  21322. /**
  21323. * An event triggered when the material is disposed
  21324. */
  21325. onDisposeObservable: Observable<Material>;
  21326. /**
  21327. * An observer which watches for dispose events
  21328. */
  21329. private _onDisposeObserver;
  21330. private _onUnBindObservable;
  21331. /**
  21332. * Called during a dispose event
  21333. */
  21334. set onDispose(callback: () => void);
  21335. private _onBindObservable;
  21336. /**
  21337. * An event triggered when the material is bound
  21338. */
  21339. get onBindObservable(): Observable<AbstractMesh>;
  21340. /**
  21341. * An observer which watches for bind events
  21342. */
  21343. private _onBindObserver;
  21344. /**
  21345. * Called during a bind event
  21346. */
  21347. set onBind(callback: (Mesh: AbstractMesh) => void);
  21348. /**
  21349. * An event triggered when the material is unbound
  21350. */
  21351. get onUnBindObservable(): Observable<Material>;
  21352. /**
  21353. * Stores the value of the alpha mode
  21354. */
  21355. private _alphaMode;
  21356. /**
  21357. * Sets the value of the alpha mode.
  21358. *
  21359. * | Value | Type | Description |
  21360. * | --- | --- | --- |
  21361. * | 0 | ALPHA_DISABLE | |
  21362. * | 1 | ALPHA_ADD | |
  21363. * | 2 | ALPHA_COMBINE | |
  21364. * | 3 | ALPHA_SUBTRACT | |
  21365. * | 4 | ALPHA_MULTIPLY | |
  21366. * | 5 | ALPHA_MAXIMIZED | |
  21367. * | 6 | ALPHA_ONEONE | |
  21368. * | 7 | ALPHA_PREMULTIPLIED | |
  21369. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21370. * | 9 | ALPHA_INTERPOLATE | |
  21371. * | 10 | ALPHA_SCREENMODE | |
  21372. *
  21373. */
  21374. set alphaMode(value: number);
  21375. /**
  21376. * Gets the value of the alpha mode
  21377. */
  21378. get alphaMode(): number;
  21379. /**
  21380. * Stores the state of the need depth pre-pass value
  21381. */
  21382. private _needDepthPrePass;
  21383. /**
  21384. * Sets the need depth pre-pass value
  21385. */
  21386. set needDepthPrePass(value: boolean);
  21387. /**
  21388. * Gets the depth pre-pass value
  21389. */
  21390. get needDepthPrePass(): boolean;
  21391. /**
  21392. * Specifies if depth writing should be disabled
  21393. */
  21394. disableDepthWrite: boolean;
  21395. /**
  21396. * Specifies if depth writing should be forced
  21397. */
  21398. forceDepthWrite: boolean;
  21399. /**
  21400. * Specifies the depth function that should be used. 0 means the default engine function
  21401. */
  21402. depthFunction: number;
  21403. /**
  21404. * Specifies if there should be a separate pass for culling
  21405. */
  21406. separateCullingPass: boolean;
  21407. /**
  21408. * Stores the state specifing if fog should be enabled
  21409. */
  21410. private _fogEnabled;
  21411. /**
  21412. * Sets the state for enabling fog
  21413. */
  21414. set fogEnabled(value: boolean);
  21415. /**
  21416. * Gets the value of the fog enabled state
  21417. */
  21418. get fogEnabled(): boolean;
  21419. /**
  21420. * Stores the size of points
  21421. */
  21422. pointSize: number;
  21423. /**
  21424. * Stores the z offset value
  21425. */
  21426. zOffset: number;
  21427. /**
  21428. * Gets a value specifying if wireframe mode is enabled
  21429. */
  21430. get wireframe(): boolean;
  21431. /**
  21432. * Sets the state of wireframe mode
  21433. */
  21434. set wireframe(value: boolean);
  21435. /**
  21436. * Gets the value specifying if point clouds are enabled
  21437. */
  21438. get pointsCloud(): boolean;
  21439. /**
  21440. * Sets the state of point cloud mode
  21441. */
  21442. set pointsCloud(value: boolean);
  21443. /**
  21444. * Gets the material fill mode
  21445. */
  21446. get fillMode(): number;
  21447. /**
  21448. * Sets the material fill mode
  21449. */
  21450. set fillMode(value: number);
  21451. /**
  21452. * @hidden
  21453. * Stores the effects for the material
  21454. */
  21455. _effect: Nullable<Effect>;
  21456. /**
  21457. * @hidden
  21458. * Specifies if the material was previously ready
  21459. */
  21460. _wasPreviouslyReady: boolean;
  21461. /**
  21462. * Specifies if uniform buffers should be used
  21463. */
  21464. private _useUBO;
  21465. /**
  21466. * Stores a reference to the scene
  21467. */
  21468. private _scene;
  21469. /**
  21470. * Stores the fill mode state
  21471. */
  21472. private _fillMode;
  21473. /**
  21474. * Specifies if the depth write state should be cached
  21475. */
  21476. private _cachedDepthWriteState;
  21477. /**
  21478. * Specifies if the depth function state should be cached
  21479. */
  21480. private _cachedDepthFunctionState;
  21481. /**
  21482. * Stores the uniform buffer
  21483. */
  21484. protected _uniformBuffer: UniformBuffer;
  21485. /** @hidden */
  21486. _indexInSceneMaterialArray: number;
  21487. /** @hidden */
  21488. meshMap: Nullable<{
  21489. [id: string]: AbstractMesh | undefined;
  21490. }>;
  21491. /**
  21492. * Creates a material instance
  21493. * @param name defines the name of the material
  21494. * @param scene defines the scene to reference
  21495. * @param doNotAdd specifies if the material should be added to the scene
  21496. */
  21497. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21498. /**
  21499. * Returns a string representation of the current material
  21500. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21501. * @returns a string with material information
  21502. */
  21503. toString(fullDetails?: boolean): string;
  21504. /**
  21505. * Gets the class name of the material
  21506. * @returns a string with the class name of the material
  21507. */
  21508. getClassName(): string;
  21509. /**
  21510. * Specifies if updates for the material been locked
  21511. */
  21512. get isFrozen(): boolean;
  21513. /**
  21514. * Locks updates for the material
  21515. */
  21516. freeze(): void;
  21517. /**
  21518. * Unlocks updates for the material
  21519. */
  21520. unfreeze(): void;
  21521. /**
  21522. * Specifies if the material is ready to be used
  21523. * @param mesh defines the mesh to check
  21524. * @param useInstances specifies if instances should be used
  21525. * @returns a boolean indicating if the material is ready to be used
  21526. */
  21527. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21528. /**
  21529. * Specifies that the submesh is ready to be used
  21530. * @param mesh defines the mesh to check
  21531. * @param subMesh defines which submesh to check
  21532. * @param useInstances specifies that instances should be used
  21533. * @returns a boolean indicating that the submesh is ready or not
  21534. */
  21535. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21536. /**
  21537. * Returns the material effect
  21538. * @returns the effect associated with the material
  21539. */
  21540. getEffect(): Nullable<Effect>;
  21541. /**
  21542. * Returns the current scene
  21543. * @returns a Scene
  21544. */
  21545. getScene(): Scene;
  21546. /**
  21547. * Specifies if the material will require alpha blending
  21548. * @returns a boolean specifying if alpha blending is needed
  21549. */
  21550. needAlphaBlending(): boolean;
  21551. /**
  21552. * Specifies if the mesh will require alpha blending
  21553. * @param mesh defines the mesh to check
  21554. * @returns a boolean specifying if alpha blending is needed for the mesh
  21555. */
  21556. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21557. /**
  21558. * Specifies if this material should be rendered in alpha test mode
  21559. * @returns a boolean specifying if an alpha test is needed.
  21560. */
  21561. needAlphaTesting(): boolean;
  21562. /**
  21563. * Gets the texture used for the alpha test
  21564. * @returns the texture to use for alpha testing
  21565. */
  21566. getAlphaTestTexture(): Nullable<BaseTexture>;
  21567. /**
  21568. * Marks the material to indicate that it needs to be re-calculated
  21569. */
  21570. markDirty(): void;
  21571. /** @hidden */
  21572. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21573. /**
  21574. * Binds the material to the mesh
  21575. * @param world defines the world transformation matrix
  21576. * @param mesh defines the mesh to bind the material to
  21577. */
  21578. bind(world: Matrix, mesh?: Mesh): void;
  21579. /**
  21580. * Binds the submesh to the material
  21581. * @param world defines the world transformation matrix
  21582. * @param mesh defines the mesh containing the submesh
  21583. * @param subMesh defines the submesh to bind the material to
  21584. */
  21585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21586. /**
  21587. * Binds the world matrix to the material
  21588. * @param world defines the world transformation matrix
  21589. */
  21590. bindOnlyWorldMatrix(world: Matrix): void;
  21591. /**
  21592. * Binds the scene's uniform buffer to the effect.
  21593. * @param effect defines the effect to bind to the scene uniform buffer
  21594. * @param sceneUbo defines the uniform buffer storing scene data
  21595. */
  21596. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21597. /**
  21598. * Binds the view matrix to the effect
  21599. * @param effect defines the effect to bind the view matrix to
  21600. */
  21601. bindView(effect: Effect): void;
  21602. /**
  21603. * Binds the view projection matrix to the effect
  21604. * @param effect defines the effect to bind the view projection matrix to
  21605. */
  21606. bindViewProjection(effect: Effect): void;
  21607. /**
  21608. * Specifies if material alpha testing should be turned on for the mesh
  21609. * @param mesh defines the mesh to check
  21610. */
  21611. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21612. /**
  21613. * Processes to execute after binding the material to a mesh
  21614. * @param mesh defines the rendered mesh
  21615. */
  21616. protected _afterBind(mesh?: Mesh): void;
  21617. /**
  21618. * Unbinds the material from the mesh
  21619. */
  21620. unbind(): void;
  21621. /**
  21622. * Gets the active textures from the material
  21623. * @returns an array of textures
  21624. */
  21625. getActiveTextures(): BaseTexture[];
  21626. /**
  21627. * Specifies if the material uses a texture
  21628. * @param texture defines the texture to check against the material
  21629. * @returns a boolean specifying if the material uses the texture
  21630. */
  21631. hasTexture(texture: BaseTexture): boolean;
  21632. /**
  21633. * Makes a duplicate of the material, and gives it a new name
  21634. * @param name defines the new name for the duplicated material
  21635. * @returns the cloned material
  21636. */
  21637. clone(name: string): Nullable<Material>;
  21638. /**
  21639. * Gets the meshes bound to the material
  21640. * @returns an array of meshes bound to the material
  21641. */
  21642. getBindedMeshes(): AbstractMesh[];
  21643. /**
  21644. * Force shader compilation
  21645. * @param mesh defines the mesh associated with this material
  21646. * @param onCompiled defines a function to execute once the material is compiled
  21647. * @param options defines the options to configure the compilation
  21648. * @param onError defines a function to execute if the material fails compiling
  21649. */
  21650. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21651. /**
  21652. * Force shader compilation
  21653. * @param mesh defines the mesh that will use this material
  21654. * @param options defines additional options for compiling the shaders
  21655. * @returns a promise that resolves when the compilation completes
  21656. */
  21657. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21658. private static readonly _AllDirtyCallBack;
  21659. private static readonly _ImageProcessingDirtyCallBack;
  21660. private static readonly _TextureDirtyCallBack;
  21661. private static readonly _FresnelDirtyCallBack;
  21662. private static readonly _MiscDirtyCallBack;
  21663. private static readonly _LightsDirtyCallBack;
  21664. private static readonly _AttributeDirtyCallBack;
  21665. private static _FresnelAndMiscDirtyCallBack;
  21666. private static _TextureAndMiscDirtyCallBack;
  21667. private static readonly _DirtyCallbackArray;
  21668. private static readonly _RunDirtyCallBacks;
  21669. /**
  21670. * Marks a define in the material to indicate that it needs to be re-computed
  21671. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21672. */
  21673. markAsDirty(flag: number): void;
  21674. /**
  21675. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21676. * @param func defines a function which checks material defines against the submeshes
  21677. */
  21678. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21679. /**
  21680. * Indicates that we need to re-calculated for all submeshes
  21681. */
  21682. protected _markAllSubMeshesAsAllDirty(): void;
  21683. /**
  21684. * Indicates that image processing needs to be re-calculated for all submeshes
  21685. */
  21686. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21687. /**
  21688. * Indicates that textures need to be re-calculated for all submeshes
  21689. */
  21690. protected _markAllSubMeshesAsTexturesDirty(): void;
  21691. /**
  21692. * Indicates that fresnel needs to be re-calculated for all submeshes
  21693. */
  21694. protected _markAllSubMeshesAsFresnelDirty(): void;
  21695. /**
  21696. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21697. */
  21698. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21699. /**
  21700. * Indicates that lights need to be re-calculated for all submeshes
  21701. */
  21702. protected _markAllSubMeshesAsLightsDirty(): void;
  21703. /**
  21704. * Indicates that attributes need to be re-calculated for all submeshes
  21705. */
  21706. protected _markAllSubMeshesAsAttributesDirty(): void;
  21707. /**
  21708. * Indicates that misc needs to be re-calculated for all submeshes
  21709. */
  21710. protected _markAllSubMeshesAsMiscDirty(): void;
  21711. /**
  21712. * Indicates that textures and misc need to be re-calculated for all submeshes
  21713. */
  21714. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21715. /**
  21716. * Disposes the material
  21717. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21718. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21719. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21720. */
  21721. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21722. /** @hidden */
  21723. private releaseVertexArrayObject;
  21724. /**
  21725. * Serializes this material
  21726. * @returns the serialized material object
  21727. */
  21728. serialize(): any;
  21729. /**
  21730. * Creates a material from parsed material data
  21731. * @param parsedMaterial defines parsed material data
  21732. * @param scene defines the hosting scene
  21733. * @param rootUrl defines the root URL to use to load textures
  21734. * @returns a new material
  21735. */
  21736. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21737. }
  21738. }
  21739. declare module "babylonjs/Materials/multiMaterial" {
  21740. import { Nullable } from "babylonjs/types";
  21741. import { Scene } from "babylonjs/scene";
  21742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21743. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21745. import { Material } from "babylonjs/Materials/material";
  21746. /**
  21747. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21748. * separate meshes. This can be use to improve performances.
  21749. * @see http://doc.babylonjs.com/how_to/multi_materials
  21750. */
  21751. export class MultiMaterial extends Material {
  21752. private _subMaterials;
  21753. /**
  21754. * Gets or Sets the list of Materials used within the multi material.
  21755. * They need to be ordered according to the submeshes order in the associated mesh
  21756. */
  21757. get subMaterials(): Nullable<Material>[];
  21758. set subMaterials(value: Nullable<Material>[]);
  21759. /**
  21760. * Function used to align with Node.getChildren()
  21761. * @returns the list of Materials used within the multi material
  21762. */
  21763. getChildren(): Nullable<Material>[];
  21764. /**
  21765. * Instantiates a new Multi Material
  21766. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21767. * separate meshes. This can be use to improve performances.
  21768. * @see http://doc.babylonjs.com/how_to/multi_materials
  21769. * @param name Define the name in the scene
  21770. * @param scene Define the scene the material belongs to
  21771. */
  21772. constructor(name: string, scene: Scene);
  21773. private _hookArray;
  21774. /**
  21775. * Get one of the submaterial by its index in the submaterials array
  21776. * @param index The index to look the sub material at
  21777. * @returns The Material if the index has been defined
  21778. */
  21779. getSubMaterial(index: number): Nullable<Material>;
  21780. /**
  21781. * Get the list of active textures for the whole sub materials list.
  21782. * @returns All the textures that will be used during the rendering
  21783. */
  21784. getActiveTextures(): BaseTexture[];
  21785. /**
  21786. * Gets the current class name of the material e.g. "MultiMaterial"
  21787. * Mainly use in serialization.
  21788. * @returns the class name
  21789. */
  21790. getClassName(): string;
  21791. /**
  21792. * Checks if the material is ready to render the requested sub mesh
  21793. * @param mesh Define the mesh the submesh belongs to
  21794. * @param subMesh Define the sub mesh to look readyness for
  21795. * @param useInstances Define whether or not the material is used with instances
  21796. * @returns true if ready, otherwise false
  21797. */
  21798. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21799. /**
  21800. * Clones the current material and its related sub materials
  21801. * @param name Define the name of the newly cloned material
  21802. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21803. * @returns the cloned material
  21804. */
  21805. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21806. /**
  21807. * Serializes the materials into a JSON representation.
  21808. * @returns the JSON representation
  21809. */
  21810. serialize(): any;
  21811. /**
  21812. * Dispose the material and release its associated resources
  21813. * @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)
  21814. * @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)
  21815. * @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)
  21816. */
  21817. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21818. /**
  21819. * Creates a MultiMaterial from parsed MultiMaterial data.
  21820. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21821. * @param scene defines the hosting scene
  21822. * @returns a new MultiMaterial
  21823. */
  21824. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21825. }
  21826. }
  21827. declare module "babylonjs/Meshes/subMesh" {
  21828. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21830. import { Engine } from "babylonjs/Engines/engine";
  21831. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21832. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21833. import { Effect } from "babylonjs/Materials/effect";
  21834. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21835. import { Plane } from "babylonjs/Maths/math.plane";
  21836. import { Collider } from "babylonjs/Collisions/collider";
  21837. import { Material } from "babylonjs/Materials/material";
  21838. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21840. import { Mesh } from "babylonjs/Meshes/mesh";
  21841. import { Ray } from "babylonjs/Culling/ray";
  21842. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21843. /**
  21844. * Base class for submeshes
  21845. */
  21846. export class BaseSubMesh {
  21847. /** @hidden */
  21848. _materialDefines: Nullable<MaterialDefines>;
  21849. /** @hidden */
  21850. _materialEffect: Nullable<Effect>;
  21851. /**
  21852. * Gets material defines used by the effect associated to the sub mesh
  21853. */
  21854. get materialDefines(): Nullable<MaterialDefines>;
  21855. /**
  21856. * Sets material defines used by the effect associated to the sub mesh
  21857. */
  21858. set materialDefines(defines: Nullable<MaterialDefines>);
  21859. /**
  21860. * Gets associated effect
  21861. */
  21862. get effect(): Nullable<Effect>;
  21863. /**
  21864. * Sets associated effect (effect used to render this submesh)
  21865. * @param effect defines the effect to associate with
  21866. * @param defines defines the set of defines used to compile this effect
  21867. */
  21868. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21869. }
  21870. /**
  21871. * Defines a subdivision inside a mesh
  21872. */
  21873. export class SubMesh extends BaseSubMesh implements ICullable {
  21874. /** the material index to use */
  21875. materialIndex: number;
  21876. /** vertex index start */
  21877. verticesStart: number;
  21878. /** vertices count */
  21879. verticesCount: number;
  21880. /** index start */
  21881. indexStart: number;
  21882. /** indices count */
  21883. indexCount: number;
  21884. /** @hidden */
  21885. _linesIndexCount: number;
  21886. private _mesh;
  21887. private _renderingMesh;
  21888. private _boundingInfo;
  21889. private _linesIndexBuffer;
  21890. /** @hidden */
  21891. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21892. /** @hidden */
  21893. _trianglePlanes: Plane[];
  21894. /** @hidden */
  21895. _lastColliderTransformMatrix: Nullable<Matrix>;
  21896. /** @hidden */
  21897. _renderId: number;
  21898. /** @hidden */
  21899. _alphaIndex: number;
  21900. /** @hidden */
  21901. _distanceToCamera: number;
  21902. /** @hidden */
  21903. _id: number;
  21904. private _currentMaterial;
  21905. /**
  21906. * Add a new submesh to a mesh
  21907. * @param materialIndex defines the material index to use
  21908. * @param verticesStart defines vertex index start
  21909. * @param verticesCount defines vertices count
  21910. * @param indexStart defines index start
  21911. * @param indexCount defines indices count
  21912. * @param mesh defines the parent mesh
  21913. * @param renderingMesh defines an optional rendering mesh
  21914. * @param createBoundingBox defines if bounding box should be created for this submesh
  21915. * @returns the new submesh
  21916. */
  21917. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21918. /**
  21919. * Creates a new submesh
  21920. * @param materialIndex defines the material index to use
  21921. * @param verticesStart defines vertex index start
  21922. * @param verticesCount defines vertices count
  21923. * @param indexStart defines index start
  21924. * @param indexCount defines indices count
  21925. * @param mesh defines the parent mesh
  21926. * @param renderingMesh defines an optional rendering mesh
  21927. * @param createBoundingBox defines if bounding box should be created for this submesh
  21928. */
  21929. constructor(
  21930. /** the material index to use */
  21931. materialIndex: number,
  21932. /** vertex index start */
  21933. verticesStart: number,
  21934. /** vertices count */
  21935. verticesCount: number,
  21936. /** index start */
  21937. indexStart: number,
  21938. /** indices count */
  21939. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21940. /**
  21941. * Returns true if this submesh covers the entire parent mesh
  21942. * @ignorenaming
  21943. */
  21944. get IsGlobal(): boolean;
  21945. /**
  21946. * Returns the submesh BoudingInfo object
  21947. * @returns current bounding info (or mesh's one if the submesh is global)
  21948. */
  21949. getBoundingInfo(): BoundingInfo;
  21950. /**
  21951. * Sets the submesh BoundingInfo
  21952. * @param boundingInfo defines the new bounding info to use
  21953. * @returns the SubMesh
  21954. */
  21955. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21956. /**
  21957. * Returns the mesh of the current submesh
  21958. * @return the parent mesh
  21959. */
  21960. getMesh(): AbstractMesh;
  21961. /**
  21962. * Returns the rendering mesh of the submesh
  21963. * @returns the rendering mesh (could be different from parent mesh)
  21964. */
  21965. getRenderingMesh(): Mesh;
  21966. /**
  21967. * Returns the submesh material
  21968. * @returns null or the current material
  21969. */
  21970. getMaterial(): Nullable<Material>;
  21971. /**
  21972. * Sets a new updated BoundingInfo object to the submesh
  21973. * @param data defines an optional position array to use to determine the bounding info
  21974. * @returns the SubMesh
  21975. */
  21976. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21977. /** @hidden */
  21978. _checkCollision(collider: Collider): boolean;
  21979. /**
  21980. * Updates the submesh BoundingInfo
  21981. * @param world defines the world matrix to use to update the bounding info
  21982. * @returns the submesh
  21983. */
  21984. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21985. /**
  21986. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21987. * @param frustumPlanes defines the frustum planes
  21988. * @returns true if the submesh is intersecting with the frustum
  21989. */
  21990. isInFrustum(frustumPlanes: Plane[]): boolean;
  21991. /**
  21992. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21993. * @param frustumPlanes defines the frustum planes
  21994. * @returns true if the submesh is inside the frustum
  21995. */
  21996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21997. /**
  21998. * Renders the submesh
  21999. * @param enableAlphaMode defines if alpha needs to be used
  22000. * @returns the submesh
  22001. */
  22002. render(enableAlphaMode: boolean): SubMesh;
  22003. /**
  22004. * @hidden
  22005. */
  22006. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22007. /**
  22008. * Checks if the submesh intersects with a ray
  22009. * @param ray defines the ray to test
  22010. * @returns true is the passed ray intersects the submesh bounding box
  22011. */
  22012. canIntersects(ray: Ray): boolean;
  22013. /**
  22014. * Intersects current submesh with a ray
  22015. * @param ray defines the ray to test
  22016. * @param positions defines mesh's positions array
  22017. * @param indices defines mesh's indices array
  22018. * @param fastCheck defines if only bounding info should be used
  22019. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22020. * @returns intersection info or null if no intersection
  22021. */
  22022. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22023. /** @hidden */
  22024. private _intersectLines;
  22025. /** @hidden */
  22026. private _intersectUnIndexedLines;
  22027. /** @hidden */
  22028. private _intersectTriangles;
  22029. /** @hidden */
  22030. private _intersectUnIndexedTriangles;
  22031. /** @hidden */
  22032. _rebuild(): void;
  22033. /**
  22034. * Creates a new submesh from the passed mesh
  22035. * @param newMesh defines the new hosting mesh
  22036. * @param newRenderingMesh defines an optional rendering mesh
  22037. * @returns the new submesh
  22038. */
  22039. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22040. /**
  22041. * Release associated resources
  22042. */
  22043. dispose(): void;
  22044. /**
  22045. * Gets the class name
  22046. * @returns the string "SubMesh".
  22047. */
  22048. getClassName(): string;
  22049. /**
  22050. * Creates a new submesh from indices data
  22051. * @param materialIndex the index of the main mesh material
  22052. * @param startIndex the index where to start the copy in the mesh indices array
  22053. * @param indexCount the number of indices to copy then from the startIndex
  22054. * @param mesh the main mesh to create the submesh from
  22055. * @param renderingMesh the optional rendering mesh
  22056. * @returns a new submesh
  22057. */
  22058. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22059. }
  22060. }
  22061. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22062. /**
  22063. * Class used to represent data loading progression
  22064. */
  22065. export class SceneLoaderFlags {
  22066. private static _ForceFullSceneLoadingForIncremental;
  22067. private static _ShowLoadingScreen;
  22068. private static _CleanBoneMatrixWeights;
  22069. private static _loggingLevel;
  22070. /**
  22071. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22072. */
  22073. static get ForceFullSceneLoadingForIncremental(): boolean;
  22074. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22075. /**
  22076. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22077. */
  22078. static get ShowLoadingScreen(): boolean;
  22079. static set ShowLoadingScreen(value: boolean);
  22080. /**
  22081. * Defines the current logging level (while loading the scene)
  22082. * @ignorenaming
  22083. */
  22084. static get loggingLevel(): number;
  22085. static set loggingLevel(value: number);
  22086. /**
  22087. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22088. */
  22089. static get CleanBoneMatrixWeights(): boolean;
  22090. static set CleanBoneMatrixWeights(value: boolean);
  22091. }
  22092. }
  22093. declare module "babylonjs/Meshes/geometry" {
  22094. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22095. import { Scene } from "babylonjs/scene";
  22096. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22097. import { Engine } from "babylonjs/Engines/engine";
  22098. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22099. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22100. import { Effect } from "babylonjs/Materials/effect";
  22101. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22102. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22103. import { Mesh } from "babylonjs/Meshes/mesh";
  22104. /**
  22105. * Class used to store geometry data (vertex buffers + index buffer)
  22106. */
  22107. export class Geometry implements IGetSetVerticesData {
  22108. /**
  22109. * Gets or sets the ID of the geometry
  22110. */
  22111. id: string;
  22112. /**
  22113. * Gets or sets the unique ID of the geometry
  22114. */
  22115. uniqueId: number;
  22116. /**
  22117. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22118. */
  22119. delayLoadState: number;
  22120. /**
  22121. * Gets the file containing the data to load when running in delay load state
  22122. */
  22123. delayLoadingFile: Nullable<string>;
  22124. /**
  22125. * Callback called when the geometry is updated
  22126. */
  22127. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22128. private _scene;
  22129. private _engine;
  22130. private _meshes;
  22131. private _totalVertices;
  22132. /** @hidden */
  22133. _indices: IndicesArray;
  22134. /** @hidden */
  22135. _vertexBuffers: {
  22136. [key: string]: VertexBuffer;
  22137. };
  22138. private _isDisposed;
  22139. private _extend;
  22140. private _boundingBias;
  22141. /** @hidden */
  22142. _delayInfo: Array<string>;
  22143. private _indexBuffer;
  22144. private _indexBufferIsUpdatable;
  22145. /** @hidden */
  22146. _boundingInfo: Nullable<BoundingInfo>;
  22147. /** @hidden */
  22148. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22149. /** @hidden */
  22150. _softwareSkinningFrameId: number;
  22151. private _vertexArrayObjects;
  22152. private _updatable;
  22153. /** @hidden */
  22154. _positions: Nullable<Vector3[]>;
  22155. /**
  22156. * 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
  22157. */
  22158. get boundingBias(): Vector2;
  22159. /**
  22160. * 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
  22161. */
  22162. set boundingBias(value: Vector2);
  22163. /**
  22164. * Static function used to attach a new empty geometry to a mesh
  22165. * @param mesh defines the mesh to attach the geometry to
  22166. * @returns the new Geometry
  22167. */
  22168. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22169. /**
  22170. * Creates a new geometry
  22171. * @param id defines the unique ID
  22172. * @param scene defines the hosting scene
  22173. * @param vertexData defines the VertexData used to get geometry data
  22174. * @param updatable defines if geometry must be updatable (false by default)
  22175. * @param mesh defines the mesh that will be associated with the geometry
  22176. */
  22177. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22178. /**
  22179. * Gets the current extend of the geometry
  22180. */
  22181. get extend(): {
  22182. minimum: Vector3;
  22183. maximum: Vector3;
  22184. };
  22185. /**
  22186. * Gets the hosting scene
  22187. * @returns the hosting Scene
  22188. */
  22189. getScene(): Scene;
  22190. /**
  22191. * Gets the hosting engine
  22192. * @returns the hosting Engine
  22193. */
  22194. getEngine(): Engine;
  22195. /**
  22196. * Defines if the geometry is ready to use
  22197. * @returns true if the geometry is ready to be used
  22198. */
  22199. isReady(): boolean;
  22200. /**
  22201. * Gets a value indicating that the geometry should not be serialized
  22202. */
  22203. get doNotSerialize(): boolean;
  22204. /** @hidden */
  22205. _rebuild(): void;
  22206. /**
  22207. * Affects all geometry data in one call
  22208. * @param vertexData defines the geometry data
  22209. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22210. */
  22211. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22212. /**
  22213. * Set specific vertex data
  22214. * @param kind defines the data kind (Position, normal, etc...)
  22215. * @param data defines the vertex data to use
  22216. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22217. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22218. */
  22219. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22220. /**
  22221. * Removes a specific vertex data
  22222. * @param kind defines the data kind (Position, normal, etc...)
  22223. */
  22224. removeVerticesData(kind: string): void;
  22225. /**
  22226. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22227. * @param buffer defines the vertex buffer to use
  22228. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22229. */
  22230. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22231. /**
  22232. * Update a specific vertex buffer
  22233. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22234. * It will do nothing if the buffer is not updatable
  22235. * @param kind defines the data kind (Position, normal, etc...)
  22236. * @param data defines the data to use
  22237. * @param offset defines the offset in the target buffer where to store the data
  22238. * @param useBytes set to true if the offset is in bytes
  22239. */
  22240. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22241. /**
  22242. * Update a specific vertex buffer
  22243. * This function will create a new buffer if the current one is not updatable
  22244. * @param kind defines the data kind (Position, normal, etc...)
  22245. * @param data defines the data to use
  22246. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22247. */
  22248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22249. private _updateBoundingInfo;
  22250. /** @hidden */
  22251. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22252. /**
  22253. * Gets total number of vertices
  22254. * @returns the total number of vertices
  22255. */
  22256. getTotalVertices(): number;
  22257. /**
  22258. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22259. * @param kind defines the data kind (Position, normal, etc...)
  22260. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22262. * @returns a float array containing vertex data
  22263. */
  22264. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22265. /**
  22266. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22267. * @param kind defines the data kind (Position, normal, etc...)
  22268. * @returns true if the vertex buffer with the specified kind is updatable
  22269. */
  22270. isVertexBufferUpdatable(kind: string): boolean;
  22271. /**
  22272. * Gets a specific vertex buffer
  22273. * @param kind defines the data kind (Position, normal, etc...)
  22274. * @returns a VertexBuffer
  22275. */
  22276. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22277. /**
  22278. * Returns all vertex buffers
  22279. * @return an object holding all vertex buffers indexed by kind
  22280. */
  22281. getVertexBuffers(): Nullable<{
  22282. [key: string]: VertexBuffer;
  22283. }>;
  22284. /**
  22285. * Gets a boolean indicating if specific vertex buffer is present
  22286. * @param kind defines the data kind (Position, normal, etc...)
  22287. * @returns true if data is present
  22288. */
  22289. isVerticesDataPresent(kind: string): boolean;
  22290. /**
  22291. * Gets a list of all attached data kinds (Position, normal, etc...)
  22292. * @returns a list of string containing all kinds
  22293. */
  22294. getVerticesDataKinds(): string[];
  22295. /**
  22296. * Update index buffer
  22297. * @param indices defines the indices to store in the index buffer
  22298. * @param offset defines the offset in the target buffer where to store the data
  22299. * @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)
  22300. */
  22301. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22302. /**
  22303. * Creates a new index buffer
  22304. * @param indices defines the indices to store in the index buffer
  22305. * @param totalVertices defines the total number of vertices (could be null)
  22306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22307. */
  22308. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22309. /**
  22310. * Return the total number of indices
  22311. * @returns the total number of indices
  22312. */
  22313. getTotalIndices(): number;
  22314. /**
  22315. * Gets the index buffer array
  22316. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22317. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22318. * @returns the index buffer array
  22319. */
  22320. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22321. /**
  22322. * Gets the index buffer
  22323. * @return the index buffer
  22324. */
  22325. getIndexBuffer(): Nullable<DataBuffer>;
  22326. /** @hidden */
  22327. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22328. /**
  22329. * Release the associated resources for a specific mesh
  22330. * @param mesh defines the source mesh
  22331. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22332. */
  22333. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22334. /**
  22335. * Apply current geometry to a given mesh
  22336. * @param mesh defines the mesh to apply geometry to
  22337. */
  22338. applyToMesh(mesh: Mesh): void;
  22339. private _updateExtend;
  22340. private _applyToMesh;
  22341. private notifyUpdate;
  22342. /**
  22343. * Load the geometry if it was flagged as delay loaded
  22344. * @param scene defines the hosting scene
  22345. * @param onLoaded defines a callback called when the geometry is loaded
  22346. */
  22347. load(scene: Scene, onLoaded?: () => void): void;
  22348. private _queueLoad;
  22349. /**
  22350. * Invert the geometry to move from a right handed system to a left handed one.
  22351. */
  22352. toLeftHanded(): void;
  22353. /** @hidden */
  22354. _resetPointsArrayCache(): void;
  22355. /** @hidden */
  22356. _generatePointsArray(): boolean;
  22357. /**
  22358. * Gets a value indicating if the geometry is disposed
  22359. * @returns true if the geometry was disposed
  22360. */
  22361. isDisposed(): boolean;
  22362. private _disposeVertexArrayObjects;
  22363. /**
  22364. * Free all associated resources
  22365. */
  22366. dispose(): void;
  22367. /**
  22368. * Clone the current geometry into a new geometry
  22369. * @param id defines the unique ID of the new geometry
  22370. * @returns a new geometry object
  22371. */
  22372. copy(id: string): Geometry;
  22373. /**
  22374. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22375. * @return a JSON representation of the current geometry data (without the vertices data)
  22376. */
  22377. serialize(): any;
  22378. private toNumberArray;
  22379. /**
  22380. * Serialize all vertices data into a JSON oject
  22381. * @returns a JSON representation of the current geometry data
  22382. */
  22383. serializeVerticeData(): any;
  22384. /**
  22385. * Extracts a clone of a mesh geometry
  22386. * @param mesh defines the source mesh
  22387. * @param id defines the unique ID of the new geometry object
  22388. * @returns the new geometry object
  22389. */
  22390. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22391. /**
  22392. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22393. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22394. * Be aware Math.random() could cause collisions, but:
  22395. * "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"
  22396. * @returns a string containing a new GUID
  22397. */
  22398. static RandomId(): string;
  22399. /** @hidden */
  22400. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22401. private static _CleanMatricesWeights;
  22402. /**
  22403. * Create a new geometry from persisted data (Using .babylon file format)
  22404. * @param parsedVertexData defines the persisted data
  22405. * @param scene defines the hosting scene
  22406. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22407. * @returns the new geometry object
  22408. */
  22409. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22410. }
  22411. }
  22412. declare module "babylonjs/Meshes/mesh.vertexData" {
  22413. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22414. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22415. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22416. import { Geometry } from "babylonjs/Meshes/geometry";
  22417. import { Mesh } from "babylonjs/Meshes/mesh";
  22418. /**
  22419. * Define an interface for all classes that will get and set the data on vertices
  22420. */
  22421. export interface IGetSetVerticesData {
  22422. /**
  22423. * Gets a boolean indicating if specific vertex data is present
  22424. * @param kind defines the vertex data kind to use
  22425. * @returns true is data kind is present
  22426. */
  22427. isVerticesDataPresent(kind: string): boolean;
  22428. /**
  22429. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22433. * @returns a float array containing vertex data
  22434. */
  22435. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22436. /**
  22437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22438. * @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.
  22439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22440. * @returns the indices array or an empty array if the mesh has no geometry
  22441. */
  22442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22443. /**
  22444. * Set specific vertex data
  22445. * @param kind defines the data kind (Position, normal, etc...)
  22446. * @param data defines the vertex data to use
  22447. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22448. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22449. */
  22450. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22451. /**
  22452. * Update a specific associated vertex buffer
  22453. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22454. * - VertexBuffer.PositionKind
  22455. * - VertexBuffer.UVKind
  22456. * - VertexBuffer.UV2Kind
  22457. * - VertexBuffer.UV3Kind
  22458. * - VertexBuffer.UV4Kind
  22459. * - VertexBuffer.UV5Kind
  22460. * - VertexBuffer.UV6Kind
  22461. * - VertexBuffer.ColorKind
  22462. * - VertexBuffer.MatricesIndicesKind
  22463. * - VertexBuffer.MatricesIndicesExtraKind
  22464. * - VertexBuffer.MatricesWeightsKind
  22465. * - VertexBuffer.MatricesWeightsExtraKind
  22466. * @param data defines the data source
  22467. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22468. * @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)
  22469. */
  22470. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22471. /**
  22472. * Creates a new index buffer
  22473. * @param indices defines the indices to store in the index buffer
  22474. * @param totalVertices defines the total number of vertices (could be null)
  22475. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22476. */
  22477. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22478. }
  22479. /**
  22480. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22481. */
  22482. export class VertexData {
  22483. /**
  22484. * Mesh side orientation : usually the external or front surface
  22485. */
  22486. static readonly FRONTSIDE: number;
  22487. /**
  22488. * Mesh side orientation : usually the internal or back surface
  22489. */
  22490. static readonly BACKSIDE: number;
  22491. /**
  22492. * Mesh side orientation : both internal and external or front and back surfaces
  22493. */
  22494. static readonly DOUBLESIDE: number;
  22495. /**
  22496. * Mesh side orientation : by default, `FRONTSIDE`
  22497. */
  22498. static readonly DEFAULTSIDE: number;
  22499. /**
  22500. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22501. */
  22502. positions: Nullable<FloatArray>;
  22503. /**
  22504. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22505. */
  22506. normals: Nullable<FloatArray>;
  22507. /**
  22508. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22509. */
  22510. tangents: Nullable<FloatArray>;
  22511. /**
  22512. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22513. */
  22514. uvs: Nullable<FloatArray>;
  22515. /**
  22516. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22517. */
  22518. uvs2: Nullable<FloatArray>;
  22519. /**
  22520. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22521. */
  22522. uvs3: Nullable<FloatArray>;
  22523. /**
  22524. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22525. */
  22526. uvs4: Nullable<FloatArray>;
  22527. /**
  22528. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22529. */
  22530. uvs5: Nullable<FloatArray>;
  22531. /**
  22532. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22533. */
  22534. uvs6: Nullable<FloatArray>;
  22535. /**
  22536. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22537. */
  22538. colors: Nullable<FloatArray>;
  22539. /**
  22540. * 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).
  22541. */
  22542. matricesIndices: Nullable<FloatArray>;
  22543. /**
  22544. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22545. */
  22546. matricesWeights: Nullable<FloatArray>;
  22547. /**
  22548. * An array extending the number of possible indices
  22549. */
  22550. matricesIndicesExtra: Nullable<FloatArray>;
  22551. /**
  22552. * An array extending the number of possible weights when the number of indices is extended
  22553. */
  22554. matricesWeightsExtra: Nullable<FloatArray>;
  22555. /**
  22556. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22557. */
  22558. indices: Nullable<IndicesArray>;
  22559. /**
  22560. * Uses the passed data array to set the set the values for the specified kind of data
  22561. * @param data a linear array of floating numbers
  22562. * @param kind the type of data that is being set, eg positions, colors etc
  22563. */
  22564. set(data: FloatArray, kind: string): void;
  22565. /**
  22566. * Associates the vertexData to the passed Mesh.
  22567. * Sets it as updatable or not (default `false`)
  22568. * @param mesh the mesh the vertexData is applied to
  22569. * @param updatable when used and having the value true allows new data to update the vertexData
  22570. * @returns the VertexData
  22571. */
  22572. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22573. /**
  22574. * Associates the vertexData to the passed Geometry.
  22575. * Sets it as updatable or not (default `false`)
  22576. * @param geometry the geometry the vertexData is applied to
  22577. * @param updatable when used and having the value true allows new data to update the vertexData
  22578. * @returns VertexData
  22579. */
  22580. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22581. /**
  22582. * Updates the associated mesh
  22583. * @param mesh the mesh to be updated
  22584. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22585. * @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
  22586. * @returns VertexData
  22587. */
  22588. updateMesh(mesh: Mesh): VertexData;
  22589. /**
  22590. * Updates the associated geometry
  22591. * @param geometry the geometry to be updated
  22592. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22593. * @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
  22594. * @returns VertexData.
  22595. */
  22596. updateGeometry(geometry: Geometry): VertexData;
  22597. private _applyTo;
  22598. private _update;
  22599. /**
  22600. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22601. * @param matrix the transforming matrix
  22602. * @returns the VertexData
  22603. */
  22604. transform(matrix: Matrix): VertexData;
  22605. /**
  22606. * Merges the passed VertexData into the current one
  22607. * @param other the VertexData to be merged into the current one
  22608. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22609. * @returns the modified VertexData
  22610. */
  22611. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22612. private _mergeElement;
  22613. private _validate;
  22614. /**
  22615. * Serializes the VertexData
  22616. * @returns a serialized object
  22617. */
  22618. serialize(): any;
  22619. /**
  22620. * Extracts the vertexData from a mesh
  22621. * @param mesh the mesh from which to extract the VertexData
  22622. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22623. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22624. * @returns the object VertexData associated to the passed mesh
  22625. */
  22626. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22627. /**
  22628. * Extracts the vertexData from the geometry
  22629. * @param geometry the geometry from which to extract the VertexData
  22630. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22631. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22632. * @returns the object VertexData associated to the passed mesh
  22633. */
  22634. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22635. private static _ExtractFrom;
  22636. /**
  22637. * Creates the VertexData for a Ribbon
  22638. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22639. * * pathArray array of paths, each of which an array of successive Vector3
  22640. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22641. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22642. * * 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
  22643. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22644. * * 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)
  22645. * * 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)
  22646. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22647. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22648. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22649. * @returns the VertexData of the ribbon
  22650. */
  22651. static CreateRibbon(options: {
  22652. pathArray: Vector3[][];
  22653. closeArray?: boolean;
  22654. closePath?: boolean;
  22655. offset?: number;
  22656. sideOrientation?: number;
  22657. frontUVs?: Vector4;
  22658. backUVs?: Vector4;
  22659. invertUV?: boolean;
  22660. uvs?: Vector2[];
  22661. colors?: Color4[];
  22662. }): VertexData;
  22663. /**
  22664. * Creates the VertexData for a box
  22665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22666. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22667. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22668. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22669. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22670. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22671. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22673. * * 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)
  22674. * * 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)
  22675. * @returns the VertexData of the box
  22676. */
  22677. static CreateBox(options: {
  22678. size?: number;
  22679. width?: number;
  22680. height?: number;
  22681. depth?: number;
  22682. faceUV?: Vector4[];
  22683. faceColors?: Color4[];
  22684. sideOrientation?: number;
  22685. frontUVs?: Vector4;
  22686. backUVs?: Vector4;
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a tiled box
  22690. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22691. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22692. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22693. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22695. * @returns the VertexData of the box
  22696. */
  22697. static CreateTiledBox(options: {
  22698. pattern?: number;
  22699. width?: number;
  22700. height?: number;
  22701. depth?: number;
  22702. tileSize?: number;
  22703. tileWidth?: number;
  22704. tileHeight?: number;
  22705. alignHorizontal?: number;
  22706. alignVertical?: number;
  22707. faceUV?: Vector4[];
  22708. faceColors?: Color4[];
  22709. sideOrientation?: number;
  22710. }): VertexData;
  22711. /**
  22712. * Creates the VertexData for a tiled plane
  22713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22714. * * pattern a limited pattern arrangement depending on the number
  22715. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22716. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22717. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22719. * * 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)
  22720. * * 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)
  22721. * @returns the VertexData of the tiled plane
  22722. */
  22723. static CreateTiledPlane(options: {
  22724. pattern?: number;
  22725. tileSize?: number;
  22726. tileWidth?: number;
  22727. tileHeight?: number;
  22728. size?: number;
  22729. width?: number;
  22730. height?: number;
  22731. alignHorizontal?: number;
  22732. alignVertical?: number;
  22733. sideOrientation?: number;
  22734. frontUVs?: Vector4;
  22735. backUVs?: Vector4;
  22736. }): VertexData;
  22737. /**
  22738. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22739. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22740. * * segments sets the number of horizontal strips optional, default 32
  22741. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22742. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22743. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22744. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22745. * * 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
  22746. * * 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
  22747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22748. * * 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)
  22749. * * 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)
  22750. * @returns the VertexData of the ellipsoid
  22751. */
  22752. static CreateSphere(options: {
  22753. segments?: number;
  22754. diameter?: number;
  22755. diameterX?: number;
  22756. diameterY?: number;
  22757. diameterZ?: number;
  22758. arc?: number;
  22759. slice?: number;
  22760. sideOrientation?: number;
  22761. frontUVs?: Vector4;
  22762. backUVs?: Vector4;
  22763. }): VertexData;
  22764. /**
  22765. * Creates the VertexData for a cylinder, cone or prism
  22766. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22767. * * height sets the height (y direction) of the cylinder, optional, default 2
  22768. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22769. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22770. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22771. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22772. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22773. * * 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
  22774. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22775. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22776. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22777. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22779. * * 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)
  22780. * * 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)
  22781. * @returns the VertexData of the cylinder, cone or prism
  22782. */
  22783. static CreateCylinder(options: {
  22784. height?: number;
  22785. diameterTop?: number;
  22786. diameterBottom?: number;
  22787. diameter?: number;
  22788. tessellation?: number;
  22789. subdivisions?: number;
  22790. arc?: number;
  22791. faceColors?: Color4[];
  22792. faceUV?: Vector4[];
  22793. hasRings?: boolean;
  22794. enclose?: boolean;
  22795. sideOrientation?: number;
  22796. frontUVs?: Vector4;
  22797. backUVs?: Vector4;
  22798. }): VertexData;
  22799. /**
  22800. * Creates the VertexData for a torus
  22801. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22802. * * diameter the diameter of the torus, optional default 1
  22803. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22804. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22805. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22806. * * 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)
  22807. * * 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)
  22808. * @returns the VertexData of the torus
  22809. */
  22810. static CreateTorus(options: {
  22811. diameter?: number;
  22812. thickness?: number;
  22813. tessellation?: number;
  22814. sideOrientation?: number;
  22815. frontUVs?: Vector4;
  22816. backUVs?: Vector4;
  22817. }): VertexData;
  22818. /**
  22819. * Creates the VertexData of the LineSystem
  22820. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22821. * - lines an array of lines, each line being an array of successive Vector3
  22822. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22823. * @returns the VertexData of the LineSystem
  22824. */
  22825. static CreateLineSystem(options: {
  22826. lines: Vector3[][];
  22827. colors?: Nullable<Color4[][]>;
  22828. }): VertexData;
  22829. /**
  22830. * Create the VertexData for a DashedLines
  22831. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22832. * - points an array successive Vector3
  22833. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22834. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22835. * - dashNb the intended total number of dashes, optional, default 200
  22836. * @returns the VertexData for the DashedLines
  22837. */
  22838. static CreateDashedLines(options: {
  22839. points: Vector3[];
  22840. dashSize?: number;
  22841. gapSize?: number;
  22842. dashNb?: number;
  22843. }): VertexData;
  22844. /**
  22845. * Creates the VertexData for a Ground
  22846. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22847. * - width the width (x direction) of the ground, optional, default 1
  22848. * - height the height (z direction) of the ground, optional, default 1
  22849. * - subdivisions the number of subdivisions per side, optional, default 1
  22850. * @returns the VertexData of the Ground
  22851. */
  22852. static CreateGround(options: {
  22853. width?: number;
  22854. height?: number;
  22855. subdivisions?: number;
  22856. subdivisionsX?: number;
  22857. subdivisionsY?: number;
  22858. }): VertexData;
  22859. /**
  22860. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22861. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22862. * * xmin the ground minimum X coordinate, optional, default -1
  22863. * * zmin the ground minimum Z coordinate, optional, default -1
  22864. * * xmax the ground maximum X coordinate, optional, default 1
  22865. * * zmax the ground maximum Z coordinate, optional, default 1
  22866. * * 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}
  22867. * * 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}
  22868. * @returns the VertexData of the TiledGround
  22869. */
  22870. static CreateTiledGround(options: {
  22871. xmin: number;
  22872. zmin: number;
  22873. xmax: number;
  22874. zmax: number;
  22875. subdivisions?: {
  22876. w: number;
  22877. h: number;
  22878. };
  22879. precision?: {
  22880. w: number;
  22881. h: number;
  22882. };
  22883. }): VertexData;
  22884. /**
  22885. * Creates the VertexData of the Ground designed from a heightmap
  22886. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22887. * * width the width (x direction) of the ground
  22888. * * height the height (z direction) of the ground
  22889. * * subdivisions the number of subdivisions per side
  22890. * * minHeight the minimum altitude on the ground, optional, default 0
  22891. * * maxHeight the maximum altitude on the ground, optional default 1
  22892. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22893. * * buffer the array holding the image color data
  22894. * * bufferWidth the width of image
  22895. * * bufferHeight the height of image
  22896. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22897. * @returns the VertexData of the Ground designed from a heightmap
  22898. */
  22899. static CreateGroundFromHeightMap(options: {
  22900. width: number;
  22901. height: number;
  22902. subdivisions: number;
  22903. minHeight: number;
  22904. maxHeight: number;
  22905. colorFilter: Color3;
  22906. buffer: Uint8Array;
  22907. bufferWidth: number;
  22908. bufferHeight: number;
  22909. alphaFilter: number;
  22910. }): VertexData;
  22911. /**
  22912. * Creates the VertexData for a Plane
  22913. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22914. * * size sets the width and height of the plane to the value of size, optional default 1
  22915. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22916. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22918. * * 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)
  22919. * * 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)
  22920. * @returns the VertexData of the box
  22921. */
  22922. static CreatePlane(options: {
  22923. size?: number;
  22924. width?: number;
  22925. height?: number;
  22926. sideOrientation?: number;
  22927. frontUVs?: Vector4;
  22928. backUVs?: Vector4;
  22929. }): VertexData;
  22930. /**
  22931. * Creates the VertexData of the Disc or regular Polygon
  22932. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22933. * * radius the radius of the disc, optional default 0.5
  22934. * * tessellation the number of polygon sides, optional, default 64
  22935. * * 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
  22936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22937. * * 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)
  22938. * * 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)
  22939. * @returns the VertexData of the box
  22940. */
  22941. static CreateDisc(options: {
  22942. radius?: number;
  22943. tessellation?: number;
  22944. arc?: number;
  22945. sideOrientation?: number;
  22946. frontUVs?: Vector4;
  22947. backUVs?: Vector4;
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22951. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22952. * @param polygon a mesh built from polygonTriangulation.build()
  22953. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22954. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22955. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22956. * @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)
  22957. * @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)
  22958. * @returns the VertexData of the Polygon
  22959. */
  22960. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22961. /**
  22962. * Creates the VertexData of the IcoSphere
  22963. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22964. * * radius the radius of the IcoSphere, optional default 1
  22965. * * radiusX allows stretching in the x direction, optional, default radius
  22966. * * radiusY allows stretching in the y direction, optional, default radius
  22967. * * radiusZ allows stretching in the z direction, optional, default radius
  22968. * * flat when true creates a flat shaded mesh, optional, default true
  22969. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22971. * * 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)
  22972. * * 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)
  22973. * @returns the VertexData of the IcoSphere
  22974. */
  22975. static CreateIcoSphere(options: {
  22976. radius?: number;
  22977. radiusX?: number;
  22978. radiusY?: number;
  22979. radiusZ?: number;
  22980. flat?: boolean;
  22981. subdivisions?: number;
  22982. sideOrientation?: number;
  22983. frontUVs?: Vector4;
  22984. backUVs?: Vector4;
  22985. }): VertexData;
  22986. /**
  22987. * Creates the VertexData for a Polyhedron
  22988. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22989. * * type provided types are:
  22990. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22991. * * 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)
  22992. * * size the size of the IcoSphere, optional default 1
  22993. * * sizeX allows stretching in the x direction, optional, default size
  22994. * * sizeY allows stretching in the y direction, optional, default size
  22995. * * sizeZ allows stretching in the z direction, optional, default size
  22996. * * 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
  22997. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22998. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22999. * * flat when true creates a flat shaded mesh, optional, default true
  23000. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23002. * * 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)
  23003. * * 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)
  23004. * @returns the VertexData of the Polyhedron
  23005. */
  23006. static CreatePolyhedron(options: {
  23007. type?: number;
  23008. size?: number;
  23009. sizeX?: number;
  23010. sizeY?: number;
  23011. sizeZ?: number;
  23012. custom?: any;
  23013. faceUV?: Vector4[];
  23014. faceColors?: Color4[];
  23015. flat?: boolean;
  23016. sideOrientation?: number;
  23017. frontUVs?: Vector4;
  23018. backUVs?: Vector4;
  23019. }): VertexData;
  23020. /**
  23021. * Creates the VertexData for a TorusKnot
  23022. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23023. * * radius the radius of the torus knot, optional, default 2
  23024. * * tube the thickness of the tube, optional, default 0.5
  23025. * * radialSegments the number of sides on each tube segments, optional, default 32
  23026. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23027. * * p the number of windings around the z axis, optional, default 2
  23028. * * q the number of windings around the x axis, optional, default 3
  23029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23030. * * 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)
  23031. * * 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)
  23032. * @returns the VertexData of the Torus Knot
  23033. */
  23034. static CreateTorusKnot(options: {
  23035. radius?: number;
  23036. tube?: number;
  23037. radialSegments?: number;
  23038. tubularSegments?: number;
  23039. p?: number;
  23040. q?: number;
  23041. sideOrientation?: number;
  23042. frontUVs?: Vector4;
  23043. backUVs?: Vector4;
  23044. }): VertexData;
  23045. /**
  23046. * Compute normals for given positions and indices
  23047. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23048. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23049. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23050. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23051. * * facetNormals : optional array of facet normals (vector3)
  23052. * * facetPositions : optional array of facet positions (vector3)
  23053. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23054. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23055. * * bInfo : optional bounding info, required for facetPartitioning computation
  23056. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23057. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23058. * * useRightHandedSystem: optional boolean to for right handed system computation
  23059. * * depthSort : optional boolean to enable the facet depth sort computation
  23060. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23061. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23062. */
  23063. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23064. facetNormals?: any;
  23065. facetPositions?: any;
  23066. facetPartitioning?: any;
  23067. ratio?: number;
  23068. bInfo?: any;
  23069. bbSize?: Vector3;
  23070. subDiv?: any;
  23071. useRightHandedSystem?: boolean;
  23072. depthSort?: boolean;
  23073. distanceTo?: Vector3;
  23074. depthSortedFacets?: any;
  23075. }): void;
  23076. /** @hidden */
  23077. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23078. /**
  23079. * Applies VertexData created from the imported parameters to the geometry
  23080. * @param parsedVertexData the parsed data from an imported file
  23081. * @param geometry the geometry to apply the VertexData to
  23082. */
  23083. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23084. }
  23085. }
  23086. declare module "babylonjs/Morph/morphTarget" {
  23087. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23088. import { Observable } from "babylonjs/Misc/observable";
  23089. import { Nullable, FloatArray } from "babylonjs/types";
  23090. import { Scene } from "babylonjs/scene";
  23091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23092. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23093. /**
  23094. * Defines a target to use with MorphTargetManager
  23095. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23096. */
  23097. export class MorphTarget implements IAnimatable {
  23098. /** defines the name of the target */
  23099. name: string;
  23100. /**
  23101. * Gets or sets the list of animations
  23102. */
  23103. animations: import("babylonjs/Animations/animation").Animation[];
  23104. private _scene;
  23105. private _positions;
  23106. private _normals;
  23107. private _tangents;
  23108. private _uvs;
  23109. private _influence;
  23110. private _uniqueId;
  23111. /**
  23112. * Observable raised when the influence changes
  23113. */
  23114. onInfluenceChanged: Observable<boolean>;
  23115. /** @hidden */
  23116. _onDataLayoutChanged: Observable<void>;
  23117. /**
  23118. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23119. */
  23120. get influence(): number;
  23121. set influence(influence: number);
  23122. /**
  23123. * Gets or sets the id of the morph Target
  23124. */
  23125. id: string;
  23126. private _animationPropertiesOverride;
  23127. /**
  23128. * Gets or sets the animation properties override
  23129. */
  23130. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23131. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23132. /**
  23133. * Creates a new MorphTarget
  23134. * @param name defines the name of the target
  23135. * @param influence defines the influence to use
  23136. * @param scene defines the scene the morphtarget belongs to
  23137. */
  23138. constructor(
  23139. /** defines the name of the target */
  23140. name: string, influence?: number, scene?: Nullable<Scene>);
  23141. /**
  23142. * Gets the unique ID of this manager
  23143. */
  23144. get uniqueId(): number;
  23145. /**
  23146. * Gets a boolean defining if the target contains position data
  23147. */
  23148. get hasPositions(): boolean;
  23149. /**
  23150. * Gets a boolean defining if the target contains normal data
  23151. */
  23152. get hasNormals(): boolean;
  23153. /**
  23154. * Gets a boolean defining if the target contains tangent data
  23155. */
  23156. get hasTangents(): boolean;
  23157. /**
  23158. * Gets a boolean defining if the target contains texture coordinates data
  23159. */
  23160. get hasUVs(): boolean;
  23161. /**
  23162. * Affects position data to this target
  23163. * @param data defines the position data to use
  23164. */
  23165. setPositions(data: Nullable<FloatArray>): void;
  23166. /**
  23167. * Gets the position data stored in this target
  23168. * @returns a FloatArray containing the position data (or null if not present)
  23169. */
  23170. getPositions(): Nullable<FloatArray>;
  23171. /**
  23172. * Affects normal data to this target
  23173. * @param data defines the normal data to use
  23174. */
  23175. setNormals(data: Nullable<FloatArray>): void;
  23176. /**
  23177. * Gets the normal data stored in this target
  23178. * @returns a FloatArray containing the normal data (or null if not present)
  23179. */
  23180. getNormals(): Nullable<FloatArray>;
  23181. /**
  23182. * Affects tangent data to this target
  23183. * @param data defines the tangent data to use
  23184. */
  23185. setTangents(data: Nullable<FloatArray>): void;
  23186. /**
  23187. * Gets the tangent data stored in this target
  23188. * @returns a FloatArray containing the tangent data (or null if not present)
  23189. */
  23190. getTangents(): Nullable<FloatArray>;
  23191. /**
  23192. * Affects texture coordinates data to this target
  23193. * @param data defines the texture coordinates data to use
  23194. */
  23195. setUVs(data: Nullable<FloatArray>): void;
  23196. /**
  23197. * Gets the texture coordinates data stored in this target
  23198. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23199. */
  23200. getUVs(): Nullable<FloatArray>;
  23201. /**
  23202. * Clone the current target
  23203. * @returns a new MorphTarget
  23204. */
  23205. clone(): MorphTarget;
  23206. /**
  23207. * Serializes the current target into a Serialization object
  23208. * @returns the serialized object
  23209. */
  23210. serialize(): any;
  23211. /**
  23212. * Returns the string "MorphTarget"
  23213. * @returns "MorphTarget"
  23214. */
  23215. getClassName(): string;
  23216. /**
  23217. * Creates a new target from serialized data
  23218. * @param serializationObject defines the serialized data to use
  23219. * @returns a new MorphTarget
  23220. */
  23221. static Parse(serializationObject: any): MorphTarget;
  23222. /**
  23223. * Creates a MorphTarget from mesh data
  23224. * @param mesh defines the source mesh
  23225. * @param name defines the name to use for the new target
  23226. * @param influence defines the influence to attach to the target
  23227. * @returns a new MorphTarget
  23228. */
  23229. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23230. }
  23231. }
  23232. declare module "babylonjs/Morph/morphTargetManager" {
  23233. import { Nullable } from "babylonjs/types";
  23234. import { Scene } from "babylonjs/scene";
  23235. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23236. /**
  23237. * This class is used to deform meshes using morphing between different targets
  23238. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23239. */
  23240. export class MorphTargetManager {
  23241. private _targets;
  23242. private _targetInfluenceChangedObservers;
  23243. private _targetDataLayoutChangedObservers;
  23244. private _activeTargets;
  23245. private _scene;
  23246. private _influences;
  23247. private _supportsNormals;
  23248. private _supportsTangents;
  23249. private _supportsUVs;
  23250. private _vertexCount;
  23251. private _uniqueId;
  23252. private _tempInfluences;
  23253. /**
  23254. * Gets or sets a boolean indicating if normals must be morphed
  23255. */
  23256. enableNormalMorphing: boolean;
  23257. /**
  23258. * Gets or sets a boolean indicating if tangents must be morphed
  23259. */
  23260. enableTangentMorphing: boolean;
  23261. /**
  23262. * Gets or sets a boolean indicating if UV must be morphed
  23263. */
  23264. enableUVMorphing: boolean;
  23265. /**
  23266. * Creates a new MorphTargetManager
  23267. * @param scene defines the current scene
  23268. */
  23269. constructor(scene?: Nullable<Scene>);
  23270. /**
  23271. * Gets the unique ID of this manager
  23272. */
  23273. get uniqueId(): number;
  23274. /**
  23275. * Gets the number of vertices handled by this manager
  23276. */
  23277. get vertexCount(): number;
  23278. /**
  23279. * Gets a boolean indicating if this manager supports morphing of normals
  23280. */
  23281. get supportsNormals(): boolean;
  23282. /**
  23283. * Gets a boolean indicating if this manager supports morphing of tangents
  23284. */
  23285. get supportsTangents(): boolean;
  23286. /**
  23287. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23288. */
  23289. get supportsUVs(): boolean;
  23290. /**
  23291. * Gets the number of targets stored in this manager
  23292. */
  23293. get numTargets(): number;
  23294. /**
  23295. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23296. */
  23297. get numInfluencers(): number;
  23298. /**
  23299. * Gets the list of influences (one per target)
  23300. */
  23301. get influences(): Float32Array;
  23302. /**
  23303. * Gets the active target at specified index. An active target is a target with an influence > 0
  23304. * @param index defines the index to check
  23305. * @returns the requested target
  23306. */
  23307. getActiveTarget(index: number): MorphTarget;
  23308. /**
  23309. * Gets the target at specified index
  23310. * @param index defines the index to check
  23311. * @returns the requested target
  23312. */
  23313. getTarget(index: number): MorphTarget;
  23314. /**
  23315. * Add a new target to this manager
  23316. * @param target defines the target to add
  23317. */
  23318. addTarget(target: MorphTarget): void;
  23319. /**
  23320. * Removes a target from the manager
  23321. * @param target defines the target to remove
  23322. */
  23323. removeTarget(target: MorphTarget): void;
  23324. /**
  23325. * Clone the current manager
  23326. * @returns a new MorphTargetManager
  23327. */
  23328. clone(): MorphTargetManager;
  23329. /**
  23330. * Serializes the current manager into a Serialization object
  23331. * @returns the serialized object
  23332. */
  23333. serialize(): any;
  23334. private _syncActiveTargets;
  23335. /**
  23336. * Syncrhonize the targets with all the meshes using this morph target manager
  23337. */
  23338. synchronize(): void;
  23339. /**
  23340. * Creates a new MorphTargetManager from serialized data
  23341. * @param serializationObject defines the serialized data
  23342. * @param scene defines the hosting scene
  23343. * @returns the new MorphTargetManager
  23344. */
  23345. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23346. }
  23347. }
  23348. declare module "babylonjs/Meshes/meshLODLevel" {
  23349. import { Mesh } from "babylonjs/Meshes/mesh";
  23350. import { Nullable } from "babylonjs/types";
  23351. /**
  23352. * Class used to represent a specific level of detail of a mesh
  23353. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23354. */
  23355. export class MeshLODLevel {
  23356. /** Defines the distance where this level should start being displayed */
  23357. distance: number;
  23358. /** Defines the mesh to use to render this level */
  23359. mesh: Nullable<Mesh>;
  23360. /**
  23361. * Creates a new LOD level
  23362. * @param distance defines the distance where this level should star being displayed
  23363. * @param mesh defines the mesh to use to render this level
  23364. */
  23365. constructor(
  23366. /** Defines the distance where this level should start being displayed */
  23367. distance: number,
  23368. /** Defines the mesh to use to render this level */
  23369. mesh: Nullable<Mesh>);
  23370. }
  23371. }
  23372. declare module "babylonjs/Meshes/groundMesh" {
  23373. import { Scene } from "babylonjs/scene";
  23374. import { Vector3 } from "babylonjs/Maths/math.vector";
  23375. import { Mesh } from "babylonjs/Meshes/mesh";
  23376. /**
  23377. * Mesh representing the gorund
  23378. */
  23379. export class GroundMesh extends Mesh {
  23380. /** If octree should be generated */
  23381. generateOctree: boolean;
  23382. private _heightQuads;
  23383. /** @hidden */
  23384. _subdivisionsX: number;
  23385. /** @hidden */
  23386. _subdivisionsY: number;
  23387. /** @hidden */
  23388. _width: number;
  23389. /** @hidden */
  23390. _height: number;
  23391. /** @hidden */
  23392. _minX: number;
  23393. /** @hidden */
  23394. _maxX: number;
  23395. /** @hidden */
  23396. _minZ: number;
  23397. /** @hidden */
  23398. _maxZ: number;
  23399. constructor(name: string, scene: Scene);
  23400. /**
  23401. * "GroundMesh"
  23402. * @returns "GroundMesh"
  23403. */
  23404. getClassName(): string;
  23405. /**
  23406. * The minimum of x and y subdivisions
  23407. */
  23408. get subdivisions(): number;
  23409. /**
  23410. * X subdivisions
  23411. */
  23412. get subdivisionsX(): number;
  23413. /**
  23414. * Y subdivisions
  23415. */
  23416. get subdivisionsY(): number;
  23417. /**
  23418. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23419. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23420. * @param chunksCount the number of subdivisions for x and y
  23421. * @param octreeBlocksSize (Default: 32)
  23422. */
  23423. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23424. /**
  23425. * Returns a height (y) value in the Worl system :
  23426. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23427. * @param x x coordinate
  23428. * @param z z coordinate
  23429. * @returns the ground y position if (x, z) are outside the ground surface.
  23430. */
  23431. getHeightAtCoordinates(x: number, z: number): number;
  23432. /**
  23433. * Returns a normalized vector (Vector3) orthogonal to the ground
  23434. * at the ground coordinates (x, z) expressed in the World system.
  23435. * @param x x coordinate
  23436. * @param z z coordinate
  23437. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23438. */
  23439. getNormalAtCoordinates(x: number, z: number): Vector3;
  23440. /**
  23441. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23442. * at the ground coordinates (x, z) expressed in the World system.
  23443. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23444. * @param x x coordinate
  23445. * @param z z coordinate
  23446. * @param ref vector to store the result
  23447. * @returns the GroundMesh.
  23448. */
  23449. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23450. /**
  23451. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23452. * if the ground has been updated.
  23453. * This can be used in the render loop.
  23454. * @returns the GroundMesh.
  23455. */
  23456. updateCoordinateHeights(): GroundMesh;
  23457. private _getFacetAt;
  23458. private _initHeightQuads;
  23459. private _computeHeightQuads;
  23460. /**
  23461. * Serializes this ground mesh
  23462. * @param serializationObject object to write serialization to
  23463. */
  23464. serialize(serializationObject: any): void;
  23465. /**
  23466. * Parses a serialized ground mesh
  23467. * @param parsedMesh the serialized mesh
  23468. * @param scene the scene to create the ground mesh in
  23469. * @returns the created ground mesh
  23470. */
  23471. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23472. }
  23473. }
  23474. declare module "babylonjs/Physics/physicsJoint" {
  23475. import { Vector3 } from "babylonjs/Maths/math.vector";
  23476. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23477. /**
  23478. * Interface for Physics-Joint data
  23479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23480. */
  23481. export interface PhysicsJointData {
  23482. /**
  23483. * The main pivot of the joint
  23484. */
  23485. mainPivot?: Vector3;
  23486. /**
  23487. * The connected pivot of the joint
  23488. */
  23489. connectedPivot?: Vector3;
  23490. /**
  23491. * The main axis of the joint
  23492. */
  23493. mainAxis?: Vector3;
  23494. /**
  23495. * The connected axis of the joint
  23496. */
  23497. connectedAxis?: Vector3;
  23498. /**
  23499. * The collision of the joint
  23500. */
  23501. collision?: boolean;
  23502. /**
  23503. * Native Oimo/Cannon/Energy data
  23504. */
  23505. nativeParams?: any;
  23506. }
  23507. /**
  23508. * This is a holder class for the physics joint created by the physics plugin
  23509. * It holds a set of functions to control the underlying joint
  23510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23511. */
  23512. export class PhysicsJoint {
  23513. /**
  23514. * The type of the physics joint
  23515. */
  23516. type: number;
  23517. /**
  23518. * The data for the physics joint
  23519. */
  23520. jointData: PhysicsJointData;
  23521. private _physicsJoint;
  23522. protected _physicsPlugin: IPhysicsEnginePlugin;
  23523. /**
  23524. * Initializes the physics joint
  23525. * @param type The type of the physics joint
  23526. * @param jointData The data for the physics joint
  23527. */
  23528. constructor(
  23529. /**
  23530. * The type of the physics joint
  23531. */
  23532. type: number,
  23533. /**
  23534. * The data for the physics joint
  23535. */
  23536. jointData: PhysicsJointData);
  23537. /**
  23538. * Gets the physics joint
  23539. */
  23540. get physicsJoint(): any;
  23541. /**
  23542. * Sets the physics joint
  23543. */
  23544. set physicsJoint(newJoint: any);
  23545. /**
  23546. * Sets the physics plugin
  23547. */
  23548. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23549. /**
  23550. * Execute a function that is physics-plugin specific.
  23551. * @param {Function} func the function that will be executed.
  23552. * It accepts two parameters: the physics world and the physics joint
  23553. */
  23554. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23555. /**
  23556. * Distance-Joint type
  23557. */
  23558. static DistanceJoint: number;
  23559. /**
  23560. * Hinge-Joint type
  23561. */
  23562. static HingeJoint: number;
  23563. /**
  23564. * Ball-and-Socket joint type
  23565. */
  23566. static BallAndSocketJoint: number;
  23567. /**
  23568. * Wheel-Joint type
  23569. */
  23570. static WheelJoint: number;
  23571. /**
  23572. * Slider-Joint type
  23573. */
  23574. static SliderJoint: number;
  23575. /**
  23576. * Prismatic-Joint type
  23577. */
  23578. static PrismaticJoint: number;
  23579. /**
  23580. * Universal-Joint type
  23581. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23582. */
  23583. static UniversalJoint: number;
  23584. /**
  23585. * Hinge-Joint 2 type
  23586. */
  23587. static Hinge2Joint: number;
  23588. /**
  23589. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23590. */
  23591. static PointToPointJoint: number;
  23592. /**
  23593. * Spring-Joint type
  23594. */
  23595. static SpringJoint: number;
  23596. /**
  23597. * Lock-Joint type
  23598. */
  23599. static LockJoint: number;
  23600. }
  23601. /**
  23602. * A class representing a physics distance joint
  23603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23604. */
  23605. export class DistanceJoint extends PhysicsJoint {
  23606. /**
  23607. *
  23608. * @param jointData The data for the Distance-Joint
  23609. */
  23610. constructor(jointData: DistanceJointData);
  23611. /**
  23612. * Update the predefined distance.
  23613. * @param maxDistance The maximum preferred distance
  23614. * @param minDistance The minimum preferred distance
  23615. */
  23616. updateDistance(maxDistance: number, minDistance?: number): void;
  23617. }
  23618. /**
  23619. * Represents a Motor-Enabled Joint
  23620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23621. */
  23622. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23623. /**
  23624. * Initializes the Motor-Enabled Joint
  23625. * @param type The type of the joint
  23626. * @param jointData The physica joint data for the joint
  23627. */
  23628. constructor(type: number, jointData: PhysicsJointData);
  23629. /**
  23630. * Set the motor values.
  23631. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23632. * @param force the force to apply
  23633. * @param maxForce max force for this motor.
  23634. */
  23635. setMotor(force?: number, maxForce?: number): void;
  23636. /**
  23637. * Set the motor's limits.
  23638. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23639. * @param upperLimit The upper limit of the motor
  23640. * @param lowerLimit The lower limit of the motor
  23641. */
  23642. setLimit(upperLimit: number, lowerLimit?: number): void;
  23643. }
  23644. /**
  23645. * This class represents a single physics Hinge-Joint
  23646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23647. */
  23648. export class HingeJoint extends MotorEnabledJoint {
  23649. /**
  23650. * Initializes the Hinge-Joint
  23651. * @param jointData The joint data for the Hinge-Joint
  23652. */
  23653. constructor(jointData: PhysicsJointData);
  23654. /**
  23655. * Set the motor values.
  23656. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23657. * @param {number} force the force to apply
  23658. * @param {number} maxForce max force for this motor.
  23659. */
  23660. setMotor(force?: number, maxForce?: number): void;
  23661. /**
  23662. * Set the motor's limits.
  23663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23664. * @param upperLimit The upper limit of the motor
  23665. * @param lowerLimit The lower limit of the motor
  23666. */
  23667. setLimit(upperLimit: number, lowerLimit?: number): void;
  23668. }
  23669. /**
  23670. * This class represents a dual hinge physics joint (same as wheel joint)
  23671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23672. */
  23673. export class Hinge2Joint extends MotorEnabledJoint {
  23674. /**
  23675. * Initializes the Hinge2-Joint
  23676. * @param jointData The joint data for the Hinge2-Joint
  23677. */
  23678. constructor(jointData: PhysicsJointData);
  23679. /**
  23680. * Set the motor values.
  23681. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23682. * @param {number} targetSpeed the speed the motor is to reach
  23683. * @param {number} maxForce max force for this motor.
  23684. * @param {motorIndex} the motor's index, 0 or 1.
  23685. */
  23686. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23687. /**
  23688. * Set the motor limits.
  23689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23690. * @param {number} upperLimit the upper limit
  23691. * @param {number} lowerLimit lower limit
  23692. * @param {motorIndex} the motor's index, 0 or 1.
  23693. */
  23694. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23695. }
  23696. /**
  23697. * Interface for a motor enabled joint
  23698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23699. */
  23700. export interface IMotorEnabledJoint {
  23701. /**
  23702. * Physics joint
  23703. */
  23704. physicsJoint: any;
  23705. /**
  23706. * Sets the motor of the motor-enabled joint
  23707. * @param force The force of the motor
  23708. * @param maxForce The maximum force of the motor
  23709. * @param motorIndex The index of the motor
  23710. */
  23711. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23712. /**
  23713. * Sets the limit of the motor
  23714. * @param upperLimit The upper limit of the motor
  23715. * @param lowerLimit The lower limit of the motor
  23716. * @param motorIndex The index of the motor
  23717. */
  23718. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23719. }
  23720. /**
  23721. * Joint data for a Distance-Joint
  23722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23723. */
  23724. export interface DistanceJointData extends PhysicsJointData {
  23725. /**
  23726. * Max distance the 2 joint objects can be apart
  23727. */
  23728. maxDistance: number;
  23729. }
  23730. /**
  23731. * Joint data from a spring joint
  23732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23733. */
  23734. export interface SpringJointData extends PhysicsJointData {
  23735. /**
  23736. * Length of the spring
  23737. */
  23738. length: number;
  23739. /**
  23740. * Stiffness of the spring
  23741. */
  23742. stiffness: number;
  23743. /**
  23744. * Damping of the spring
  23745. */
  23746. damping: number;
  23747. /** this callback will be called when applying the force to the impostors. */
  23748. forceApplicationCallback: () => void;
  23749. }
  23750. }
  23751. declare module "babylonjs/Physics/physicsRaycastResult" {
  23752. import { Vector3 } from "babylonjs/Maths/math.vector";
  23753. /**
  23754. * Holds the data for the raycast result
  23755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23756. */
  23757. export class PhysicsRaycastResult {
  23758. private _hasHit;
  23759. private _hitDistance;
  23760. private _hitNormalWorld;
  23761. private _hitPointWorld;
  23762. private _rayFromWorld;
  23763. private _rayToWorld;
  23764. /**
  23765. * Gets if there was a hit
  23766. */
  23767. get hasHit(): boolean;
  23768. /**
  23769. * Gets the distance from the hit
  23770. */
  23771. get hitDistance(): number;
  23772. /**
  23773. * Gets the hit normal/direction in the world
  23774. */
  23775. get hitNormalWorld(): Vector3;
  23776. /**
  23777. * Gets the hit point in the world
  23778. */
  23779. get hitPointWorld(): Vector3;
  23780. /**
  23781. * Gets the ray "start point" of the ray in the world
  23782. */
  23783. get rayFromWorld(): Vector3;
  23784. /**
  23785. * Gets the ray "end point" of the ray in the world
  23786. */
  23787. get rayToWorld(): Vector3;
  23788. /**
  23789. * Sets the hit data (normal & point in world space)
  23790. * @param hitNormalWorld defines the normal in world space
  23791. * @param hitPointWorld defines the point in world space
  23792. */
  23793. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23794. /**
  23795. * Sets the distance from the start point to the hit point
  23796. * @param distance
  23797. */
  23798. setHitDistance(distance: number): void;
  23799. /**
  23800. * Calculates the distance manually
  23801. */
  23802. calculateHitDistance(): void;
  23803. /**
  23804. * Resets all the values to default
  23805. * @param from The from point on world space
  23806. * @param to The to point on world space
  23807. */
  23808. reset(from?: Vector3, to?: Vector3): void;
  23809. }
  23810. /**
  23811. * Interface for the size containing width and height
  23812. */
  23813. interface IXYZ {
  23814. /**
  23815. * X
  23816. */
  23817. x: number;
  23818. /**
  23819. * Y
  23820. */
  23821. y: number;
  23822. /**
  23823. * Z
  23824. */
  23825. z: number;
  23826. }
  23827. }
  23828. declare module "babylonjs/Physics/IPhysicsEngine" {
  23829. import { Nullable } from "babylonjs/types";
  23830. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23832. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23833. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23834. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23835. /**
  23836. * Interface used to describe a physics joint
  23837. */
  23838. export interface PhysicsImpostorJoint {
  23839. /** Defines the main impostor to which the joint is linked */
  23840. mainImpostor: PhysicsImpostor;
  23841. /** Defines the impostor that is connected to the main impostor using this joint */
  23842. connectedImpostor: PhysicsImpostor;
  23843. /** Defines the joint itself */
  23844. joint: PhysicsJoint;
  23845. }
  23846. /** @hidden */
  23847. export interface IPhysicsEnginePlugin {
  23848. world: any;
  23849. name: string;
  23850. setGravity(gravity: Vector3): void;
  23851. setTimeStep(timeStep: number): void;
  23852. getTimeStep(): number;
  23853. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23854. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23855. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23856. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23857. removePhysicsBody(impostor: PhysicsImpostor): void;
  23858. generateJoint(joint: PhysicsImpostorJoint): void;
  23859. removeJoint(joint: PhysicsImpostorJoint): void;
  23860. isSupported(): boolean;
  23861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23862. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23863. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23864. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23865. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23866. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23867. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23868. getBodyMass(impostor: PhysicsImpostor): number;
  23869. getBodyFriction(impostor: PhysicsImpostor): number;
  23870. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23871. getBodyRestitution(impostor: PhysicsImpostor): number;
  23872. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23873. getBodyPressure?(impostor: PhysicsImpostor): number;
  23874. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23875. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23876. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23877. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23878. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23879. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23880. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23881. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23882. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23883. sleepBody(impostor: PhysicsImpostor): void;
  23884. wakeUpBody(impostor: PhysicsImpostor): void;
  23885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23887. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23888. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23889. getRadius(impostor: PhysicsImpostor): number;
  23890. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23891. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23892. dispose(): void;
  23893. }
  23894. /**
  23895. * Interface used to define a physics engine
  23896. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23897. */
  23898. export interface IPhysicsEngine {
  23899. /**
  23900. * Gets the gravity vector used by the simulation
  23901. */
  23902. gravity: Vector3;
  23903. /**
  23904. * Sets the gravity vector used by the simulation
  23905. * @param gravity defines the gravity vector to use
  23906. */
  23907. setGravity(gravity: Vector3): void;
  23908. /**
  23909. * Set the time step of the physics engine.
  23910. * Default is 1/60.
  23911. * To slow it down, enter 1/600 for example.
  23912. * To speed it up, 1/30
  23913. * @param newTimeStep the new timestep to apply to this world.
  23914. */
  23915. setTimeStep(newTimeStep: number): void;
  23916. /**
  23917. * Get the time step of the physics engine.
  23918. * @returns the current time step
  23919. */
  23920. getTimeStep(): number;
  23921. /**
  23922. * Set the sub time step of the physics engine.
  23923. * Default is 0 meaning there is no sub steps
  23924. * To increase physics resolution precision, set a small value (like 1 ms)
  23925. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23926. */
  23927. setSubTimeStep(subTimeStep: number): void;
  23928. /**
  23929. * Get the sub time step of the physics engine.
  23930. * @returns the current sub time step
  23931. */
  23932. getSubTimeStep(): number;
  23933. /**
  23934. * Release all resources
  23935. */
  23936. dispose(): void;
  23937. /**
  23938. * Gets the name of the current physics plugin
  23939. * @returns the name of the plugin
  23940. */
  23941. getPhysicsPluginName(): string;
  23942. /**
  23943. * Adding a new impostor for the impostor tracking.
  23944. * This will be done by the impostor itself.
  23945. * @param impostor the impostor to add
  23946. */
  23947. addImpostor(impostor: PhysicsImpostor): void;
  23948. /**
  23949. * Remove an impostor from the engine.
  23950. * This impostor and its mesh will not longer be updated by the physics engine.
  23951. * @param impostor the impostor to remove
  23952. */
  23953. removeImpostor(impostor: PhysicsImpostor): void;
  23954. /**
  23955. * Add a joint to the physics engine
  23956. * @param mainImpostor defines the main impostor to which the joint is added.
  23957. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23958. * @param joint defines the joint that will connect both impostors.
  23959. */
  23960. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23961. /**
  23962. * Removes a joint from the simulation
  23963. * @param mainImpostor defines the impostor used with the joint
  23964. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23965. * @param joint defines the joint to remove
  23966. */
  23967. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23968. /**
  23969. * Gets the current plugin used to run the simulation
  23970. * @returns current plugin
  23971. */
  23972. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23973. /**
  23974. * Gets the list of physic impostors
  23975. * @returns an array of PhysicsImpostor
  23976. */
  23977. getImpostors(): Array<PhysicsImpostor>;
  23978. /**
  23979. * Gets the impostor for a physics enabled object
  23980. * @param object defines the object impersonated by the impostor
  23981. * @returns the PhysicsImpostor or null if not found
  23982. */
  23983. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23984. /**
  23985. * Gets the impostor for a physics body object
  23986. * @param body defines physics body used by the impostor
  23987. * @returns the PhysicsImpostor or null if not found
  23988. */
  23989. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23990. /**
  23991. * Does a raycast in the physics world
  23992. * @param from when should the ray start?
  23993. * @param to when should the ray end?
  23994. * @returns PhysicsRaycastResult
  23995. */
  23996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23997. /**
  23998. * Called by the scene. No need to call it.
  23999. * @param delta defines the timespam between frames
  24000. */
  24001. _step(delta: number): void;
  24002. }
  24003. }
  24004. declare module "babylonjs/Physics/physicsImpostor" {
  24005. import { Nullable, IndicesArray } from "babylonjs/types";
  24006. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24007. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24009. import { Scene } from "babylonjs/scene";
  24010. import { Bone } from "babylonjs/Bones/bone";
  24011. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24012. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24013. import { Space } from "babylonjs/Maths/math.axis";
  24014. /**
  24015. * The interface for the physics imposter parameters
  24016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24017. */
  24018. export interface PhysicsImpostorParameters {
  24019. /**
  24020. * The mass of the physics imposter
  24021. */
  24022. mass: number;
  24023. /**
  24024. * The friction of the physics imposter
  24025. */
  24026. friction?: number;
  24027. /**
  24028. * The coefficient of restitution of the physics imposter
  24029. */
  24030. restitution?: number;
  24031. /**
  24032. * The native options of the physics imposter
  24033. */
  24034. nativeOptions?: any;
  24035. /**
  24036. * Specifies if the parent should be ignored
  24037. */
  24038. ignoreParent?: boolean;
  24039. /**
  24040. * Specifies if bi-directional transformations should be disabled
  24041. */
  24042. disableBidirectionalTransformation?: boolean;
  24043. /**
  24044. * The pressure inside the physics imposter, soft object only
  24045. */
  24046. pressure?: number;
  24047. /**
  24048. * The stiffness the physics imposter, soft object only
  24049. */
  24050. stiffness?: number;
  24051. /**
  24052. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24053. */
  24054. velocityIterations?: number;
  24055. /**
  24056. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24057. */
  24058. positionIterations?: number;
  24059. /**
  24060. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24061. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24062. * Add to fix multiple points
  24063. */
  24064. fixedPoints?: number;
  24065. /**
  24066. * The collision margin around a soft object
  24067. */
  24068. margin?: number;
  24069. /**
  24070. * The collision margin around a soft object
  24071. */
  24072. damping?: number;
  24073. /**
  24074. * The path for a rope based on an extrusion
  24075. */
  24076. path?: any;
  24077. /**
  24078. * The shape of an extrusion used for a rope based on an extrusion
  24079. */
  24080. shape?: any;
  24081. }
  24082. /**
  24083. * Interface for a physics-enabled object
  24084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24085. */
  24086. export interface IPhysicsEnabledObject {
  24087. /**
  24088. * The position of the physics-enabled object
  24089. */
  24090. position: Vector3;
  24091. /**
  24092. * The rotation of the physics-enabled object
  24093. */
  24094. rotationQuaternion: Nullable<Quaternion>;
  24095. /**
  24096. * The scale of the physics-enabled object
  24097. */
  24098. scaling: Vector3;
  24099. /**
  24100. * The rotation of the physics-enabled object
  24101. */
  24102. rotation?: Vector3;
  24103. /**
  24104. * The parent of the physics-enabled object
  24105. */
  24106. parent?: any;
  24107. /**
  24108. * The bounding info of the physics-enabled object
  24109. * @returns The bounding info of the physics-enabled object
  24110. */
  24111. getBoundingInfo(): BoundingInfo;
  24112. /**
  24113. * Computes the world matrix
  24114. * @param force Specifies if the world matrix should be computed by force
  24115. * @returns A world matrix
  24116. */
  24117. computeWorldMatrix(force: boolean): Matrix;
  24118. /**
  24119. * Gets the world matrix
  24120. * @returns A world matrix
  24121. */
  24122. getWorldMatrix?(): Matrix;
  24123. /**
  24124. * Gets the child meshes
  24125. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24126. * @returns An array of abstract meshes
  24127. */
  24128. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24129. /**
  24130. * Gets the vertex data
  24131. * @param kind The type of vertex data
  24132. * @returns A nullable array of numbers, or a float32 array
  24133. */
  24134. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24135. /**
  24136. * Gets the indices from the mesh
  24137. * @returns A nullable array of index arrays
  24138. */
  24139. getIndices?(): Nullable<IndicesArray>;
  24140. /**
  24141. * Gets the scene from the mesh
  24142. * @returns the indices array or null
  24143. */
  24144. getScene?(): Scene;
  24145. /**
  24146. * Gets the absolute position from the mesh
  24147. * @returns the absolute position
  24148. */
  24149. getAbsolutePosition(): Vector3;
  24150. /**
  24151. * Gets the absolute pivot point from the mesh
  24152. * @returns the absolute pivot point
  24153. */
  24154. getAbsolutePivotPoint(): Vector3;
  24155. /**
  24156. * Rotates the mesh
  24157. * @param axis The axis of rotation
  24158. * @param amount The amount of rotation
  24159. * @param space The space of the rotation
  24160. * @returns The rotation transform node
  24161. */
  24162. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24163. /**
  24164. * Translates the mesh
  24165. * @param axis The axis of translation
  24166. * @param distance The distance of translation
  24167. * @param space The space of the translation
  24168. * @returns The transform node
  24169. */
  24170. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24171. /**
  24172. * Sets the absolute position of the mesh
  24173. * @param absolutePosition The absolute position of the mesh
  24174. * @returns The transform node
  24175. */
  24176. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24177. /**
  24178. * Gets the class name of the mesh
  24179. * @returns The class name
  24180. */
  24181. getClassName(): string;
  24182. }
  24183. /**
  24184. * Represents a physics imposter
  24185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24186. */
  24187. export class PhysicsImpostor {
  24188. /**
  24189. * The physics-enabled object used as the physics imposter
  24190. */
  24191. object: IPhysicsEnabledObject;
  24192. /**
  24193. * The type of the physics imposter
  24194. */
  24195. type: number;
  24196. private _options;
  24197. private _scene?;
  24198. /**
  24199. * The default object size of the imposter
  24200. */
  24201. static DEFAULT_OBJECT_SIZE: Vector3;
  24202. /**
  24203. * The identity quaternion of the imposter
  24204. */
  24205. static IDENTITY_QUATERNION: Quaternion;
  24206. /** @hidden */
  24207. _pluginData: any;
  24208. private _physicsEngine;
  24209. private _physicsBody;
  24210. private _bodyUpdateRequired;
  24211. private _onBeforePhysicsStepCallbacks;
  24212. private _onAfterPhysicsStepCallbacks;
  24213. /** @hidden */
  24214. _onPhysicsCollideCallbacks: Array<{
  24215. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24216. otherImpostors: Array<PhysicsImpostor>;
  24217. }>;
  24218. private _deltaPosition;
  24219. private _deltaRotation;
  24220. private _deltaRotationConjugated;
  24221. /** @hidden */
  24222. _isFromLine: boolean;
  24223. private _parent;
  24224. private _isDisposed;
  24225. private static _tmpVecs;
  24226. private static _tmpQuat;
  24227. /**
  24228. * Specifies if the physics imposter is disposed
  24229. */
  24230. get isDisposed(): boolean;
  24231. /**
  24232. * Gets the mass of the physics imposter
  24233. */
  24234. get mass(): number;
  24235. set mass(value: number);
  24236. /**
  24237. * Gets the coefficient of friction
  24238. */
  24239. get friction(): number;
  24240. /**
  24241. * Sets the coefficient of friction
  24242. */
  24243. set friction(value: number);
  24244. /**
  24245. * Gets the coefficient of restitution
  24246. */
  24247. get restitution(): number;
  24248. /**
  24249. * Sets the coefficient of restitution
  24250. */
  24251. set restitution(value: number);
  24252. /**
  24253. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24254. */
  24255. get pressure(): number;
  24256. /**
  24257. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24258. */
  24259. set pressure(value: number);
  24260. /**
  24261. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24262. */
  24263. get stiffness(): number;
  24264. /**
  24265. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24266. */
  24267. set stiffness(value: number);
  24268. /**
  24269. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24270. */
  24271. get velocityIterations(): number;
  24272. /**
  24273. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24274. */
  24275. set velocityIterations(value: number);
  24276. /**
  24277. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24278. */
  24279. get positionIterations(): number;
  24280. /**
  24281. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24282. */
  24283. set positionIterations(value: number);
  24284. /**
  24285. * The unique id of the physics imposter
  24286. * set by the physics engine when adding this impostor to the array
  24287. */
  24288. uniqueId: number;
  24289. /**
  24290. * @hidden
  24291. */
  24292. soft: boolean;
  24293. /**
  24294. * @hidden
  24295. */
  24296. segments: number;
  24297. private _joints;
  24298. /**
  24299. * Initializes the physics imposter
  24300. * @param object The physics-enabled object used as the physics imposter
  24301. * @param type The type of the physics imposter
  24302. * @param _options The options for the physics imposter
  24303. * @param _scene The Babylon scene
  24304. */
  24305. constructor(
  24306. /**
  24307. * The physics-enabled object used as the physics imposter
  24308. */
  24309. object: IPhysicsEnabledObject,
  24310. /**
  24311. * The type of the physics imposter
  24312. */
  24313. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24314. /**
  24315. * This function will completly initialize this impostor.
  24316. * It will create a new body - but only if this mesh has no parent.
  24317. * If it has, this impostor will not be used other than to define the impostor
  24318. * of the child mesh.
  24319. * @hidden
  24320. */
  24321. _init(): void;
  24322. private _getPhysicsParent;
  24323. /**
  24324. * Should a new body be generated.
  24325. * @returns boolean specifying if body initialization is required
  24326. */
  24327. isBodyInitRequired(): boolean;
  24328. /**
  24329. * Sets the updated scaling
  24330. * @param updated Specifies if the scaling is updated
  24331. */
  24332. setScalingUpdated(): void;
  24333. /**
  24334. * Force a regeneration of this or the parent's impostor's body.
  24335. * Use under cautious - This will remove all joints already implemented.
  24336. */
  24337. forceUpdate(): void;
  24338. /**
  24339. * Gets the body that holds this impostor. Either its own, or its parent.
  24340. */
  24341. get physicsBody(): any;
  24342. /**
  24343. * Get the parent of the physics imposter
  24344. * @returns Physics imposter or null
  24345. */
  24346. get parent(): Nullable<PhysicsImpostor>;
  24347. /**
  24348. * Sets the parent of the physics imposter
  24349. */
  24350. set parent(value: Nullable<PhysicsImpostor>);
  24351. /**
  24352. * Set the physics body. Used mainly by the physics engine/plugin
  24353. */
  24354. set physicsBody(physicsBody: any);
  24355. /**
  24356. * Resets the update flags
  24357. */
  24358. resetUpdateFlags(): void;
  24359. /**
  24360. * Gets the object extend size
  24361. * @returns the object extend size
  24362. */
  24363. getObjectExtendSize(): Vector3;
  24364. /**
  24365. * Gets the object center
  24366. * @returns The object center
  24367. */
  24368. getObjectCenter(): Vector3;
  24369. /**
  24370. * Get a specific parametes from the options parameter
  24371. * @param paramName The object parameter name
  24372. * @returns The object parameter
  24373. */
  24374. getParam(paramName: string): any;
  24375. /**
  24376. * Sets a specific parameter in the options given to the physics plugin
  24377. * @param paramName The parameter name
  24378. * @param value The value of the parameter
  24379. */
  24380. setParam(paramName: string, value: number): void;
  24381. /**
  24382. * Specifically change the body's mass option. Won't recreate the physics body object
  24383. * @param mass The mass of the physics imposter
  24384. */
  24385. setMass(mass: number): void;
  24386. /**
  24387. * Gets the linear velocity
  24388. * @returns linear velocity or null
  24389. */
  24390. getLinearVelocity(): Nullable<Vector3>;
  24391. /**
  24392. * Sets the linear velocity
  24393. * @param velocity linear velocity or null
  24394. */
  24395. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24396. /**
  24397. * Gets the angular velocity
  24398. * @returns angular velocity or null
  24399. */
  24400. getAngularVelocity(): Nullable<Vector3>;
  24401. /**
  24402. * Sets the angular velocity
  24403. * @param velocity The velocity or null
  24404. */
  24405. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24406. /**
  24407. * Execute a function with the physics plugin native code
  24408. * Provide a function the will have two variables - the world object and the physics body object
  24409. * @param func The function to execute with the physics plugin native code
  24410. */
  24411. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24412. /**
  24413. * Register a function that will be executed before the physics world is stepping forward
  24414. * @param func The function to execute before the physics world is stepped forward
  24415. */
  24416. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24417. /**
  24418. * Unregister a function that will be executed before the physics world is stepping forward
  24419. * @param func The function to execute before the physics world is stepped forward
  24420. */
  24421. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24422. /**
  24423. * Register a function that will be executed after the physics step
  24424. * @param func The function to execute after physics step
  24425. */
  24426. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24427. /**
  24428. * Unregisters a function that will be executed after the physics step
  24429. * @param func The function to execute after physics step
  24430. */
  24431. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24432. /**
  24433. * register a function that will be executed when this impostor collides against a different body
  24434. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24435. * @param func Callback that is executed on collision
  24436. */
  24437. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24438. /**
  24439. * Unregisters the physics imposter on contact
  24440. * @param collideAgainst The physics object to collide against
  24441. * @param func Callback to execute on collision
  24442. */
  24443. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24444. private _tmpQuat;
  24445. private _tmpQuat2;
  24446. /**
  24447. * Get the parent rotation
  24448. * @returns The parent rotation
  24449. */
  24450. getParentsRotation(): Quaternion;
  24451. /**
  24452. * this function is executed by the physics engine.
  24453. */
  24454. beforeStep: () => void;
  24455. /**
  24456. * this function is executed by the physics engine
  24457. */
  24458. afterStep: () => void;
  24459. /**
  24460. * Legacy collision detection event support
  24461. */
  24462. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24463. /**
  24464. * event and body object due to cannon's event-based architecture.
  24465. */
  24466. onCollide: (e: {
  24467. body: any;
  24468. }) => void;
  24469. /**
  24470. * Apply a force
  24471. * @param force The force to apply
  24472. * @param contactPoint The contact point for the force
  24473. * @returns The physics imposter
  24474. */
  24475. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24476. /**
  24477. * Apply an impulse
  24478. * @param force The impulse force
  24479. * @param contactPoint The contact point for the impulse force
  24480. * @returns The physics imposter
  24481. */
  24482. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24483. /**
  24484. * A help function to create a joint
  24485. * @param otherImpostor A physics imposter used to create a joint
  24486. * @param jointType The type of joint
  24487. * @param jointData The data for the joint
  24488. * @returns The physics imposter
  24489. */
  24490. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24491. /**
  24492. * Add a joint to this impostor with a different impostor
  24493. * @param otherImpostor A physics imposter used to add a joint
  24494. * @param joint The joint to add
  24495. * @returns The physics imposter
  24496. */
  24497. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24498. /**
  24499. * Add an anchor to a cloth impostor
  24500. * @param otherImpostor rigid impostor to anchor to
  24501. * @param width ratio across width from 0 to 1
  24502. * @param height ratio up height from 0 to 1
  24503. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24504. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24505. * @returns impostor the soft imposter
  24506. */
  24507. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24508. /**
  24509. * Add a hook to a rope impostor
  24510. * @param otherImpostor rigid impostor to anchor to
  24511. * @param length ratio across rope from 0 to 1
  24512. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24513. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24514. * @returns impostor the rope imposter
  24515. */
  24516. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24517. /**
  24518. * Will keep this body still, in a sleep mode.
  24519. * @returns the physics imposter
  24520. */
  24521. sleep(): PhysicsImpostor;
  24522. /**
  24523. * Wake the body up.
  24524. * @returns The physics imposter
  24525. */
  24526. wakeUp(): PhysicsImpostor;
  24527. /**
  24528. * Clones the physics imposter
  24529. * @param newObject The physics imposter clones to this physics-enabled object
  24530. * @returns A nullable physics imposter
  24531. */
  24532. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24533. /**
  24534. * Disposes the physics imposter
  24535. */
  24536. dispose(): void;
  24537. /**
  24538. * Sets the delta position
  24539. * @param position The delta position amount
  24540. */
  24541. setDeltaPosition(position: Vector3): void;
  24542. /**
  24543. * Sets the delta rotation
  24544. * @param rotation The delta rotation amount
  24545. */
  24546. setDeltaRotation(rotation: Quaternion): void;
  24547. /**
  24548. * Gets the box size of the physics imposter and stores the result in the input parameter
  24549. * @param result Stores the box size
  24550. * @returns The physics imposter
  24551. */
  24552. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24553. /**
  24554. * Gets the radius of the physics imposter
  24555. * @returns Radius of the physics imposter
  24556. */
  24557. getRadius(): number;
  24558. /**
  24559. * Sync a bone with this impostor
  24560. * @param bone The bone to sync to the impostor.
  24561. * @param boneMesh The mesh that the bone is influencing.
  24562. * @param jointPivot The pivot of the joint / bone in local space.
  24563. * @param distToJoint Optional distance from the impostor to the joint.
  24564. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24565. */
  24566. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24567. /**
  24568. * Sync impostor to a bone
  24569. * @param bone The bone that the impostor will be synced to.
  24570. * @param boneMesh The mesh that the bone is influencing.
  24571. * @param jointPivot The pivot of the joint / bone in local space.
  24572. * @param distToJoint Optional distance from the impostor to the joint.
  24573. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24574. * @param boneAxis Optional vector3 axis the bone is aligned with
  24575. */
  24576. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24577. /**
  24578. * No-Imposter type
  24579. */
  24580. static NoImpostor: number;
  24581. /**
  24582. * Sphere-Imposter type
  24583. */
  24584. static SphereImpostor: number;
  24585. /**
  24586. * Box-Imposter type
  24587. */
  24588. static BoxImpostor: number;
  24589. /**
  24590. * Plane-Imposter type
  24591. */
  24592. static PlaneImpostor: number;
  24593. /**
  24594. * Mesh-imposter type
  24595. */
  24596. static MeshImpostor: number;
  24597. /**
  24598. * Capsule-Impostor type (Ammo.js plugin only)
  24599. */
  24600. static CapsuleImpostor: number;
  24601. /**
  24602. * Cylinder-Imposter type
  24603. */
  24604. static CylinderImpostor: number;
  24605. /**
  24606. * Particle-Imposter type
  24607. */
  24608. static ParticleImpostor: number;
  24609. /**
  24610. * Heightmap-Imposter type
  24611. */
  24612. static HeightmapImpostor: number;
  24613. /**
  24614. * ConvexHull-Impostor type (Ammo.js plugin only)
  24615. */
  24616. static ConvexHullImpostor: number;
  24617. /**
  24618. * Custom-Imposter type (Ammo.js plugin only)
  24619. */
  24620. static CustomImpostor: number;
  24621. /**
  24622. * Rope-Imposter type
  24623. */
  24624. static RopeImpostor: number;
  24625. /**
  24626. * Cloth-Imposter type
  24627. */
  24628. static ClothImpostor: number;
  24629. /**
  24630. * Softbody-Imposter type
  24631. */
  24632. static SoftbodyImpostor: number;
  24633. }
  24634. }
  24635. declare module "babylonjs/Meshes/mesh" {
  24636. import { Observable } from "babylonjs/Misc/observable";
  24637. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24638. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24639. import { Camera } from "babylonjs/Cameras/camera";
  24640. import { Scene } from "babylonjs/scene";
  24641. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24642. import { Color4 } from "babylonjs/Maths/math.color";
  24643. import { Engine } from "babylonjs/Engines/engine";
  24644. import { Node } from "babylonjs/node";
  24645. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24646. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24647. import { Buffer } from "babylonjs/Meshes/buffer";
  24648. import { Geometry } from "babylonjs/Meshes/geometry";
  24649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24651. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24652. import { Effect } from "babylonjs/Materials/effect";
  24653. import { Material } from "babylonjs/Materials/material";
  24654. import { Skeleton } from "babylonjs/Bones/skeleton";
  24655. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24656. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24657. import { Path3D } from "babylonjs/Maths/math.path";
  24658. import { Plane } from "babylonjs/Maths/math.plane";
  24659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24660. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24661. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24662. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24663. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24664. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24665. /**
  24666. * @hidden
  24667. **/
  24668. export class _CreationDataStorage {
  24669. closePath?: boolean;
  24670. closeArray?: boolean;
  24671. idx: number[];
  24672. dashSize: number;
  24673. gapSize: number;
  24674. path3D: Path3D;
  24675. pathArray: Vector3[][];
  24676. arc: number;
  24677. radius: number;
  24678. cap: number;
  24679. tessellation: number;
  24680. }
  24681. /**
  24682. * @hidden
  24683. **/
  24684. class _InstanceDataStorage {
  24685. visibleInstances: any;
  24686. batchCache: _InstancesBatch;
  24687. instancesBufferSize: number;
  24688. instancesBuffer: Nullable<Buffer>;
  24689. instancesData: Float32Array;
  24690. overridenInstanceCount: number;
  24691. isFrozen: boolean;
  24692. previousBatch: Nullable<_InstancesBatch>;
  24693. hardwareInstancedRendering: boolean;
  24694. sideOrientation: number;
  24695. manualUpdate: boolean;
  24696. }
  24697. /**
  24698. * @hidden
  24699. **/
  24700. export class _InstancesBatch {
  24701. mustReturn: boolean;
  24702. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24703. renderSelf: boolean[];
  24704. hardwareInstancedRendering: boolean[];
  24705. }
  24706. /**
  24707. * Class used to represent renderable models
  24708. */
  24709. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24710. /**
  24711. * Mesh side orientation : usually the external or front surface
  24712. */
  24713. static readonly FRONTSIDE: number;
  24714. /**
  24715. * Mesh side orientation : usually the internal or back surface
  24716. */
  24717. static readonly BACKSIDE: number;
  24718. /**
  24719. * Mesh side orientation : both internal and external or front and back surfaces
  24720. */
  24721. static readonly DOUBLESIDE: number;
  24722. /**
  24723. * Mesh side orientation : by default, `FRONTSIDE`
  24724. */
  24725. static readonly DEFAULTSIDE: number;
  24726. /**
  24727. * Mesh cap setting : no cap
  24728. */
  24729. static readonly NO_CAP: number;
  24730. /**
  24731. * Mesh cap setting : one cap at the beginning of the mesh
  24732. */
  24733. static readonly CAP_START: number;
  24734. /**
  24735. * Mesh cap setting : one cap at the end of the mesh
  24736. */
  24737. static readonly CAP_END: number;
  24738. /**
  24739. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24740. */
  24741. static readonly CAP_ALL: number;
  24742. /**
  24743. * Mesh pattern setting : no flip or rotate
  24744. */
  24745. static readonly NO_FLIP: number;
  24746. /**
  24747. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24748. */
  24749. static readonly FLIP_TILE: number;
  24750. /**
  24751. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24752. */
  24753. static readonly ROTATE_TILE: number;
  24754. /**
  24755. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24756. */
  24757. static readonly FLIP_ROW: number;
  24758. /**
  24759. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24760. */
  24761. static readonly ROTATE_ROW: number;
  24762. /**
  24763. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24764. */
  24765. static readonly FLIP_N_ROTATE_TILE: number;
  24766. /**
  24767. * Mesh pattern setting : rotate pattern and rotate
  24768. */
  24769. static readonly FLIP_N_ROTATE_ROW: number;
  24770. /**
  24771. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24772. */
  24773. static readonly CENTER: number;
  24774. /**
  24775. * Mesh tile positioning : part tiles on left
  24776. */
  24777. static readonly LEFT: number;
  24778. /**
  24779. * Mesh tile positioning : part tiles on right
  24780. */
  24781. static readonly RIGHT: number;
  24782. /**
  24783. * Mesh tile positioning : part tiles on top
  24784. */
  24785. static readonly TOP: number;
  24786. /**
  24787. * Mesh tile positioning : part tiles on bottom
  24788. */
  24789. static readonly BOTTOM: number;
  24790. /**
  24791. * Gets the default side orientation.
  24792. * @param orientation the orientation to value to attempt to get
  24793. * @returns the default orientation
  24794. * @hidden
  24795. */
  24796. static _GetDefaultSideOrientation(orientation?: number): number;
  24797. private _internalMeshDataInfo;
  24798. /**
  24799. * An event triggered before rendering the mesh
  24800. */
  24801. get onBeforeRenderObservable(): Observable<Mesh>;
  24802. /**
  24803. * An event triggered before binding the mesh
  24804. */
  24805. get onBeforeBindObservable(): Observable<Mesh>;
  24806. /**
  24807. * An event triggered after rendering the mesh
  24808. */
  24809. get onAfterRenderObservable(): Observable<Mesh>;
  24810. /**
  24811. * An event triggered before drawing the mesh
  24812. */
  24813. get onBeforeDrawObservable(): Observable<Mesh>;
  24814. private _onBeforeDrawObserver;
  24815. /**
  24816. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24817. */
  24818. set onBeforeDraw(callback: () => void);
  24819. get hasInstances(): boolean;
  24820. /**
  24821. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24822. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24823. */
  24824. delayLoadState: number;
  24825. /**
  24826. * Gets the list of instances created from this mesh
  24827. * it is not supposed to be modified manually.
  24828. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24829. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24830. */
  24831. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24832. /**
  24833. * Gets the file containing delay loading data for this mesh
  24834. */
  24835. delayLoadingFile: string;
  24836. /** @hidden */
  24837. _binaryInfo: any;
  24838. /**
  24839. * User defined function used to change how LOD level selection is done
  24840. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24841. */
  24842. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24843. /**
  24844. * Gets or sets the morph target manager
  24845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24846. */
  24847. get morphTargetManager(): Nullable<MorphTargetManager>;
  24848. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24849. /** @hidden */
  24850. _creationDataStorage: Nullable<_CreationDataStorage>;
  24851. /** @hidden */
  24852. _geometry: Nullable<Geometry>;
  24853. /** @hidden */
  24854. _delayInfo: Array<string>;
  24855. /** @hidden */
  24856. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24857. /** @hidden */
  24858. _instanceDataStorage: _InstanceDataStorage;
  24859. private _effectiveMaterial;
  24860. /** @hidden */
  24861. _shouldGenerateFlatShading: boolean;
  24862. /** @hidden */
  24863. _originalBuilderSideOrientation: number;
  24864. /**
  24865. * Use this property to change the original side orientation defined at construction time
  24866. */
  24867. overrideMaterialSideOrientation: Nullable<number>;
  24868. /**
  24869. * Gets the source mesh (the one used to clone this one from)
  24870. */
  24871. get source(): Nullable<Mesh>;
  24872. /**
  24873. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24874. */
  24875. get isUnIndexed(): boolean;
  24876. set isUnIndexed(value: boolean);
  24877. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24878. get worldMatrixInstancedBuffer(): Float32Array;
  24879. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24880. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24881. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24882. /**
  24883. * @constructor
  24884. * @param name The value used by scene.getMeshByName() to do a lookup.
  24885. * @param scene The scene to add this mesh to.
  24886. * @param parent The parent of this mesh, if it has one
  24887. * @param source An optional Mesh from which geometry is shared, cloned.
  24888. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24889. * When false, achieved by calling a clone(), also passing False.
  24890. * This will make creation of children, recursive.
  24891. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24892. */
  24893. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24894. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24895. doNotInstantiate: boolean;
  24896. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24897. /**
  24898. * Gets the class name
  24899. * @returns the string "Mesh".
  24900. */
  24901. getClassName(): string;
  24902. /** @hidden */
  24903. get _isMesh(): boolean;
  24904. /**
  24905. * Returns a description of this mesh
  24906. * @param fullDetails define if full details about this mesh must be used
  24907. * @returns a descriptive string representing this mesh
  24908. */
  24909. toString(fullDetails?: boolean): string;
  24910. /** @hidden */
  24911. _unBindEffect(): void;
  24912. /**
  24913. * Gets a boolean indicating if this mesh has LOD
  24914. */
  24915. get hasLODLevels(): boolean;
  24916. /**
  24917. * Gets the list of MeshLODLevel associated with the current mesh
  24918. * @returns an array of MeshLODLevel
  24919. */
  24920. getLODLevels(): MeshLODLevel[];
  24921. private _sortLODLevels;
  24922. /**
  24923. * Add a mesh as LOD level triggered at the given distance.
  24924. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24925. * @param distance The distance from the center of the object to show this level
  24926. * @param mesh The mesh to be added as LOD level (can be null)
  24927. * @return This mesh (for chaining)
  24928. */
  24929. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24930. /**
  24931. * Returns the LOD level mesh at the passed distance or null if not found.
  24932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24933. * @param distance The distance from the center of the object to show this level
  24934. * @returns a Mesh or `null`
  24935. */
  24936. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24937. /**
  24938. * Remove a mesh from the LOD array
  24939. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24940. * @param mesh defines the mesh to be removed
  24941. * @return This mesh (for chaining)
  24942. */
  24943. removeLODLevel(mesh: Mesh): Mesh;
  24944. /**
  24945. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24947. * @param camera defines the camera to use to compute distance
  24948. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24949. * @return This mesh (for chaining)
  24950. */
  24951. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24952. /**
  24953. * Gets the mesh internal Geometry object
  24954. */
  24955. get geometry(): Nullable<Geometry>;
  24956. /**
  24957. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24958. * @returns the total number of vertices
  24959. */
  24960. getTotalVertices(): number;
  24961. /**
  24962. * Returns the content of an associated vertex buffer
  24963. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24964. * - VertexBuffer.PositionKind
  24965. * - VertexBuffer.UVKind
  24966. * - VertexBuffer.UV2Kind
  24967. * - VertexBuffer.UV3Kind
  24968. * - VertexBuffer.UV4Kind
  24969. * - VertexBuffer.UV5Kind
  24970. * - VertexBuffer.UV6Kind
  24971. * - VertexBuffer.ColorKind
  24972. * - VertexBuffer.MatricesIndicesKind
  24973. * - VertexBuffer.MatricesIndicesExtraKind
  24974. * - VertexBuffer.MatricesWeightsKind
  24975. * - VertexBuffer.MatricesWeightsExtraKind
  24976. * @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
  24977. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24978. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24979. */
  24980. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24981. /**
  24982. * Returns the mesh VertexBuffer object from the requested `kind`
  24983. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24984. * - VertexBuffer.PositionKind
  24985. * - VertexBuffer.NormalKind
  24986. * - VertexBuffer.UVKind
  24987. * - VertexBuffer.UV2Kind
  24988. * - VertexBuffer.UV3Kind
  24989. * - VertexBuffer.UV4Kind
  24990. * - VertexBuffer.UV5Kind
  24991. * - VertexBuffer.UV6Kind
  24992. * - VertexBuffer.ColorKind
  24993. * - VertexBuffer.MatricesIndicesKind
  24994. * - VertexBuffer.MatricesIndicesExtraKind
  24995. * - VertexBuffer.MatricesWeightsKind
  24996. * - VertexBuffer.MatricesWeightsExtraKind
  24997. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24998. */
  24999. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25000. /**
  25001. * Tests if a specific vertex buffer is associated with this mesh
  25002. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25003. * - VertexBuffer.PositionKind
  25004. * - VertexBuffer.NormalKind
  25005. * - VertexBuffer.UVKind
  25006. * - VertexBuffer.UV2Kind
  25007. * - VertexBuffer.UV3Kind
  25008. * - VertexBuffer.UV4Kind
  25009. * - VertexBuffer.UV5Kind
  25010. * - VertexBuffer.UV6Kind
  25011. * - VertexBuffer.ColorKind
  25012. * - VertexBuffer.MatricesIndicesKind
  25013. * - VertexBuffer.MatricesIndicesExtraKind
  25014. * - VertexBuffer.MatricesWeightsKind
  25015. * - VertexBuffer.MatricesWeightsExtraKind
  25016. * @returns a boolean
  25017. */
  25018. isVerticesDataPresent(kind: string): boolean;
  25019. /**
  25020. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25021. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25022. * - VertexBuffer.PositionKind
  25023. * - VertexBuffer.UVKind
  25024. * - VertexBuffer.UV2Kind
  25025. * - VertexBuffer.UV3Kind
  25026. * - VertexBuffer.UV4Kind
  25027. * - VertexBuffer.UV5Kind
  25028. * - VertexBuffer.UV6Kind
  25029. * - VertexBuffer.ColorKind
  25030. * - VertexBuffer.MatricesIndicesKind
  25031. * - VertexBuffer.MatricesIndicesExtraKind
  25032. * - VertexBuffer.MatricesWeightsKind
  25033. * - VertexBuffer.MatricesWeightsExtraKind
  25034. * @returns a boolean
  25035. */
  25036. isVertexBufferUpdatable(kind: string): boolean;
  25037. /**
  25038. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25039. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25040. * - VertexBuffer.PositionKind
  25041. * - VertexBuffer.NormalKind
  25042. * - VertexBuffer.UVKind
  25043. * - VertexBuffer.UV2Kind
  25044. * - VertexBuffer.UV3Kind
  25045. * - VertexBuffer.UV4Kind
  25046. * - VertexBuffer.UV5Kind
  25047. * - VertexBuffer.UV6Kind
  25048. * - VertexBuffer.ColorKind
  25049. * - VertexBuffer.MatricesIndicesKind
  25050. * - VertexBuffer.MatricesIndicesExtraKind
  25051. * - VertexBuffer.MatricesWeightsKind
  25052. * - VertexBuffer.MatricesWeightsExtraKind
  25053. * @returns an array of strings
  25054. */
  25055. getVerticesDataKinds(): string[];
  25056. /**
  25057. * Returns a positive integer : the total number of indices in this mesh geometry.
  25058. * @returns the numner of indices or zero if the mesh has no geometry.
  25059. */
  25060. getTotalIndices(): number;
  25061. /**
  25062. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25063. * @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.
  25064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25065. * @returns the indices array or an empty array if the mesh has no geometry
  25066. */
  25067. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25068. get isBlocked(): boolean;
  25069. /**
  25070. * Determine if the current mesh is ready to be rendered
  25071. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25072. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25073. * @returns true if all associated assets are ready (material, textures, shaders)
  25074. */
  25075. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25076. /**
  25077. * 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.
  25078. */
  25079. get areNormalsFrozen(): boolean;
  25080. /**
  25081. * 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.
  25082. * @returns the current mesh
  25083. */
  25084. freezeNormals(): Mesh;
  25085. /**
  25086. * 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
  25087. * @returns the current mesh
  25088. */
  25089. unfreezeNormals(): Mesh;
  25090. /**
  25091. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25092. */
  25093. set overridenInstanceCount(count: number);
  25094. /** @hidden */
  25095. _preActivate(): Mesh;
  25096. /** @hidden */
  25097. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25098. /** @hidden */
  25099. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25100. /**
  25101. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25102. * This means the mesh underlying bounding box and sphere are recomputed.
  25103. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25104. * @returns the current mesh
  25105. */
  25106. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25107. /** @hidden */
  25108. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25109. /**
  25110. * This function will subdivide the mesh into multiple submeshes
  25111. * @param count defines the expected number of submeshes
  25112. */
  25113. subdivide(count: number): void;
  25114. /**
  25115. * Copy a FloatArray into a specific associated vertex buffer
  25116. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25117. * - VertexBuffer.PositionKind
  25118. * - VertexBuffer.UVKind
  25119. * - VertexBuffer.UV2Kind
  25120. * - VertexBuffer.UV3Kind
  25121. * - VertexBuffer.UV4Kind
  25122. * - VertexBuffer.UV5Kind
  25123. * - VertexBuffer.UV6Kind
  25124. * - VertexBuffer.ColorKind
  25125. * - VertexBuffer.MatricesIndicesKind
  25126. * - VertexBuffer.MatricesIndicesExtraKind
  25127. * - VertexBuffer.MatricesWeightsKind
  25128. * - VertexBuffer.MatricesWeightsExtraKind
  25129. * @param data defines the data source
  25130. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25131. * @param stride defines the data stride size (can be null)
  25132. * @returns the current mesh
  25133. */
  25134. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25135. /**
  25136. * Delete a vertex buffer associated with this mesh
  25137. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25138. * - VertexBuffer.PositionKind
  25139. * - VertexBuffer.UVKind
  25140. * - VertexBuffer.UV2Kind
  25141. * - VertexBuffer.UV3Kind
  25142. * - VertexBuffer.UV4Kind
  25143. * - VertexBuffer.UV5Kind
  25144. * - VertexBuffer.UV6Kind
  25145. * - VertexBuffer.ColorKind
  25146. * - VertexBuffer.MatricesIndicesKind
  25147. * - VertexBuffer.MatricesIndicesExtraKind
  25148. * - VertexBuffer.MatricesWeightsKind
  25149. * - VertexBuffer.MatricesWeightsExtraKind
  25150. */
  25151. removeVerticesData(kind: string): void;
  25152. /**
  25153. * Flags an associated vertex buffer as updatable
  25154. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25155. * - VertexBuffer.PositionKind
  25156. * - VertexBuffer.UVKind
  25157. * - VertexBuffer.UV2Kind
  25158. * - VertexBuffer.UV3Kind
  25159. * - VertexBuffer.UV4Kind
  25160. * - VertexBuffer.UV5Kind
  25161. * - VertexBuffer.UV6Kind
  25162. * - VertexBuffer.ColorKind
  25163. * - VertexBuffer.MatricesIndicesKind
  25164. * - VertexBuffer.MatricesIndicesExtraKind
  25165. * - VertexBuffer.MatricesWeightsKind
  25166. * - VertexBuffer.MatricesWeightsExtraKind
  25167. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25168. */
  25169. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25170. /**
  25171. * Sets the mesh global Vertex Buffer
  25172. * @param buffer defines the buffer to use
  25173. * @returns the current mesh
  25174. */
  25175. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25176. /**
  25177. * Update a specific associated vertex buffer
  25178. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25179. * - VertexBuffer.PositionKind
  25180. * - VertexBuffer.UVKind
  25181. * - VertexBuffer.UV2Kind
  25182. * - VertexBuffer.UV3Kind
  25183. * - VertexBuffer.UV4Kind
  25184. * - VertexBuffer.UV5Kind
  25185. * - VertexBuffer.UV6Kind
  25186. * - VertexBuffer.ColorKind
  25187. * - VertexBuffer.MatricesIndicesKind
  25188. * - VertexBuffer.MatricesIndicesExtraKind
  25189. * - VertexBuffer.MatricesWeightsKind
  25190. * - VertexBuffer.MatricesWeightsExtraKind
  25191. * @param data defines the data source
  25192. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25193. * @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)
  25194. * @returns the current mesh
  25195. */
  25196. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25197. /**
  25198. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25199. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25200. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25201. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25202. * @returns the current mesh
  25203. */
  25204. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25205. /**
  25206. * Creates a un-shared specific occurence of the geometry for the mesh.
  25207. * @returns the current mesh
  25208. */
  25209. makeGeometryUnique(): Mesh;
  25210. /**
  25211. * Set the index buffer of this mesh
  25212. * @param indices defines the source data
  25213. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25214. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25215. * @returns the current mesh
  25216. */
  25217. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25218. /**
  25219. * Update the current index buffer
  25220. * @param indices defines the source data
  25221. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25222. * @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)
  25223. * @returns the current mesh
  25224. */
  25225. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25226. /**
  25227. * Invert the geometry to move from a right handed system to a left handed one.
  25228. * @returns the current mesh
  25229. */
  25230. toLeftHanded(): Mesh;
  25231. /** @hidden */
  25232. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25233. /** @hidden */
  25234. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25235. /**
  25236. * Registers for this mesh a javascript function called just before the rendering process
  25237. * @param func defines the function to call before rendering this mesh
  25238. * @returns the current mesh
  25239. */
  25240. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25241. /**
  25242. * Disposes a previously registered javascript function called before the rendering
  25243. * @param func defines the function to remove
  25244. * @returns the current mesh
  25245. */
  25246. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25247. /**
  25248. * Registers for this mesh a javascript function called just after the rendering is complete
  25249. * @param func defines the function to call after rendering this mesh
  25250. * @returns the current mesh
  25251. */
  25252. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25253. /**
  25254. * Disposes a previously registered javascript function called after the rendering.
  25255. * @param func defines the function to remove
  25256. * @returns the current mesh
  25257. */
  25258. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25259. /** @hidden */
  25260. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25261. /** @hidden */
  25262. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25263. /** @hidden */
  25264. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25265. /** @hidden */
  25266. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25267. /** @hidden */
  25268. _rebuild(): void;
  25269. /** @hidden */
  25270. _freeze(): void;
  25271. /** @hidden */
  25272. _unFreeze(): void;
  25273. /**
  25274. * 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
  25275. * @param subMesh defines the subMesh to render
  25276. * @param enableAlphaMode defines if alpha mode can be changed
  25277. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25278. * @returns the current mesh
  25279. */
  25280. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25281. private _onBeforeDraw;
  25282. /**
  25283. * Renormalize the mesh and patch it up if there are no weights
  25284. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25285. * However in the case of zero weights then we set just a single influence to 1.
  25286. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25287. */
  25288. cleanMatrixWeights(): void;
  25289. private normalizeSkinFourWeights;
  25290. private normalizeSkinWeightsAndExtra;
  25291. /**
  25292. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25293. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25294. * the user know there was an issue with importing the mesh
  25295. * @returns a validation object with skinned, valid and report string
  25296. */
  25297. validateSkinning(): {
  25298. skinned: boolean;
  25299. valid: boolean;
  25300. report: string;
  25301. };
  25302. /** @hidden */
  25303. _checkDelayState(): Mesh;
  25304. private _queueLoad;
  25305. /**
  25306. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25307. * A mesh is in the frustum if its bounding box intersects the frustum
  25308. * @param frustumPlanes defines the frustum to test
  25309. * @returns true if the mesh is in the frustum planes
  25310. */
  25311. isInFrustum(frustumPlanes: Plane[]): boolean;
  25312. /**
  25313. * Sets the mesh material by the material or multiMaterial `id` property
  25314. * @param id is a string identifying the material or the multiMaterial
  25315. * @returns the current mesh
  25316. */
  25317. setMaterialByID(id: string): Mesh;
  25318. /**
  25319. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25320. * @returns an array of IAnimatable
  25321. */
  25322. getAnimatables(): IAnimatable[];
  25323. /**
  25324. * Modifies the mesh geometry according to the passed transformation matrix.
  25325. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25326. * The mesh normals are modified using the same transformation.
  25327. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25328. * @param transform defines the transform matrix to use
  25329. * @see http://doc.babylonjs.com/resources/baking_transformations
  25330. * @returns the current mesh
  25331. */
  25332. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25333. /**
  25334. * Modifies the mesh geometry according to its own current World Matrix.
  25335. * The mesh World Matrix is then reset.
  25336. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25337. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25338. * @see http://doc.babylonjs.com/resources/baking_transformations
  25339. * @returns the current mesh
  25340. */
  25341. bakeCurrentTransformIntoVertices(): Mesh;
  25342. /** @hidden */
  25343. get _positions(): Nullable<Vector3[]>;
  25344. /** @hidden */
  25345. _resetPointsArrayCache(): Mesh;
  25346. /** @hidden */
  25347. _generatePointsArray(): boolean;
  25348. /**
  25349. * Returns a new Mesh object generated from the current mesh properties.
  25350. * This method must not get confused with createInstance()
  25351. * @param name is a string, the name given to the new mesh
  25352. * @param newParent can be any Node object (default `null`)
  25353. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25354. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25355. * @returns a new mesh
  25356. */
  25357. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25358. /**
  25359. * Releases resources associated with this mesh.
  25360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25362. */
  25363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25364. /** @hidden */
  25365. _disposeInstanceSpecificData(): void;
  25366. /**
  25367. * Modifies the mesh geometry according to a displacement map.
  25368. * 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.
  25369. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25370. * @param url is a string, the URL from the image file is to be downloaded.
  25371. * @param minHeight is the lower limit of the displacement.
  25372. * @param maxHeight is the upper limit of the displacement.
  25373. * @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.
  25374. * @param uvOffset is an optional vector2 used to offset UV.
  25375. * @param uvScale is an optional vector2 used to scale UV.
  25376. * @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.
  25377. * @returns the Mesh.
  25378. */
  25379. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25380. /**
  25381. * Modifies the mesh geometry according to a displacementMap buffer.
  25382. * 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.
  25383. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25384. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25385. * @param heightMapWidth is the width of the buffer image.
  25386. * @param heightMapHeight is the height of the buffer image.
  25387. * @param minHeight is the lower limit of the displacement.
  25388. * @param maxHeight is the upper limit of the displacement.
  25389. * @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.
  25390. * @param uvOffset is an optional vector2 used to offset UV.
  25391. * @param uvScale is an optional vector2 used to scale UV.
  25392. * @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.
  25393. * @returns the Mesh.
  25394. */
  25395. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25396. /**
  25397. * Modify the mesh to get a flat shading rendering.
  25398. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25399. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25400. * @returns current mesh
  25401. */
  25402. convertToFlatShadedMesh(): Mesh;
  25403. /**
  25404. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25405. * In other words, more vertices, no more indices and a single bigger VBO.
  25406. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25407. * @returns current mesh
  25408. */
  25409. convertToUnIndexedMesh(): Mesh;
  25410. /**
  25411. * Inverses facet orientations.
  25412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25413. * @param flipNormals will also inverts the normals
  25414. * @returns current mesh
  25415. */
  25416. flipFaces(flipNormals?: boolean): Mesh;
  25417. /**
  25418. * Increase the number of facets and hence vertices in a mesh
  25419. * Vertex normals are interpolated from existing vertex normals
  25420. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25421. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25422. */
  25423. increaseVertices(numberPerEdge: number): void;
  25424. /**
  25425. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25426. * This will undo any application of covertToFlatShadedMesh
  25427. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25428. */
  25429. forceSharedVertices(): void;
  25430. /** @hidden */
  25431. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25432. /** @hidden */
  25433. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25434. /**
  25435. * Creates a new InstancedMesh object from the mesh model.
  25436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25437. * @param name defines the name of the new instance
  25438. * @returns a new InstancedMesh
  25439. */
  25440. createInstance(name: string): InstancedMesh;
  25441. /**
  25442. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25443. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25444. * @returns the current mesh
  25445. */
  25446. synchronizeInstances(): Mesh;
  25447. /**
  25448. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25449. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25450. * This should be used together with the simplification to avoid disappearing triangles.
  25451. * @param successCallback an optional success callback to be called after the optimization finished.
  25452. * @returns the current mesh
  25453. */
  25454. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25455. /**
  25456. * Serialize current mesh
  25457. * @param serializationObject defines the object which will receive the serialization data
  25458. */
  25459. serialize(serializationObject: any): void;
  25460. /** @hidden */
  25461. _syncGeometryWithMorphTargetManager(): void;
  25462. /** @hidden */
  25463. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25464. /**
  25465. * Returns a new Mesh object parsed from the source provided.
  25466. * @param parsedMesh is the source
  25467. * @param scene defines the hosting scene
  25468. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25469. * @returns a new Mesh
  25470. */
  25471. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25472. /**
  25473. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25475. * @param name defines the name of the mesh to create
  25476. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25477. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25478. * @param closePath creates a seam between the first and the last points of each path of the path array
  25479. * @param offset is taken in account only if the `pathArray` is containing a single path
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25483. * @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)
  25484. * @returns a new Mesh
  25485. */
  25486. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25487. /**
  25488. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25489. * @param name defines the name of the mesh to create
  25490. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25491. * @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
  25492. * @param scene defines the hosting scene
  25493. * @param updatable defines if the mesh must be flagged as updatable
  25494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25495. * @returns a new Mesh
  25496. */
  25497. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25498. /**
  25499. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25500. * @param name defines the name of the mesh to create
  25501. * @param size sets the size (float) of each box side (default 1)
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25505. * @returns a new Mesh
  25506. */
  25507. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25508. /**
  25509. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25510. * @param name defines the name of the mesh to create
  25511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25513. * @param scene defines the hosting scene
  25514. * @param updatable defines if the mesh must be flagged as updatable
  25515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25516. * @returns a new Mesh
  25517. */
  25518. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25519. /**
  25520. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25521. * @param name defines the name of the mesh to create
  25522. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25523. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25524. * @param scene defines the hosting scene
  25525. * @returns a new Mesh
  25526. */
  25527. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25528. /**
  25529. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25530. * @param name defines the name of the mesh to create
  25531. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25532. * @param diameterTop set the top cap diameter (floats, default 1)
  25533. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25534. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25535. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25536. * @param scene defines the hosting scene
  25537. * @param updatable defines if the mesh must be flagged as updatable
  25538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25539. * @returns a new Mesh
  25540. */
  25541. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25542. /**
  25543. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25544. * @param name defines the name of the mesh to create
  25545. * @param diameter sets the diameter size (float) of the torus (default 1)
  25546. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25547. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25548. * @param scene defines the hosting scene
  25549. * @param updatable defines if the mesh must be flagged as updatable
  25550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25551. * @returns a new Mesh
  25552. */
  25553. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25554. /**
  25555. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25556. * @param name defines the name of the mesh to create
  25557. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25558. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25559. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25560. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25561. * @param p the number of windings on X axis (positive integers, default 2)
  25562. * @param q the number of windings on Y axis (positive integers, default 3)
  25563. * @param scene defines the hosting scene
  25564. * @param updatable defines if the mesh must be flagged as updatable
  25565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25566. * @returns a new Mesh
  25567. */
  25568. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25569. /**
  25570. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25571. * @param name defines the name of the mesh to create
  25572. * @param points is an array successive Vector3
  25573. * @param scene defines the hosting scene
  25574. * @param updatable defines if the mesh must be flagged as updatable
  25575. * @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).
  25576. * @returns a new Mesh
  25577. */
  25578. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25579. /**
  25580. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25581. * @param name defines the name of the mesh to create
  25582. * @param points is an array successive Vector3
  25583. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25584. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25585. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25586. * @param scene defines the hosting scene
  25587. * @param updatable defines if the mesh must be flagged as updatable
  25588. * @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)
  25589. * @returns a new Mesh
  25590. */
  25591. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25592. /**
  25593. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25595. * 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.
  25596. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25598. * Remember you can only change the shape positions, not their number when updating a polygon.
  25599. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25600. * @param name defines the name of the mesh to create
  25601. * @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
  25602. * @param scene defines the hosting scene
  25603. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25604. * @param updatable defines if the mesh must be flagged as updatable
  25605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25606. * @param earcutInjection can be used to inject your own earcut reference
  25607. * @returns a new Mesh
  25608. */
  25609. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25610. /**
  25611. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25612. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25613. * @param name defines the name of the mesh to create
  25614. * @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
  25615. * @param depth defines the height of extrusion
  25616. * @param scene defines the hosting scene
  25617. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25618. * @param updatable defines if the mesh must be flagged as updatable
  25619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25620. * @param earcutInjection can be used to inject your own earcut reference
  25621. * @returns a new Mesh
  25622. */
  25623. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25624. /**
  25625. * Creates an extruded shape mesh.
  25626. * 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
  25627. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25628. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25629. * @param name defines the name of the mesh to create
  25630. * @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
  25631. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25632. * @param scale is the value to scale the shape
  25633. * @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
  25634. * @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
  25635. * @param scene defines the hosting scene
  25636. * @param updatable defines if the mesh must be flagged as updatable
  25637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25638. * @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)
  25639. * @returns a new Mesh
  25640. */
  25641. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25642. /**
  25643. * Creates an custom extruded shape mesh.
  25644. * The custom extrusion is a parametric shape.
  25645. * It has no predefined shape. Its final shape will depend on the input parameters.
  25646. * Please consider using the same method from the MeshBuilder class instead
  25647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25648. * @param name defines the name of the mesh to create
  25649. * @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
  25650. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25651. * @param scaleFunction is a custom Javascript function called on each path point
  25652. * @param rotationFunction is a custom Javascript function called on each path point
  25653. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25654. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25655. * @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
  25656. * @param scene defines the hosting scene
  25657. * @param updatable defines if the mesh must be flagged as updatable
  25658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25659. * @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)
  25660. * @returns a new Mesh
  25661. */
  25662. 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;
  25663. /**
  25664. * Creates lathe mesh.
  25665. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25666. * Please consider using the same method from the MeshBuilder class instead
  25667. * @param name defines the name of the mesh to create
  25668. * @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
  25669. * @param radius is the radius value of the lathe
  25670. * @param tessellation is the side number of the lathe.
  25671. * @param scene defines the hosting scene
  25672. * @param updatable defines if the mesh must be flagged as updatable
  25673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25674. * @returns a new Mesh
  25675. */
  25676. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25677. /**
  25678. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25679. * @param name defines the name of the mesh to create
  25680. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25681. * @param scene defines the hosting scene
  25682. * @param updatable defines if the mesh must be flagged as updatable
  25683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25684. * @returns a new Mesh
  25685. */
  25686. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25687. /**
  25688. * Creates a ground mesh.
  25689. * Please consider using the same method from the MeshBuilder class instead
  25690. * @param name defines the name of the mesh to create
  25691. * @param width set the width of the ground
  25692. * @param height set the height of the ground
  25693. * @param subdivisions sets the number of subdivisions per side
  25694. * @param scene defines the hosting scene
  25695. * @param updatable defines if the mesh must be flagged as updatable
  25696. * @returns a new Mesh
  25697. */
  25698. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25699. /**
  25700. * Creates a tiled ground mesh.
  25701. * Please consider using the same method from the MeshBuilder class instead
  25702. * @param name defines the name of the mesh to create
  25703. * @param xmin set the ground minimum X coordinate
  25704. * @param zmin set the ground minimum Y coordinate
  25705. * @param xmax set the ground maximum X coordinate
  25706. * @param zmax set the ground maximum Z coordinate
  25707. * @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
  25708. * @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
  25709. * @param scene defines the hosting scene
  25710. * @param updatable defines if the mesh must be flagged as updatable
  25711. * @returns a new Mesh
  25712. */
  25713. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25714. w: number;
  25715. h: number;
  25716. }, precision: {
  25717. w: number;
  25718. h: number;
  25719. }, scene: Scene, updatable?: boolean): Mesh;
  25720. /**
  25721. * Creates a ground mesh from a height map.
  25722. * Please consider using the same method from the MeshBuilder class instead
  25723. * @see http://doc.babylonjs.com/babylon101/height_map
  25724. * @param name defines the name of the mesh to create
  25725. * @param url sets the URL of the height map image resource
  25726. * @param width set the ground width size
  25727. * @param height set the ground height size
  25728. * @param subdivisions sets the number of subdivision per side
  25729. * @param minHeight is the minimum altitude on the ground
  25730. * @param maxHeight is the maximum altitude on the ground
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25734. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25735. * @returns a new Mesh
  25736. */
  25737. 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;
  25738. /**
  25739. * Creates a tube mesh.
  25740. * The tube is a parametric shape.
  25741. * It has no predefined shape. Its final shape will depend on the input parameters.
  25742. * Please consider using the same method from the MeshBuilder class instead
  25743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25744. * @param name defines the name of the mesh to create
  25745. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25746. * @param radius sets the tube radius size
  25747. * @param tessellation is the number of sides on the tubular surface
  25748. * @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
  25749. * @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
  25750. * @param scene defines the hosting scene
  25751. * @param updatable defines if the mesh must be flagged as updatable
  25752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25753. * @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)
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25757. (i: number, distance: number): number;
  25758. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25759. /**
  25760. * Creates a polyhedron mesh.
  25761. * Please consider using the same method from the MeshBuilder class instead.
  25762. * * 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
  25763. * * The parameter `size` (positive float, default 1) sets the polygon size
  25764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25765. * * 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`
  25766. * * 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
  25767. * * 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)`)
  25768. * * 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
  25769. * * 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
  25770. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25771. * * If you create a double-sided mesh, you can choose what parts of 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
  25772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25773. * @param name defines the name of the mesh to create
  25774. * @param options defines the options used to create the mesh
  25775. * @param scene defines the hosting scene
  25776. * @returns a new Mesh
  25777. */
  25778. static CreatePolyhedron(name: string, options: {
  25779. type?: number;
  25780. size?: number;
  25781. sizeX?: number;
  25782. sizeY?: number;
  25783. sizeZ?: number;
  25784. custom?: any;
  25785. faceUV?: Vector4[];
  25786. faceColors?: Color4[];
  25787. updatable?: boolean;
  25788. sideOrientation?: number;
  25789. }, scene: Scene): Mesh;
  25790. /**
  25791. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25792. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25793. * * 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`)
  25794. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25795. * * 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
  25796. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25797. * * If you create a double-sided mesh, you can choose what parts of 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
  25798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25799. * @param name defines the name of the mesh
  25800. * @param options defines the options used to create the mesh
  25801. * @param scene defines the hosting scene
  25802. * @returns a new Mesh
  25803. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25804. */
  25805. static CreateIcoSphere(name: string, options: {
  25806. radius?: number;
  25807. flat?: boolean;
  25808. subdivisions?: number;
  25809. sideOrientation?: number;
  25810. updatable?: boolean;
  25811. }, scene: Scene): Mesh;
  25812. /**
  25813. * Creates a decal mesh.
  25814. * Please consider using the same method from the MeshBuilder class instead.
  25815. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25816. * @param name defines the name of the mesh
  25817. * @param sourceMesh defines the mesh receiving the decal
  25818. * @param position sets the position of the decal in world coordinates
  25819. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25820. * @param size sets the decal scaling
  25821. * @param angle sets the angle to rotate the decal
  25822. * @returns a new Mesh
  25823. */
  25824. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25825. /**
  25826. * Prepare internal position array for software CPU skinning
  25827. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25828. */
  25829. setPositionsForCPUSkinning(): Float32Array;
  25830. /**
  25831. * Prepare internal normal array for software CPU skinning
  25832. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25833. */
  25834. setNormalsForCPUSkinning(): Float32Array;
  25835. /**
  25836. * Updates the vertex buffer by applying transformation from the bones
  25837. * @param skeleton defines the skeleton to apply to current mesh
  25838. * @returns the current mesh
  25839. */
  25840. applySkeleton(skeleton: Skeleton): Mesh;
  25841. /**
  25842. * 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
  25843. * @param meshes defines the list of meshes to scan
  25844. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25845. */
  25846. static MinMax(meshes: AbstractMesh[]): {
  25847. min: Vector3;
  25848. max: Vector3;
  25849. };
  25850. /**
  25851. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25852. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25853. * @returns a vector3
  25854. */
  25855. static Center(meshesOrMinMaxVector: {
  25856. min: Vector3;
  25857. max: Vector3;
  25858. } | AbstractMesh[]): Vector3;
  25859. /**
  25860. * Merge the array of meshes into a single mesh for performance reasons.
  25861. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25862. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25863. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25864. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25865. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25866. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25867. * @returns a new mesh
  25868. */
  25869. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25870. /** @hidden */
  25871. addInstance(instance: InstancedMesh): void;
  25872. /** @hidden */
  25873. removeInstance(instance: InstancedMesh): void;
  25874. }
  25875. }
  25876. declare module "babylonjs/Cameras/camera" {
  25877. import { SmartArray } from "babylonjs/Misc/smartArray";
  25878. import { Observable } from "babylonjs/Misc/observable";
  25879. import { Nullable } from "babylonjs/types";
  25880. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25881. import { Scene } from "babylonjs/scene";
  25882. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25883. import { Node } from "babylonjs/node";
  25884. import { Mesh } from "babylonjs/Meshes/mesh";
  25885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25886. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25887. import { Viewport } from "babylonjs/Maths/math.viewport";
  25888. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25889. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25891. import { Ray } from "babylonjs/Culling/ray";
  25892. /**
  25893. * This is the base class of all the camera used in the application.
  25894. * @see http://doc.babylonjs.com/features/cameras
  25895. */
  25896. export class Camera extends Node {
  25897. /** @hidden */
  25898. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25899. /**
  25900. * This is the default projection mode used by the cameras.
  25901. * It helps recreating a feeling of perspective and better appreciate depth.
  25902. * This is the best way to simulate real life cameras.
  25903. */
  25904. static readonly PERSPECTIVE_CAMERA: number;
  25905. /**
  25906. * This helps creating camera with an orthographic mode.
  25907. * 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.
  25908. */
  25909. static readonly ORTHOGRAPHIC_CAMERA: number;
  25910. /**
  25911. * This is the default FOV mode for perspective cameras.
  25912. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25913. */
  25914. static readonly FOVMODE_VERTICAL_FIXED: number;
  25915. /**
  25916. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25917. */
  25918. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25919. /**
  25920. * This specifies ther is no need for a camera rig.
  25921. * Basically only one eye is rendered corresponding to the camera.
  25922. */
  25923. static readonly RIG_MODE_NONE: number;
  25924. /**
  25925. * Simulates a camera Rig with one blue eye and one red eye.
  25926. * This can be use with 3d blue and red glasses.
  25927. */
  25928. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25929. /**
  25930. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25931. */
  25932. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25933. /**
  25934. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25935. */
  25936. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25937. /**
  25938. * Defines that both eyes of the camera will be rendered over under each other.
  25939. */
  25940. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25941. /**
  25942. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25943. */
  25944. static readonly RIG_MODE_VR: number;
  25945. /**
  25946. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25947. */
  25948. static readonly RIG_MODE_WEBVR: number;
  25949. /**
  25950. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25951. */
  25952. static readonly RIG_MODE_CUSTOM: number;
  25953. /**
  25954. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25955. */
  25956. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25957. /**
  25958. * Define the input manager associated with the camera.
  25959. */
  25960. inputs: CameraInputsManager<Camera>;
  25961. /** @hidden */
  25962. _position: Vector3;
  25963. /**
  25964. * Define the current local position of the camera in the scene
  25965. */
  25966. get position(): Vector3;
  25967. set position(newPosition: Vector3);
  25968. /**
  25969. * The vector the camera should consider as up.
  25970. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25971. */
  25972. upVector: Vector3;
  25973. /**
  25974. * Define the current limit on the left side for an orthographic camera
  25975. * In scene unit
  25976. */
  25977. orthoLeft: Nullable<number>;
  25978. /**
  25979. * Define the current limit on the right side for an orthographic camera
  25980. * In scene unit
  25981. */
  25982. orthoRight: Nullable<number>;
  25983. /**
  25984. * Define the current limit on the bottom side for an orthographic camera
  25985. * In scene unit
  25986. */
  25987. orthoBottom: Nullable<number>;
  25988. /**
  25989. * Define the current limit on the top side for an orthographic camera
  25990. * In scene unit
  25991. */
  25992. orthoTop: Nullable<number>;
  25993. /**
  25994. * Field Of View is set in Radians. (default is 0.8)
  25995. */
  25996. fov: number;
  25997. /**
  25998. * Define the minimum distance the camera can see from.
  25999. * This is important to note that the depth buffer are not infinite and the closer it starts
  26000. * the more your scene might encounter depth fighting issue.
  26001. */
  26002. minZ: number;
  26003. /**
  26004. * Define the maximum distance the camera can see to.
  26005. * This is important to note that the depth buffer are not infinite and the further it end
  26006. * the more your scene might encounter depth fighting issue.
  26007. */
  26008. maxZ: number;
  26009. /**
  26010. * Define the default inertia of the camera.
  26011. * This helps giving a smooth feeling to the camera movement.
  26012. */
  26013. inertia: number;
  26014. /**
  26015. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26016. */
  26017. mode: number;
  26018. /**
  26019. * Define wether the camera is intermediate.
  26020. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26021. */
  26022. isIntermediate: boolean;
  26023. /**
  26024. * Define the viewport of the camera.
  26025. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26026. */
  26027. viewport: Viewport;
  26028. /**
  26029. * Restricts the camera to viewing objects with the same layerMask.
  26030. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26031. */
  26032. layerMask: number;
  26033. /**
  26034. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26035. */
  26036. fovMode: number;
  26037. /**
  26038. * Rig mode of the camera.
  26039. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26040. * This is normally controlled byt the camera themselves as internal use.
  26041. */
  26042. cameraRigMode: number;
  26043. /**
  26044. * Defines the distance between both "eyes" in case of a RIG
  26045. */
  26046. interaxialDistance: number;
  26047. /**
  26048. * Defines if stereoscopic rendering is done side by side or over under.
  26049. */
  26050. isStereoscopicSideBySide: boolean;
  26051. /**
  26052. * 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
  26053. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26054. * else in the scene. (Eg. security camera)
  26055. *
  26056. * 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)
  26057. */
  26058. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26059. /**
  26060. * When set, the camera will render to this render target instead of the default canvas
  26061. *
  26062. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26063. */
  26064. outputRenderTarget: Nullable<RenderTargetTexture>;
  26065. /**
  26066. * Observable triggered when the camera view matrix has changed.
  26067. */
  26068. onViewMatrixChangedObservable: Observable<Camera>;
  26069. /**
  26070. * Observable triggered when the camera Projection matrix has changed.
  26071. */
  26072. onProjectionMatrixChangedObservable: Observable<Camera>;
  26073. /**
  26074. * Observable triggered when the inputs have been processed.
  26075. */
  26076. onAfterCheckInputsObservable: Observable<Camera>;
  26077. /**
  26078. * Observable triggered when reset has been called and applied to the camera.
  26079. */
  26080. onRestoreStateObservable: Observable<Camera>;
  26081. /** @hidden */
  26082. _cameraRigParams: any;
  26083. /** @hidden */
  26084. _rigCameras: Camera[];
  26085. /** @hidden */
  26086. _rigPostProcess: Nullable<PostProcess>;
  26087. protected _webvrViewMatrix: Matrix;
  26088. /** @hidden */
  26089. _skipRendering: boolean;
  26090. /** @hidden */
  26091. _projectionMatrix: Matrix;
  26092. /** @hidden */
  26093. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26094. /** @hidden */
  26095. _activeMeshes: SmartArray<AbstractMesh>;
  26096. protected _globalPosition: Vector3;
  26097. /** @hidden */
  26098. _computedViewMatrix: Matrix;
  26099. private _doNotComputeProjectionMatrix;
  26100. private _transformMatrix;
  26101. private _frustumPlanes;
  26102. private _refreshFrustumPlanes;
  26103. private _storedFov;
  26104. private _stateStored;
  26105. /**
  26106. * Instantiates a new camera object.
  26107. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26108. * @see http://doc.babylonjs.com/features/cameras
  26109. * @param name Defines the name of the camera in the scene
  26110. * @param position Defines the position of the camera
  26111. * @param scene Defines the scene the camera belongs too
  26112. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26113. */
  26114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26115. /**
  26116. * Store current camera state (fov, position, etc..)
  26117. * @returns the camera
  26118. */
  26119. storeState(): Camera;
  26120. /**
  26121. * Restores the camera state values if it has been stored. You must call storeState() first
  26122. */
  26123. protected _restoreStateValues(): boolean;
  26124. /**
  26125. * Restored camera state. You must call storeState() first.
  26126. * @returns true if restored and false otherwise
  26127. */
  26128. restoreState(): boolean;
  26129. /**
  26130. * Gets the class name of the camera.
  26131. * @returns the class name
  26132. */
  26133. getClassName(): string;
  26134. /** @hidden */
  26135. readonly _isCamera: boolean;
  26136. /**
  26137. * Gets a string representation of the camera useful for debug purpose.
  26138. * @param fullDetails Defines that a more verboe level of logging is required
  26139. * @returns the string representation
  26140. */
  26141. toString(fullDetails?: boolean): string;
  26142. /**
  26143. * Gets the current world space position of the camera.
  26144. */
  26145. get globalPosition(): Vector3;
  26146. /**
  26147. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26148. * @returns the active meshe list
  26149. */
  26150. getActiveMeshes(): SmartArray<AbstractMesh>;
  26151. /**
  26152. * Check wether a mesh is part of the current active mesh list of the camera
  26153. * @param mesh Defines the mesh to check
  26154. * @returns true if active, false otherwise
  26155. */
  26156. isActiveMesh(mesh: Mesh): boolean;
  26157. /**
  26158. * Is this camera ready to be used/rendered
  26159. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26160. * @return true if the camera is ready
  26161. */
  26162. isReady(completeCheck?: boolean): boolean;
  26163. /** @hidden */
  26164. _initCache(): void;
  26165. /** @hidden */
  26166. _updateCache(ignoreParentClass?: boolean): void;
  26167. /** @hidden */
  26168. _isSynchronized(): boolean;
  26169. /** @hidden */
  26170. _isSynchronizedViewMatrix(): boolean;
  26171. /** @hidden */
  26172. _isSynchronizedProjectionMatrix(): boolean;
  26173. /**
  26174. * Attach the input controls to a specific dom element to get the input from.
  26175. * @param element Defines the element the controls should be listened from
  26176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26177. */
  26178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26179. /**
  26180. * Detach the current controls from the specified dom element.
  26181. * @param element Defines the element to stop listening the inputs from
  26182. */
  26183. detachControl(element: HTMLElement): void;
  26184. /**
  26185. * Update the camera state according to the different inputs gathered during the frame.
  26186. */
  26187. update(): void;
  26188. /** @hidden */
  26189. _checkInputs(): void;
  26190. /** @hidden */
  26191. get rigCameras(): Camera[];
  26192. /**
  26193. * Gets the post process used by the rig cameras
  26194. */
  26195. get rigPostProcess(): Nullable<PostProcess>;
  26196. /**
  26197. * Internal, gets the first post proces.
  26198. * @returns the first post process to be run on this camera.
  26199. */
  26200. _getFirstPostProcess(): Nullable<PostProcess>;
  26201. private _cascadePostProcessesToRigCams;
  26202. /**
  26203. * Attach a post process to the camera.
  26204. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26205. * @param postProcess The post process to attach to the camera
  26206. * @param insertAt The position of the post process in case several of them are in use in the scene
  26207. * @returns the position the post process has been inserted at
  26208. */
  26209. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26210. /**
  26211. * Detach a post process to the camera.
  26212. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26213. * @param postProcess The post process to detach from the camera
  26214. */
  26215. detachPostProcess(postProcess: PostProcess): void;
  26216. /**
  26217. * Gets the current world matrix of the camera
  26218. */
  26219. getWorldMatrix(): Matrix;
  26220. /** @hidden */
  26221. _getViewMatrix(): Matrix;
  26222. /**
  26223. * Gets the current view matrix of the camera.
  26224. * @param force forces the camera to recompute the matrix without looking at the cached state
  26225. * @returns the view matrix
  26226. */
  26227. getViewMatrix(force?: boolean): Matrix;
  26228. /**
  26229. * Freeze the projection matrix.
  26230. * It will prevent the cache check of the camera projection compute and can speed up perf
  26231. * if no parameter of the camera are meant to change
  26232. * @param projection Defines manually a projection if necessary
  26233. */
  26234. freezeProjectionMatrix(projection?: Matrix): void;
  26235. /**
  26236. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26237. */
  26238. unfreezeProjectionMatrix(): void;
  26239. /**
  26240. * Gets the current projection matrix of the camera.
  26241. * @param force forces the camera to recompute the matrix without looking at the cached state
  26242. * @returns the projection matrix
  26243. */
  26244. getProjectionMatrix(force?: boolean): Matrix;
  26245. /**
  26246. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26247. * @returns a Matrix
  26248. */
  26249. getTransformationMatrix(): Matrix;
  26250. private _updateFrustumPlanes;
  26251. /**
  26252. * Checks if a cullable object (mesh...) is in the camera frustum
  26253. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26254. * @param target The object to check
  26255. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26256. * @returns true if the object is in frustum otherwise false
  26257. */
  26258. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26259. /**
  26260. * Checks if a cullable object (mesh...) is in the camera frustum
  26261. * Unlike isInFrustum this cheks the full bounding box
  26262. * @param target The object to check
  26263. * @returns true if the object is in frustum otherwise false
  26264. */
  26265. isCompletelyInFrustum(target: ICullable): boolean;
  26266. /**
  26267. * Gets a ray in the forward direction from the camera.
  26268. * @param length Defines the length of the ray to create
  26269. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26270. * @param origin Defines the start point of the ray which defaults to the camera position
  26271. * @returns the forward ray
  26272. */
  26273. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26274. /**
  26275. * Releases resources associated with this node.
  26276. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26277. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26278. */
  26279. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26280. /** @hidden */
  26281. _isLeftCamera: boolean;
  26282. /**
  26283. * Gets the left camera of a rig setup in case of Rigged Camera
  26284. */
  26285. get isLeftCamera(): boolean;
  26286. /** @hidden */
  26287. _isRightCamera: boolean;
  26288. /**
  26289. * Gets the right camera of a rig setup in case of Rigged Camera
  26290. */
  26291. get isRightCamera(): boolean;
  26292. /**
  26293. * Gets the left camera of a rig setup in case of Rigged Camera
  26294. */
  26295. get leftCamera(): Nullable<FreeCamera>;
  26296. /**
  26297. * Gets the right camera of a rig setup in case of Rigged Camera
  26298. */
  26299. get rightCamera(): Nullable<FreeCamera>;
  26300. /**
  26301. * Gets the left camera target of a rig setup in case of Rigged Camera
  26302. * @returns the target position
  26303. */
  26304. getLeftTarget(): Nullable<Vector3>;
  26305. /**
  26306. * Gets the right camera target of a rig setup in case of Rigged Camera
  26307. * @returns the target position
  26308. */
  26309. getRightTarget(): Nullable<Vector3>;
  26310. /**
  26311. * @hidden
  26312. */
  26313. setCameraRigMode(mode: number, rigParams: any): void;
  26314. /** @hidden */
  26315. static _setStereoscopicRigMode(camera: Camera): void;
  26316. /** @hidden */
  26317. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26318. /** @hidden */
  26319. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26320. /** @hidden */
  26321. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26322. /** @hidden */
  26323. _getVRProjectionMatrix(): Matrix;
  26324. protected _updateCameraRotationMatrix(): void;
  26325. protected _updateWebVRCameraRotationMatrix(): void;
  26326. /**
  26327. * This function MUST be overwritten by the different WebVR cameras available.
  26328. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26329. * @hidden
  26330. */
  26331. _getWebVRProjectionMatrix(): Matrix;
  26332. /**
  26333. * This function MUST be overwritten by the different WebVR cameras available.
  26334. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26335. * @hidden
  26336. */
  26337. _getWebVRViewMatrix(): Matrix;
  26338. /** @hidden */
  26339. setCameraRigParameter(name: string, value: any): void;
  26340. /**
  26341. * needs to be overridden by children so sub has required properties to be copied
  26342. * @hidden
  26343. */
  26344. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26345. /**
  26346. * May need to be overridden by children
  26347. * @hidden
  26348. */
  26349. _updateRigCameras(): void;
  26350. /** @hidden */
  26351. _setupInputs(): void;
  26352. /**
  26353. * Serialiaze the camera setup to a json represention
  26354. * @returns the JSON representation
  26355. */
  26356. serialize(): any;
  26357. /**
  26358. * Clones the current camera.
  26359. * @param name The cloned camera name
  26360. * @returns the cloned camera
  26361. */
  26362. clone(name: string): Camera;
  26363. /**
  26364. * Gets the direction of the camera relative to a given local axis.
  26365. * @param localAxis Defines the reference axis to provide a relative direction.
  26366. * @return the direction
  26367. */
  26368. getDirection(localAxis: Vector3): Vector3;
  26369. /**
  26370. * Returns the current camera absolute rotation
  26371. */
  26372. get absoluteRotation(): Quaternion;
  26373. /**
  26374. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26375. * @param localAxis Defines the reference axis to provide a relative direction.
  26376. * @param result Defines the vector to store the result in
  26377. */
  26378. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26379. /**
  26380. * Gets a camera constructor for a given camera type
  26381. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26382. * @param name The name of the camera the result will be able to instantiate
  26383. * @param scene The scene the result will construct the camera in
  26384. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26385. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26386. * @returns a factory method to construc the camera
  26387. */
  26388. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26389. /**
  26390. * Compute the world matrix of the camera.
  26391. * @returns the camera world matrix
  26392. */
  26393. computeWorldMatrix(): Matrix;
  26394. /**
  26395. * Parse a JSON and creates the camera from the parsed information
  26396. * @param parsedCamera The JSON to parse
  26397. * @param scene The scene to instantiate the camera in
  26398. * @returns the newly constructed camera
  26399. */
  26400. static Parse(parsedCamera: any, scene: Scene): Camera;
  26401. }
  26402. }
  26403. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26404. import { Nullable } from "babylonjs/types";
  26405. import { Scene } from "babylonjs/scene";
  26406. import { Vector4 } from "babylonjs/Maths/math.vector";
  26407. import { Mesh } from "babylonjs/Meshes/mesh";
  26408. /**
  26409. * Class containing static functions to help procedurally build meshes
  26410. */
  26411. export class DiscBuilder {
  26412. /**
  26413. * Creates a plane polygonal mesh. By default, this is a disc
  26414. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26415. * * 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
  26416. * * 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
  26417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26420. * @param name defines the name of the mesh
  26421. * @param options defines the options used to create the mesh
  26422. * @param scene defines the hosting scene
  26423. * @returns the plane polygonal mesh
  26424. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26425. */
  26426. static CreateDisc(name: string, options: {
  26427. radius?: number;
  26428. tessellation?: number;
  26429. arc?: number;
  26430. updatable?: boolean;
  26431. sideOrientation?: number;
  26432. frontUVs?: Vector4;
  26433. backUVs?: Vector4;
  26434. }, scene?: Nullable<Scene>): Mesh;
  26435. }
  26436. }
  26437. declare module "babylonjs/Materials/fresnelParameters" {
  26438. import { Color3 } from "babylonjs/Maths/math.color";
  26439. /**
  26440. * This represents all the required information to add a fresnel effect on a material:
  26441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26442. */
  26443. export class FresnelParameters {
  26444. private _isEnabled;
  26445. /**
  26446. * Define if the fresnel effect is enable or not.
  26447. */
  26448. get isEnabled(): boolean;
  26449. set isEnabled(value: boolean);
  26450. /**
  26451. * Define the color used on edges (grazing angle)
  26452. */
  26453. leftColor: Color3;
  26454. /**
  26455. * Define the color used on center
  26456. */
  26457. rightColor: Color3;
  26458. /**
  26459. * Define bias applied to computed fresnel term
  26460. */
  26461. bias: number;
  26462. /**
  26463. * Defined the power exponent applied to fresnel term
  26464. */
  26465. power: number;
  26466. /**
  26467. * Clones the current fresnel and its valuues
  26468. * @returns a clone fresnel configuration
  26469. */
  26470. clone(): FresnelParameters;
  26471. /**
  26472. * Serializes the current fresnel parameters to a JSON representation.
  26473. * @return the JSON serialization
  26474. */
  26475. serialize(): any;
  26476. /**
  26477. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26478. * @param parsedFresnelParameters Define the JSON representation
  26479. * @returns the parsed parameters
  26480. */
  26481. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26482. }
  26483. }
  26484. declare module "babylonjs/Materials/pushMaterial" {
  26485. import { Nullable } from "babylonjs/types";
  26486. import { Scene } from "babylonjs/scene";
  26487. import { Matrix } from "babylonjs/Maths/math.vector";
  26488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26489. import { Mesh } from "babylonjs/Meshes/mesh";
  26490. import { Material } from "babylonjs/Materials/material";
  26491. import { Effect } from "babylonjs/Materials/effect";
  26492. /**
  26493. * Base class of materials working in push mode in babylon JS
  26494. * @hidden
  26495. */
  26496. export class PushMaterial extends Material {
  26497. protected _activeEffect: Effect;
  26498. protected _normalMatrix: Matrix;
  26499. /**
  26500. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26501. * This means that the material can keep using a previous shader while a new one is being compiled.
  26502. * This is mostly used when shader parallel compilation is supported (true by default)
  26503. */
  26504. allowShaderHotSwapping: boolean;
  26505. constructor(name: string, scene: Scene);
  26506. getEffect(): Effect;
  26507. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26508. /**
  26509. * Binds the given world matrix to the active effect
  26510. *
  26511. * @param world the matrix to bind
  26512. */
  26513. bindOnlyWorldMatrix(world: Matrix): void;
  26514. /**
  26515. * Binds the given normal matrix to the active effect
  26516. *
  26517. * @param normalMatrix the matrix to bind
  26518. */
  26519. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26520. bind(world: Matrix, mesh?: Mesh): void;
  26521. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26522. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26523. }
  26524. }
  26525. declare module "babylonjs/Materials/materialFlags" {
  26526. /**
  26527. * This groups all the flags used to control the materials channel.
  26528. */
  26529. export class MaterialFlags {
  26530. private static _DiffuseTextureEnabled;
  26531. /**
  26532. * Are diffuse textures enabled in the application.
  26533. */
  26534. static get DiffuseTextureEnabled(): boolean;
  26535. static set DiffuseTextureEnabled(value: boolean);
  26536. private static _AmbientTextureEnabled;
  26537. /**
  26538. * Are ambient textures enabled in the application.
  26539. */
  26540. static get AmbientTextureEnabled(): boolean;
  26541. static set AmbientTextureEnabled(value: boolean);
  26542. private static _OpacityTextureEnabled;
  26543. /**
  26544. * Are opacity textures enabled in the application.
  26545. */
  26546. static get OpacityTextureEnabled(): boolean;
  26547. static set OpacityTextureEnabled(value: boolean);
  26548. private static _ReflectionTextureEnabled;
  26549. /**
  26550. * Are reflection textures enabled in the application.
  26551. */
  26552. static get ReflectionTextureEnabled(): boolean;
  26553. static set ReflectionTextureEnabled(value: boolean);
  26554. private static _EmissiveTextureEnabled;
  26555. /**
  26556. * Are emissive textures enabled in the application.
  26557. */
  26558. static get EmissiveTextureEnabled(): boolean;
  26559. static set EmissiveTextureEnabled(value: boolean);
  26560. private static _SpecularTextureEnabled;
  26561. /**
  26562. * Are specular textures enabled in the application.
  26563. */
  26564. static get SpecularTextureEnabled(): boolean;
  26565. static set SpecularTextureEnabled(value: boolean);
  26566. private static _BumpTextureEnabled;
  26567. /**
  26568. * Are bump textures enabled in the application.
  26569. */
  26570. static get BumpTextureEnabled(): boolean;
  26571. static set BumpTextureEnabled(value: boolean);
  26572. private static _LightmapTextureEnabled;
  26573. /**
  26574. * Are lightmap textures enabled in the application.
  26575. */
  26576. static get LightmapTextureEnabled(): boolean;
  26577. static set LightmapTextureEnabled(value: boolean);
  26578. private static _RefractionTextureEnabled;
  26579. /**
  26580. * Are refraction textures enabled in the application.
  26581. */
  26582. static get RefractionTextureEnabled(): boolean;
  26583. static set RefractionTextureEnabled(value: boolean);
  26584. private static _ColorGradingTextureEnabled;
  26585. /**
  26586. * Are color grading textures enabled in the application.
  26587. */
  26588. static get ColorGradingTextureEnabled(): boolean;
  26589. static set ColorGradingTextureEnabled(value: boolean);
  26590. private static _FresnelEnabled;
  26591. /**
  26592. * Are fresnels enabled in the application.
  26593. */
  26594. static get FresnelEnabled(): boolean;
  26595. static set FresnelEnabled(value: boolean);
  26596. private static _ClearCoatTextureEnabled;
  26597. /**
  26598. * Are clear coat textures enabled in the application.
  26599. */
  26600. static get ClearCoatTextureEnabled(): boolean;
  26601. static set ClearCoatTextureEnabled(value: boolean);
  26602. private static _ClearCoatBumpTextureEnabled;
  26603. /**
  26604. * Are clear coat bump textures enabled in the application.
  26605. */
  26606. static get ClearCoatBumpTextureEnabled(): boolean;
  26607. static set ClearCoatBumpTextureEnabled(value: boolean);
  26608. private static _ClearCoatTintTextureEnabled;
  26609. /**
  26610. * Are clear coat tint textures enabled in the application.
  26611. */
  26612. static get ClearCoatTintTextureEnabled(): boolean;
  26613. static set ClearCoatTintTextureEnabled(value: boolean);
  26614. private static _SheenTextureEnabled;
  26615. /**
  26616. * Are sheen textures enabled in the application.
  26617. */
  26618. static get SheenTextureEnabled(): boolean;
  26619. static set SheenTextureEnabled(value: boolean);
  26620. private static _AnisotropicTextureEnabled;
  26621. /**
  26622. * Are anisotropic textures enabled in the application.
  26623. */
  26624. static get AnisotropicTextureEnabled(): boolean;
  26625. static set AnisotropicTextureEnabled(value: boolean);
  26626. private static _ThicknessTextureEnabled;
  26627. /**
  26628. * Are thickness textures enabled in the application.
  26629. */
  26630. static get ThicknessTextureEnabled(): boolean;
  26631. static set ThicknessTextureEnabled(value: boolean);
  26632. }
  26633. }
  26634. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26635. /** @hidden */
  26636. export var defaultFragmentDeclaration: {
  26637. name: string;
  26638. shader: string;
  26639. };
  26640. }
  26641. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26642. /** @hidden */
  26643. export var defaultUboDeclaration: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26649. /** @hidden */
  26650. export var lightFragmentDeclaration: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26656. /** @hidden */
  26657. export var lightUboDeclaration: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26663. /** @hidden */
  26664. export var lightsFragmentFunctions: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26670. /** @hidden */
  26671. export var shadowsFragmentFunctions: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26677. /** @hidden */
  26678. export var fresnelFunction: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26684. /** @hidden */
  26685. export var reflectionFunction: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26691. /** @hidden */
  26692. export var bumpFragmentFunctions: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26698. /** @hidden */
  26699. export var logDepthDeclaration: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26705. /** @hidden */
  26706. export var bumpFragment: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26712. /** @hidden */
  26713. export var depthPrePass: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26719. /** @hidden */
  26720. export var lightFragment: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26726. /** @hidden */
  26727. export var logDepthFragment: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module "babylonjs/Shaders/default.fragment" {
  26733. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26734. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26735. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26736. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26737. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26738. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26739. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26740. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26741. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26742. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26743. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26746. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26747. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26748. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26749. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26750. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26751. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26752. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26753. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26754. /** @hidden */
  26755. export var defaultPixelShader: {
  26756. name: string;
  26757. shader: string;
  26758. };
  26759. }
  26760. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26761. /** @hidden */
  26762. export var defaultVertexDeclaration: {
  26763. name: string;
  26764. shader: string;
  26765. };
  26766. }
  26767. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26768. /** @hidden */
  26769. export var bumpVertexDeclaration: {
  26770. name: string;
  26771. shader: string;
  26772. };
  26773. }
  26774. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26775. /** @hidden */
  26776. export var bumpVertex: {
  26777. name: string;
  26778. shader: string;
  26779. };
  26780. }
  26781. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26782. /** @hidden */
  26783. export var fogVertex: {
  26784. name: string;
  26785. shader: string;
  26786. };
  26787. }
  26788. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26789. /** @hidden */
  26790. export var shadowsVertex: {
  26791. name: string;
  26792. shader: string;
  26793. };
  26794. }
  26795. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26796. /** @hidden */
  26797. export var pointCloudVertex: {
  26798. name: string;
  26799. shader: string;
  26800. };
  26801. }
  26802. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26803. /** @hidden */
  26804. export var logDepthVertex: {
  26805. name: string;
  26806. shader: string;
  26807. };
  26808. }
  26809. declare module "babylonjs/Shaders/default.vertex" {
  26810. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26811. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26812. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26813. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26814. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26815. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26816. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26817. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26818. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26819. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26820. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26822. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26823. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26824. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26825. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26826. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26828. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26829. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26830. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26831. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26832. /** @hidden */
  26833. export var defaultVertexShader: {
  26834. name: string;
  26835. shader: string;
  26836. };
  26837. }
  26838. declare module "babylonjs/Materials/standardMaterial" {
  26839. import { SmartArray } from "babylonjs/Misc/smartArray";
  26840. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26841. import { Nullable } from "babylonjs/types";
  26842. import { Scene } from "babylonjs/scene";
  26843. import { Matrix } from "babylonjs/Maths/math.vector";
  26844. import { Color3 } from "babylonjs/Maths/math.color";
  26845. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26847. import { Mesh } from "babylonjs/Meshes/mesh";
  26848. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26849. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26850. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26851. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26852. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26855. import "babylonjs/Shaders/default.fragment";
  26856. import "babylonjs/Shaders/default.vertex";
  26857. /** @hidden */
  26858. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26859. MAINUV1: boolean;
  26860. MAINUV2: boolean;
  26861. DIFFUSE: boolean;
  26862. DIFFUSEDIRECTUV: number;
  26863. AMBIENT: boolean;
  26864. AMBIENTDIRECTUV: number;
  26865. OPACITY: boolean;
  26866. OPACITYDIRECTUV: number;
  26867. OPACITYRGB: boolean;
  26868. REFLECTION: boolean;
  26869. EMISSIVE: boolean;
  26870. EMISSIVEDIRECTUV: number;
  26871. SPECULAR: boolean;
  26872. SPECULARDIRECTUV: number;
  26873. BUMP: boolean;
  26874. BUMPDIRECTUV: number;
  26875. PARALLAX: boolean;
  26876. PARALLAXOCCLUSION: boolean;
  26877. SPECULAROVERALPHA: boolean;
  26878. CLIPPLANE: boolean;
  26879. CLIPPLANE2: boolean;
  26880. CLIPPLANE3: boolean;
  26881. CLIPPLANE4: boolean;
  26882. ALPHATEST: boolean;
  26883. DEPTHPREPASS: boolean;
  26884. ALPHAFROMDIFFUSE: boolean;
  26885. POINTSIZE: boolean;
  26886. FOG: boolean;
  26887. SPECULARTERM: boolean;
  26888. DIFFUSEFRESNEL: boolean;
  26889. OPACITYFRESNEL: boolean;
  26890. REFLECTIONFRESNEL: boolean;
  26891. REFRACTIONFRESNEL: boolean;
  26892. EMISSIVEFRESNEL: boolean;
  26893. FRESNEL: boolean;
  26894. NORMAL: boolean;
  26895. UV1: boolean;
  26896. UV2: boolean;
  26897. VERTEXCOLOR: boolean;
  26898. VERTEXALPHA: boolean;
  26899. NUM_BONE_INFLUENCERS: number;
  26900. BonesPerMesh: number;
  26901. BONETEXTURE: boolean;
  26902. INSTANCES: boolean;
  26903. GLOSSINESS: boolean;
  26904. ROUGHNESS: boolean;
  26905. EMISSIVEASILLUMINATION: boolean;
  26906. LINKEMISSIVEWITHDIFFUSE: boolean;
  26907. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26908. LIGHTMAP: boolean;
  26909. LIGHTMAPDIRECTUV: number;
  26910. OBJECTSPACE_NORMALMAP: boolean;
  26911. USELIGHTMAPASSHADOWMAP: boolean;
  26912. REFLECTIONMAP_3D: boolean;
  26913. REFLECTIONMAP_SPHERICAL: boolean;
  26914. REFLECTIONMAP_PLANAR: boolean;
  26915. REFLECTIONMAP_CUBIC: boolean;
  26916. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26917. REFLECTIONMAP_PROJECTION: boolean;
  26918. REFLECTIONMAP_SKYBOX: boolean;
  26919. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26920. REFLECTIONMAP_EXPLICIT: boolean;
  26921. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26922. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26923. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26924. INVERTCUBICMAP: boolean;
  26925. LOGARITHMICDEPTH: boolean;
  26926. REFRACTION: boolean;
  26927. REFRACTIONMAP_3D: boolean;
  26928. REFLECTIONOVERALPHA: boolean;
  26929. TWOSIDEDLIGHTING: boolean;
  26930. SHADOWFLOAT: boolean;
  26931. MORPHTARGETS: boolean;
  26932. MORPHTARGETS_NORMAL: boolean;
  26933. MORPHTARGETS_TANGENT: boolean;
  26934. MORPHTARGETS_UV: boolean;
  26935. NUM_MORPH_INFLUENCERS: number;
  26936. NONUNIFORMSCALING: boolean;
  26937. PREMULTIPLYALPHA: boolean;
  26938. IMAGEPROCESSING: boolean;
  26939. VIGNETTE: boolean;
  26940. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26941. VIGNETTEBLENDMODEOPAQUE: boolean;
  26942. TONEMAPPING: boolean;
  26943. TONEMAPPING_ACES: boolean;
  26944. CONTRAST: boolean;
  26945. COLORCURVES: boolean;
  26946. COLORGRADING: boolean;
  26947. COLORGRADING3D: boolean;
  26948. SAMPLER3DGREENDEPTH: boolean;
  26949. SAMPLER3DBGRMAP: boolean;
  26950. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26951. MULTIVIEW: boolean;
  26952. /**
  26953. * If the reflection texture on this material is in linear color space
  26954. * @hidden
  26955. */
  26956. IS_REFLECTION_LINEAR: boolean;
  26957. /**
  26958. * If the refraction texture on this material is in linear color space
  26959. * @hidden
  26960. */
  26961. IS_REFRACTION_LINEAR: boolean;
  26962. EXPOSURE: boolean;
  26963. constructor();
  26964. setReflectionMode(modeToEnable: string): void;
  26965. }
  26966. /**
  26967. * This is the default material used in Babylon. It is the best trade off between quality
  26968. * and performances.
  26969. * @see http://doc.babylonjs.com/babylon101/materials
  26970. */
  26971. export class StandardMaterial extends PushMaterial {
  26972. private _diffuseTexture;
  26973. /**
  26974. * The basic texture of the material as viewed under a light.
  26975. */
  26976. diffuseTexture: Nullable<BaseTexture>;
  26977. private _ambientTexture;
  26978. /**
  26979. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26980. */
  26981. ambientTexture: Nullable<BaseTexture>;
  26982. private _opacityTexture;
  26983. /**
  26984. * Define the transparency of the material from a texture.
  26985. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26986. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26987. */
  26988. opacityTexture: Nullable<BaseTexture>;
  26989. private _reflectionTexture;
  26990. /**
  26991. * Define the texture used to display the reflection.
  26992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26993. */
  26994. reflectionTexture: Nullable<BaseTexture>;
  26995. private _emissiveTexture;
  26996. /**
  26997. * Define texture of the material as if self lit.
  26998. * This will be mixed in the final result even in the absence of light.
  26999. */
  27000. emissiveTexture: Nullable<BaseTexture>;
  27001. private _specularTexture;
  27002. /**
  27003. * Define how the color and intensity of the highlight given by the light in the material.
  27004. */
  27005. specularTexture: Nullable<BaseTexture>;
  27006. private _bumpTexture;
  27007. /**
  27008. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27009. * 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.
  27010. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27011. */
  27012. bumpTexture: Nullable<BaseTexture>;
  27013. private _lightmapTexture;
  27014. /**
  27015. * Complex lighting can be computationally expensive to compute at runtime.
  27016. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27017. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27018. */
  27019. lightmapTexture: Nullable<BaseTexture>;
  27020. private _refractionTexture;
  27021. /**
  27022. * Define the texture used to display the refraction.
  27023. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27024. */
  27025. refractionTexture: Nullable<BaseTexture>;
  27026. /**
  27027. * The color of the material lit by the environmental background lighting.
  27028. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27029. */
  27030. ambientColor: Color3;
  27031. /**
  27032. * The basic color of the material as viewed under a light.
  27033. */
  27034. diffuseColor: Color3;
  27035. /**
  27036. * Define how the color and intensity of the highlight given by the light in the material.
  27037. */
  27038. specularColor: Color3;
  27039. /**
  27040. * Define the color of the material as if self lit.
  27041. * This will be mixed in the final result even in the absence of light.
  27042. */
  27043. emissiveColor: Color3;
  27044. /**
  27045. * Defines how sharp are the highlights in the material.
  27046. * The bigger the value the sharper giving a more glossy feeling to the result.
  27047. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27048. */
  27049. specularPower: number;
  27050. private _useAlphaFromDiffuseTexture;
  27051. /**
  27052. * Does the transparency come from the diffuse texture alpha channel.
  27053. */
  27054. useAlphaFromDiffuseTexture: boolean;
  27055. private _useEmissiveAsIllumination;
  27056. /**
  27057. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27058. */
  27059. useEmissiveAsIllumination: boolean;
  27060. private _linkEmissiveWithDiffuse;
  27061. /**
  27062. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27063. * the emissive level when the final color is close to one.
  27064. */
  27065. linkEmissiveWithDiffuse: boolean;
  27066. private _useSpecularOverAlpha;
  27067. /**
  27068. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27069. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27070. */
  27071. useSpecularOverAlpha: boolean;
  27072. private _useReflectionOverAlpha;
  27073. /**
  27074. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27075. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27076. */
  27077. useReflectionOverAlpha: boolean;
  27078. private _disableLighting;
  27079. /**
  27080. * Does lights from the scene impacts this material.
  27081. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27082. */
  27083. disableLighting: boolean;
  27084. private _useObjectSpaceNormalMap;
  27085. /**
  27086. * Allows using an object space normal map (instead of tangent space).
  27087. */
  27088. useObjectSpaceNormalMap: boolean;
  27089. private _useParallax;
  27090. /**
  27091. * Is parallax enabled or not.
  27092. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27093. */
  27094. useParallax: boolean;
  27095. private _useParallaxOcclusion;
  27096. /**
  27097. * Is parallax occlusion enabled or not.
  27098. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27099. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27100. */
  27101. useParallaxOcclusion: boolean;
  27102. /**
  27103. * 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.
  27104. */
  27105. parallaxScaleBias: number;
  27106. private _roughness;
  27107. /**
  27108. * Helps to define how blurry the reflections should appears in the material.
  27109. */
  27110. roughness: number;
  27111. /**
  27112. * In case of refraction, define the value of the index of refraction.
  27113. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27114. */
  27115. indexOfRefraction: number;
  27116. /**
  27117. * Invert the refraction texture alongside the y axis.
  27118. * It can be useful with procedural textures or probe for instance.
  27119. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27120. */
  27121. invertRefractionY: boolean;
  27122. /**
  27123. * Defines the alpha limits in alpha test mode.
  27124. */
  27125. alphaCutOff: number;
  27126. private _useLightmapAsShadowmap;
  27127. /**
  27128. * In case of light mapping, define whether the map contains light or shadow informations.
  27129. */
  27130. useLightmapAsShadowmap: boolean;
  27131. private _diffuseFresnelParameters;
  27132. /**
  27133. * Define the diffuse fresnel parameters of the material.
  27134. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27135. */
  27136. diffuseFresnelParameters: FresnelParameters;
  27137. private _opacityFresnelParameters;
  27138. /**
  27139. * Define the opacity fresnel parameters of the material.
  27140. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27141. */
  27142. opacityFresnelParameters: FresnelParameters;
  27143. private _reflectionFresnelParameters;
  27144. /**
  27145. * Define the reflection fresnel parameters of the material.
  27146. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27147. */
  27148. reflectionFresnelParameters: FresnelParameters;
  27149. private _refractionFresnelParameters;
  27150. /**
  27151. * Define the refraction fresnel parameters of the material.
  27152. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27153. */
  27154. refractionFresnelParameters: FresnelParameters;
  27155. private _emissiveFresnelParameters;
  27156. /**
  27157. * Define the emissive fresnel parameters of the material.
  27158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27159. */
  27160. emissiveFresnelParameters: FresnelParameters;
  27161. private _useReflectionFresnelFromSpecular;
  27162. /**
  27163. * If true automatically deducts the fresnels values from the material specularity.
  27164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27165. */
  27166. useReflectionFresnelFromSpecular: boolean;
  27167. private _useGlossinessFromSpecularMapAlpha;
  27168. /**
  27169. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27170. */
  27171. useGlossinessFromSpecularMapAlpha: boolean;
  27172. private _maxSimultaneousLights;
  27173. /**
  27174. * Defines the maximum number of lights that can be used in the material
  27175. */
  27176. maxSimultaneousLights: number;
  27177. private _invertNormalMapX;
  27178. /**
  27179. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27180. */
  27181. invertNormalMapX: boolean;
  27182. private _invertNormalMapY;
  27183. /**
  27184. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27185. */
  27186. invertNormalMapY: boolean;
  27187. private _twoSidedLighting;
  27188. /**
  27189. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27190. */
  27191. twoSidedLighting: boolean;
  27192. /**
  27193. * Default configuration related to image processing available in the standard Material.
  27194. */
  27195. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27196. /**
  27197. * Gets the image processing configuration used either in this material.
  27198. */
  27199. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27200. /**
  27201. * Sets the Default image processing configuration used either in the this material.
  27202. *
  27203. * If sets to null, the scene one is in use.
  27204. */
  27205. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27206. /**
  27207. * Keep track of the image processing observer to allow dispose and replace.
  27208. */
  27209. private _imageProcessingObserver;
  27210. /**
  27211. * Attaches a new image processing configuration to the Standard Material.
  27212. * @param configuration
  27213. */
  27214. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27215. /**
  27216. * Gets wether the color curves effect is enabled.
  27217. */
  27218. get cameraColorCurvesEnabled(): boolean;
  27219. /**
  27220. * Sets wether the color curves effect is enabled.
  27221. */
  27222. set cameraColorCurvesEnabled(value: boolean);
  27223. /**
  27224. * Gets wether the color grading effect is enabled.
  27225. */
  27226. get cameraColorGradingEnabled(): boolean;
  27227. /**
  27228. * Gets wether the color grading effect is enabled.
  27229. */
  27230. set cameraColorGradingEnabled(value: boolean);
  27231. /**
  27232. * Gets wether tonemapping is enabled or not.
  27233. */
  27234. get cameraToneMappingEnabled(): boolean;
  27235. /**
  27236. * Sets wether tonemapping is enabled or not
  27237. */
  27238. set cameraToneMappingEnabled(value: boolean);
  27239. /**
  27240. * The camera exposure used on this material.
  27241. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27242. * This corresponds to a photographic exposure.
  27243. */
  27244. get cameraExposure(): number;
  27245. /**
  27246. * The camera exposure used on this material.
  27247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27248. * This corresponds to a photographic exposure.
  27249. */
  27250. set cameraExposure(value: number);
  27251. /**
  27252. * Gets The camera contrast used on this material.
  27253. */
  27254. get cameraContrast(): number;
  27255. /**
  27256. * Sets The camera contrast used on this material.
  27257. */
  27258. set cameraContrast(value: number);
  27259. /**
  27260. * Gets the Color Grading 2D Lookup Texture.
  27261. */
  27262. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27263. /**
  27264. * Sets the Color Grading 2D Lookup Texture.
  27265. */
  27266. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27267. /**
  27268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27270. * 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;
  27271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27272. */
  27273. get cameraColorCurves(): Nullable<ColorCurves>;
  27274. /**
  27275. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27276. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27277. * 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;
  27278. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27279. */
  27280. set cameraColorCurves(value: Nullable<ColorCurves>);
  27281. /**
  27282. * Custom callback helping to override the default shader used in the material.
  27283. */
  27284. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27285. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27286. protected _worldViewProjectionMatrix: Matrix;
  27287. protected _globalAmbientColor: Color3;
  27288. protected _useLogarithmicDepth: boolean;
  27289. protected _rebuildInParallel: boolean;
  27290. /**
  27291. * Instantiates a new standard material.
  27292. * This is the default material used in Babylon. It is the best trade off between quality
  27293. * and performances.
  27294. * @see http://doc.babylonjs.com/babylon101/materials
  27295. * @param name Define the name of the material in the scene
  27296. * @param scene Define the scene the material belong to
  27297. */
  27298. constructor(name: string, scene: Scene);
  27299. /**
  27300. * Gets a boolean indicating that current material needs to register RTT
  27301. */
  27302. get hasRenderTargetTextures(): boolean;
  27303. /**
  27304. * Gets the current class name of the material e.g. "StandardMaterial"
  27305. * Mainly use in serialization.
  27306. * @returns the class name
  27307. */
  27308. getClassName(): string;
  27309. /**
  27310. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27311. * You can try switching to logarithmic depth.
  27312. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27313. */
  27314. get useLogarithmicDepth(): boolean;
  27315. set useLogarithmicDepth(value: boolean);
  27316. /**
  27317. * Specifies if the material will require alpha blending
  27318. * @returns a boolean specifying if alpha blending is needed
  27319. */
  27320. needAlphaBlending(): boolean;
  27321. /**
  27322. * Specifies if this material should be rendered in alpha test mode
  27323. * @returns a boolean specifying if an alpha test is needed.
  27324. */
  27325. needAlphaTesting(): boolean;
  27326. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27327. /**
  27328. * Get the texture used for alpha test purpose.
  27329. * @returns the diffuse texture in case of the standard material.
  27330. */
  27331. getAlphaTestTexture(): Nullable<BaseTexture>;
  27332. /**
  27333. * Get if the submesh is ready to be used and all its information available.
  27334. * Child classes can use it to update shaders
  27335. * @param mesh defines the mesh to check
  27336. * @param subMesh defines which submesh to check
  27337. * @param useInstances specifies that instances should be used
  27338. * @returns a boolean indicating that the submesh is ready or not
  27339. */
  27340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27341. /**
  27342. * Builds the material UBO layouts.
  27343. * Used internally during the effect preparation.
  27344. */
  27345. buildUniformLayout(): void;
  27346. /**
  27347. * Unbinds the material from the mesh
  27348. */
  27349. unbind(): void;
  27350. /**
  27351. * Binds the submesh to this material by preparing the effect and shader to draw
  27352. * @param world defines the world transformation matrix
  27353. * @param mesh defines the mesh containing the submesh
  27354. * @param subMesh defines the submesh to bind the material to
  27355. */
  27356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27357. /**
  27358. * Get the list of animatables in the material.
  27359. * @returns the list of animatables object used in the material
  27360. */
  27361. getAnimatables(): IAnimatable[];
  27362. /**
  27363. * Gets the active textures from the material
  27364. * @returns an array of textures
  27365. */
  27366. getActiveTextures(): BaseTexture[];
  27367. /**
  27368. * Specifies if the material uses a texture
  27369. * @param texture defines the texture to check against the material
  27370. * @returns a boolean specifying if the material uses the texture
  27371. */
  27372. hasTexture(texture: BaseTexture): boolean;
  27373. /**
  27374. * Disposes the material
  27375. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27376. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27377. */
  27378. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27379. /**
  27380. * Makes a duplicate of the material, and gives it a new name
  27381. * @param name defines the new name for the duplicated material
  27382. * @returns the cloned material
  27383. */
  27384. clone(name: string): StandardMaterial;
  27385. /**
  27386. * Serializes this material in a JSON representation
  27387. * @returns the serialized material object
  27388. */
  27389. serialize(): any;
  27390. /**
  27391. * Creates a standard material from parsed material data
  27392. * @param source defines the JSON representation of the material
  27393. * @param scene defines the hosting scene
  27394. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27395. * @returns a new standard material
  27396. */
  27397. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27398. /**
  27399. * Are diffuse textures enabled in the application.
  27400. */
  27401. static get DiffuseTextureEnabled(): boolean;
  27402. static set DiffuseTextureEnabled(value: boolean);
  27403. /**
  27404. * Are ambient textures enabled in the application.
  27405. */
  27406. static get AmbientTextureEnabled(): boolean;
  27407. static set AmbientTextureEnabled(value: boolean);
  27408. /**
  27409. * Are opacity textures enabled in the application.
  27410. */
  27411. static get OpacityTextureEnabled(): boolean;
  27412. static set OpacityTextureEnabled(value: boolean);
  27413. /**
  27414. * Are reflection textures enabled in the application.
  27415. */
  27416. static get ReflectionTextureEnabled(): boolean;
  27417. static set ReflectionTextureEnabled(value: boolean);
  27418. /**
  27419. * Are emissive textures enabled in the application.
  27420. */
  27421. static get EmissiveTextureEnabled(): boolean;
  27422. static set EmissiveTextureEnabled(value: boolean);
  27423. /**
  27424. * Are specular textures enabled in the application.
  27425. */
  27426. static get SpecularTextureEnabled(): boolean;
  27427. static set SpecularTextureEnabled(value: boolean);
  27428. /**
  27429. * Are bump textures enabled in the application.
  27430. */
  27431. static get BumpTextureEnabled(): boolean;
  27432. static set BumpTextureEnabled(value: boolean);
  27433. /**
  27434. * Are lightmap textures enabled in the application.
  27435. */
  27436. static get LightmapTextureEnabled(): boolean;
  27437. static set LightmapTextureEnabled(value: boolean);
  27438. /**
  27439. * Are refraction textures enabled in the application.
  27440. */
  27441. static get RefractionTextureEnabled(): boolean;
  27442. static set RefractionTextureEnabled(value: boolean);
  27443. /**
  27444. * Are color grading textures enabled in the application.
  27445. */
  27446. static get ColorGradingTextureEnabled(): boolean;
  27447. static set ColorGradingTextureEnabled(value: boolean);
  27448. /**
  27449. * Are fresnels enabled in the application.
  27450. */
  27451. static get FresnelEnabled(): boolean;
  27452. static set FresnelEnabled(value: boolean);
  27453. }
  27454. }
  27455. declare module "babylonjs/Particles/solidParticleSystem" {
  27456. import { Nullable } from "babylonjs/types";
  27457. import { Vector3 } from "babylonjs/Maths/math.vector";
  27458. import { Mesh } from "babylonjs/Meshes/mesh";
  27459. import { Scene, IDisposable } from "babylonjs/scene";
  27460. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27461. import { Material } from "babylonjs/Materials/material";
  27462. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27463. /**
  27464. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27465. *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.
  27466. * The SPS is also a particle system. It provides some methods to manage the particles.
  27467. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27468. *
  27469. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27470. */
  27471. export class SolidParticleSystem implements IDisposable {
  27472. /**
  27473. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27474. * Example : var p = SPS.particles[i];
  27475. */
  27476. particles: SolidParticle[];
  27477. /**
  27478. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27479. */
  27480. nbParticles: number;
  27481. /**
  27482. * If the particles must ever face the camera (default false). Useful for planar particles.
  27483. */
  27484. billboard: boolean;
  27485. /**
  27486. * Recompute normals when adding a shape
  27487. */
  27488. recomputeNormals: boolean;
  27489. /**
  27490. * This a counter ofr your own usage. It's not set by any SPS functions.
  27491. */
  27492. counter: number;
  27493. /**
  27494. * The SPS name. This name is also given to the underlying mesh.
  27495. */
  27496. name: string;
  27497. /**
  27498. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27499. */
  27500. mesh: Mesh;
  27501. /**
  27502. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27503. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27504. */
  27505. vars: any;
  27506. /**
  27507. * This array is populated when the SPS is set as 'pickable'.
  27508. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27509. * Each element of this array is an object `{idx: int, faceId: int}`.
  27510. * `idx` is the picked particle index in the `SPS.particles` array
  27511. * `faceId` is the picked face index counted within this particle.
  27512. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27513. */
  27514. pickedParticles: {
  27515. idx: number;
  27516. faceId: number;
  27517. }[];
  27518. /**
  27519. * This array is populated when `enableDepthSort` is set to true.
  27520. * Each element of this array is an instance of the class DepthSortedParticle.
  27521. */
  27522. depthSortedParticles: DepthSortedParticle[];
  27523. /**
  27524. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27525. * @hidden
  27526. */
  27527. _bSphereOnly: boolean;
  27528. /**
  27529. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27530. * @hidden
  27531. */
  27532. _bSphereRadiusFactor: number;
  27533. private _scene;
  27534. private _positions;
  27535. private _indices;
  27536. private _normals;
  27537. private _colors;
  27538. private _uvs;
  27539. private _indices32;
  27540. private _positions32;
  27541. private _normals32;
  27542. private _fixedNormal32;
  27543. private _colors32;
  27544. private _uvs32;
  27545. private _index;
  27546. private _updatable;
  27547. private _pickable;
  27548. private _isVisibilityBoxLocked;
  27549. private _alwaysVisible;
  27550. private _depthSort;
  27551. private _expandable;
  27552. private _shapeCounter;
  27553. private _copy;
  27554. private _color;
  27555. private _computeParticleColor;
  27556. private _computeParticleTexture;
  27557. private _computeParticleRotation;
  27558. private _computeParticleVertex;
  27559. private _computeBoundingBox;
  27560. private _depthSortParticles;
  27561. private _camera;
  27562. private _mustUnrotateFixedNormals;
  27563. private _particlesIntersect;
  27564. private _needs32Bits;
  27565. private _isNotBuilt;
  27566. private _lastParticleId;
  27567. private _idxOfId;
  27568. private _multimaterialEnabled;
  27569. private _useModelMaterial;
  27570. private _indicesByMaterial;
  27571. private _materialIndexes;
  27572. private _depthSortFunction;
  27573. private _materialSortFunction;
  27574. private _materials;
  27575. private _multimaterial;
  27576. private _materialIndexesById;
  27577. private _defaultMaterial;
  27578. private _autoUpdateSubMeshes;
  27579. /**
  27580. * Creates a SPS (Solid Particle System) object.
  27581. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27582. * @param scene (Scene) is the scene in which the SPS is added.
  27583. * @param options defines the options of the sps e.g.
  27584. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27585. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27586. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27587. * * 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.
  27588. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27589. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27590. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27591. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27592. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27593. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27594. */
  27595. constructor(name: string, scene: Scene, options?: {
  27596. updatable?: boolean;
  27597. isPickable?: boolean;
  27598. enableDepthSort?: boolean;
  27599. particleIntersection?: boolean;
  27600. boundingSphereOnly?: boolean;
  27601. bSphereRadiusFactor?: number;
  27602. expandable?: boolean;
  27603. useModelMaterial?: boolean;
  27604. enableMultiMaterial?: boolean;
  27605. });
  27606. /**
  27607. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27608. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27609. * @returns the created mesh
  27610. */
  27611. buildMesh(): Mesh;
  27612. /**
  27613. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27614. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27615. * Thus the particles generated from `digest()` have their property `position` set yet.
  27616. * @param mesh ( Mesh ) is the mesh to be digested
  27617. * @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
  27618. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27619. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27620. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27621. * @returns the current SPS
  27622. */
  27623. digest(mesh: Mesh, options?: {
  27624. facetNb?: number;
  27625. number?: number;
  27626. delta?: number;
  27627. storage?: [];
  27628. }): SolidParticleSystem;
  27629. /**
  27630. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27631. * @hidden
  27632. */
  27633. private _unrotateFixedNormals;
  27634. /**
  27635. * Resets the temporary working copy particle
  27636. * @hidden
  27637. */
  27638. private _resetCopy;
  27639. /**
  27640. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27641. * @param p the current index in the positions array to be updated
  27642. * @param ind the current index in the indices array
  27643. * @param shape a Vector3 array, the shape geometry
  27644. * @param positions the positions array to be updated
  27645. * @param meshInd the shape indices array
  27646. * @param indices the indices array to be updated
  27647. * @param meshUV the shape uv array
  27648. * @param uvs the uv array to be updated
  27649. * @param meshCol the shape color array
  27650. * @param colors the color array to be updated
  27651. * @param meshNor the shape normals array
  27652. * @param normals the normals array to be updated
  27653. * @param idx the particle index
  27654. * @param idxInShape the particle index in its shape
  27655. * @param options the addShape() method passed options
  27656. * @model the particle model
  27657. * @hidden
  27658. */
  27659. private _meshBuilder;
  27660. /**
  27661. * Returns a shape Vector3 array from positions float array
  27662. * @param positions float array
  27663. * @returns a vector3 array
  27664. * @hidden
  27665. */
  27666. private _posToShape;
  27667. /**
  27668. * Returns a shapeUV array from a float uvs (array deep copy)
  27669. * @param uvs as a float array
  27670. * @returns a shapeUV array
  27671. * @hidden
  27672. */
  27673. private _uvsToShapeUV;
  27674. /**
  27675. * Adds a new particle object in the particles array
  27676. * @param idx particle index in particles array
  27677. * @param id particle id
  27678. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27679. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27680. * @param model particle ModelShape object
  27681. * @param shapeId model shape identifier
  27682. * @param idxInShape index of the particle in the current model
  27683. * @param bInfo model bounding info object
  27684. * @param storage target storage array, if any
  27685. * @hidden
  27686. */
  27687. private _addParticle;
  27688. /**
  27689. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27690. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27691. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27692. * @param nb (positive integer) the number of particles to be created from this model
  27693. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27694. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27695. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27696. * @returns the number of shapes in the system
  27697. */
  27698. addShape(mesh: Mesh, nb: number, options?: {
  27699. positionFunction?: any;
  27700. vertexFunction?: any;
  27701. storage?: [];
  27702. }): number;
  27703. /**
  27704. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27705. * @hidden
  27706. */
  27707. private _rebuildParticle;
  27708. /**
  27709. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27710. * @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.
  27711. * @returns the SPS.
  27712. */
  27713. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27714. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27715. * Returns an array with the removed particles.
  27716. * 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.
  27717. * The SPS can't be empty so at least one particle needs to remain in place.
  27718. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27719. * @param start index of the first particle to remove
  27720. * @param end index of the last particle to remove (included)
  27721. * @returns an array populated with the removed particles
  27722. */
  27723. removeParticles(start: number, end: number): SolidParticle[];
  27724. /**
  27725. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27726. * @param solidParticleArray an array populated with Solid Particles objects
  27727. * @returns the SPS
  27728. */
  27729. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27730. /**
  27731. * Creates a new particle and modifies the SPS mesh geometry :
  27732. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27733. * - calls _addParticle() to populate the particle array
  27734. * factorized code from addShape() and insertParticlesFromArray()
  27735. * @param idx particle index in the particles array
  27736. * @param i particle index in its shape
  27737. * @param modelShape particle ModelShape object
  27738. * @param shape shape vertex array
  27739. * @param meshInd shape indices array
  27740. * @param meshUV shape uv array
  27741. * @param meshCol shape color array
  27742. * @param meshNor shape normals array
  27743. * @param bbInfo shape bounding info
  27744. * @param storage target particle storage
  27745. * @options addShape() passed options
  27746. * @hidden
  27747. */
  27748. private _insertNewParticle;
  27749. /**
  27750. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27751. * This method calls `updateParticle()` for each particle of the SPS.
  27752. * For an animated SPS, it is usually called within the render loop.
  27753. * 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.
  27754. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27755. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27756. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27757. * @returns the SPS.
  27758. */
  27759. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27760. /**
  27761. * Disposes the SPS.
  27762. */
  27763. dispose(): void;
  27764. /**
  27765. * Returns a SolidParticle object from its identifier : particle.id
  27766. * @param id (integer) the particle Id
  27767. * @returns the searched particle or null if not found in the SPS.
  27768. */
  27769. getParticleById(id: number): Nullable<SolidParticle>;
  27770. /**
  27771. * Returns a new array populated with the particles having the passed shapeId.
  27772. * @param shapeId (integer) the shape identifier
  27773. * @returns a new solid particle array
  27774. */
  27775. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27776. /**
  27777. * Populates the passed array "ref" with the particles having the passed shapeId.
  27778. * @param shapeId the shape identifier
  27779. * @returns the SPS
  27780. * @param ref
  27781. */
  27782. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27783. /**
  27784. * Computes the required SubMeshes according the materials assigned to the particles.
  27785. * @returns the solid particle system.
  27786. * Does nothing if called before the SPS mesh is built.
  27787. */
  27788. computeSubMeshes(): SolidParticleSystem;
  27789. /**
  27790. * Sorts the solid particles by material when MultiMaterial is enabled.
  27791. * Updates the indices32 array.
  27792. * Updates the indicesByMaterial array.
  27793. * Updates the mesh indices array.
  27794. * @returns the SPS
  27795. * @hidden
  27796. */
  27797. private _sortParticlesByMaterial;
  27798. /**
  27799. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27800. * @hidden
  27801. */
  27802. private _setMaterialIndexesById;
  27803. /**
  27804. * Returns an array with unique values of Materials from the passed array
  27805. * @param array the material array to be checked and filtered
  27806. * @hidden
  27807. */
  27808. private _filterUniqueMaterialId;
  27809. /**
  27810. * Sets a new Standard Material as _defaultMaterial if not already set.
  27811. * @hidden
  27812. */
  27813. private _setDefaultMaterial;
  27814. /**
  27815. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27816. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27817. * @returns the SPS.
  27818. */
  27819. refreshVisibleSize(): SolidParticleSystem;
  27820. /**
  27821. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27822. * @param size the size (float) of the visibility box
  27823. * note : this doesn't lock the SPS mesh bounding box.
  27824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27825. */
  27826. setVisibilityBox(size: number): void;
  27827. /**
  27828. * Gets whether the SPS as always visible or not
  27829. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27830. */
  27831. get isAlwaysVisible(): boolean;
  27832. /**
  27833. * Sets the SPS as always visible or not
  27834. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27835. */
  27836. set isAlwaysVisible(val: boolean);
  27837. /**
  27838. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27839. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27840. */
  27841. set isVisibilityBoxLocked(val: boolean);
  27842. /**
  27843. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27844. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27845. */
  27846. get isVisibilityBoxLocked(): boolean;
  27847. /**
  27848. * Tells to `setParticles()` to compute the particle rotations or not.
  27849. * Default value : true. The SPS is faster when it's set to false.
  27850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27851. */
  27852. set computeParticleRotation(val: boolean);
  27853. /**
  27854. * Tells to `setParticles()` to compute the particle colors or not.
  27855. * Default value : true. The SPS is faster when it's set to false.
  27856. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27857. */
  27858. set computeParticleColor(val: boolean);
  27859. set computeParticleTexture(val: boolean);
  27860. /**
  27861. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27862. * Default value : false. The SPS is faster when it's set to false.
  27863. * Note : the particle custom vertex positions aren't stored values.
  27864. */
  27865. set computeParticleVertex(val: boolean);
  27866. /**
  27867. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27868. */
  27869. set computeBoundingBox(val: boolean);
  27870. /**
  27871. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27872. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27873. * Default : `true`
  27874. */
  27875. set depthSortParticles(val: boolean);
  27876. /**
  27877. * Gets if `setParticles()` computes the particle rotations or not.
  27878. * Default value : true. The SPS is faster when it's set to false.
  27879. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27880. */
  27881. get computeParticleRotation(): boolean;
  27882. /**
  27883. * Gets if `setParticles()` computes the particle colors or not.
  27884. * Default value : true. The SPS is faster when it's set to false.
  27885. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27886. */
  27887. get computeParticleColor(): boolean;
  27888. /**
  27889. * Gets if `setParticles()` computes the particle textures or not.
  27890. * Default value : true. The SPS is faster when it's set to false.
  27891. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27892. */
  27893. get computeParticleTexture(): boolean;
  27894. /**
  27895. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27896. * Default value : false. The SPS is faster when it's set to false.
  27897. * Note : the particle custom vertex positions aren't stored values.
  27898. */
  27899. get computeParticleVertex(): boolean;
  27900. /**
  27901. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27902. */
  27903. get computeBoundingBox(): boolean;
  27904. /**
  27905. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27906. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27907. * Default : `true`
  27908. */
  27909. get depthSortParticles(): boolean;
  27910. /**
  27911. * Gets if the SPS is created as expandable at construction time.
  27912. * Default : `false`
  27913. */
  27914. get expandable(): boolean;
  27915. /**
  27916. * Gets if the SPS supports the Multi Materials
  27917. */
  27918. get multimaterialEnabled(): boolean;
  27919. /**
  27920. * Gets if the SPS uses the model materials for its own multimaterial.
  27921. */
  27922. get useModelMaterial(): boolean;
  27923. /**
  27924. * The SPS used material array.
  27925. */
  27926. get materials(): Material[];
  27927. /**
  27928. * Sets the SPS MultiMaterial from the passed materials.
  27929. * Note : the passed array is internally copied and not used then by reference.
  27930. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27931. */
  27932. setMultiMaterial(materials: Material[]): void;
  27933. /**
  27934. * The SPS computed multimaterial object
  27935. */
  27936. get multimaterial(): MultiMaterial;
  27937. set multimaterial(mm: MultiMaterial);
  27938. /**
  27939. * If the subMeshes must be updated on the next call to setParticles()
  27940. */
  27941. get autoUpdateSubMeshes(): boolean;
  27942. set autoUpdateSubMeshes(val: boolean);
  27943. /**
  27944. * This function does nothing. It may be overwritten to set all the particle first values.
  27945. * The SPS doesn't call this function, you may have to call it by your own.
  27946. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27947. */
  27948. initParticles(): void;
  27949. /**
  27950. * This function does nothing. It may be overwritten to recycle a particle.
  27951. * The SPS doesn't call this function, you may have to call it by your own.
  27952. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27953. * @param particle The particle to recycle
  27954. * @returns the recycled particle
  27955. */
  27956. recycleParticle(particle: SolidParticle): SolidParticle;
  27957. /**
  27958. * Updates a particle : this function should be overwritten by the user.
  27959. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27961. * @example : just set a particle position or velocity and recycle conditions
  27962. * @param particle The particle to update
  27963. * @returns the updated particle
  27964. */
  27965. updateParticle(particle: SolidParticle): SolidParticle;
  27966. /**
  27967. * Updates a vertex of a particle : it can be overwritten by the user.
  27968. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27969. * @param particle the current particle
  27970. * @param vertex the current index of the current particle
  27971. * @param pt the index of the current vertex in the particle shape
  27972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27973. * @example : just set a vertex particle position
  27974. * @returns the updated vertex
  27975. */
  27976. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27977. /**
  27978. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27979. * This does nothing and may be overwritten by the user.
  27980. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27981. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27982. * @param update the boolean update value actually passed to setParticles()
  27983. */
  27984. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27985. /**
  27986. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27987. * This will be passed three parameters.
  27988. * This does nothing and may be overwritten by the user.
  27989. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27990. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27991. * @param update the boolean update value actually passed to setParticles()
  27992. */
  27993. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27994. }
  27995. }
  27996. declare module "babylonjs/Particles/solidParticle" {
  27997. import { Nullable } from "babylonjs/types";
  27998. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27999. import { Color4 } from "babylonjs/Maths/math.color";
  28000. import { Mesh } from "babylonjs/Meshes/mesh";
  28001. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28002. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28003. import { Plane } from "babylonjs/Maths/math.plane";
  28004. import { Material } from "babylonjs/Materials/material";
  28005. /**
  28006. * Represents one particle of a solid particle system.
  28007. */
  28008. export class SolidParticle {
  28009. /**
  28010. * particle global index
  28011. */
  28012. idx: number;
  28013. /**
  28014. * particle identifier
  28015. */
  28016. id: number;
  28017. /**
  28018. * The color of the particle
  28019. */
  28020. color: Nullable<Color4>;
  28021. /**
  28022. * The world space position of the particle.
  28023. */
  28024. position: Vector3;
  28025. /**
  28026. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28027. */
  28028. rotation: Vector3;
  28029. /**
  28030. * The world space rotation quaternion of the particle.
  28031. */
  28032. rotationQuaternion: Nullable<Quaternion>;
  28033. /**
  28034. * The scaling of the particle.
  28035. */
  28036. scaling: Vector3;
  28037. /**
  28038. * The uvs of the particle.
  28039. */
  28040. uvs: Vector4;
  28041. /**
  28042. * The current speed of the particle.
  28043. */
  28044. velocity: Vector3;
  28045. /**
  28046. * The pivot point in the particle local space.
  28047. */
  28048. pivot: Vector3;
  28049. /**
  28050. * Must the particle be translated from its pivot point in its local space ?
  28051. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28052. * Default : false
  28053. */
  28054. translateFromPivot: boolean;
  28055. /**
  28056. * Is the particle active or not ?
  28057. */
  28058. alive: boolean;
  28059. /**
  28060. * Is the particle visible or not ?
  28061. */
  28062. isVisible: boolean;
  28063. /**
  28064. * Index of this particle in the global "positions" array (Internal use)
  28065. * @hidden
  28066. */
  28067. _pos: number;
  28068. /**
  28069. * @hidden Index of this particle in the global "indices" array (Internal use)
  28070. */
  28071. _ind: number;
  28072. /**
  28073. * @hidden ModelShape of this particle (Internal use)
  28074. */
  28075. _model: ModelShape;
  28076. /**
  28077. * ModelShape id of this particle
  28078. */
  28079. shapeId: number;
  28080. /**
  28081. * Index of the particle in its shape id
  28082. */
  28083. idxInShape: number;
  28084. /**
  28085. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28086. */
  28087. _modelBoundingInfo: BoundingInfo;
  28088. /**
  28089. * @hidden Particle BoundingInfo object (Internal use)
  28090. */
  28091. _boundingInfo: BoundingInfo;
  28092. /**
  28093. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28094. */
  28095. _sps: SolidParticleSystem;
  28096. /**
  28097. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28098. */
  28099. _stillInvisible: boolean;
  28100. /**
  28101. * @hidden Last computed particle rotation matrix
  28102. */
  28103. _rotationMatrix: number[];
  28104. /**
  28105. * Parent particle Id, if any.
  28106. * Default null.
  28107. */
  28108. parentId: Nullable<number>;
  28109. /**
  28110. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28111. */
  28112. materialIndex: Nullable<number>;
  28113. /**
  28114. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28115. * The possible values are :
  28116. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28117. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28118. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28119. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28120. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28121. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28122. * */
  28123. cullingStrategy: number;
  28124. /**
  28125. * @hidden Internal global position in the SPS.
  28126. */
  28127. _globalPosition: Vector3;
  28128. /**
  28129. * Creates a Solid Particle object.
  28130. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28131. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28132. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28133. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28134. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28135. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28136. * @param shapeId (integer) is the model shape identifier in the SPS.
  28137. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28138. * @param sps defines the sps it is associated to
  28139. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28140. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28141. */
  28142. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28143. /**
  28144. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28145. * @param target the particle target
  28146. * @returns the current particle
  28147. */
  28148. copyToRef(target: SolidParticle): SolidParticle;
  28149. /**
  28150. * Legacy support, changed scale to scaling
  28151. */
  28152. get scale(): Vector3;
  28153. /**
  28154. * Legacy support, changed scale to scaling
  28155. */
  28156. set scale(scale: Vector3);
  28157. /**
  28158. * Legacy support, changed quaternion to rotationQuaternion
  28159. */
  28160. get quaternion(): Nullable<Quaternion>;
  28161. /**
  28162. * Legacy support, changed quaternion to rotationQuaternion
  28163. */
  28164. set quaternion(q: Nullable<Quaternion>);
  28165. /**
  28166. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28167. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28168. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28169. * @returns true if it intersects
  28170. */
  28171. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28172. /**
  28173. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28174. * A particle is in the frustum if its bounding box intersects the frustum
  28175. * @param frustumPlanes defines the frustum to test
  28176. * @returns true if the particle is in the frustum planes
  28177. */
  28178. isInFrustum(frustumPlanes: Plane[]): boolean;
  28179. /**
  28180. * get the rotation matrix of the particle
  28181. * @hidden
  28182. */
  28183. getRotationMatrix(m: Matrix): void;
  28184. }
  28185. /**
  28186. * Represents the shape of the model used by one particle of a solid particle system.
  28187. * SPS internal tool, don't use it manually.
  28188. */
  28189. export class ModelShape {
  28190. /**
  28191. * The shape id
  28192. * @hidden
  28193. */
  28194. shapeID: number;
  28195. /**
  28196. * flat array of model positions (internal use)
  28197. * @hidden
  28198. */
  28199. _shape: Vector3[];
  28200. /**
  28201. * flat array of model UVs (internal use)
  28202. * @hidden
  28203. */
  28204. _shapeUV: number[];
  28205. /**
  28206. * color array of the model
  28207. * @hidden
  28208. */
  28209. _shapeColors: number[];
  28210. /**
  28211. * indices array of the model
  28212. * @hidden
  28213. */
  28214. _indices: number[];
  28215. /**
  28216. * normals array of the model
  28217. * @hidden
  28218. */
  28219. _normals: number[];
  28220. /**
  28221. * length of the shape in the model indices array (internal use)
  28222. * @hidden
  28223. */
  28224. _indicesLength: number;
  28225. /**
  28226. * Custom position function (internal use)
  28227. * @hidden
  28228. */
  28229. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28230. /**
  28231. * Custom vertex function (internal use)
  28232. * @hidden
  28233. */
  28234. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28235. /**
  28236. * Model material (internal use)
  28237. * @hidden
  28238. */
  28239. _material: Nullable<Material>;
  28240. /**
  28241. * 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.
  28242. * SPS internal tool, don't use it manually.
  28243. * @hidden
  28244. */
  28245. 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>);
  28246. }
  28247. /**
  28248. * Represents a Depth Sorted Particle in the solid particle system.
  28249. * @hidden
  28250. */
  28251. export class DepthSortedParticle {
  28252. /**
  28253. * Index of the particle in the "indices" array
  28254. */
  28255. ind: number;
  28256. /**
  28257. * Length of the particle shape in the "indices" array
  28258. */
  28259. indicesLength: number;
  28260. /**
  28261. * Squared distance from the particle to the camera
  28262. */
  28263. sqDistance: number;
  28264. /**
  28265. * Material index when used with MultiMaterials
  28266. */
  28267. materialIndex: number;
  28268. /**
  28269. * Creates a new sorted particle
  28270. * @param materialIndex
  28271. */
  28272. constructor(ind: number, indLength: number, materialIndex: number);
  28273. }
  28274. }
  28275. declare module "babylonjs/Collisions/meshCollisionData" {
  28276. import { Collider } from "babylonjs/Collisions/collider";
  28277. import { Vector3 } from "babylonjs/Maths/math.vector";
  28278. import { Nullable } from "babylonjs/types";
  28279. import { Observer } from "babylonjs/Misc/observable";
  28280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28281. /**
  28282. * @hidden
  28283. */
  28284. export class _MeshCollisionData {
  28285. _checkCollisions: boolean;
  28286. _collisionMask: number;
  28287. _collisionGroup: number;
  28288. _collider: Nullable<Collider>;
  28289. _oldPositionForCollisions: Vector3;
  28290. _diffPositionForCollisions: Vector3;
  28291. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28292. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28293. }
  28294. }
  28295. declare module "babylonjs/Meshes/abstractMesh" {
  28296. import { Observable } from "babylonjs/Misc/observable";
  28297. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28298. import { Camera } from "babylonjs/Cameras/camera";
  28299. import { Scene, IDisposable } from "babylonjs/scene";
  28300. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28301. import { Node } from "babylonjs/node";
  28302. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28303. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28306. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28307. import { Material } from "babylonjs/Materials/material";
  28308. import { Light } from "babylonjs/Lights/light";
  28309. import { Skeleton } from "babylonjs/Bones/skeleton";
  28310. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28311. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28312. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28313. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28314. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28315. import { Plane } from "babylonjs/Maths/math.plane";
  28316. import { Ray } from "babylonjs/Culling/ray";
  28317. import { Collider } from "babylonjs/Collisions/collider";
  28318. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28319. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28320. /** @hidden */
  28321. class _FacetDataStorage {
  28322. facetPositions: Vector3[];
  28323. facetNormals: Vector3[];
  28324. facetPartitioning: number[][];
  28325. facetNb: number;
  28326. partitioningSubdivisions: number;
  28327. partitioningBBoxRatio: number;
  28328. facetDataEnabled: boolean;
  28329. facetParameters: any;
  28330. bbSize: Vector3;
  28331. subDiv: {
  28332. max: number;
  28333. X: number;
  28334. Y: number;
  28335. Z: number;
  28336. };
  28337. facetDepthSort: boolean;
  28338. facetDepthSortEnabled: boolean;
  28339. depthSortedIndices: IndicesArray;
  28340. depthSortedFacets: {
  28341. ind: number;
  28342. sqDistance: number;
  28343. }[];
  28344. facetDepthSortFunction: (f1: {
  28345. ind: number;
  28346. sqDistance: number;
  28347. }, f2: {
  28348. ind: number;
  28349. sqDistance: number;
  28350. }) => number;
  28351. facetDepthSortFrom: Vector3;
  28352. facetDepthSortOrigin: Vector3;
  28353. invertedMatrix: Matrix;
  28354. }
  28355. /**
  28356. * @hidden
  28357. **/
  28358. class _InternalAbstractMeshDataInfo {
  28359. _hasVertexAlpha: boolean;
  28360. _useVertexColors: boolean;
  28361. _numBoneInfluencers: number;
  28362. _applyFog: boolean;
  28363. _receiveShadows: boolean;
  28364. _facetData: _FacetDataStorage;
  28365. _visibility: number;
  28366. _skeleton: Nullable<Skeleton>;
  28367. _layerMask: number;
  28368. _computeBonesUsingShaders: boolean;
  28369. _isActive: boolean;
  28370. _onlyForInstances: boolean;
  28371. _isActiveIntermediate: boolean;
  28372. _onlyForInstancesIntermediate: boolean;
  28373. _actAsRegularMesh: boolean;
  28374. }
  28375. /**
  28376. * Class used to store all common mesh properties
  28377. */
  28378. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28379. /** No occlusion */
  28380. static OCCLUSION_TYPE_NONE: number;
  28381. /** Occlusion set to optimisitic */
  28382. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28383. /** Occlusion set to strict */
  28384. static OCCLUSION_TYPE_STRICT: number;
  28385. /** Use an accurante occlusion algorithm */
  28386. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28387. /** Use a conservative occlusion algorithm */
  28388. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28389. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28390. * Test order :
  28391. * Is the bounding sphere outside the frustum ?
  28392. * If not, are the bounding box vertices outside the frustum ?
  28393. * It not, then the cullable object is in the frustum.
  28394. */
  28395. static readonly CULLINGSTRATEGY_STANDARD: number;
  28396. /** Culling strategy : Bounding Sphere Only.
  28397. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28398. * It's also less accurate than the standard because some not visible objects can still be selected.
  28399. * Test : is the bounding sphere outside the frustum ?
  28400. * If not, then the cullable object is in the frustum.
  28401. */
  28402. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28403. /** Culling strategy : Optimistic Inclusion.
  28404. * This in an inclusion test first, then the standard exclusion test.
  28405. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28406. * 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.
  28407. * Anyway, it's as accurate as the standard strategy.
  28408. * Test :
  28409. * Is the cullable object bounding sphere center in the frustum ?
  28410. * If not, apply the default culling strategy.
  28411. */
  28412. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28413. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28414. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28415. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28416. * 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.
  28417. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28418. * Test :
  28419. * Is the cullable object bounding sphere center in the frustum ?
  28420. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28421. */
  28422. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28423. /**
  28424. * No billboard
  28425. */
  28426. static get BILLBOARDMODE_NONE(): number;
  28427. /** Billboard on X axis */
  28428. static get BILLBOARDMODE_X(): number;
  28429. /** Billboard on Y axis */
  28430. static get BILLBOARDMODE_Y(): number;
  28431. /** Billboard on Z axis */
  28432. static get BILLBOARDMODE_Z(): number;
  28433. /** Billboard on all axes */
  28434. static get BILLBOARDMODE_ALL(): number;
  28435. /** Billboard on using position instead of orientation */
  28436. static get BILLBOARDMODE_USE_POSITION(): number;
  28437. /** @hidden */
  28438. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28439. /**
  28440. * The culling strategy to use to check whether the mesh must be rendered or not.
  28441. * This value can be changed at any time and will be used on the next render mesh selection.
  28442. * The possible values are :
  28443. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28444. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28445. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28446. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28447. * Please read each static variable documentation to get details about the culling process.
  28448. * */
  28449. cullingStrategy: number;
  28450. /**
  28451. * Gets the number of facets in the mesh
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28453. */
  28454. get facetNb(): number;
  28455. /**
  28456. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28458. */
  28459. get partitioningSubdivisions(): number;
  28460. set partitioningSubdivisions(nb: number);
  28461. /**
  28462. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28463. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28465. */
  28466. get partitioningBBoxRatio(): number;
  28467. set partitioningBBoxRatio(ratio: number);
  28468. /**
  28469. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28470. * Works only for updatable meshes.
  28471. * Doesn't work with multi-materials
  28472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28473. */
  28474. get mustDepthSortFacets(): boolean;
  28475. set mustDepthSortFacets(sort: boolean);
  28476. /**
  28477. * The location (Vector3) where the facet depth sort must be computed from.
  28478. * By default, the active camera position.
  28479. * Used only when facet depth sort is enabled
  28480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28481. */
  28482. get facetDepthSortFrom(): Vector3;
  28483. set facetDepthSortFrom(location: Vector3);
  28484. /**
  28485. * gets a boolean indicating if facetData is enabled
  28486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28487. */
  28488. get isFacetDataEnabled(): boolean;
  28489. /** @hidden */
  28490. _updateNonUniformScalingState(value: boolean): boolean;
  28491. /**
  28492. * An event triggered when this mesh collides with another one
  28493. */
  28494. onCollideObservable: Observable<AbstractMesh>;
  28495. /** Set a function to call when this mesh collides with another one */
  28496. set onCollide(callback: () => void);
  28497. /**
  28498. * An event triggered when the collision's position changes
  28499. */
  28500. onCollisionPositionChangeObservable: Observable<Vector3>;
  28501. /** Set a function to call when the collision's position changes */
  28502. set onCollisionPositionChange(callback: () => void);
  28503. /**
  28504. * An event triggered when material is changed
  28505. */
  28506. onMaterialChangedObservable: Observable<AbstractMesh>;
  28507. /**
  28508. * Gets or sets the orientation for POV movement & rotation
  28509. */
  28510. definedFacingForward: boolean;
  28511. /** @hidden */
  28512. _occlusionQuery: Nullable<WebGLQuery>;
  28513. /** @hidden */
  28514. _renderingGroup: Nullable<RenderingGroup>;
  28515. /**
  28516. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28517. */
  28518. get visibility(): number;
  28519. /**
  28520. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28521. */
  28522. set visibility(value: number);
  28523. /** Gets or sets the alpha index used to sort transparent meshes
  28524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28525. */
  28526. alphaIndex: number;
  28527. /**
  28528. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28529. */
  28530. isVisible: boolean;
  28531. /**
  28532. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28533. */
  28534. isPickable: boolean;
  28535. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28536. showSubMeshesBoundingBox: boolean;
  28537. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28539. */
  28540. isBlocker: boolean;
  28541. /**
  28542. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28543. */
  28544. enablePointerMoveEvents: boolean;
  28545. /**
  28546. * Specifies the rendering group id for this mesh (0 by default)
  28547. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28548. */
  28549. renderingGroupId: number;
  28550. private _material;
  28551. /** Gets or sets current material */
  28552. get material(): Nullable<Material>;
  28553. set material(value: Nullable<Material>);
  28554. /**
  28555. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28556. * @see http://doc.babylonjs.com/babylon101/shadows
  28557. */
  28558. get receiveShadows(): boolean;
  28559. set receiveShadows(value: boolean);
  28560. /** Defines color to use when rendering outline */
  28561. outlineColor: Color3;
  28562. /** Define width to use when rendering outline */
  28563. outlineWidth: number;
  28564. /** Defines color to use when rendering overlay */
  28565. overlayColor: Color3;
  28566. /** Defines alpha to use when rendering overlay */
  28567. overlayAlpha: number;
  28568. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28569. get hasVertexAlpha(): boolean;
  28570. set hasVertexAlpha(value: boolean);
  28571. /** 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) */
  28572. get useVertexColors(): boolean;
  28573. set useVertexColors(value: boolean);
  28574. /**
  28575. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28576. */
  28577. get computeBonesUsingShaders(): boolean;
  28578. set computeBonesUsingShaders(value: boolean);
  28579. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28580. get numBoneInfluencers(): number;
  28581. set numBoneInfluencers(value: number);
  28582. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28583. get applyFog(): boolean;
  28584. set applyFog(value: boolean);
  28585. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28586. useOctreeForRenderingSelection: boolean;
  28587. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28588. useOctreeForPicking: boolean;
  28589. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28590. useOctreeForCollisions: boolean;
  28591. /**
  28592. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28593. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28594. */
  28595. get layerMask(): number;
  28596. set layerMask(value: number);
  28597. /**
  28598. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28599. */
  28600. alwaysSelectAsActiveMesh: boolean;
  28601. /**
  28602. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28603. */
  28604. doNotSyncBoundingInfo: boolean;
  28605. /**
  28606. * Gets or sets the current action manager
  28607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28608. */
  28609. actionManager: Nullable<AbstractActionManager>;
  28610. private _meshCollisionData;
  28611. /**
  28612. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28614. */
  28615. ellipsoid: Vector3;
  28616. /**
  28617. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28618. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28619. */
  28620. ellipsoidOffset: Vector3;
  28621. /**
  28622. * Gets or sets a collision mask used to mask collisions (default is -1).
  28623. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28624. */
  28625. get collisionMask(): number;
  28626. set collisionMask(mask: number);
  28627. /**
  28628. * Gets or sets the current collision group mask (-1 by default).
  28629. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28630. */
  28631. get collisionGroup(): number;
  28632. set collisionGroup(mask: number);
  28633. /**
  28634. * Defines edge width used when edgesRenderer is enabled
  28635. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28636. */
  28637. edgesWidth: number;
  28638. /**
  28639. * Defines edge color used when edgesRenderer is enabled
  28640. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28641. */
  28642. edgesColor: Color4;
  28643. /** @hidden */
  28644. _edgesRenderer: Nullable<IEdgesRenderer>;
  28645. /** @hidden */
  28646. _masterMesh: Nullable<AbstractMesh>;
  28647. /** @hidden */
  28648. _boundingInfo: Nullable<BoundingInfo>;
  28649. /** @hidden */
  28650. _renderId: number;
  28651. /**
  28652. * Gets or sets the list of subMeshes
  28653. * @see http://doc.babylonjs.com/how_to/multi_materials
  28654. */
  28655. subMeshes: SubMesh[];
  28656. /** @hidden */
  28657. _intersectionsInProgress: AbstractMesh[];
  28658. /** @hidden */
  28659. _unIndexed: boolean;
  28660. /** @hidden */
  28661. _lightSources: Light[];
  28662. /** Gets the list of lights affecting that mesh */
  28663. get lightSources(): Light[];
  28664. /** @hidden */
  28665. get _positions(): Nullable<Vector3[]>;
  28666. /** @hidden */
  28667. _waitingData: {
  28668. lods: Nullable<any>;
  28669. actions: Nullable<any>;
  28670. freezeWorldMatrix: Nullable<boolean>;
  28671. };
  28672. /** @hidden */
  28673. _bonesTransformMatrices: Nullable<Float32Array>;
  28674. /** @hidden */
  28675. _transformMatrixTexture: Nullable<RawTexture>;
  28676. /**
  28677. * Gets or sets a skeleton to apply skining transformations
  28678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28679. */
  28680. set skeleton(value: Nullable<Skeleton>);
  28681. get skeleton(): Nullable<Skeleton>;
  28682. /**
  28683. * An event triggered when the mesh is rebuilt.
  28684. */
  28685. onRebuildObservable: Observable<AbstractMesh>;
  28686. /**
  28687. * Creates a new AbstractMesh
  28688. * @param name defines the name of the mesh
  28689. * @param scene defines the hosting scene
  28690. */
  28691. constructor(name: string, scene?: Nullable<Scene>);
  28692. /**
  28693. * Returns the string "AbstractMesh"
  28694. * @returns "AbstractMesh"
  28695. */
  28696. getClassName(): string;
  28697. /**
  28698. * Gets a string representation of the current mesh
  28699. * @param fullDetails defines a boolean indicating if full details must be included
  28700. * @returns a string representation of the current mesh
  28701. */
  28702. toString(fullDetails?: boolean): string;
  28703. /**
  28704. * @hidden
  28705. */
  28706. protected _getEffectiveParent(): Nullable<Node>;
  28707. /** @hidden */
  28708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28709. /** @hidden */
  28710. _rebuild(): void;
  28711. /** @hidden */
  28712. _resyncLightSources(): void;
  28713. /** @hidden */
  28714. _resyncLightSource(light: Light): void;
  28715. /** @hidden */
  28716. _unBindEffect(): void;
  28717. /** @hidden */
  28718. _removeLightSource(light: Light, dispose: boolean): void;
  28719. private _markSubMeshesAsDirty;
  28720. /** @hidden */
  28721. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28722. /** @hidden */
  28723. _markSubMeshesAsAttributesDirty(): void;
  28724. /** @hidden */
  28725. _markSubMeshesAsMiscDirty(): void;
  28726. /**
  28727. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28728. */
  28729. get scaling(): Vector3;
  28730. set scaling(newScaling: Vector3);
  28731. /**
  28732. * Returns true if the mesh is blocked. Implemented by child classes
  28733. */
  28734. get isBlocked(): boolean;
  28735. /**
  28736. * Returns the mesh itself by default. Implemented by child classes
  28737. * @param camera defines the camera to use to pick the right LOD level
  28738. * @returns the currentAbstractMesh
  28739. */
  28740. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28741. /**
  28742. * Returns 0 by default. Implemented by child classes
  28743. * @returns an integer
  28744. */
  28745. getTotalVertices(): number;
  28746. /**
  28747. * Returns a positive integer : the total number of indices in this mesh geometry.
  28748. * @returns the numner of indices or zero if the mesh has no geometry.
  28749. */
  28750. getTotalIndices(): number;
  28751. /**
  28752. * Returns null by default. Implemented by child classes
  28753. * @returns null
  28754. */
  28755. getIndices(): Nullable<IndicesArray>;
  28756. /**
  28757. * Returns the array of the requested vertex data kind. Implemented by child classes
  28758. * @param kind defines the vertex data kind to use
  28759. * @returns null
  28760. */
  28761. getVerticesData(kind: string): Nullable<FloatArray>;
  28762. /**
  28763. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28764. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28765. * Note that a new underlying VertexBuffer object is created each call.
  28766. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28767. * @param kind defines vertex data kind:
  28768. * * VertexBuffer.PositionKind
  28769. * * VertexBuffer.UVKind
  28770. * * VertexBuffer.UV2Kind
  28771. * * VertexBuffer.UV3Kind
  28772. * * VertexBuffer.UV4Kind
  28773. * * VertexBuffer.UV5Kind
  28774. * * VertexBuffer.UV6Kind
  28775. * * VertexBuffer.ColorKind
  28776. * * VertexBuffer.MatricesIndicesKind
  28777. * * VertexBuffer.MatricesIndicesExtraKind
  28778. * * VertexBuffer.MatricesWeightsKind
  28779. * * VertexBuffer.MatricesWeightsExtraKind
  28780. * @param data defines the data source
  28781. * @param updatable defines if the data must be flagged as updatable (or static)
  28782. * @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
  28783. * @returns the current mesh
  28784. */
  28785. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28786. /**
  28787. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28788. * If the mesh has no geometry, it is simply returned as it is.
  28789. * @param kind defines vertex data kind:
  28790. * * VertexBuffer.PositionKind
  28791. * * VertexBuffer.UVKind
  28792. * * VertexBuffer.UV2Kind
  28793. * * VertexBuffer.UV3Kind
  28794. * * VertexBuffer.UV4Kind
  28795. * * VertexBuffer.UV5Kind
  28796. * * VertexBuffer.UV6Kind
  28797. * * VertexBuffer.ColorKind
  28798. * * VertexBuffer.MatricesIndicesKind
  28799. * * VertexBuffer.MatricesIndicesExtraKind
  28800. * * VertexBuffer.MatricesWeightsKind
  28801. * * VertexBuffer.MatricesWeightsExtraKind
  28802. * @param data defines the data source
  28803. * @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
  28804. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28805. * @returns the current mesh
  28806. */
  28807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28808. /**
  28809. * Sets the mesh indices,
  28810. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28811. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28812. * @param totalVertices Defines the total number of vertices
  28813. * @returns the current mesh
  28814. */
  28815. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28816. /**
  28817. * Gets a boolean indicating if specific vertex data is present
  28818. * @param kind defines the vertex data kind to use
  28819. * @returns true is data kind is present
  28820. */
  28821. isVerticesDataPresent(kind: string): boolean;
  28822. /**
  28823. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28824. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28825. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28826. * @returns a BoundingInfo
  28827. */
  28828. getBoundingInfo(): BoundingInfo;
  28829. /**
  28830. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28831. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28832. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28833. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28834. * @returns the current mesh
  28835. */
  28836. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28837. /**
  28838. * Overwrite the current bounding info
  28839. * @param boundingInfo defines the new bounding info
  28840. * @returns the current mesh
  28841. */
  28842. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28843. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28844. get useBones(): boolean;
  28845. /** @hidden */
  28846. _preActivate(): void;
  28847. /** @hidden */
  28848. _preActivateForIntermediateRendering(renderId: number): void;
  28849. /** @hidden */
  28850. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28851. /** @hidden */
  28852. _postActivate(): void;
  28853. /** @hidden */
  28854. _freeze(): void;
  28855. /** @hidden */
  28856. _unFreeze(): void;
  28857. /**
  28858. * Gets the current world matrix
  28859. * @returns a Matrix
  28860. */
  28861. getWorldMatrix(): Matrix;
  28862. /** @hidden */
  28863. _getWorldMatrixDeterminant(): number;
  28864. /**
  28865. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28866. */
  28867. get isAnInstance(): boolean;
  28868. /**
  28869. * Gets a boolean indicating if this mesh has instances
  28870. */
  28871. get hasInstances(): boolean;
  28872. /**
  28873. * Perform relative position change from the point of view of behind the front of the mesh.
  28874. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28875. * Supports definition of mesh facing forward or backward
  28876. * @param amountRight defines the distance on the right axis
  28877. * @param amountUp defines the distance on the up axis
  28878. * @param amountForward defines the distance on the forward axis
  28879. * @returns the current mesh
  28880. */
  28881. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28882. /**
  28883. * Calculate relative position change from the point of view of behind the front of the mesh.
  28884. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28885. * Supports definition of mesh facing forward or backward
  28886. * @param amountRight defines the distance on the right axis
  28887. * @param amountUp defines the distance on the up axis
  28888. * @param amountForward defines the distance on the forward axis
  28889. * @returns the new displacement vector
  28890. */
  28891. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28892. /**
  28893. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28894. * Supports definition of mesh facing forward or backward
  28895. * @param flipBack defines the flip
  28896. * @param twirlClockwise defines the twirl
  28897. * @param tiltRight defines the tilt
  28898. * @returns the current mesh
  28899. */
  28900. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28901. /**
  28902. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28903. * Supports definition of mesh facing forward or backward.
  28904. * @param flipBack defines the flip
  28905. * @param twirlClockwise defines the twirl
  28906. * @param tiltRight defines the tilt
  28907. * @returns the new rotation vector
  28908. */
  28909. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28910. /**
  28911. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28912. * This means the mesh underlying bounding box and sphere are recomputed.
  28913. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28914. * @returns the current mesh
  28915. */
  28916. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28917. /** @hidden */
  28918. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28919. /** @hidden */
  28920. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28921. /** @hidden */
  28922. _updateBoundingInfo(): AbstractMesh;
  28923. /** @hidden */
  28924. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28925. /** @hidden */
  28926. protected _afterComputeWorldMatrix(): void;
  28927. /** @hidden */
  28928. get _effectiveMesh(): AbstractMesh;
  28929. /**
  28930. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28931. * A mesh is in the frustum if its bounding box intersects the frustum
  28932. * @param frustumPlanes defines the frustum to test
  28933. * @returns true if the mesh is in the frustum planes
  28934. */
  28935. isInFrustum(frustumPlanes: Plane[]): boolean;
  28936. /**
  28937. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28938. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28939. * @param frustumPlanes defines the frustum to test
  28940. * @returns true if the mesh is completely in the frustum planes
  28941. */
  28942. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28943. /**
  28944. * True if the mesh intersects another mesh or a SolidParticle object
  28945. * @param mesh defines a target mesh or SolidParticle to test
  28946. * @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)
  28947. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28948. * @returns true if there is an intersection
  28949. */
  28950. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28951. /**
  28952. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28953. * @param point defines the point to test
  28954. * @returns true if there is an intersection
  28955. */
  28956. intersectsPoint(point: Vector3): boolean;
  28957. /**
  28958. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28959. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28960. */
  28961. get checkCollisions(): boolean;
  28962. set checkCollisions(collisionEnabled: boolean);
  28963. /**
  28964. * Gets Collider object used to compute collisions (not physics)
  28965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28966. */
  28967. get collider(): Nullable<Collider>;
  28968. /**
  28969. * Move the mesh using collision engine
  28970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28971. * @param displacement defines the requested displacement vector
  28972. * @returns the current mesh
  28973. */
  28974. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28975. private _onCollisionPositionChange;
  28976. /** @hidden */
  28977. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28978. /** @hidden */
  28979. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28980. /** @hidden */
  28981. _checkCollision(collider: Collider): AbstractMesh;
  28982. /** @hidden */
  28983. _generatePointsArray(): boolean;
  28984. /**
  28985. * Checks if the passed Ray intersects with the mesh
  28986. * @param ray defines the ray to use
  28987. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28988. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28989. * @returns the picking info
  28990. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28991. */
  28992. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28993. /**
  28994. * Clones the current mesh
  28995. * @param name defines the mesh name
  28996. * @param newParent defines the new mesh parent
  28997. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28998. * @returns the new mesh
  28999. */
  29000. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29001. /**
  29002. * Disposes all the submeshes of the current meshnp
  29003. * @returns the current mesh
  29004. */
  29005. releaseSubMeshes(): AbstractMesh;
  29006. /**
  29007. * Releases resources associated with this abstract mesh.
  29008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29010. */
  29011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29012. /**
  29013. * Adds the passed mesh as a child to the current mesh
  29014. * @param mesh defines the child mesh
  29015. * @returns the current mesh
  29016. */
  29017. addChild(mesh: AbstractMesh): AbstractMesh;
  29018. /**
  29019. * Removes the passed mesh from the current mesh children list
  29020. * @param mesh defines the child mesh
  29021. * @returns the current mesh
  29022. */
  29023. removeChild(mesh: AbstractMesh): AbstractMesh;
  29024. /** @hidden */
  29025. private _initFacetData;
  29026. /**
  29027. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29028. * This method can be called within the render loop.
  29029. * 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
  29030. * @returns the current mesh
  29031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29032. */
  29033. updateFacetData(): AbstractMesh;
  29034. /**
  29035. * Returns the facetLocalNormals array.
  29036. * The normals are expressed in the mesh local spac
  29037. * @returns an array of Vector3
  29038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29039. */
  29040. getFacetLocalNormals(): Vector3[];
  29041. /**
  29042. * Returns the facetLocalPositions array.
  29043. * The facet positions are expressed in the mesh local space
  29044. * @returns an array of Vector3
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29046. */
  29047. getFacetLocalPositions(): Vector3[];
  29048. /**
  29049. * Returns the facetLocalPartioning array
  29050. * @returns an array of array of numbers
  29051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29052. */
  29053. getFacetLocalPartitioning(): number[][];
  29054. /**
  29055. * Returns the i-th facet position in the world system.
  29056. * This method allocates a new Vector3 per call
  29057. * @param i defines the facet index
  29058. * @returns a new Vector3
  29059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29060. */
  29061. getFacetPosition(i: number): Vector3;
  29062. /**
  29063. * Sets the reference Vector3 with the i-th facet position in the world system
  29064. * @param i defines the facet index
  29065. * @param ref defines the target vector
  29066. * @returns the current mesh
  29067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29068. */
  29069. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29070. /**
  29071. * Returns the i-th facet normal in the world system.
  29072. * This method allocates a new Vector3 per call
  29073. * @param i defines the facet index
  29074. * @returns a new Vector3
  29075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29076. */
  29077. getFacetNormal(i: number): Vector3;
  29078. /**
  29079. * Sets the reference Vector3 with the i-th facet normal in the world system
  29080. * @param i defines the facet index
  29081. * @param ref defines the target vector
  29082. * @returns the current mesh
  29083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29084. */
  29085. getFacetNormalToRef(i: number, ref: Vector3): this;
  29086. /**
  29087. * 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)
  29088. * @param x defines x coordinate
  29089. * @param y defines y coordinate
  29090. * @param z defines z coordinate
  29091. * @returns the array of facet indexes
  29092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29093. */
  29094. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29095. /**
  29096. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29097. * @param projected sets as the (x,y,z) world projection on the facet
  29098. * @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
  29099. * @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
  29100. * @param x defines x coordinate
  29101. * @param y defines y coordinate
  29102. * @param z defines z coordinate
  29103. * @returns the face index if found (or null instead)
  29104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29105. */
  29106. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29107. /**
  29108. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29109. * @param projected sets as the (x,y,z) local projection on the facet
  29110. * @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
  29111. * @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
  29112. * @param x defines x coordinate
  29113. * @param y defines y coordinate
  29114. * @param z defines z coordinate
  29115. * @returns the face index if found (or null instead)
  29116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29117. */
  29118. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29119. /**
  29120. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29121. * @returns the parameters
  29122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29123. */
  29124. getFacetDataParameters(): any;
  29125. /**
  29126. * Disables the feature FacetData and frees the related memory
  29127. * @returns the current mesh
  29128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29129. */
  29130. disableFacetData(): AbstractMesh;
  29131. /**
  29132. * Updates the AbstractMesh indices array
  29133. * @param indices defines the data source
  29134. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29135. * @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)
  29136. * @returns the current mesh
  29137. */
  29138. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29139. /**
  29140. * Creates new normals data for the mesh
  29141. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29142. * @returns the current mesh
  29143. */
  29144. createNormals(updatable: boolean): AbstractMesh;
  29145. /**
  29146. * Align the mesh with a normal
  29147. * @param normal defines the normal to use
  29148. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29149. * @returns the current mesh
  29150. */
  29151. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29152. /** @hidden */
  29153. _checkOcclusionQuery(): boolean;
  29154. /**
  29155. * Disables the mesh edge rendering mode
  29156. * @returns the currentAbstractMesh
  29157. */
  29158. disableEdgesRendering(): AbstractMesh;
  29159. /**
  29160. * Enables the edge rendering mode on the mesh.
  29161. * This mode makes the mesh edges visible
  29162. * @param epsilon defines the maximal distance between two angles to detect a face
  29163. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29164. * @returns the currentAbstractMesh
  29165. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29166. */
  29167. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29168. }
  29169. }
  29170. declare module "babylonjs/Actions/actionEvent" {
  29171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29172. import { Nullable } from "babylonjs/types";
  29173. import { Sprite } from "babylonjs/Sprites/sprite";
  29174. import { Scene } from "babylonjs/scene";
  29175. import { Vector2 } from "babylonjs/Maths/math.vector";
  29176. /**
  29177. * Interface used to define ActionEvent
  29178. */
  29179. export interface IActionEvent {
  29180. /** The mesh or sprite that triggered the action */
  29181. source: any;
  29182. /** The X mouse cursor position at the time of the event */
  29183. pointerX: number;
  29184. /** The Y mouse cursor position at the time of the event */
  29185. pointerY: number;
  29186. /** The mesh that is currently pointed at (can be null) */
  29187. meshUnderPointer: Nullable<AbstractMesh>;
  29188. /** the original (browser) event that triggered the ActionEvent */
  29189. sourceEvent?: any;
  29190. /** additional data for the event */
  29191. additionalData?: any;
  29192. }
  29193. /**
  29194. * ActionEvent is the event being sent when an action is triggered.
  29195. */
  29196. export class ActionEvent implements IActionEvent {
  29197. /** The mesh or sprite that triggered the action */
  29198. source: any;
  29199. /** The X mouse cursor position at the time of the event */
  29200. pointerX: number;
  29201. /** The Y mouse cursor position at the time of the event */
  29202. pointerY: number;
  29203. /** The mesh that is currently pointed at (can be null) */
  29204. meshUnderPointer: Nullable<AbstractMesh>;
  29205. /** the original (browser) event that triggered the ActionEvent */
  29206. sourceEvent?: any;
  29207. /** additional data for the event */
  29208. additionalData?: any;
  29209. /**
  29210. * Creates a new ActionEvent
  29211. * @param source The mesh or sprite that triggered the action
  29212. * @param pointerX The X mouse cursor position at the time of the event
  29213. * @param pointerY The Y mouse cursor position at the time of the event
  29214. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29215. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29216. * @param additionalData additional data for the event
  29217. */
  29218. constructor(
  29219. /** The mesh or sprite that triggered the action */
  29220. source: any,
  29221. /** The X mouse cursor position at the time of the event */
  29222. pointerX: number,
  29223. /** The Y mouse cursor position at the time of the event */
  29224. pointerY: number,
  29225. /** The mesh that is currently pointed at (can be null) */
  29226. meshUnderPointer: Nullable<AbstractMesh>,
  29227. /** the original (browser) event that triggered the ActionEvent */
  29228. sourceEvent?: any,
  29229. /** additional data for the event */
  29230. additionalData?: any);
  29231. /**
  29232. * Helper function to auto-create an ActionEvent from a source mesh.
  29233. * @param source The source mesh that triggered the event
  29234. * @param evt The original (browser) event
  29235. * @param additionalData additional data for the event
  29236. * @returns the new ActionEvent
  29237. */
  29238. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29239. /**
  29240. * Helper function to auto-create an ActionEvent from a source sprite
  29241. * @param source The source sprite that triggered the event
  29242. * @param scene Scene associated with the sprite
  29243. * @param evt The original (browser) event
  29244. * @param additionalData additional data for the event
  29245. * @returns the new ActionEvent
  29246. */
  29247. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29248. /**
  29249. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29250. * @param scene the scene where the event occurred
  29251. * @param evt The original (browser) event
  29252. * @returns the new ActionEvent
  29253. */
  29254. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29255. /**
  29256. * Helper function to auto-create an ActionEvent from a primitive
  29257. * @param prim defines the target primitive
  29258. * @param pointerPos defines the pointer position
  29259. * @param evt The original (browser) event
  29260. * @param additionalData additional data for the event
  29261. * @returns the new ActionEvent
  29262. */
  29263. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29264. }
  29265. }
  29266. declare module "babylonjs/Actions/abstractActionManager" {
  29267. import { IDisposable } from "babylonjs/scene";
  29268. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29269. import { IAction } from "babylonjs/Actions/action";
  29270. import { Nullable } from "babylonjs/types";
  29271. /**
  29272. * Abstract class used to decouple action Manager from scene and meshes.
  29273. * Do not instantiate.
  29274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29275. */
  29276. export abstract class AbstractActionManager implements IDisposable {
  29277. /** Gets the list of active triggers */
  29278. static Triggers: {
  29279. [key: string]: number;
  29280. };
  29281. /** Gets the cursor to use when hovering items */
  29282. hoverCursor: string;
  29283. /** Gets the list of actions */
  29284. actions: IAction[];
  29285. /**
  29286. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29287. */
  29288. isRecursive: boolean;
  29289. /**
  29290. * Releases all associated resources
  29291. */
  29292. abstract dispose(): void;
  29293. /**
  29294. * Does this action manager has pointer triggers
  29295. */
  29296. abstract get hasPointerTriggers(): boolean;
  29297. /**
  29298. * Does this action manager has pick triggers
  29299. */
  29300. abstract get hasPickTriggers(): boolean;
  29301. /**
  29302. * Process a specific trigger
  29303. * @param trigger defines the trigger to process
  29304. * @param evt defines the event details to be processed
  29305. */
  29306. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29307. /**
  29308. * Does this action manager handles actions of any of the given triggers
  29309. * @param triggers defines the triggers to be tested
  29310. * @return a boolean indicating whether one (or more) of the triggers is handled
  29311. */
  29312. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29313. /**
  29314. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29315. * speed.
  29316. * @param triggerA defines the trigger to be tested
  29317. * @param triggerB defines the trigger to be tested
  29318. * @return a boolean indicating whether one (or more) of the triggers is handled
  29319. */
  29320. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29321. /**
  29322. * Does this action manager handles actions of a given trigger
  29323. * @param trigger defines the trigger to be tested
  29324. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29325. * @return whether the trigger is handled
  29326. */
  29327. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29328. /**
  29329. * Serialize this manager to a JSON object
  29330. * @param name defines the property name to store this manager
  29331. * @returns a JSON representation of this manager
  29332. */
  29333. abstract serialize(name: string): any;
  29334. /**
  29335. * Registers an action to this action manager
  29336. * @param action defines the action to be registered
  29337. * @return the action amended (prepared) after registration
  29338. */
  29339. abstract registerAction(action: IAction): Nullable<IAction>;
  29340. /**
  29341. * Unregisters an action to this action manager
  29342. * @param action defines the action to be unregistered
  29343. * @return a boolean indicating whether the action has been unregistered
  29344. */
  29345. abstract unregisterAction(action: IAction): Boolean;
  29346. /**
  29347. * Does exist one action manager with at least one trigger
  29348. **/
  29349. static get HasTriggers(): boolean;
  29350. /**
  29351. * Does exist one action manager with at least one pick trigger
  29352. **/
  29353. static get HasPickTriggers(): boolean;
  29354. /**
  29355. * Does exist one action manager that handles actions of a given trigger
  29356. * @param trigger defines the trigger to be tested
  29357. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29358. **/
  29359. static HasSpecificTrigger(trigger: number): boolean;
  29360. }
  29361. }
  29362. declare module "babylonjs/node" {
  29363. import { Scene } from "babylonjs/scene";
  29364. import { Nullable } from "babylonjs/types";
  29365. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29366. import { Engine } from "babylonjs/Engines/engine";
  29367. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29368. import { Observable } from "babylonjs/Misc/observable";
  29369. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29370. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29371. import { Animatable } from "babylonjs/Animations/animatable";
  29372. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29373. import { Animation } from "babylonjs/Animations/animation";
  29374. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29376. /**
  29377. * Defines how a node can be built from a string name.
  29378. */
  29379. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29380. /**
  29381. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29382. */
  29383. export class Node implements IBehaviorAware<Node> {
  29384. /** @hidden */
  29385. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29386. private static _NodeConstructors;
  29387. /**
  29388. * Add a new node constructor
  29389. * @param type defines the type name of the node to construct
  29390. * @param constructorFunc defines the constructor function
  29391. */
  29392. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29393. /**
  29394. * Returns a node constructor based on type name
  29395. * @param type defines the type name
  29396. * @param name defines the new node name
  29397. * @param scene defines the hosting scene
  29398. * @param options defines optional options to transmit to constructors
  29399. * @returns the new constructor or null
  29400. */
  29401. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29402. /**
  29403. * Gets or sets the name of the node
  29404. */
  29405. name: string;
  29406. /**
  29407. * Gets or sets the id of the node
  29408. */
  29409. id: string;
  29410. /**
  29411. * Gets or sets the unique id of the node
  29412. */
  29413. uniqueId: number;
  29414. /**
  29415. * Gets or sets a string used to store user defined state for the node
  29416. */
  29417. state: string;
  29418. /**
  29419. * Gets or sets an object used to store user defined information for the node
  29420. */
  29421. metadata: any;
  29422. /**
  29423. * For internal use only. Please do not use.
  29424. */
  29425. reservedDataStore: any;
  29426. /**
  29427. * List of inspectable custom properties (used by the Inspector)
  29428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29429. */
  29430. inspectableCustomProperties: IInspectable[];
  29431. private _doNotSerialize;
  29432. /**
  29433. * Gets or sets a boolean used to define if the node must be serialized
  29434. */
  29435. get doNotSerialize(): boolean;
  29436. set doNotSerialize(value: boolean);
  29437. /** @hidden */
  29438. _isDisposed: boolean;
  29439. /**
  29440. * Gets a list of Animations associated with the node
  29441. */
  29442. animations: import("babylonjs/Animations/animation").Animation[];
  29443. protected _ranges: {
  29444. [name: string]: Nullable<AnimationRange>;
  29445. };
  29446. /**
  29447. * Callback raised when the node is ready to be used
  29448. */
  29449. onReady: Nullable<(node: Node) => void>;
  29450. private _isEnabled;
  29451. private _isParentEnabled;
  29452. private _isReady;
  29453. /** @hidden */
  29454. _currentRenderId: number;
  29455. private _parentUpdateId;
  29456. /** @hidden */
  29457. _childUpdateId: number;
  29458. /** @hidden */
  29459. _waitingParentId: Nullable<string>;
  29460. /** @hidden */
  29461. _scene: Scene;
  29462. /** @hidden */
  29463. _cache: any;
  29464. private _parentNode;
  29465. private _children;
  29466. /** @hidden */
  29467. _worldMatrix: Matrix;
  29468. /** @hidden */
  29469. _worldMatrixDeterminant: number;
  29470. /** @hidden */
  29471. _worldMatrixDeterminantIsDirty: boolean;
  29472. /** @hidden */
  29473. private _sceneRootNodesIndex;
  29474. /**
  29475. * Gets a boolean indicating if the node has been disposed
  29476. * @returns true if the node was disposed
  29477. */
  29478. isDisposed(): boolean;
  29479. /**
  29480. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29481. * @see https://doc.babylonjs.com/how_to/parenting
  29482. */
  29483. set parent(parent: Nullable<Node>);
  29484. get parent(): Nullable<Node>;
  29485. /** @hidden */
  29486. _addToSceneRootNodes(): void;
  29487. /** @hidden */
  29488. _removeFromSceneRootNodes(): void;
  29489. private _animationPropertiesOverride;
  29490. /**
  29491. * Gets or sets the animation properties override
  29492. */
  29493. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29494. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29495. /**
  29496. * Gets a string idenfifying the name of the class
  29497. * @returns "Node" string
  29498. */
  29499. getClassName(): string;
  29500. /** @hidden */
  29501. readonly _isNode: boolean;
  29502. /**
  29503. * An event triggered when the mesh is disposed
  29504. */
  29505. onDisposeObservable: Observable<Node>;
  29506. private _onDisposeObserver;
  29507. /**
  29508. * Sets a callback that will be raised when the node will be disposed
  29509. */
  29510. set onDispose(callback: () => void);
  29511. /**
  29512. * Creates a new Node
  29513. * @param name the name and id to be given to this node
  29514. * @param scene the scene this node will be added to
  29515. */
  29516. constructor(name: string, scene?: Nullable<Scene>);
  29517. /**
  29518. * Gets the scene of the node
  29519. * @returns a scene
  29520. */
  29521. getScene(): Scene;
  29522. /**
  29523. * Gets the engine of the node
  29524. * @returns a Engine
  29525. */
  29526. getEngine(): Engine;
  29527. private _behaviors;
  29528. /**
  29529. * Attach a behavior to the node
  29530. * @see http://doc.babylonjs.com/features/behaviour
  29531. * @param behavior defines the behavior to attach
  29532. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29533. * @returns the current Node
  29534. */
  29535. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29536. /**
  29537. * Remove an attached behavior
  29538. * @see http://doc.babylonjs.com/features/behaviour
  29539. * @param behavior defines the behavior to attach
  29540. * @returns the current Node
  29541. */
  29542. removeBehavior(behavior: Behavior<Node>): Node;
  29543. /**
  29544. * Gets the list of attached behaviors
  29545. * @see http://doc.babylonjs.com/features/behaviour
  29546. */
  29547. get behaviors(): Behavior<Node>[];
  29548. /**
  29549. * Gets an attached behavior by name
  29550. * @param name defines the name of the behavior to look for
  29551. * @see http://doc.babylonjs.com/features/behaviour
  29552. * @returns null if behavior was not found else the requested behavior
  29553. */
  29554. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29555. /**
  29556. * Returns the latest update of the World matrix
  29557. * @returns a Matrix
  29558. */
  29559. getWorldMatrix(): Matrix;
  29560. /** @hidden */
  29561. _getWorldMatrixDeterminant(): number;
  29562. /**
  29563. * Returns directly the latest state of the mesh World matrix.
  29564. * A Matrix is returned.
  29565. */
  29566. get worldMatrixFromCache(): Matrix;
  29567. /** @hidden */
  29568. _initCache(): void;
  29569. /** @hidden */
  29570. updateCache(force?: boolean): void;
  29571. /** @hidden */
  29572. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29573. /** @hidden */
  29574. _updateCache(ignoreParentClass?: boolean): void;
  29575. /** @hidden */
  29576. _isSynchronized(): boolean;
  29577. /** @hidden */
  29578. _markSyncedWithParent(): void;
  29579. /** @hidden */
  29580. isSynchronizedWithParent(): boolean;
  29581. /** @hidden */
  29582. isSynchronized(): boolean;
  29583. /**
  29584. * Is this node ready to be used/rendered
  29585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29586. * @return true if the node is ready
  29587. */
  29588. isReady(completeCheck?: boolean): boolean;
  29589. /**
  29590. * Is this node enabled?
  29591. * 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
  29592. * @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
  29593. * @return whether this node (and its parent) is enabled
  29594. */
  29595. isEnabled(checkAncestors?: boolean): boolean;
  29596. /** @hidden */
  29597. protected _syncParentEnabledState(): void;
  29598. /**
  29599. * Set the enabled state of this node
  29600. * @param value defines the new enabled state
  29601. */
  29602. setEnabled(value: boolean): void;
  29603. /**
  29604. * Is this node a descendant of the given node?
  29605. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29606. * @param ancestor defines the parent node to inspect
  29607. * @returns a boolean indicating if this node is a descendant of the given node
  29608. */
  29609. isDescendantOf(ancestor: Node): boolean;
  29610. /** @hidden */
  29611. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29612. /**
  29613. * Will return all nodes that have this node as ascendant
  29614. * @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
  29615. * @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
  29616. * @return all children nodes of all types
  29617. */
  29618. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29619. /**
  29620. * Get all child-meshes of this node
  29621. * @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)
  29622. * @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
  29623. * @returns an array of AbstractMesh
  29624. */
  29625. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29626. /**
  29627. * Get all direct children of this node
  29628. * @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
  29629. * @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)
  29630. * @returns an array of Node
  29631. */
  29632. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29633. /** @hidden */
  29634. _setReady(state: boolean): void;
  29635. /**
  29636. * Get an animation by name
  29637. * @param name defines the name of the animation to look for
  29638. * @returns null if not found else the requested animation
  29639. */
  29640. getAnimationByName(name: string): Nullable<Animation>;
  29641. /**
  29642. * Creates an animation range for this node
  29643. * @param name defines the name of the range
  29644. * @param from defines the starting key
  29645. * @param to defines the end key
  29646. */
  29647. createAnimationRange(name: string, from: number, to: number): void;
  29648. /**
  29649. * Delete a specific animation range
  29650. * @param name defines the name of the range to delete
  29651. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29652. */
  29653. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29654. /**
  29655. * Get an animation range by name
  29656. * @param name defines the name of the animation range to look for
  29657. * @returns null if not found else the requested animation range
  29658. */
  29659. getAnimationRange(name: string): Nullable<AnimationRange>;
  29660. /**
  29661. * Gets the list of all animation ranges defined on this node
  29662. * @returns an array
  29663. */
  29664. getAnimationRanges(): Nullable<AnimationRange>[];
  29665. /**
  29666. * Will start the animation sequence
  29667. * @param name defines the range frames for animation sequence
  29668. * @param loop defines if the animation should loop (false by default)
  29669. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29670. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29671. * @returns the object created for this animation. If range does not exist, it will return null
  29672. */
  29673. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29674. /**
  29675. * Serialize animation ranges into a JSON compatible object
  29676. * @returns serialization object
  29677. */
  29678. serializeAnimationRanges(): any;
  29679. /**
  29680. * Computes the world matrix of the node
  29681. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29682. * @returns the world matrix
  29683. */
  29684. computeWorldMatrix(force?: boolean): Matrix;
  29685. /**
  29686. * Releases resources associated with this node.
  29687. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29688. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29689. */
  29690. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29691. /**
  29692. * Parse animation range data from a serialization object and store them into a given node
  29693. * @param node defines where to store the animation ranges
  29694. * @param parsedNode defines the serialization object to read data from
  29695. * @param scene defines the hosting scene
  29696. */
  29697. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29698. /**
  29699. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29700. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29701. * @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
  29702. * @returns the new bounding vectors
  29703. */
  29704. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29705. min: Vector3;
  29706. max: Vector3;
  29707. };
  29708. }
  29709. }
  29710. declare module "babylonjs/Animations/animation" {
  29711. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29712. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29713. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29714. import { Nullable } from "babylonjs/types";
  29715. import { Scene } from "babylonjs/scene";
  29716. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29717. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29718. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29719. import { Node } from "babylonjs/node";
  29720. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29721. import { Size } from "babylonjs/Maths/math.size";
  29722. import { Animatable } from "babylonjs/Animations/animatable";
  29723. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29724. /**
  29725. * @hidden
  29726. */
  29727. export class _IAnimationState {
  29728. key: number;
  29729. repeatCount: number;
  29730. workValue?: any;
  29731. loopMode?: number;
  29732. offsetValue?: any;
  29733. highLimitValue?: any;
  29734. }
  29735. /**
  29736. * Class used to store any kind of animation
  29737. */
  29738. export class Animation {
  29739. /**Name of the animation */
  29740. name: string;
  29741. /**Property to animate */
  29742. targetProperty: string;
  29743. /**The frames per second of the animation */
  29744. framePerSecond: number;
  29745. /**The data type of the animation */
  29746. dataType: number;
  29747. /**The loop mode of the animation */
  29748. loopMode?: number | undefined;
  29749. /**Specifies if blending should be enabled */
  29750. enableBlending?: boolean | undefined;
  29751. /**
  29752. * Use matrix interpolation instead of using direct key value when animating matrices
  29753. */
  29754. static AllowMatricesInterpolation: boolean;
  29755. /**
  29756. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29757. */
  29758. static AllowMatrixDecomposeForInterpolation: boolean;
  29759. /**
  29760. * Stores the key frames of the animation
  29761. */
  29762. private _keys;
  29763. /**
  29764. * Stores the easing function of the animation
  29765. */
  29766. private _easingFunction;
  29767. /**
  29768. * @hidden Internal use only
  29769. */
  29770. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29771. /**
  29772. * The set of event that will be linked to this animation
  29773. */
  29774. private _events;
  29775. /**
  29776. * Stores an array of target property paths
  29777. */
  29778. targetPropertyPath: string[];
  29779. /**
  29780. * Stores the blending speed of the animation
  29781. */
  29782. blendingSpeed: number;
  29783. /**
  29784. * Stores the animation ranges for the animation
  29785. */
  29786. private _ranges;
  29787. /**
  29788. * @hidden Internal use
  29789. */
  29790. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29791. /**
  29792. * Sets up an animation
  29793. * @param property The property to animate
  29794. * @param animationType The animation type to apply
  29795. * @param framePerSecond The frames per second of the animation
  29796. * @param easingFunction The easing function used in the animation
  29797. * @returns The created animation
  29798. */
  29799. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29800. /**
  29801. * Create and start an animation on a node
  29802. * @param name defines the name of the global animation that will be run on all nodes
  29803. * @param node defines the root node where the animation will take place
  29804. * @param targetProperty defines property to animate
  29805. * @param framePerSecond defines the number of frame per second yo use
  29806. * @param totalFrame defines the number of frames in total
  29807. * @param from defines the initial value
  29808. * @param to defines the final value
  29809. * @param loopMode defines which loop mode you want to use (off by default)
  29810. * @param easingFunction defines the easing function to use (linear by default)
  29811. * @param onAnimationEnd defines the callback to call when animation end
  29812. * @returns the animatable created for this animation
  29813. */
  29814. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29815. /**
  29816. * Create and start an animation on a node and its descendants
  29817. * @param name defines the name of the global animation that will be run on all nodes
  29818. * @param node defines the root node where the animation will take place
  29819. * @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
  29820. * @param targetProperty defines property to animate
  29821. * @param framePerSecond defines the number of frame per second to use
  29822. * @param totalFrame defines the number of frames in total
  29823. * @param from defines the initial value
  29824. * @param to defines the final value
  29825. * @param loopMode defines which loop mode you want to use (off by default)
  29826. * @param easingFunction defines the easing function to use (linear by default)
  29827. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29828. * @returns the list of animatables created for all nodes
  29829. * @example https://www.babylonjs-playground.com/#MH0VLI
  29830. */
  29831. 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[]>;
  29832. /**
  29833. * Creates a new animation, merges it with the existing animations and starts it
  29834. * @param name Name of the animation
  29835. * @param node Node which contains the scene that begins the animations
  29836. * @param targetProperty Specifies which property to animate
  29837. * @param framePerSecond The frames per second of the animation
  29838. * @param totalFrame The total number of frames
  29839. * @param from The frame at the beginning of the animation
  29840. * @param to The frame at the end of the animation
  29841. * @param loopMode Specifies the loop mode of the animation
  29842. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29843. * @param onAnimationEnd Callback to run once the animation is complete
  29844. * @returns Nullable animation
  29845. */
  29846. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29847. /**
  29848. * Transition property of an host to the target Value
  29849. * @param property The property to transition
  29850. * @param targetValue The target Value of the property
  29851. * @param host The object where the property to animate belongs
  29852. * @param scene Scene used to run the animation
  29853. * @param frameRate Framerate (in frame/s) to use
  29854. * @param transition The transition type we want to use
  29855. * @param duration The duration of the animation, in milliseconds
  29856. * @param onAnimationEnd Callback trigger at the end of the animation
  29857. * @returns Nullable animation
  29858. */
  29859. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29860. /**
  29861. * Return the array of runtime animations currently using this animation
  29862. */
  29863. get runtimeAnimations(): RuntimeAnimation[];
  29864. /**
  29865. * Specifies if any of the runtime animations are currently running
  29866. */
  29867. get hasRunningRuntimeAnimations(): boolean;
  29868. /**
  29869. * Initializes the animation
  29870. * @param name Name of the animation
  29871. * @param targetProperty Property to animate
  29872. * @param framePerSecond The frames per second of the animation
  29873. * @param dataType The data type of the animation
  29874. * @param loopMode The loop mode of the animation
  29875. * @param enableBlending Specifies if blending should be enabled
  29876. */
  29877. constructor(
  29878. /**Name of the animation */
  29879. name: string,
  29880. /**Property to animate */
  29881. targetProperty: string,
  29882. /**The frames per second of the animation */
  29883. framePerSecond: number,
  29884. /**The data type of the animation */
  29885. dataType: number,
  29886. /**The loop mode of the animation */
  29887. loopMode?: number | undefined,
  29888. /**Specifies if blending should be enabled */
  29889. enableBlending?: boolean | undefined);
  29890. /**
  29891. * Converts the animation to a string
  29892. * @param fullDetails support for multiple levels of logging within scene loading
  29893. * @returns String form of the animation
  29894. */
  29895. toString(fullDetails?: boolean): string;
  29896. /**
  29897. * Add an event to this animation
  29898. * @param event Event to add
  29899. */
  29900. addEvent(event: AnimationEvent): void;
  29901. /**
  29902. * Remove all events found at the given frame
  29903. * @param frame The frame to remove events from
  29904. */
  29905. removeEvents(frame: number): void;
  29906. /**
  29907. * Retrieves all the events from the animation
  29908. * @returns Events from the animation
  29909. */
  29910. getEvents(): AnimationEvent[];
  29911. /**
  29912. * Creates an animation range
  29913. * @param name Name of the animation range
  29914. * @param from Starting frame of the animation range
  29915. * @param to Ending frame of the animation
  29916. */
  29917. createRange(name: string, from: number, to: number): void;
  29918. /**
  29919. * Deletes an animation range by name
  29920. * @param name Name of the animation range to delete
  29921. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29922. */
  29923. deleteRange(name: string, deleteFrames?: boolean): void;
  29924. /**
  29925. * Gets the animation range by name, or null if not defined
  29926. * @param name Name of the animation range
  29927. * @returns Nullable animation range
  29928. */
  29929. getRange(name: string): Nullable<AnimationRange>;
  29930. /**
  29931. * Gets the key frames from the animation
  29932. * @returns The key frames of the animation
  29933. */
  29934. getKeys(): Array<IAnimationKey>;
  29935. /**
  29936. * Gets the highest frame rate of the animation
  29937. * @returns Highest frame rate of the animation
  29938. */
  29939. getHighestFrame(): number;
  29940. /**
  29941. * Gets the easing function of the animation
  29942. * @returns Easing function of the animation
  29943. */
  29944. getEasingFunction(): IEasingFunction;
  29945. /**
  29946. * Sets the easing function of the animation
  29947. * @param easingFunction A custom mathematical formula for animation
  29948. */
  29949. setEasingFunction(easingFunction: EasingFunction): void;
  29950. /**
  29951. * Interpolates a scalar linearly
  29952. * @param startValue Start value of the animation curve
  29953. * @param endValue End value of the animation curve
  29954. * @param gradient Scalar amount to interpolate
  29955. * @returns Interpolated scalar value
  29956. */
  29957. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29958. /**
  29959. * Interpolates a scalar cubically
  29960. * @param startValue Start value of the animation curve
  29961. * @param outTangent End tangent of the animation
  29962. * @param endValue End value of the animation curve
  29963. * @param inTangent Start tangent of the animation curve
  29964. * @param gradient Scalar amount to interpolate
  29965. * @returns Interpolated scalar value
  29966. */
  29967. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29968. /**
  29969. * Interpolates a quaternion using a spherical linear interpolation
  29970. * @param startValue Start value of the animation curve
  29971. * @param endValue End value of the animation curve
  29972. * @param gradient Scalar amount to interpolate
  29973. * @returns Interpolated quaternion value
  29974. */
  29975. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29976. /**
  29977. * Interpolates a quaternion cubically
  29978. * @param startValue Start value of the animation curve
  29979. * @param outTangent End tangent of the animation curve
  29980. * @param endValue End value of the animation curve
  29981. * @param inTangent Start tangent of the animation curve
  29982. * @param gradient Scalar amount to interpolate
  29983. * @returns Interpolated quaternion value
  29984. */
  29985. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29986. /**
  29987. * Interpolates a Vector3 linearl
  29988. * @param startValue Start value of the animation curve
  29989. * @param endValue End value of the animation curve
  29990. * @param gradient Scalar amount to interpolate
  29991. * @returns Interpolated scalar value
  29992. */
  29993. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29994. /**
  29995. * Interpolates a Vector3 cubically
  29996. * @param startValue Start value of the animation curve
  29997. * @param outTangent End tangent of the animation
  29998. * @param endValue End value of the animation curve
  29999. * @param inTangent Start tangent of the animation curve
  30000. * @param gradient Scalar amount to interpolate
  30001. * @returns InterpolatedVector3 value
  30002. */
  30003. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30004. /**
  30005. * Interpolates a Vector2 linearly
  30006. * @param startValue Start value of the animation curve
  30007. * @param endValue End value of the animation curve
  30008. * @param gradient Scalar amount to interpolate
  30009. * @returns Interpolated Vector2 value
  30010. */
  30011. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30012. /**
  30013. * Interpolates a Vector2 cubically
  30014. * @param startValue Start value of the animation curve
  30015. * @param outTangent End tangent of the animation
  30016. * @param endValue End value of the animation curve
  30017. * @param inTangent Start tangent of the animation curve
  30018. * @param gradient Scalar amount to interpolate
  30019. * @returns Interpolated Vector2 value
  30020. */
  30021. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30022. /**
  30023. * Interpolates a size linearly
  30024. * @param startValue Start value of the animation curve
  30025. * @param endValue End value of the animation curve
  30026. * @param gradient Scalar amount to interpolate
  30027. * @returns Interpolated Size value
  30028. */
  30029. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30030. /**
  30031. * Interpolates a Color3 linearly
  30032. * @param startValue Start value of the animation curve
  30033. * @param endValue End value of the animation curve
  30034. * @param gradient Scalar amount to interpolate
  30035. * @returns Interpolated Color3 value
  30036. */
  30037. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30038. /**
  30039. * Interpolates a Color4 linearly
  30040. * @param startValue Start value of the animation curve
  30041. * @param endValue End value of the animation curve
  30042. * @param gradient Scalar amount to interpolate
  30043. * @returns Interpolated Color3 value
  30044. */
  30045. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30046. /**
  30047. * @hidden Internal use only
  30048. */
  30049. _getKeyValue(value: any): any;
  30050. /**
  30051. * @hidden Internal use only
  30052. */
  30053. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30054. /**
  30055. * Defines the function to use to interpolate matrices
  30056. * @param startValue defines the start matrix
  30057. * @param endValue defines the end matrix
  30058. * @param gradient defines the gradient between both matrices
  30059. * @param result defines an optional target matrix where to store the interpolation
  30060. * @returns the interpolated matrix
  30061. */
  30062. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30063. /**
  30064. * Makes a copy of the animation
  30065. * @returns Cloned animation
  30066. */
  30067. clone(): Animation;
  30068. /**
  30069. * Sets the key frames of the animation
  30070. * @param values The animation key frames to set
  30071. */
  30072. setKeys(values: Array<IAnimationKey>): void;
  30073. /**
  30074. * Serializes the animation to an object
  30075. * @returns Serialized object
  30076. */
  30077. serialize(): any;
  30078. /**
  30079. * Float animation type
  30080. */
  30081. static readonly ANIMATIONTYPE_FLOAT: number;
  30082. /**
  30083. * Vector3 animation type
  30084. */
  30085. static readonly ANIMATIONTYPE_VECTOR3: number;
  30086. /**
  30087. * Quaternion animation type
  30088. */
  30089. static readonly ANIMATIONTYPE_QUATERNION: number;
  30090. /**
  30091. * Matrix animation type
  30092. */
  30093. static readonly ANIMATIONTYPE_MATRIX: number;
  30094. /**
  30095. * Color3 animation type
  30096. */
  30097. static readonly ANIMATIONTYPE_COLOR3: number;
  30098. /**
  30099. * Color3 animation type
  30100. */
  30101. static readonly ANIMATIONTYPE_COLOR4: number;
  30102. /**
  30103. * Vector2 animation type
  30104. */
  30105. static readonly ANIMATIONTYPE_VECTOR2: number;
  30106. /**
  30107. * Size animation type
  30108. */
  30109. static readonly ANIMATIONTYPE_SIZE: number;
  30110. /**
  30111. * Relative Loop Mode
  30112. */
  30113. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30114. /**
  30115. * Cycle Loop Mode
  30116. */
  30117. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30118. /**
  30119. * Constant Loop Mode
  30120. */
  30121. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30122. /** @hidden */
  30123. static _UniversalLerp(left: any, right: any, amount: number): any;
  30124. /**
  30125. * Parses an animation object and creates an animation
  30126. * @param parsedAnimation Parsed animation object
  30127. * @returns Animation object
  30128. */
  30129. static Parse(parsedAnimation: any): Animation;
  30130. /**
  30131. * Appends the serialized animations from the source animations
  30132. * @param source Source containing the animations
  30133. * @param destination Target to store the animations
  30134. */
  30135. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30136. }
  30137. }
  30138. declare module "babylonjs/Animations/animatable.interface" {
  30139. import { Nullable } from "babylonjs/types";
  30140. import { Animation } from "babylonjs/Animations/animation";
  30141. /**
  30142. * Interface containing an array of animations
  30143. */
  30144. export interface IAnimatable {
  30145. /**
  30146. * Array of animations
  30147. */
  30148. animations: Nullable<Array<Animation>>;
  30149. }
  30150. }
  30151. declare module "babylonjs/Misc/decorators" {
  30152. import { Nullable } from "babylonjs/types";
  30153. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30154. import { Scene } from "babylonjs/scene";
  30155. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30156. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30157. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30158. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. /**
  30169. * Decorator used to define property that can be serialized as reference to a camera
  30170. * @param sourceName defines the name of the property to decorate
  30171. */
  30172. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30173. /**
  30174. * Class used to help serialization objects
  30175. */
  30176. export class SerializationHelper {
  30177. /** @hidden */
  30178. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30179. /** @hidden */
  30180. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30181. /** @hidden */
  30182. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30183. /** @hidden */
  30184. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30185. /**
  30186. * Appends the serialized animations from the source animations
  30187. * @param source Source containing the animations
  30188. * @param destination Target to store the animations
  30189. */
  30190. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30191. /**
  30192. * Static function used to serialized a specific entity
  30193. * @param entity defines the entity to serialize
  30194. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30195. * @returns a JSON compatible object representing the serialization of the entity
  30196. */
  30197. static Serialize<T>(entity: T, serializationObject?: any): any;
  30198. /**
  30199. * Creates a new entity from a serialization data object
  30200. * @param creationFunction defines a function used to instanciated the new entity
  30201. * @param source defines the source serialization data
  30202. * @param scene defines the hosting scene
  30203. * @param rootUrl defines the root url for resources
  30204. * @returns a new entity
  30205. */
  30206. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30207. /**
  30208. * Clones an object
  30209. * @param creationFunction defines the function used to instanciate the new object
  30210. * @param source defines the source object
  30211. * @returns the cloned object
  30212. */
  30213. static Clone<T>(creationFunction: () => T, source: T): T;
  30214. /**
  30215. * Instanciates a new object based on a source one (some data will be shared between both object)
  30216. * @param creationFunction defines the function used to instanciate the new object
  30217. * @param source defines the source object
  30218. * @returns the new object
  30219. */
  30220. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30221. }
  30222. }
  30223. declare module "babylonjs/Misc/guid" {
  30224. /**
  30225. * Class used to manipulate GUIDs
  30226. */
  30227. export class GUID {
  30228. /**
  30229. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30230. * Be aware Math.random() could cause collisions, but:
  30231. * "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"
  30232. * @returns a pseudo random id
  30233. */
  30234. static RandomId(): string;
  30235. }
  30236. }
  30237. declare module "babylonjs/Materials/Textures/baseTexture" {
  30238. import { Observable } from "babylonjs/Misc/observable";
  30239. import { Nullable } from "babylonjs/types";
  30240. import { Scene } from "babylonjs/scene";
  30241. import { Matrix } from "babylonjs/Maths/math.vector";
  30242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30243. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30244. import { ISize } from "babylonjs/Maths/math.size";
  30245. /**
  30246. * Base class of all the textures in babylon.
  30247. * It groups all the common properties the materials, post process, lights... might need
  30248. * in order to make a correct use of the texture.
  30249. */
  30250. export class BaseTexture implements IAnimatable {
  30251. /**
  30252. * Default anisotropic filtering level for the application.
  30253. * It is set to 4 as a good tradeoff between perf and quality.
  30254. */
  30255. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30256. /**
  30257. * Gets or sets the unique id of the texture
  30258. */
  30259. uniqueId: number;
  30260. /**
  30261. * Define the name of the texture.
  30262. */
  30263. name: string;
  30264. /**
  30265. * Gets or sets an object used to store user defined information.
  30266. */
  30267. metadata: any;
  30268. /**
  30269. * For internal use only. Please do not use.
  30270. */
  30271. reservedDataStore: any;
  30272. private _hasAlpha;
  30273. /**
  30274. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30275. */
  30276. set hasAlpha(value: boolean);
  30277. get hasAlpha(): boolean;
  30278. /**
  30279. * Defines if the alpha value should be determined via the rgb values.
  30280. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30281. */
  30282. getAlphaFromRGB: boolean;
  30283. /**
  30284. * Intensity or strength of the texture.
  30285. * It is commonly used by materials to fine tune the intensity of the texture
  30286. */
  30287. level: number;
  30288. /**
  30289. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30290. * This is part of the texture as textures usually maps to one uv set.
  30291. */
  30292. coordinatesIndex: number;
  30293. private _coordinatesMode;
  30294. /**
  30295. * How a texture is mapped.
  30296. *
  30297. * | Value | Type | Description |
  30298. * | ----- | ----------------------------------- | ----------- |
  30299. * | 0 | EXPLICIT_MODE | |
  30300. * | 1 | SPHERICAL_MODE | |
  30301. * | 2 | PLANAR_MODE | |
  30302. * | 3 | CUBIC_MODE | |
  30303. * | 4 | PROJECTION_MODE | |
  30304. * | 5 | SKYBOX_MODE | |
  30305. * | 6 | INVCUBIC_MODE | |
  30306. * | 7 | EQUIRECTANGULAR_MODE | |
  30307. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30308. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30309. */
  30310. set coordinatesMode(value: number);
  30311. get coordinatesMode(): number;
  30312. /**
  30313. * | Value | Type | Description |
  30314. * | ----- | ------------------ | ----------- |
  30315. * | 0 | CLAMP_ADDRESSMODE | |
  30316. * | 1 | WRAP_ADDRESSMODE | |
  30317. * | 2 | MIRROR_ADDRESSMODE | |
  30318. */
  30319. wrapU: number;
  30320. /**
  30321. * | Value | Type | Description |
  30322. * | ----- | ------------------ | ----------- |
  30323. * | 0 | CLAMP_ADDRESSMODE | |
  30324. * | 1 | WRAP_ADDRESSMODE | |
  30325. * | 2 | MIRROR_ADDRESSMODE | |
  30326. */
  30327. wrapV: number;
  30328. /**
  30329. * | Value | Type | Description |
  30330. * | ----- | ------------------ | ----------- |
  30331. * | 0 | CLAMP_ADDRESSMODE | |
  30332. * | 1 | WRAP_ADDRESSMODE | |
  30333. * | 2 | MIRROR_ADDRESSMODE | |
  30334. */
  30335. wrapR: number;
  30336. /**
  30337. * With compliant hardware and browser (supporting anisotropic filtering)
  30338. * this defines the level of anisotropic filtering in the texture.
  30339. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30340. */
  30341. anisotropicFilteringLevel: number;
  30342. /**
  30343. * Define if the texture is a cube texture or if false a 2d texture.
  30344. */
  30345. get isCube(): boolean;
  30346. set isCube(value: boolean);
  30347. /**
  30348. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30349. */
  30350. get is3D(): boolean;
  30351. set is3D(value: boolean);
  30352. /**
  30353. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30354. */
  30355. get is2DArray(): boolean;
  30356. set is2DArray(value: boolean);
  30357. /**
  30358. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30359. * HDR texture are usually stored in linear space.
  30360. * This only impacts the PBR and Background materials
  30361. */
  30362. gammaSpace: boolean;
  30363. /**
  30364. * Gets or sets whether or not the texture contains RGBD data.
  30365. */
  30366. get isRGBD(): boolean;
  30367. set isRGBD(value: boolean);
  30368. /**
  30369. * Is Z inverted in the texture (useful in a cube texture).
  30370. */
  30371. invertZ: boolean;
  30372. /**
  30373. * Are mip maps generated for this texture or not.
  30374. */
  30375. get noMipmap(): boolean;
  30376. /**
  30377. * @hidden
  30378. */
  30379. lodLevelInAlpha: boolean;
  30380. /**
  30381. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30382. */
  30383. get lodGenerationOffset(): number;
  30384. set lodGenerationOffset(value: number);
  30385. /**
  30386. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30387. */
  30388. get lodGenerationScale(): number;
  30389. set lodGenerationScale(value: number);
  30390. /**
  30391. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30392. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30393. * average roughness values.
  30394. */
  30395. get linearSpecularLOD(): boolean;
  30396. set linearSpecularLOD(value: boolean);
  30397. /**
  30398. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30399. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30400. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30401. */
  30402. get irradianceTexture(): Nullable<BaseTexture>;
  30403. set irradianceTexture(value: Nullable<BaseTexture>);
  30404. /**
  30405. * Define if the texture is a render target.
  30406. */
  30407. isRenderTarget: boolean;
  30408. /**
  30409. * Define the unique id of the texture in the scene.
  30410. */
  30411. get uid(): string;
  30412. /**
  30413. * Return a string representation of the texture.
  30414. * @returns the texture as a string
  30415. */
  30416. toString(): string;
  30417. /**
  30418. * Get the class name of the texture.
  30419. * @returns "BaseTexture"
  30420. */
  30421. getClassName(): string;
  30422. /**
  30423. * Define the list of animation attached to the texture.
  30424. */
  30425. animations: import("babylonjs/Animations/animation").Animation[];
  30426. /**
  30427. * An event triggered when the texture is disposed.
  30428. */
  30429. onDisposeObservable: Observable<BaseTexture>;
  30430. private _onDisposeObserver;
  30431. /**
  30432. * Callback triggered when the texture has been disposed.
  30433. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30434. */
  30435. set onDispose(callback: () => void);
  30436. /**
  30437. * Define the current state of the loading sequence when in delayed load mode.
  30438. */
  30439. delayLoadState: number;
  30440. private _scene;
  30441. /** @hidden */
  30442. _texture: Nullable<InternalTexture>;
  30443. private _uid;
  30444. /**
  30445. * Define if the texture is preventinga material to render or not.
  30446. * If not and the texture is not ready, the engine will use a default black texture instead.
  30447. */
  30448. get isBlocking(): boolean;
  30449. /**
  30450. * Instantiates a new BaseTexture.
  30451. * Base class of all the textures in babylon.
  30452. * It groups all the common properties the materials, post process, lights... might need
  30453. * in order to make a correct use of the texture.
  30454. * @param scene Define the scene the texture blongs to
  30455. */
  30456. constructor(scene: Nullable<Scene>);
  30457. /**
  30458. * Get the scene the texture belongs to.
  30459. * @returns the scene or null if undefined
  30460. */
  30461. getScene(): Nullable<Scene>;
  30462. /**
  30463. * Get the texture transform matrix used to offset tile the texture for istance.
  30464. * @returns the transformation matrix
  30465. */
  30466. getTextureMatrix(): Matrix;
  30467. /**
  30468. * Get the texture reflection matrix used to rotate/transform the reflection.
  30469. * @returns the reflection matrix
  30470. */
  30471. getReflectionTextureMatrix(): Matrix;
  30472. /**
  30473. * Get the underlying lower level texture from Babylon.
  30474. * @returns the insternal texture
  30475. */
  30476. getInternalTexture(): Nullable<InternalTexture>;
  30477. /**
  30478. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30479. * @returns true if ready or not blocking
  30480. */
  30481. isReadyOrNotBlocking(): boolean;
  30482. /**
  30483. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30484. * @returns true if fully ready
  30485. */
  30486. isReady(): boolean;
  30487. private _cachedSize;
  30488. /**
  30489. * Get the size of the texture.
  30490. * @returns the texture size.
  30491. */
  30492. getSize(): ISize;
  30493. /**
  30494. * Get the base size of the texture.
  30495. * It can be different from the size if the texture has been resized for POT for instance
  30496. * @returns the base size
  30497. */
  30498. getBaseSize(): ISize;
  30499. /**
  30500. * Update the sampling mode of the texture.
  30501. * Default is Trilinear mode.
  30502. *
  30503. * | Value | Type | Description |
  30504. * | ----- | ------------------ | ----------- |
  30505. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30506. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30507. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30508. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30509. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30510. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30511. * | 7 | NEAREST_LINEAR | |
  30512. * | 8 | NEAREST_NEAREST | |
  30513. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30514. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30515. * | 11 | LINEAR_LINEAR | |
  30516. * | 12 | LINEAR_NEAREST | |
  30517. *
  30518. * > _mag_: magnification filter (close to the viewer)
  30519. * > _min_: minification filter (far from the viewer)
  30520. * > _mip_: filter used between mip map levels
  30521. *@param samplingMode Define the new sampling mode of the texture
  30522. */
  30523. updateSamplingMode(samplingMode: number): void;
  30524. /**
  30525. * Scales the texture if is `canRescale()`
  30526. * @param ratio the resize factor we want to use to rescale
  30527. */
  30528. scale(ratio: number): void;
  30529. /**
  30530. * Get if the texture can rescale.
  30531. */
  30532. get canRescale(): boolean;
  30533. /** @hidden */
  30534. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30535. /** @hidden */
  30536. _rebuild(): void;
  30537. /**
  30538. * Triggers the load sequence in delayed load mode.
  30539. */
  30540. delayLoad(): void;
  30541. /**
  30542. * Clones the texture.
  30543. * @returns the cloned texture
  30544. */
  30545. clone(): Nullable<BaseTexture>;
  30546. /**
  30547. * Get the texture underlying type (INT, FLOAT...)
  30548. */
  30549. get textureType(): number;
  30550. /**
  30551. * Get the texture underlying format (RGB, RGBA...)
  30552. */
  30553. get textureFormat(): number;
  30554. /**
  30555. * Indicates that textures need to be re-calculated for all materials
  30556. */
  30557. protected _markAllSubMeshesAsTexturesDirty(): void;
  30558. /**
  30559. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30560. * This will returns an RGBA array buffer containing either in values (0-255) or
  30561. * float values (0-1) depending of the underlying buffer type.
  30562. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30563. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30564. * @param buffer defines a user defined buffer to fill with data (can be null)
  30565. * @returns The Array buffer containing the pixels data.
  30566. */
  30567. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30568. /**
  30569. * Release and destroy the underlying lower level texture aka internalTexture.
  30570. */
  30571. releaseInternalTexture(): void;
  30572. /** @hidden */
  30573. get _lodTextureHigh(): Nullable<BaseTexture>;
  30574. /** @hidden */
  30575. get _lodTextureMid(): Nullable<BaseTexture>;
  30576. /** @hidden */
  30577. get _lodTextureLow(): Nullable<BaseTexture>;
  30578. /**
  30579. * Dispose the texture and release its associated resources.
  30580. */
  30581. dispose(): void;
  30582. /**
  30583. * Serialize the texture into a JSON representation that can be parsed later on.
  30584. * @returns the JSON representation of the texture
  30585. */
  30586. serialize(): any;
  30587. /**
  30588. * Helper function to be called back once a list of texture contains only ready textures.
  30589. * @param textures Define the list of textures to wait for
  30590. * @param callback Define the callback triggered once the entire list will be ready
  30591. */
  30592. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30593. }
  30594. }
  30595. declare module "babylonjs/Materials/effect" {
  30596. import { Observable } from "babylonjs/Misc/observable";
  30597. import { Nullable } from "babylonjs/types";
  30598. import { IDisposable } from "babylonjs/scene";
  30599. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30600. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30601. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30602. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30603. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30604. import { Engine } from "babylonjs/Engines/engine";
  30605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30609. /**
  30610. * Options to be used when creating an effect.
  30611. */
  30612. export interface IEffectCreationOptions {
  30613. /**
  30614. * Atrributes that will be used in the shader.
  30615. */
  30616. attributes: string[];
  30617. /**
  30618. * Uniform varible names that will be set in the shader.
  30619. */
  30620. uniformsNames: string[];
  30621. /**
  30622. * Uniform buffer variable names that will be set in the shader.
  30623. */
  30624. uniformBuffersNames: string[];
  30625. /**
  30626. * Sampler texture variable names that will be set in the shader.
  30627. */
  30628. samplers: string[];
  30629. /**
  30630. * Define statements that will be set in the shader.
  30631. */
  30632. defines: any;
  30633. /**
  30634. * Possible fallbacks for this effect to improve performance when needed.
  30635. */
  30636. fallbacks: Nullable<IEffectFallbacks>;
  30637. /**
  30638. * Callback that will be called when the shader is compiled.
  30639. */
  30640. onCompiled: Nullable<(effect: Effect) => void>;
  30641. /**
  30642. * Callback that will be called if an error occurs during shader compilation.
  30643. */
  30644. onError: Nullable<(effect: Effect, errors: string) => void>;
  30645. /**
  30646. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30647. */
  30648. indexParameters?: any;
  30649. /**
  30650. * Max number of lights that can be used in the shader.
  30651. */
  30652. maxSimultaneousLights?: number;
  30653. /**
  30654. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30655. */
  30656. transformFeedbackVaryings?: Nullable<string[]>;
  30657. }
  30658. /**
  30659. * Effect containing vertex and fragment shader that can be executed on an object.
  30660. */
  30661. export class Effect implements IDisposable {
  30662. /**
  30663. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30664. */
  30665. static ShadersRepository: string;
  30666. /**
  30667. * Name of the effect.
  30668. */
  30669. name: any;
  30670. /**
  30671. * String container all the define statements that should be set on the shader.
  30672. */
  30673. defines: string;
  30674. /**
  30675. * Callback that will be called when the shader is compiled.
  30676. */
  30677. onCompiled: Nullable<(effect: Effect) => void>;
  30678. /**
  30679. * Callback that will be called if an error occurs during shader compilation.
  30680. */
  30681. onError: Nullable<(effect: Effect, errors: string) => void>;
  30682. /**
  30683. * Callback that will be called when effect is bound.
  30684. */
  30685. onBind: Nullable<(effect: Effect) => void>;
  30686. /**
  30687. * Unique ID of the effect.
  30688. */
  30689. uniqueId: number;
  30690. /**
  30691. * Observable that will be called when the shader is compiled.
  30692. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30693. */
  30694. onCompileObservable: Observable<Effect>;
  30695. /**
  30696. * Observable that will be called if an error occurs during shader compilation.
  30697. */
  30698. onErrorObservable: Observable<Effect>;
  30699. /** @hidden */
  30700. _onBindObservable: Nullable<Observable<Effect>>;
  30701. /**
  30702. * Observable that will be called when effect is bound.
  30703. */
  30704. get onBindObservable(): Observable<Effect>;
  30705. /** @hidden */
  30706. _bonesComputationForcedToCPU: boolean;
  30707. private static _uniqueIdSeed;
  30708. private _engine;
  30709. private _uniformBuffersNames;
  30710. private _uniformsNames;
  30711. private _samplerList;
  30712. private _samplers;
  30713. private _isReady;
  30714. private _compilationError;
  30715. private _allFallbacksProcessed;
  30716. private _attributesNames;
  30717. private _attributes;
  30718. private _attributeLocationByName;
  30719. private _uniforms;
  30720. /**
  30721. * Key for the effect.
  30722. * @hidden
  30723. */
  30724. _key: string;
  30725. private _indexParameters;
  30726. private _fallbacks;
  30727. private _vertexSourceCode;
  30728. private _fragmentSourceCode;
  30729. private _vertexSourceCodeOverride;
  30730. private _fragmentSourceCodeOverride;
  30731. private _transformFeedbackVaryings;
  30732. /**
  30733. * Compiled shader to webGL program.
  30734. * @hidden
  30735. */
  30736. _pipelineContext: Nullable<IPipelineContext>;
  30737. private _valueCache;
  30738. private static _baseCache;
  30739. /**
  30740. * Instantiates an effect.
  30741. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30742. * @param baseName Name of the effect.
  30743. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30744. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30745. * @param samplers List of sampler variables that will be passed to the shader.
  30746. * @param engine Engine to be used to render the effect
  30747. * @param defines Define statements to be added to the shader.
  30748. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30749. * @param onCompiled Callback that will be called when the shader is compiled.
  30750. * @param onError Callback that will be called if an error occurs during shader compilation.
  30751. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30752. */
  30753. 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);
  30754. private _useFinalCode;
  30755. /**
  30756. * Unique key for this effect
  30757. */
  30758. get key(): string;
  30759. /**
  30760. * If the effect has been compiled and prepared.
  30761. * @returns if the effect is compiled and prepared.
  30762. */
  30763. isReady(): boolean;
  30764. private _isReadyInternal;
  30765. /**
  30766. * The engine the effect was initialized with.
  30767. * @returns the engine.
  30768. */
  30769. getEngine(): Engine;
  30770. /**
  30771. * The pipeline context for this effect
  30772. * @returns the associated pipeline context
  30773. */
  30774. getPipelineContext(): Nullable<IPipelineContext>;
  30775. /**
  30776. * The set of names of attribute variables for the shader.
  30777. * @returns An array of attribute names.
  30778. */
  30779. getAttributesNames(): string[];
  30780. /**
  30781. * Returns the attribute at the given index.
  30782. * @param index The index of the attribute.
  30783. * @returns The location of the attribute.
  30784. */
  30785. getAttributeLocation(index: number): number;
  30786. /**
  30787. * Returns the attribute based on the name of the variable.
  30788. * @param name of the attribute to look up.
  30789. * @returns the attribute location.
  30790. */
  30791. getAttributeLocationByName(name: string): number;
  30792. /**
  30793. * The number of attributes.
  30794. * @returns the numnber of attributes.
  30795. */
  30796. getAttributesCount(): number;
  30797. /**
  30798. * Gets the index of a uniform variable.
  30799. * @param uniformName of the uniform to look up.
  30800. * @returns the index.
  30801. */
  30802. getUniformIndex(uniformName: string): number;
  30803. /**
  30804. * Returns the attribute based on the name of the variable.
  30805. * @param uniformName of the uniform to look up.
  30806. * @returns the location of the uniform.
  30807. */
  30808. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30809. /**
  30810. * Returns an array of sampler variable names
  30811. * @returns The array of sampler variable neames.
  30812. */
  30813. getSamplers(): string[];
  30814. /**
  30815. * The error from the last compilation.
  30816. * @returns the error string.
  30817. */
  30818. getCompilationError(): string;
  30819. /**
  30820. * Gets a boolean indicating that all fallbacks were used during compilation
  30821. * @returns true if all fallbacks were used
  30822. */
  30823. allFallbacksProcessed(): boolean;
  30824. /**
  30825. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30826. * @param func The callback to be used.
  30827. */
  30828. executeWhenCompiled(func: (effect: Effect) => void): void;
  30829. private _checkIsReady;
  30830. private _loadShader;
  30831. /**
  30832. * Recompiles the webGL program
  30833. * @param vertexSourceCode The source code for the vertex shader.
  30834. * @param fragmentSourceCode The source code for the fragment shader.
  30835. * @param onCompiled Callback called when completed.
  30836. * @param onError Callback called on error.
  30837. * @hidden
  30838. */
  30839. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30840. /**
  30841. * Prepares the effect
  30842. * @hidden
  30843. */
  30844. _prepareEffect(): void;
  30845. private _processCompilationErrors;
  30846. /**
  30847. * Checks if the effect is supported. (Must be called after compilation)
  30848. */
  30849. get isSupported(): boolean;
  30850. /**
  30851. * Binds a texture to the engine to be used as output of the shader.
  30852. * @param channel Name of the output variable.
  30853. * @param texture Texture to bind.
  30854. * @hidden
  30855. */
  30856. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30857. /**
  30858. * Sets a texture on the engine to be used in the shader.
  30859. * @param channel Name of the sampler variable.
  30860. * @param texture Texture to set.
  30861. */
  30862. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30863. /**
  30864. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30865. * @param channel Name of the sampler variable.
  30866. * @param texture Texture to set.
  30867. */
  30868. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30869. /**
  30870. * Sets an array of textures on the engine to be used in the shader.
  30871. * @param channel Name of the variable.
  30872. * @param textures Textures to set.
  30873. */
  30874. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30875. /**
  30876. * 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)
  30877. * @param channel Name of the sampler variable.
  30878. * @param postProcess Post process to get the input texture from.
  30879. */
  30880. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30881. /**
  30882. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30883. * 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)
  30884. * @param channel Name of the sampler variable.
  30885. * @param postProcess Post process to get the output texture from.
  30886. */
  30887. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30888. /** @hidden */
  30889. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30890. /** @hidden */
  30891. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30892. /** @hidden */
  30893. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30894. /** @hidden */
  30895. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30896. /**
  30897. * Binds a buffer to a uniform.
  30898. * @param buffer Buffer to bind.
  30899. * @param name Name of the uniform variable to bind to.
  30900. */
  30901. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30902. /**
  30903. * Binds block to a uniform.
  30904. * @param blockName Name of the block to bind.
  30905. * @param index Index to bind.
  30906. */
  30907. bindUniformBlock(blockName: string, index: number): void;
  30908. /**
  30909. * Sets an interger value on a uniform variable.
  30910. * @param uniformName Name of the variable.
  30911. * @param value Value to be set.
  30912. * @returns this effect.
  30913. */
  30914. setInt(uniformName: string, value: number): Effect;
  30915. /**
  30916. * Sets an int array on a uniform variable.
  30917. * @param uniformName Name of the variable.
  30918. * @param array array to be set.
  30919. * @returns this effect.
  30920. */
  30921. setIntArray(uniformName: string, array: Int32Array): Effect;
  30922. /**
  30923. * 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)
  30924. * @param uniformName Name of the variable.
  30925. * @param array array to be set.
  30926. * @returns this effect.
  30927. */
  30928. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30929. /**
  30930. * 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)
  30931. * @param uniformName Name of the variable.
  30932. * @param array array to be set.
  30933. * @returns this effect.
  30934. */
  30935. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30936. /**
  30937. * 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)
  30938. * @param uniformName Name of the variable.
  30939. * @param array array to be set.
  30940. * @returns this effect.
  30941. */
  30942. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30943. /**
  30944. * Sets an float array on a uniform variable.
  30945. * @param uniformName Name of the variable.
  30946. * @param array array to be set.
  30947. * @returns this effect.
  30948. */
  30949. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30950. /**
  30951. * 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)
  30952. * @param uniformName Name of the variable.
  30953. * @param array array to be set.
  30954. * @returns this effect.
  30955. */
  30956. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30957. /**
  30958. * 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)
  30959. * @param uniformName Name of the variable.
  30960. * @param array array to be set.
  30961. * @returns this effect.
  30962. */
  30963. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30964. /**
  30965. * 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)
  30966. * @param uniformName Name of the variable.
  30967. * @param array array to be set.
  30968. * @returns this effect.
  30969. */
  30970. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30971. /**
  30972. * Sets an array on a uniform variable.
  30973. * @param uniformName Name of the variable.
  30974. * @param array array to be set.
  30975. * @returns this effect.
  30976. */
  30977. setArray(uniformName: string, array: number[]): Effect;
  30978. /**
  30979. * 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)
  30980. * @param uniformName Name of the variable.
  30981. * @param array array to be set.
  30982. * @returns this effect.
  30983. */
  30984. setArray2(uniformName: string, array: number[]): Effect;
  30985. /**
  30986. * 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)
  30987. * @param uniformName Name of the variable.
  30988. * @param array array to be set.
  30989. * @returns this effect.
  30990. */
  30991. setArray3(uniformName: string, array: number[]): Effect;
  30992. /**
  30993. * 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)
  30994. * @param uniformName Name of the variable.
  30995. * @param array array to be set.
  30996. * @returns this effect.
  30997. */
  30998. setArray4(uniformName: string, array: number[]): Effect;
  30999. /**
  31000. * Sets matrices on a uniform variable.
  31001. * @param uniformName Name of the variable.
  31002. * @param matrices matrices to be set.
  31003. * @returns this effect.
  31004. */
  31005. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31006. /**
  31007. * Sets matrix on a uniform variable.
  31008. * @param uniformName Name of the variable.
  31009. * @param matrix matrix to be set.
  31010. * @returns this effect.
  31011. */
  31012. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31013. /**
  31014. * 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)
  31015. * @param uniformName Name of the variable.
  31016. * @param matrix matrix to be set.
  31017. * @returns this effect.
  31018. */
  31019. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31020. /**
  31021. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31022. * @param uniformName Name of the variable.
  31023. * @param matrix matrix to be set.
  31024. * @returns this effect.
  31025. */
  31026. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31027. /**
  31028. * Sets a float on a uniform variable.
  31029. * @param uniformName Name of the variable.
  31030. * @param value value to be set.
  31031. * @returns this effect.
  31032. */
  31033. setFloat(uniformName: string, value: number): Effect;
  31034. /**
  31035. * Sets a boolean on a uniform variable.
  31036. * @param uniformName Name of the variable.
  31037. * @param bool value to be set.
  31038. * @returns this effect.
  31039. */
  31040. setBool(uniformName: string, bool: boolean): Effect;
  31041. /**
  31042. * Sets a Vector2 on a uniform variable.
  31043. * @param uniformName Name of the variable.
  31044. * @param vector2 vector2 to be set.
  31045. * @returns this effect.
  31046. */
  31047. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31048. /**
  31049. * Sets a float2 on a uniform variable.
  31050. * @param uniformName Name of the variable.
  31051. * @param x First float in float2.
  31052. * @param y Second float in float2.
  31053. * @returns this effect.
  31054. */
  31055. setFloat2(uniformName: string, x: number, y: number): Effect;
  31056. /**
  31057. * Sets a Vector3 on a uniform variable.
  31058. * @param uniformName Name of the variable.
  31059. * @param vector3 Value to be set.
  31060. * @returns this effect.
  31061. */
  31062. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31063. /**
  31064. * Sets a float3 on a uniform variable.
  31065. * @param uniformName Name of the variable.
  31066. * @param x First float in float3.
  31067. * @param y Second float in float3.
  31068. * @param z Third float in float3.
  31069. * @returns this effect.
  31070. */
  31071. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31072. /**
  31073. * Sets a Vector4 on a uniform variable.
  31074. * @param uniformName Name of the variable.
  31075. * @param vector4 Value to be set.
  31076. * @returns this effect.
  31077. */
  31078. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31079. /**
  31080. * Sets a float4 on a uniform variable.
  31081. * @param uniformName Name of the variable.
  31082. * @param x First float in float4.
  31083. * @param y Second float in float4.
  31084. * @param z Third float in float4.
  31085. * @param w Fourth float in float4.
  31086. * @returns this effect.
  31087. */
  31088. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31089. /**
  31090. * Sets a Color3 on a uniform variable.
  31091. * @param uniformName Name of the variable.
  31092. * @param color3 Value to be set.
  31093. * @returns this effect.
  31094. */
  31095. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31096. /**
  31097. * Sets a Color4 on a uniform variable.
  31098. * @param uniformName Name of the variable.
  31099. * @param color3 Value to be set.
  31100. * @param alpha Alpha value to be set.
  31101. * @returns this effect.
  31102. */
  31103. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31104. /**
  31105. * Sets a Color4 on a uniform variable
  31106. * @param uniformName defines the name of the variable
  31107. * @param color4 defines the value to be set
  31108. * @returns this effect.
  31109. */
  31110. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31111. /** Release all associated resources */
  31112. dispose(): void;
  31113. /**
  31114. * This function will add a new shader to the shader store
  31115. * @param name the name of the shader
  31116. * @param pixelShader optional pixel shader content
  31117. * @param vertexShader optional vertex shader content
  31118. */
  31119. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31120. /**
  31121. * Store of each shader (The can be looked up using effect.key)
  31122. */
  31123. static ShadersStore: {
  31124. [key: string]: string;
  31125. };
  31126. /**
  31127. * Store of each included file for a shader (The can be looked up using effect.key)
  31128. */
  31129. static IncludesShadersStore: {
  31130. [key: string]: string;
  31131. };
  31132. /**
  31133. * Resets the cache of effects.
  31134. */
  31135. static ResetCache(): void;
  31136. }
  31137. }
  31138. declare module "babylonjs/Engines/engineCapabilities" {
  31139. /**
  31140. * Interface used to describe the capabilities of the engine relatively to the current browser
  31141. */
  31142. export interface EngineCapabilities {
  31143. /** Maximum textures units per fragment shader */
  31144. maxTexturesImageUnits: number;
  31145. /** Maximum texture units per vertex shader */
  31146. maxVertexTextureImageUnits: number;
  31147. /** Maximum textures units in the entire pipeline */
  31148. maxCombinedTexturesImageUnits: number;
  31149. /** Maximum texture size */
  31150. maxTextureSize: number;
  31151. /** Maximum texture samples */
  31152. maxSamples?: number;
  31153. /** Maximum cube texture size */
  31154. maxCubemapTextureSize: number;
  31155. /** Maximum render texture size */
  31156. maxRenderTextureSize: number;
  31157. /** Maximum number of vertex attributes */
  31158. maxVertexAttribs: number;
  31159. /** Maximum number of varyings */
  31160. maxVaryingVectors: number;
  31161. /** Maximum number of uniforms per vertex shader */
  31162. maxVertexUniformVectors: number;
  31163. /** Maximum number of uniforms per fragment shader */
  31164. maxFragmentUniformVectors: number;
  31165. /** Defines if standard derivates (dx/dy) are supported */
  31166. standardDerivatives: boolean;
  31167. /** Defines if s3tc texture compression is supported */
  31168. s3tc?: WEBGL_compressed_texture_s3tc;
  31169. /** Defines if pvrtc texture compression is supported */
  31170. pvrtc: any;
  31171. /** Defines if etc1 texture compression is supported */
  31172. etc1: any;
  31173. /** Defines if etc2 texture compression is supported */
  31174. etc2: any;
  31175. /** Defines if astc texture compression is supported */
  31176. astc: any;
  31177. /** Defines if float textures are supported */
  31178. textureFloat: boolean;
  31179. /** Defines if vertex array objects are supported */
  31180. vertexArrayObject: boolean;
  31181. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31182. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31183. /** Gets the maximum level of anisotropy supported */
  31184. maxAnisotropy: number;
  31185. /** Defines if instancing is supported */
  31186. instancedArrays: boolean;
  31187. /** Defines if 32 bits indices are supported */
  31188. uintIndices: boolean;
  31189. /** Defines if high precision shaders are supported */
  31190. highPrecisionShaderSupported: boolean;
  31191. /** Defines if depth reading in the fragment shader is supported */
  31192. fragmentDepthSupported: boolean;
  31193. /** Defines if float texture linear filtering is supported*/
  31194. textureFloatLinearFiltering: boolean;
  31195. /** Defines if rendering to float textures is supported */
  31196. textureFloatRender: boolean;
  31197. /** Defines if half float textures are supported*/
  31198. textureHalfFloat: boolean;
  31199. /** Defines if half float texture linear filtering is supported*/
  31200. textureHalfFloatLinearFiltering: boolean;
  31201. /** Defines if rendering to half float textures is supported */
  31202. textureHalfFloatRender: boolean;
  31203. /** Defines if textureLOD shader command is supported */
  31204. textureLOD: boolean;
  31205. /** Defines if draw buffers extension is supported */
  31206. drawBuffersExtension: boolean;
  31207. /** Defines if depth textures are supported */
  31208. depthTextureExtension: boolean;
  31209. /** Defines if float color buffer are supported */
  31210. colorBufferFloat: boolean;
  31211. /** Gets disjoint timer query extension (null if not supported) */
  31212. timerQuery?: EXT_disjoint_timer_query;
  31213. /** Defines if timestamp can be used with timer query */
  31214. canUseTimestampForTimerQuery: boolean;
  31215. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31216. multiview?: any;
  31217. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31218. oculusMultiview?: any;
  31219. /** Function used to let the system compiles shaders in background */
  31220. parallelShaderCompile?: {
  31221. COMPLETION_STATUS_KHR: number;
  31222. };
  31223. /** Max number of texture samples for MSAA */
  31224. maxMSAASamples: number;
  31225. /** Defines if the blend min max extension is supported */
  31226. blendMinMax: boolean;
  31227. }
  31228. }
  31229. declare module "babylonjs/States/depthCullingState" {
  31230. import { Nullable } from "babylonjs/types";
  31231. /**
  31232. * @hidden
  31233. **/
  31234. export class DepthCullingState {
  31235. private _isDepthTestDirty;
  31236. private _isDepthMaskDirty;
  31237. private _isDepthFuncDirty;
  31238. private _isCullFaceDirty;
  31239. private _isCullDirty;
  31240. private _isZOffsetDirty;
  31241. private _isFrontFaceDirty;
  31242. private _depthTest;
  31243. private _depthMask;
  31244. private _depthFunc;
  31245. private _cull;
  31246. private _cullFace;
  31247. private _zOffset;
  31248. private _frontFace;
  31249. /**
  31250. * Initializes the state.
  31251. */
  31252. constructor();
  31253. get isDirty(): boolean;
  31254. get zOffset(): number;
  31255. set zOffset(value: number);
  31256. get cullFace(): Nullable<number>;
  31257. set cullFace(value: Nullable<number>);
  31258. get cull(): Nullable<boolean>;
  31259. set cull(value: Nullable<boolean>);
  31260. get depthFunc(): Nullable<number>;
  31261. set depthFunc(value: Nullable<number>);
  31262. get depthMask(): boolean;
  31263. set depthMask(value: boolean);
  31264. get depthTest(): boolean;
  31265. set depthTest(value: boolean);
  31266. get frontFace(): Nullable<number>;
  31267. set frontFace(value: Nullable<number>);
  31268. reset(): void;
  31269. apply(gl: WebGLRenderingContext): void;
  31270. }
  31271. }
  31272. declare module "babylonjs/States/stencilState" {
  31273. /**
  31274. * @hidden
  31275. **/
  31276. export class StencilState {
  31277. /** 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 */
  31278. static readonly ALWAYS: number;
  31279. /** Passed to stencilOperation to specify that stencil value must be kept */
  31280. static readonly KEEP: number;
  31281. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31282. static readonly REPLACE: number;
  31283. private _isStencilTestDirty;
  31284. private _isStencilMaskDirty;
  31285. private _isStencilFuncDirty;
  31286. private _isStencilOpDirty;
  31287. private _stencilTest;
  31288. private _stencilMask;
  31289. private _stencilFunc;
  31290. private _stencilFuncRef;
  31291. private _stencilFuncMask;
  31292. private _stencilOpStencilFail;
  31293. private _stencilOpDepthFail;
  31294. private _stencilOpStencilDepthPass;
  31295. get isDirty(): boolean;
  31296. get stencilFunc(): number;
  31297. set stencilFunc(value: number);
  31298. get stencilFuncRef(): number;
  31299. set stencilFuncRef(value: number);
  31300. get stencilFuncMask(): number;
  31301. set stencilFuncMask(value: number);
  31302. get stencilOpStencilFail(): number;
  31303. set stencilOpStencilFail(value: number);
  31304. get stencilOpDepthFail(): number;
  31305. set stencilOpDepthFail(value: number);
  31306. get stencilOpStencilDepthPass(): number;
  31307. set stencilOpStencilDepthPass(value: number);
  31308. get stencilMask(): number;
  31309. set stencilMask(value: number);
  31310. get stencilTest(): boolean;
  31311. set stencilTest(value: boolean);
  31312. constructor();
  31313. reset(): void;
  31314. apply(gl: WebGLRenderingContext): void;
  31315. }
  31316. }
  31317. declare module "babylonjs/States/alphaCullingState" {
  31318. /**
  31319. * @hidden
  31320. **/
  31321. export class AlphaState {
  31322. private _isAlphaBlendDirty;
  31323. private _isBlendFunctionParametersDirty;
  31324. private _isBlendEquationParametersDirty;
  31325. private _isBlendConstantsDirty;
  31326. private _alphaBlend;
  31327. private _blendFunctionParameters;
  31328. private _blendEquationParameters;
  31329. private _blendConstants;
  31330. /**
  31331. * Initializes the state.
  31332. */
  31333. constructor();
  31334. get isDirty(): boolean;
  31335. get alphaBlend(): boolean;
  31336. set alphaBlend(value: boolean);
  31337. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31338. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31339. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31340. reset(): void;
  31341. apply(gl: WebGLRenderingContext): void;
  31342. }
  31343. }
  31344. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31345. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31346. /** @hidden */
  31347. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31348. attributeProcessor(attribute: string): string;
  31349. varyingProcessor(varying: string, isFragment: boolean): string;
  31350. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31351. }
  31352. }
  31353. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31354. /**
  31355. * Interface for attribute information associated with buffer instanciation
  31356. */
  31357. export interface InstancingAttributeInfo {
  31358. /**
  31359. * Name of the GLSL attribute
  31360. * if attribute index is not specified, this is used to retrieve the index from the effect
  31361. */
  31362. attributeName: string;
  31363. /**
  31364. * Index/offset of the attribute in the vertex shader
  31365. * if not specified, this will be computes from the name.
  31366. */
  31367. index?: number;
  31368. /**
  31369. * size of the attribute, 1, 2, 3 or 4
  31370. */
  31371. attributeSize: number;
  31372. /**
  31373. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31374. */
  31375. offset: number;
  31376. /**
  31377. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31378. * default to 1
  31379. */
  31380. divisor?: number;
  31381. /**
  31382. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31383. * default is FLOAT
  31384. */
  31385. attributeType?: number;
  31386. /**
  31387. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31388. */
  31389. normalized?: boolean;
  31390. }
  31391. }
  31392. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31394. import { Nullable } from "babylonjs/types";
  31395. module "babylonjs/Engines/thinEngine" {
  31396. interface ThinEngine {
  31397. /**
  31398. * Update a video texture
  31399. * @param texture defines the texture to update
  31400. * @param video defines the video element to use
  31401. * @param invertY defines if data must be stored with Y axis inverted
  31402. */
  31403. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31404. }
  31405. }
  31406. }
  31407. declare module "babylonjs/Materials/Textures/videoTexture" {
  31408. import { Observable } from "babylonjs/Misc/observable";
  31409. import { Nullable } from "babylonjs/types";
  31410. import { Scene } from "babylonjs/scene";
  31411. import { Texture } from "babylonjs/Materials/Textures/texture";
  31412. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31413. /**
  31414. * Settings for finer control over video usage
  31415. */
  31416. export interface VideoTextureSettings {
  31417. /**
  31418. * Applies `autoplay` to video, if specified
  31419. */
  31420. autoPlay?: boolean;
  31421. /**
  31422. * Applies `loop` to video, if specified
  31423. */
  31424. loop?: boolean;
  31425. /**
  31426. * Automatically updates internal texture from video at every frame in the render loop
  31427. */
  31428. autoUpdateTexture: boolean;
  31429. /**
  31430. * Image src displayed during the video loading or until the user interacts with the video.
  31431. */
  31432. poster?: string;
  31433. }
  31434. /**
  31435. * If you want to display a video in your scene, this is the special texture for that.
  31436. * This special texture works similar to other textures, with the exception of a few parameters.
  31437. * @see https://doc.babylonjs.com/how_to/video_texture
  31438. */
  31439. export class VideoTexture extends Texture {
  31440. /**
  31441. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31442. */
  31443. readonly autoUpdateTexture: boolean;
  31444. /**
  31445. * The video instance used by the texture internally
  31446. */
  31447. readonly video: HTMLVideoElement;
  31448. private _onUserActionRequestedObservable;
  31449. /**
  31450. * Event triggerd when a dom action is required by the user to play the video.
  31451. * This happens due to recent changes in browser policies preventing video to auto start.
  31452. */
  31453. get onUserActionRequestedObservable(): Observable<Texture>;
  31454. private _generateMipMaps;
  31455. private _engine;
  31456. private _stillImageCaptured;
  31457. private _displayingPosterTexture;
  31458. private _settings;
  31459. private _createInternalTextureOnEvent;
  31460. private _frameId;
  31461. /**
  31462. * Creates a video texture.
  31463. * If you want to display a video in your scene, this is the special texture for that.
  31464. * This special texture works similar to other textures, with the exception of a few parameters.
  31465. * @see https://doc.babylonjs.com/how_to/video_texture
  31466. * @param name optional name, will detect from video source, if not defined
  31467. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31468. * @param scene is obviously the current scene.
  31469. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31470. * @param invertY is false by default but can be used to invert video on Y axis
  31471. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31472. * @param settings allows finer control over video usage
  31473. */
  31474. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31475. private _getName;
  31476. private _getVideo;
  31477. private _createInternalTexture;
  31478. private reset;
  31479. /**
  31480. * @hidden Internal method to initiate `update`.
  31481. */
  31482. _rebuild(): void;
  31483. /**
  31484. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31485. */
  31486. update(): void;
  31487. /**
  31488. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31489. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31490. */
  31491. updateTexture(isVisible: boolean): void;
  31492. protected _updateInternalTexture: () => void;
  31493. /**
  31494. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31495. * @param url New url.
  31496. */
  31497. updateURL(url: string): void;
  31498. /**
  31499. * Dispose the texture and release its associated resources.
  31500. */
  31501. dispose(): void;
  31502. /**
  31503. * Creates a video texture straight from a stream.
  31504. * @param scene Define the scene the texture should be created in
  31505. * @param stream Define the stream the texture should be created from
  31506. * @returns The created video texture as a promise
  31507. */
  31508. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31509. /**
  31510. * Creates a video texture straight from your WebCam video feed.
  31511. * @param scene Define the scene the texture should be created in
  31512. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31513. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31514. * @returns The created video texture as a promise
  31515. */
  31516. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31517. minWidth: number;
  31518. maxWidth: number;
  31519. minHeight: number;
  31520. maxHeight: number;
  31521. deviceId: string;
  31522. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31523. /**
  31524. * Creates a video texture straight from your WebCam video feed.
  31525. * @param scene Define the scene the texture should be created in
  31526. * @param onReady Define a callback to triggered once the texture will be ready
  31527. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31528. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31529. */
  31530. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31531. minWidth: number;
  31532. maxWidth: number;
  31533. minHeight: number;
  31534. maxHeight: number;
  31535. deviceId: string;
  31536. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31537. }
  31538. }
  31539. declare module "babylonjs/Engines/thinEngine" {
  31540. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31541. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31542. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31543. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31544. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31545. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31546. import { Observable } from "babylonjs/Misc/observable";
  31547. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31548. import { StencilState } from "babylonjs/States/stencilState";
  31549. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31550. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31551. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31553. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31554. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31555. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31556. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31557. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31559. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31560. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31561. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31562. /**
  31563. * Defines the interface used by objects working like Scene
  31564. * @hidden
  31565. */
  31566. interface ISceneLike {
  31567. _addPendingData(data: any): void;
  31568. _removePendingData(data: any): void;
  31569. offlineProvider: IOfflineProvider;
  31570. }
  31571. /** Interface defining initialization parameters for Engine class */
  31572. export interface EngineOptions extends WebGLContextAttributes {
  31573. /**
  31574. * Defines if the engine should no exceed a specified device ratio
  31575. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31576. */
  31577. limitDeviceRatio?: number;
  31578. /**
  31579. * Defines if webvr should be enabled automatically
  31580. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31581. */
  31582. autoEnableWebVR?: boolean;
  31583. /**
  31584. * Defines if webgl2 should be turned off even if supported
  31585. * @see http://doc.babylonjs.com/features/webgl2
  31586. */
  31587. disableWebGL2Support?: boolean;
  31588. /**
  31589. * Defines if webaudio should be initialized as well
  31590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31591. */
  31592. audioEngine?: boolean;
  31593. /**
  31594. * Defines if animations should run using a deterministic lock step
  31595. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31596. */
  31597. deterministicLockstep?: boolean;
  31598. /** Defines the maximum steps to use with deterministic lock step mode */
  31599. lockstepMaxSteps?: number;
  31600. /** Defines the seconds between each deterministic lock step */
  31601. timeStep?: number;
  31602. /**
  31603. * Defines that engine should ignore context lost events
  31604. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31605. */
  31606. doNotHandleContextLost?: boolean;
  31607. /**
  31608. * Defines that engine should ignore modifying touch action attribute and style
  31609. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31610. */
  31611. doNotHandleTouchAction?: boolean;
  31612. /**
  31613. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31614. */
  31615. useHighPrecisionFloats?: boolean;
  31616. }
  31617. /**
  31618. * The base engine class (root of all engines)
  31619. */
  31620. export class ThinEngine {
  31621. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31622. static ExceptionList: ({
  31623. key: string;
  31624. capture: string;
  31625. captureConstraint: number;
  31626. targets: string[];
  31627. } | {
  31628. key: string;
  31629. capture: null;
  31630. captureConstraint: null;
  31631. targets: string[];
  31632. })[];
  31633. /** @hidden */
  31634. static _TextureLoaders: IInternalTextureLoader[];
  31635. /**
  31636. * Returns the current npm package of the sdk
  31637. */
  31638. static get NpmPackage(): string;
  31639. /**
  31640. * Returns the current version of the framework
  31641. */
  31642. static get Version(): string;
  31643. /**
  31644. * Returns a string describing the current engine
  31645. */
  31646. get description(): string;
  31647. /**
  31648. * Gets or sets the epsilon value used by collision engine
  31649. */
  31650. static CollisionsEpsilon: number;
  31651. /**
  31652. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31653. */
  31654. static get ShadersRepository(): string;
  31655. static set ShadersRepository(value: string);
  31656. /**
  31657. * Gets or sets the textures that the engine should not attempt to load as compressed
  31658. */
  31659. protected _excludedCompressedTextures: string[];
  31660. /**
  31661. * Filters the compressed texture formats to only include
  31662. * files that are not included in the skippable list
  31663. *
  31664. * @param url the current extension
  31665. * @param textureFormatInUse the current compressed texture format
  31666. * @returns "format" string
  31667. */
  31668. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31669. /** @hidden */
  31670. _shaderProcessor: IShaderProcessor;
  31671. /**
  31672. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31673. */
  31674. forcePOTTextures: boolean;
  31675. /**
  31676. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31677. */
  31678. isFullscreen: boolean;
  31679. /**
  31680. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31681. */
  31682. cullBackFaces: boolean;
  31683. /**
  31684. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31685. */
  31686. renderEvenInBackground: boolean;
  31687. /**
  31688. * Gets or sets a boolean indicating that cache can be kept between frames
  31689. */
  31690. preventCacheWipeBetweenFrames: boolean;
  31691. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31692. validateShaderPrograms: boolean;
  31693. /**
  31694. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31695. * This can provide greater z depth for distant objects.
  31696. */
  31697. useReverseDepthBuffer: boolean;
  31698. /**
  31699. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31700. */
  31701. disableUniformBuffers: boolean;
  31702. /** @hidden */
  31703. _uniformBuffers: UniformBuffer[];
  31704. /**
  31705. * Gets a boolean indicating that the engine supports uniform buffers
  31706. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31707. */
  31708. get supportsUniformBuffers(): boolean;
  31709. /** @hidden */
  31710. _gl: WebGLRenderingContext;
  31711. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31712. protected _windowIsBackground: boolean;
  31713. protected _webGLVersion: number;
  31714. protected _creationOptions: EngineOptions;
  31715. protected _highPrecisionShadersAllowed: boolean;
  31716. /** @hidden */
  31717. get _shouldUseHighPrecisionShader(): boolean;
  31718. /**
  31719. * Gets a boolean indicating that only power of 2 textures are supported
  31720. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31721. */
  31722. get needPOTTextures(): boolean;
  31723. /** @hidden */
  31724. _badOS: boolean;
  31725. /** @hidden */
  31726. _badDesktopOS: boolean;
  31727. private _hardwareScalingLevel;
  31728. /** @hidden */
  31729. _caps: EngineCapabilities;
  31730. private _isStencilEnable;
  31731. private _glVersion;
  31732. private _glRenderer;
  31733. private _glVendor;
  31734. /** @hidden */
  31735. _videoTextureSupported: boolean;
  31736. protected _renderingQueueLaunched: boolean;
  31737. protected _activeRenderLoops: (() => void)[];
  31738. /**
  31739. * Observable signaled when a context lost event is raised
  31740. */
  31741. onContextLostObservable: Observable<ThinEngine>;
  31742. /**
  31743. * Observable signaled when a context restored event is raised
  31744. */
  31745. onContextRestoredObservable: Observable<ThinEngine>;
  31746. private _onContextLost;
  31747. private _onContextRestored;
  31748. protected _contextWasLost: boolean;
  31749. /** @hidden */
  31750. _doNotHandleContextLost: boolean;
  31751. /**
  31752. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31754. */
  31755. get doNotHandleContextLost(): boolean;
  31756. set doNotHandleContextLost(value: boolean);
  31757. /**
  31758. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31759. */
  31760. disableVertexArrayObjects: boolean;
  31761. /** @hidden */
  31762. protected _colorWrite: boolean;
  31763. /** @hidden */
  31764. protected _colorWriteChanged: boolean;
  31765. /** @hidden */
  31766. protected _depthCullingState: DepthCullingState;
  31767. /** @hidden */
  31768. protected _stencilState: StencilState;
  31769. /** @hidden */
  31770. _alphaState: AlphaState;
  31771. /** @hidden */
  31772. _alphaMode: number;
  31773. /** @hidden */
  31774. _alphaEquation: number;
  31775. /** @hidden */
  31776. _internalTexturesCache: InternalTexture[];
  31777. /** @hidden */
  31778. protected _activeChannel: number;
  31779. private _currentTextureChannel;
  31780. /** @hidden */
  31781. protected _boundTexturesCache: {
  31782. [key: string]: Nullable<InternalTexture>;
  31783. };
  31784. /** @hidden */
  31785. protected _currentEffect: Nullable<Effect>;
  31786. /** @hidden */
  31787. protected _currentProgram: Nullable<WebGLProgram>;
  31788. private _compiledEffects;
  31789. private _vertexAttribArraysEnabled;
  31790. /** @hidden */
  31791. protected _cachedViewport: Nullable<IViewportLike>;
  31792. private _cachedVertexArrayObject;
  31793. /** @hidden */
  31794. protected _cachedVertexBuffers: any;
  31795. /** @hidden */
  31796. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31797. /** @hidden */
  31798. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31799. /** @hidden */
  31800. _currentRenderTarget: Nullable<InternalTexture>;
  31801. private _uintIndicesCurrentlySet;
  31802. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31803. /** @hidden */
  31804. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31805. private _currentBufferPointers;
  31806. private _currentInstanceLocations;
  31807. private _currentInstanceBuffers;
  31808. private _textureUnits;
  31809. /** @hidden */
  31810. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31811. /** @hidden */
  31812. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31813. /** @hidden */
  31814. _boundRenderFunction: any;
  31815. private _vaoRecordInProgress;
  31816. private _mustWipeVertexAttributes;
  31817. private _emptyTexture;
  31818. private _emptyCubeTexture;
  31819. private _emptyTexture3D;
  31820. private _emptyTexture2DArray;
  31821. /** @hidden */
  31822. _frameHandler: number;
  31823. private _nextFreeTextureSlots;
  31824. private _maxSimultaneousTextures;
  31825. private _activeRequests;
  31826. protected _texturesSupported: string[];
  31827. /** @hidden */
  31828. _textureFormatInUse: Nullable<string>;
  31829. protected get _supportsHardwareTextureRescaling(): boolean;
  31830. /**
  31831. * Gets the list of texture formats supported
  31832. */
  31833. get texturesSupported(): Array<string>;
  31834. /**
  31835. * Gets the list of texture formats in use
  31836. */
  31837. get textureFormatInUse(): Nullable<string>;
  31838. /**
  31839. * Gets the current viewport
  31840. */
  31841. get currentViewport(): Nullable<IViewportLike>;
  31842. /**
  31843. * Gets the default empty texture
  31844. */
  31845. get emptyTexture(): InternalTexture;
  31846. /**
  31847. * Gets the default empty 3D texture
  31848. */
  31849. get emptyTexture3D(): InternalTexture;
  31850. /**
  31851. * Gets the default empty 2D array texture
  31852. */
  31853. get emptyTexture2DArray(): InternalTexture;
  31854. /**
  31855. * Gets the default empty cube texture
  31856. */
  31857. get emptyCubeTexture(): InternalTexture;
  31858. /**
  31859. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31860. */
  31861. readonly premultipliedAlpha: boolean;
  31862. /**
  31863. * Observable event triggered before each texture is initialized
  31864. */
  31865. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31866. /**
  31867. * Creates a new engine
  31868. * @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
  31869. * @param antialias defines enable antialiasing (default: false)
  31870. * @param options defines further options to be sent to the getContext() function
  31871. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31872. */
  31873. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31874. private _rebuildInternalTextures;
  31875. private _rebuildEffects;
  31876. /**
  31877. * Gets a boolean indicating if all created effects are ready
  31878. * @returns true if all effects are ready
  31879. */
  31880. areAllEffectsReady(): boolean;
  31881. protected _rebuildBuffers(): void;
  31882. private _initGLContext;
  31883. /**
  31884. * Gets version of the current webGL context
  31885. */
  31886. get webGLVersion(): number;
  31887. /**
  31888. * Gets a string idenfifying the name of the class
  31889. * @returns "Engine" string
  31890. */
  31891. getClassName(): string;
  31892. /**
  31893. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31894. */
  31895. get isStencilEnable(): boolean;
  31896. /** @hidden */
  31897. _prepareWorkingCanvas(): void;
  31898. /**
  31899. * Reset the texture cache to empty state
  31900. */
  31901. resetTextureCache(): void;
  31902. /**
  31903. * Gets an object containing information about the current webGL context
  31904. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31905. */
  31906. getGlInfo(): {
  31907. vendor: string;
  31908. renderer: string;
  31909. version: string;
  31910. };
  31911. /**
  31912. * Defines the hardware scaling level.
  31913. * By default the hardware scaling level is computed from the window device ratio.
  31914. * 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.
  31915. * @param level defines the level to use
  31916. */
  31917. setHardwareScalingLevel(level: number): void;
  31918. /**
  31919. * Gets the current hardware scaling level.
  31920. * By default the hardware scaling level is computed from the window device ratio.
  31921. * 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.
  31922. * @returns a number indicating the current hardware scaling level
  31923. */
  31924. getHardwareScalingLevel(): number;
  31925. /**
  31926. * Gets the list of loaded textures
  31927. * @returns an array containing all loaded textures
  31928. */
  31929. getLoadedTexturesCache(): InternalTexture[];
  31930. /**
  31931. * Gets the object containing all engine capabilities
  31932. * @returns the EngineCapabilities object
  31933. */
  31934. getCaps(): EngineCapabilities;
  31935. /**
  31936. * stop executing a render loop function and remove it from the execution array
  31937. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31938. */
  31939. stopRenderLoop(renderFunction?: () => void): void;
  31940. /** @hidden */
  31941. _renderLoop(): void;
  31942. /**
  31943. * Gets the HTML canvas attached with the current webGL context
  31944. * @returns a HTML canvas
  31945. */
  31946. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31947. /**
  31948. * Gets host window
  31949. * @returns the host window object
  31950. */
  31951. getHostWindow(): Nullable<Window>;
  31952. /**
  31953. * Gets the current render width
  31954. * @param useScreen defines if screen size must be used (or the current render target if any)
  31955. * @returns a number defining the current render width
  31956. */
  31957. getRenderWidth(useScreen?: boolean): number;
  31958. /**
  31959. * Gets the current render height
  31960. * @param useScreen defines if screen size must be used (or the current render target if any)
  31961. * @returns a number defining the current render height
  31962. */
  31963. getRenderHeight(useScreen?: boolean): number;
  31964. /**
  31965. * Can be used to override the current requestAnimationFrame requester.
  31966. * @hidden
  31967. */
  31968. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31969. /**
  31970. * Register and execute a render loop. The engine can have more than one render function
  31971. * @param renderFunction defines the function to continuously execute
  31972. */
  31973. runRenderLoop(renderFunction: () => void): void;
  31974. /**
  31975. * Clear the current render buffer or the current render target (if any is set up)
  31976. * @param color defines the color to use
  31977. * @param backBuffer defines if the back buffer must be cleared
  31978. * @param depth defines if the depth buffer must be cleared
  31979. * @param stencil defines if the stencil buffer must be cleared
  31980. */
  31981. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31982. private _viewportCached;
  31983. /** @hidden */
  31984. _viewport(x: number, y: number, width: number, height: number): void;
  31985. /**
  31986. * Set the WebGL's viewport
  31987. * @param viewport defines the viewport element to be used
  31988. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31989. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31990. */
  31991. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31992. /**
  31993. * Begin a new frame
  31994. */
  31995. beginFrame(): void;
  31996. /**
  31997. * Enf the current frame
  31998. */
  31999. endFrame(): void;
  32000. /**
  32001. * Resize the view according to the canvas' size
  32002. */
  32003. resize(): void;
  32004. /**
  32005. * Force a specific size of the canvas
  32006. * @param width defines the new canvas' width
  32007. * @param height defines the new canvas' height
  32008. */
  32009. setSize(width: number, height: number): void;
  32010. /**
  32011. * Binds the frame buffer to the specified texture.
  32012. * @param texture The texture to render to or null for the default canvas
  32013. * @param faceIndex The face of the texture to render to in case of cube texture
  32014. * @param requiredWidth The width of the target to render to
  32015. * @param requiredHeight The height of the target to render to
  32016. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32017. * @param depthStencilTexture The depth stencil texture to use to render
  32018. * @param lodLevel defines le lod level to bind to the frame buffer
  32019. */
  32020. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32021. /** @hidden */
  32022. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32023. /**
  32024. * Unbind the current render target texture from the webGL context
  32025. * @param texture defines the render target texture to unbind
  32026. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32027. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32028. */
  32029. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32030. /**
  32031. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32032. */
  32033. flushFramebuffer(): void;
  32034. /**
  32035. * Unbind the current render target and bind the default framebuffer
  32036. */
  32037. restoreDefaultFramebuffer(): void;
  32038. /** @hidden */
  32039. protected _resetVertexBufferBinding(): void;
  32040. /**
  32041. * Creates a vertex buffer
  32042. * @param data the data for the vertex buffer
  32043. * @returns the new WebGL static buffer
  32044. */
  32045. createVertexBuffer(data: DataArray): DataBuffer;
  32046. private _createVertexBuffer;
  32047. /**
  32048. * Creates a dynamic vertex buffer
  32049. * @param data the data for the dynamic vertex buffer
  32050. * @returns the new WebGL dynamic buffer
  32051. */
  32052. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32053. protected _resetIndexBufferBinding(): void;
  32054. /**
  32055. * Creates a new index buffer
  32056. * @param indices defines the content of the index buffer
  32057. * @param updatable defines if the index buffer must be updatable
  32058. * @returns a new webGL buffer
  32059. */
  32060. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32061. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32062. /**
  32063. * Bind a webGL buffer to the webGL context
  32064. * @param buffer defines the buffer to bind
  32065. */
  32066. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32067. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32068. private bindBuffer;
  32069. /**
  32070. * update the bound buffer with the given data
  32071. * @param data defines the data to update
  32072. */
  32073. updateArrayBuffer(data: Float32Array): void;
  32074. private _vertexAttribPointer;
  32075. private _bindIndexBufferWithCache;
  32076. private _bindVertexBuffersAttributes;
  32077. /**
  32078. * Records a vertex array object
  32079. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32080. * @param vertexBuffers defines the list of vertex buffers to store
  32081. * @param indexBuffer defines the index buffer to store
  32082. * @param effect defines the effect to store
  32083. * @returns the new vertex array object
  32084. */
  32085. recordVertexArrayObject(vertexBuffers: {
  32086. [key: string]: VertexBuffer;
  32087. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32088. /**
  32089. * Bind a specific vertex array object
  32090. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32091. * @param vertexArrayObject defines the vertex array object to bind
  32092. * @param indexBuffer defines the index buffer to bind
  32093. */
  32094. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32095. /**
  32096. * Bind webGl buffers directly to the webGL context
  32097. * @param vertexBuffer defines the vertex buffer to bind
  32098. * @param indexBuffer defines the index buffer to bind
  32099. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32100. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32101. * @param effect defines the effect associated with the vertex buffer
  32102. */
  32103. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32104. private _unbindVertexArrayObject;
  32105. /**
  32106. * Bind a list of vertex buffers to the webGL context
  32107. * @param vertexBuffers defines the list of vertex buffers to bind
  32108. * @param indexBuffer defines the index buffer to bind
  32109. * @param effect defines the effect associated with the vertex buffers
  32110. */
  32111. bindBuffers(vertexBuffers: {
  32112. [key: string]: Nullable<VertexBuffer>;
  32113. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32114. /**
  32115. * Unbind all instance attributes
  32116. */
  32117. unbindInstanceAttributes(): void;
  32118. /**
  32119. * Release and free the memory of a vertex array object
  32120. * @param vao defines the vertex array object to delete
  32121. */
  32122. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32123. /** @hidden */
  32124. _releaseBuffer(buffer: DataBuffer): boolean;
  32125. protected _deleteBuffer(buffer: DataBuffer): void;
  32126. /**
  32127. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32128. * @param instancesBuffer defines the webGL buffer to update and bind
  32129. * @param data defines the data to store in the buffer
  32130. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32131. */
  32132. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32133. /**
  32134. * Bind the content of a webGL buffer used with instanciation
  32135. * @param instancesBuffer defines the webGL buffer to bind
  32136. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32137. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32138. */
  32139. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32140. /**
  32141. * Disable the instance attribute corresponding to the name in parameter
  32142. * @param name defines the name of the attribute to disable
  32143. */
  32144. disableInstanceAttributeByName(name: string): void;
  32145. /**
  32146. * Disable the instance attribute corresponding to the location in parameter
  32147. * @param attributeLocation defines the attribute location of the attribute to disable
  32148. */
  32149. disableInstanceAttribute(attributeLocation: number): void;
  32150. /**
  32151. * Disable the attribute corresponding to the location in parameter
  32152. * @param attributeLocation defines the attribute location of the attribute to disable
  32153. */
  32154. disableAttributeByIndex(attributeLocation: number): void;
  32155. /**
  32156. * Send a draw order
  32157. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32158. * @param indexStart defines the starting index
  32159. * @param indexCount defines the number of index to draw
  32160. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32161. */
  32162. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32163. /**
  32164. * Draw a list of points
  32165. * @param verticesStart defines the index of first vertex to draw
  32166. * @param verticesCount defines the count of vertices to draw
  32167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32168. */
  32169. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32170. /**
  32171. * Draw a list of unindexed primitives
  32172. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32173. * @param verticesStart defines the index of first vertex to draw
  32174. * @param verticesCount defines the count of vertices to draw
  32175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32176. */
  32177. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32178. /**
  32179. * Draw a list of indexed primitives
  32180. * @param fillMode defines the primitive to use
  32181. * @param indexStart defines the starting index
  32182. * @param indexCount defines the number of index to draw
  32183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32184. */
  32185. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32186. /**
  32187. * Draw a list of unindexed primitives
  32188. * @param fillMode defines the primitive to use
  32189. * @param verticesStart defines the index of first vertex to draw
  32190. * @param verticesCount defines the count of vertices to draw
  32191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32192. */
  32193. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32194. private _drawMode;
  32195. /** @hidden */
  32196. protected _reportDrawCall(): void;
  32197. /** @hidden */
  32198. _releaseEffect(effect: Effect): void;
  32199. /** @hidden */
  32200. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32201. /**
  32202. * Create a new effect (used to store vertex/fragment shaders)
  32203. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32204. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32205. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32206. * @param samplers defines an array of string used to represent textures
  32207. * @param defines defines the string containing the defines to use to compile the shaders
  32208. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32209. * @param onCompiled defines a function to call when the effect creation is successful
  32210. * @param onError defines a function to call when the effect creation has failed
  32211. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32212. * @returns the new Effect
  32213. */
  32214. 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;
  32215. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32216. private _compileShader;
  32217. private _compileRawShader;
  32218. /**
  32219. * Directly creates a webGL program
  32220. * @param pipelineContext defines the pipeline context to attach to
  32221. * @param vertexCode defines the vertex shader code to use
  32222. * @param fragmentCode defines the fragment shader code to use
  32223. * @param context defines the webGL context to use (if not set, the current one will be used)
  32224. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32225. * @returns the new webGL program
  32226. */
  32227. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32228. /**
  32229. * Creates a webGL program
  32230. * @param pipelineContext defines the pipeline context to attach to
  32231. * @param vertexCode defines the vertex shader code to use
  32232. * @param fragmentCode defines the fragment shader code to use
  32233. * @param defines defines the string containing the defines to use to compile the shaders
  32234. * @param context defines the webGL context to use (if not set, the current one will be used)
  32235. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32236. * @returns the new webGL program
  32237. */
  32238. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32239. /**
  32240. * Creates a new pipeline context
  32241. * @returns the new pipeline
  32242. */
  32243. createPipelineContext(): IPipelineContext;
  32244. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32245. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32246. /** @hidden */
  32247. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32248. /** @hidden */
  32249. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32250. /** @hidden */
  32251. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32252. /**
  32253. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32254. * @param pipelineContext defines the pipeline context to use
  32255. * @param uniformsNames defines the list of uniform names
  32256. * @returns an array of webGL uniform locations
  32257. */
  32258. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32259. /**
  32260. * Gets the lsit of active attributes for a given webGL program
  32261. * @param pipelineContext defines the pipeline context to use
  32262. * @param attributesNames defines the list of attribute names to get
  32263. * @returns an array of indices indicating the offset of each attribute
  32264. */
  32265. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32266. /**
  32267. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32268. * @param effect defines the effect to activate
  32269. */
  32270. enableEffect(effect: Nullable<Effect>): void;
  32271. /**
  32272. * Set the value of an uniform to a number (int)
  32273. * @param uniform defines the webGL uniform location where to store the value
  32274. * @param value defines the int number to store
  32275. */
  32276. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32277. /**
  32278. * Set the value of an uniform to an array of int32
  32279. * @param uniform defines the webGL uniform location where to store the value
  32280. * @param array defines the array of int32 to store
  32281. */
  32282. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32283. /**
  32284. * Set the value of an uniform to an array of int32 (stored as vec2)
  32285. * @param uniform defines the webGL uniform location where to store the value
  32286. * @param array defines the array of int32 to store
  32287. */
  32288. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32289. /**
  32290. * Set the value of an uniform to an array of int32 (stored as vec3)
  32291. * @param uniform defines the webGL uniform location where to store the value
  32292. * @param array defines the array of int32 to store
  32293. */
  32294. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32295. /**
  32296. * Set the value of an uniform to an array of int32 (stored as vec4)
  32297. * @param uniform defines the webGL uniform location where to store the value
  32298. * @param array defines the array of int32 to store
  32299. */
  32300. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32301. /**
  32302. * Set the value of an uniform to an array of number
  32303. * @param uniform defines the webGL uniform location where to store the value
  32304. * @param array defines the array of number to store
  32305. */
  32306. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32307. /**
  32308. * Set the value of an uniform to an array of number (stored as vec2)
  32309. * @param uniform defines the webGL uniform location where to store the value
  32310. * @param array defines the array of number to store
  32311. */
  32312. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32313. /**
  32314. * Set the value of an uniform to an array of number (stored as vec3)
  32315. * @param uniform defines the webGL uniform location where to store the value
  32316. * @param array defines the array of number to store
  32317. */
  32318. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32319. /**
  32320. * Set the value of an uniform to an array of number (stored as vec4)
  32321. * @param uniform defines the webGL uniform location where to store the value
  32322. * @param array defines the array of number to store
  32323. */
  32324. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32325. /**
  32326. * Set the value of an uniform to an array of float32 (stored as matrices)
  32327. * @param uniform defines the webGL uniform location where to store the value
  32328. * @param matrices defines the array of float32 to store
  32329. */
  32330. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32331. /**
  32332. * Set the value of an uniform to a matrix (3x3)
  32333. * @param uniform defines the webGL uniform location where to store the value
  32334. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32335. */
  32336. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32337. /**
  32338. * Set the value of an uniform to a matrix (2x2)
  32339. * @param uniform defines the webGL uniform location where to store the value
  32340. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32341. */
  32342. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32343. /**
  32344. * Set the value of an uniform to a number (float)
  32345. * @param uniform defines the webGL uniform location where to store the value
  32346. * @param value defines the float number to store
  32347. */
  32348. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32349. /**
  32350. * Set the value of an uniform to a vec2
  32351. * @param uniform defines the webGL uniform location where to store the value
  32352. * @param x defines the 1st component of the value
  32353. * @param y defines the 2nd component of the value
  32354. */
  32355. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32356. /**
  32357. * Set the value of an uniform to a vec3
  32358. * @param uniform defines the webGL uniform location where to store the value
  32359. * @param x defines the 1st component of the value
  32360. * @param y defines the 2nd component of the value
  32361. * @param z defines the 3rd component of the value
  32362. */
  32363. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32364. /**
  32365. * Set the value of an uniform to a vec4
  32366. * @param uniform defines the webGL uniform location where to store the value
  32367. * @param x defines the 1st component of the value
  32368. * @param y defines the 2nd component of the value
  32369. * @param z defines the 3rd component of the value
  32370. * @param w defines the 4th component of the value
  32371. */
  32372. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32373. /**
  32374. * Apply all cached states (depth, culling, stencil and alpha)
  32375. */
  32376. applyStates(): void;
  32377. /**
  32378. * Enable or disable color writing
  32379. * @param enable defines the state to set
  32380. */
  32381. setColorWrite(enable: boolean): void;
  32382. /**
  32383. * Gets a boolean indicating if color writing is enabled
  32384. * @returns the current color writing state
  32385. */
  32386. getColorWrite(): boolean;
  32387. /**
  32388. * Gets the depth culling state manager
  32389. */
  32390. get depthCullingState(): DepthCullingState;
  32391. /**
  32392. * Gets the alpha state manager
  32393. */
  32394. get alphaState(): AlphaState;
  32395. /**
  32396. * Gets the stencil state manager
  32397. */
  32398. get stencilState(): StencilState;
  32399. /**
  32400. * Clears the list of texture accessible through engine.
  32401. * This can help preventing texture load conflict due to name collision.
  32402. */
  32403. clearInternalTexturesCache(): void;
  32404. /**
  32405. * Force the entire cache to be cleared
  32406. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32407. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32408. */
  32409. wipeCaches(bruteForce?: boolean): void;
  32410. /** @hidden */
  32411. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32412. min: number;
  32413. mag: number;
  32414. };
  32415. /** @hidden */
  32416. _createTexture(): WebGLTexture;
  32417. /**
  32418. * Usually called from Texture.ts.
  32419. * Passed information to create a WebGLTexture
  32420. * @param urlArg defines a value which contains one of the following:
  32421. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32422. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32423. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32424. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32425. * @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)
  32426. * @param scene needed for loading to the correct scene
  32427. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32428. * @param onLoad optional callback to be called upon successful completion
  32429. * @param onError optional callback to be called upon failure
  32430. * @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
  32431. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32432. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32433. * @param forcedExtension defines the extension to use to pick the right loader
  32434. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32435. * @param mimeType defines an optional mime type
  32436. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32437. */
  32438. 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;
  32439. /**
  32440. * @hidden
  32441. */
  32442. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32443. /**
  32444. * Creates a raw texture
  32445. * @param data defines the data to store in the texture
  32446. * @param width defines the width of the texture
  32447. * @param height defines the height of the texture
  32448. * @param format defines the format of the data
  32449. * @param generateMipMaps defines if the engine should generate the mip levels
  32450. * @param invertY defines if data must be stored with Y axis inverted
  32451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32452. * @param compression defines the compression used (null by default)
  32453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32454. * @returns the raw texture inside an InternalTexture
  32455. */
  32456. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32457. /**
  32458. * Creates a new raw cube texture
  32459. * @param data defines the array of data to use to create each face
  32460. * @param size defines the size of the textures
  32461. * @param format defines the format of the data
  32462. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32463. * @param generateMipMaps defines if the engine should generate the mip levels
  32464. * @param invertY defines if data must be stored with Y axis inverted
  32465. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32466. * @param compression defines the compression used (null by default)
  32467. * @returns the cube texture as an InternalTexture
  32468. */
  32469. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32470. /**
  32471. * Creates a new raw 3D texture
  32472. * @param data defines the data used to create the texture
  32473. * @param width defines the width of the texture
  32474. * @param height defines the height of the texture
  32475. * @param depth defines the depth of the texture
  32476. * @param format defines the format of the texture
  32477. * @param generateMipMaps defines if the engine must generate mip levels
  32478. * @param invertY defines if data must be stored with Y axis inverted
  32479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32480. * @param compression defines the compressed used (can be null)
  32481. * @param textureType defines the compressed used (can be null)
  32482. * @returns a new raw 3D texture (stored in an InternalTexture)
  32483. */
  32484. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32485. /**
  32486. * Creates a new raw 2D array texture
  32487. * @param data defines the data used to create the texture
  32488. * @param width defines the width of the texture
  32489. * @param height defines the height of the texture
  32490. * @param depth defines the number of layers of the texture
  32491. * @param format defines the format of the texture
  32492. * @param generateMipMaps defines if the engine must generate mip levels
  32493. * @param invertY defines if data must be stored with Y axis inverted
  32494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32495. * @param compression defines the compressed used (can be null)
  32496. * @param textureType defines the compressed used (can be null)
  32497. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32498. */
  32499. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32500. private _unpackFlipYCached;
  32501. /**
  32502. * In case you are sharing the context with other applications, it might
  32503. * be interested to not cache the unpack flip y state to ensure a consistent
  32504. * value would be set.
  32505. */
  32506. enableUnpackFlipYCached: boolean;
  32507. /** @hidden */
  32508. _unpackFlipY(value: boolean): void;
  32509. /** @hidden */
  32510. _getUnpackAlignement(): number;
  32511. private _getTextureTarget;
  32512. /**
  32513. * Update the sampling mode of a given texture
  32514. * @param samplingMode defines the required sampling mode
  32515. * @param texture defines the texture to update
  32516. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32517. */
  32518. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32519. /**
  32520. * Update the sampling mode of a given texture
  32521. * @param texture defines the texture to update
  32522. * @param wrapU defines the texture wrap mode of the u coordinates
  32523. * @param wrapV defines the texture wrap mode of the v coordinates
  32524. * @param wrapR defines the texture wrap mode of the r coordinates
  32525. */
  32526. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32527. /** @hidden */
  32528. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32529. width: number;
  32530. height: number;
  32531. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32532. /** @hidden */
  32533. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32534. /** @hidden */
  32535. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32536. /** @hidden */
  32537. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32538. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32539. private _prepareWebGLTexture;
  32540. /** @hidden */
  32541. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32542. private _getDepthStencilBuffer;
  32543. /** @hidden */
  32544. _releaseFramebufferObjects(texture: InternalTexture): void;
  32545. /** @hidden */
  32546. _releaseTexture(texture: InternalTexture): void;
  32547. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32548. protected _setProgram(program: WebGLProgram): void;
  32549. protected _boundUniforms: {
  32550. [key: number]: WebGLUniformLocation;
  32551. };
  32552. /**
  32553. * Binds an effect to the webGL context
  32554. * @param effect defines the effect to bind
  32555. */
  32556. bindSamplers(effect: Effect): void;
  32557. private _activateCurrentTexture;
  32558. /** @hidden */
  32559. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32560. /** @hidden */
  32561. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32562. /**
  32563. * Unbind all textures from the webGL context
  32564. */
  32565. unbindAllTextures(): void;
  32566. /**
  32567. * Sets a texture to the according uniform.
  32568. * @param channel The texture channel
  32569. * @param uniform The uniform to set
  32570. * @param texture The texture to apply
  32571. */
  32572. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32573. private _bindSamplerUniformToChannel;
  32574. private _getTextureWrapMode;
  32575. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32576. /**
  32577. * Sets an array of texture to the webGL context
  32578. * @param channel defines the channel where the texture array must be set
  32579. * @param uniform defines the associated uniform location
  32580. * @param textures defines the array of textures to bind
  32581. */
  32582. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32583. /** @hidden */
  32584. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32585. private _setTextureParameterFloat;
  32586. private _setTextureParameterInteger;
  32587. /**
  32588. * Unbind all vertex attributes from the webGL context
  32589. */
  32590. unbindAllAttributes(): void;
  32591. /**
  32592. * 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
  32593. */
  32594. releaseEffects(): void;
  32595. /**
  32596. * Dispose and release all associated resources
  32597. */
  32598. dispose(): void;
  32599. /**
  32600. * Attach a new callback raised when context lost event is fired
  32601. * @param callback defines the callback to call
  32602. */
  32603. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32604. /**
  32605. * Attach a new callback raised when context restored event is fired
  32606. * @param callback defines the callback to call
  32607. */
  32608. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32609. /**
  32610. * Get the current error code of the webGL context
  32611. * @returns the error code
  32612. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32613. */
  32614. getError(): number;
  32615. private _canRenderToFloatFramebuffer;
  32616. private _canRenderToHalfFloatFramebuffer;
  32617. private _canRenderToFramebuffer;
  32618. /** @hidden */
  32619. _getWebGLTextureType(type: number): number;
  32620. /** @hidden */
  32621. _getInternalFormat(format: number): number;
  32622. /** @hidden */
  32623. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32624. /** @hidden */
  32625. _getRGBAMultiSampleBufferFormat(type: number): number;
  32626. /** @hidden */
  32627. _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;
  32628. /**
  32629. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32630. * @param x defines the x coordinate of the rectangle where pixels must be read
  32631. * @param y defines the y coordinate of the rectangle where pixels must be read
  32632. * @param width defines the width of the rectangle where pixels must be read
  32633. * @param height defines the height of the rectangle where pixels must be read
  32634. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32635. * @returns a Uint8Array containing RGBA colors
  32636. */
  32637. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32638. private static _isSupported;
  32639. /**
  32640. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32641. * @returns true if the engine can be created
  32642. * @ignorenaming
  32643. */
  32644. static isSupported(): boolean;
  32645. /**
  32646. * Find the next highest power of two.
  32647. * @param x Number to start search from.
  32648. * @return Next highest power of two.
  32649. */
  32650. static CeilingPOT(x: number): number;
  32651. /**
  32652. * Find the next lowest power of two.
  32653. * @param x Number to start search from.
  32654. * @return Next lowest power of two.
  32655. */
  32656. static FloorPOT(x: number): number;
  32657. /**
  32658. * Find the nearest power of two.
  32659. * @param x Number to start search from.
  32660. * @return Next nearest power of two.
  32661. */
  32662. static NearestPOT(x: number): number;
  32663. /**
  32664. * Get the closest exponent of two
  32665. * @param value defines the value to approximate
  32666. * @param max defines the maximum value to return
  32667. * @param mode defines how to define the closest value
  32668. * @returns closest exponent of two of the given value
  32669. */
  32670. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32671. /**
  32672. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32673. * @param func - the function to be called
  32674. * @param requester - the object that will request the next frame. Falls back to window.
  32675. * @returns frame number
  32676. */
  32677. static QueueNewFrame(func: () => void, requester?: any): number;
  32678. /**
  32679. * Gets host document
  32680. * @returns the host document object
  32681. */
  32682. getHostDocument(): Nullable<Document>;
  32683. }
  32684. }
  32685. declare module "babylonjs/Maths/sphericalPolynomial" {
  32686. import { Vector3 } from "babylonjs/Maths/math.vector";
  32687. import { Color3 } from "babylonjs/Maths/math.color";
  32688. /**
  32689. * Class representing spherical harmonics coefficients to the 3rd degree
  32690. */
  32691. export class SphericalHarmonics {
  32692. /**
  32693. * Defines whether or not the harmonics have been prescaled for rendering.
  32694. */
  32695. preScaled: boolean;
  32696. /**
  32697. * The l0,0 coefficients of the spherical harmonics
  32698. */
  32699. l00: Vector3;
  32700. /**
  32701. * The l1,-1 coefficients of the spherical harmonics
  32702. */
  32703. l1_1: Vector3;
  32704. /**
  32705. * The l1,0 coefficients of the spherical harmonics
  32706. */
  32707. l10: Vector3;
  32708. /**
  32709. * The l1,1 coefficients of the spherical harmonics
  32710. */
  32711. l11: Vector3;
  32712. /**
  32713. * The l2,-2 coefficients of the spherical harmonics
  32714. */
  32715. l2_2: Vector3;
  32716. /**
  32717. * The l2,-1 coefficients of the spherical harmonics
  32718. */
  32719. l2_1: Vector3;
  32720. /**
  32721. * The l2,0 coefficients of the spherical harmonics
  32722. */
  32723. l20: Vector3;
  32724. /**
  32725. * The l2,1 coefficients of the spherical harmonics
  32726. */
  32727. l21: Vector3;
  32728. /**
  32729. * The l2,2 coefficients of the spherical harmonics
  32730. */
  32731. l22: Vector3;
  32732. /**
  32733. * Adds a light to the spherical harmonics
  32734. * @param direction the direction of the light
  32735. * @param color the color of the light
  32736. * @param deltaSolidAngle the delta solid angle of the light
  32737. */
  32738. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32739. /**
  32740. * Scales the spherical harmonics by the given amount
  32741. * @param scale the amount to scale
  32742. */
  32743. scaleInPlace(scale: number): void;
  32744. /**
  32745. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32746. *
  32747. * ```
  32748. * E_lm = A_l * L_lm
  32749. * ```
  32750. *
  32751. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32752. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32753. * the scaling factors are given in equation 9.
  32754. */
  32755. convertIncidentRadianceToIrradiance(): void;
  32756. /**
  32757. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32758. *
  32759. * ```
  32760. * L = (1/pi) * E * rho
  32761. * ```
  32762. *
  32763. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32764. */
  32765. convertIrradianceToLambertianRadiance(): void;
  32766. /**
  32767. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32768. * required operations at run time.
  32769. *
  32770. * This is simply done by scaling back the SH with Ylm constants parameter.
  32771. * The trigonometric part being applied by the shader at run time.
  32772. */
  32773. preScaleForRendering(): void;
  32774. /**
  32775. * Constructs a spherical harmonics from an array.
  32776. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32777. * @returns the spherical harmonics
  32778. */
  32779. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32780. /**
  32781. * Gets the spherical harmonics from polynomial
  32782. * @param polynomial the spherical polynomial
  32783. * @returns the spherical harmonics
  32784. */
  32785. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32786. }
  32787. /**
  32788. * Class representing spherical polynomial coefficients to the 3rd degree
  32789. */
  32790. export class SphericalPolynomial {
  32791. private _harmonics;
  32792. /**
  32793. * The spherical harmonics used to create the polynomials.
  32794. */
  32795. get preScaledHarmonics(): SphericalHarmonics;
  32796. /**
  32797. * The x coefficients of the spherical polynomial
  32798. */
  32799. x: Vector3;
  32800. /**
  32801. * The y coefficients of the spherical polynomial
  32802. */
  32803. y: Vector3;
  32804. /**
  32805. * The z coefficients of the spherical polynomial
  32806. */
  32807. z: Vector3;
  32808. /**
  32809. * The xx coefficients of the spherical polynomial
  32810. */
  32811. xx: Vector3;
  32812. /**
  32813. * The yy coefficients of the spherical polynomial
  32814. */
  32815. yy: Vector3;
  32816. /**
  32817. * The zz coefficients of the spherical polynomial
  32818. */
  32819. zz: Vector3;
  32820. /**
  32821. * The xy coefficients of the spherical polynomial
  32822. */
  32823. xy: Vector3;
  32824. /**
  32825. * The yz coefficients of the spherical polynomial
  32826. */
  32827. yz: Vector3;
  32828. /**
  32829. * The zx coefficients of the spherical polynomial
  32830. */
  32831. zx: Vector3;
  32832. /**
  32833. * Adds an ambient color to the spherical polynomial
  32834. * @param color the color to add
  32835. */
  32836. addAmbient(color: Color3): void;
  32837. /**
  32838. * Scales the spherical polynomial by the given amount
  32839. * @param scale the amount to scale
  32840. */
  32841. scaleInPlace(scale: number): void;
  32842. /**
  32843. * Gets the spherical polynomial from harmonics
  32844. * @param harmonics the spherical harmonics
  32845. * @returns the spherical polynomial
  32846. */
  32847. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32848. /**
  32849. * Constructs a spherical polynomial from an array.
  32850. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32851. * @returns the spherical polynomial
  32852. */
  32853. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32854. }
  32855. }
  32856. declare module "babylonjs/Materials/Textures/internalTexture" {
  32857. import { Observable } from "babylonjs/Misc/observable";
  32858. import { Nullable, int } from "babylonjs/types";
  32859. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32861. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32862. /**
  32863. * Defines the source of the internal texture
  32864. */
  32865. export enum InternalTextureSource {
  32866. /**
  32867. * The source of the texture data is unknown
  32868. */
  32869. Unknown = 0,
  32870. /**
  32871. * Texture data comes from an URL
  32872. */
  32873. Url = 1,
  32874. /**
  32875. * Texture data is only used for temporary storage
  32876. */
  32877. Temp = 2,
  32878. /**
  32879. * Texture data comes from raw data (ArrayBuffer)
  32880. */
  32881. Raw = 3,
  32882. /**
  32883. * Texture content is dynamic (video or dynamic texture)
  32884. */
  32885. Dynamic = 4,
  32886. /**
  32887. * Texture content is generated by rendering to it
  32888. */
  32889. RenderTarget = 5,
  32890. /**
  32891. * Texture content is part of a multi render target process
  32892. */
  32893. MultiRenderTarget = 6,
  32894. /**
  32895. * Texture data comes from a cube data file
  32896. */
  32897. Cube = 7,
  32898. /**
  32899. * Texture data comes from a raw cube data
  32900. */
  32901. CubeRaw = 8,
  32902. /**
  32903. * Texture data come from a prefiltered cube data file
  32904. */
  32905. CubePrefiltered = 9,
  32906. /**
  32907. * Texture content is raw 3D data
  32908. */
  32909. Raw3D = 10,
  32910. /**
  32911. * Texture content is raw 2D array data
  32912. */
  32913. Raw2DArray = 11,
  32914. /**
  32915. * Texture content is a depth texture
  32916. */
  32917. Depth = 12,
  32918. /**
  32919. * Texture data comes from a raw cube data encoded with RGBD
  32920. */
  32921. CubeRawRGBD = 13
  32922. }
  32923. /**
  32924. * Class used to store data associated with WebGL texture data for the engine
  32925. * This class should not be used directly
  32926. */
  32927. export class InternalTexture {
  32928. /** @hidden */
  32929. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32930. /**
  32931. * Defines if the texture is ready
  32932. */
  32933. isReady: boolean;
  32934. /**
  32935. * Defines if the texture is a cube texture
  32936. */
  32937. isCube: boolean;
  32938. /**
  32939. * Defines if the texture contains 3D data
  32940. */
  32941. is3D: boolean;
  32942. /**
  32943. * Defines if the texture contains 2D array data
  32944. */
  32945. is2DArray: boolean;
  32946. /**
  32947. * Defines if the texture contains multiview data
  32948. */
  32949. isMultiview: boolean;
  32950. /**
  32951. * Gets the URL used to load this texture
  32952. */
  32953. url: string;
  32954. /**
  32955. * Gets the sampling mode of the texture
  32956. */
  32957. samplingMode: number;
  32958. /**
  32959. * Gets a boolean indicating if the texture needs mipmaps generation
  32960. */
  32961. generateMipMaps: boolean;
  32962. /**
  32963. * Gets the number of samples used by the texture (WebGL2+ only)
  32964. */
  32965. samples: number;
  32966. /**
  32967. * Gets the type of the texture (int, float...)
  32968. */
  32969. type: number;
  32970. /**
  32971. * Gets the format of the texture (RGB, RGBA...)
  32972. */
  32973. format: number;
  32974. /**
  32975. * Observable called when the texture is loaded
  32976. */
  32977. onLoadedObservable: Observable<InternalTexture>;
  32978. /**
  32979. * Gets the width of the texture
  32980. */
  32981. width: number;
  32982. /**
  32983. * Gets the height of the texture
  32984. */
  32985. height: number;
  32986. /**
  32987. * Gets the depth of the texture
  32988. */
  32989. depth: number;
  32990. /**
  32991. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32992. */
  32993. baseWidth: number;
  32994. /**
  32995. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32996. */
  32997. baseHeight: number;
  32998. /**
  32999. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33000. */
  33001. baseDepth: number;
  33002. /**
  33003. * Gets a boolean indicating if the texture is inverted on Y axis
  33004. */
  33005. invertY: boolean;
  33006. /** @hidden */
  33007. _invertVScale: boolean;
  33008. /** @hidden */
  33009. _associatedChannel: number;
  33010. /** @hidden */
  33011. _source: InternalTextureSource;
  33012. /** @hidden */
  33013. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33014. /** @hidden */
  33015. _bufferView: Nullable<ArrayBufferView>;
  33016. /** @hidden */
  33017. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33018. /** @hidden */
  33019. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33020. /** @hidden */
  33021. _size: number;
  33022. /** @hidden */
  33023. _extension: string;
  33024. /** @hidden */
  33025. _files: Nullable<string[]>;
  33026. /** @hidden */
  33027. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33028. /** @hidden */
  33029. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33030. /** @hidden */
  33031. _framebuffer: Nullable<WebGLFramebuffer>;
  33032. /** @hidden */
  33033. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33034. /** @hidden */
  33035. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33036. /** @hidden */
  33037. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33038. /** @hidden */
  33039. _attachments: Nullable<number[]>;
  33040. /** @hidden */
  33041. _cachedCoordinatesMode: Nullable<number>;
  33042. /** @hidden */
  33043. _cachedWrapU: Nullable<number>;
  33044. /** @hidden */
  33045. _cachedWrapV: Nullable<number>;
  33046. /** @hidden */
  33047. _cachedWrapR: Nullable<number>;
  33048. /** @hidden */
  33049. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33050. /** @hidden */
  33051. _isDisabled: boolean;
  33052. /** @hidden */
  33053. _compression: Nullable<string>;
  33054. /** @hidden */
  33055. _generateStencilBuffer: boolean;
  33056. /** @hidden */
  33057. _generateDepthBuffer: boolean;
  33058. /** @hidden */
  33059. _comparisonFunction: number;
  33060. /** @hidden */
  33061. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33062. /** @hidden */
  33063. _lodGenerationScale: number;
  33064. /** @hidden */
  33065. _lodGenerationOffset: number;
  33066. /** @hidden */
  33067. _colorTextureArray: Nullable<WebGLTexture>;
  33068. /** @hidden */
  33069. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33070. /** @hidden */
  33071. _lodTextureHigh: Nullable<BaseTexture>;
  33072. /** @hidden */
  33073. _lodTextureMid: Nullable<BaseTexture>;
  33074. /** @hidden */
  33075. _lodTextureLow: Nullable<BaseTexture>;
  33076. /** @hidden */
  33077. _isRGBD: boolean;
  33078. /** @hidden */
  33079. _linearSpecularLOD: boolean;
  33080. /** @hidden */
  33081. _irradianceTexture: Nullable<BaseTexture>;
  33082. /** @hidden */
  33083. _webGLTexture: Nullable<WebGLTexture>;
  33084. /** @hidden */
  33085. _references: number;
  33086. private _engine;
  33087. /**
  33088. * Gets the Engine the texture belongs to.
  33089. * @returns The babylon engine
  33090. */
  33091. getEngine(): ThinEngine;
  33092. /**
  33093. * Gets the data source type of the texture
  33094. */
  33095. get source(): InternalTextureSource;
  33096. /**
  33097. * Creates a new InternalTexture
  33098. * @param engine defines the engine to use
  33099. * @param source defines the type of data that will be used
  33100. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33101. */
  33102. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33103. /**
  33104. * Increments the number of references (ie. the number of Texture that point to it)
  33105. */
  33106. incrementReferences(): void;
  33107. /**
  33108. * Change the size of the texture (not the size of the content)
  33109. * @param width defines the new width
  33110. * @param height defines the new height
  33111. * @param depth defines the new depth (1 by default)
  33112. */
  33113. updateSize(width: int, height: int, depth?: int): void;
  33114. /** @hidden */
  33115. _rebuild(): void;
  33116. /** @hidden */
  33117. _swapAndDie(target: InternalTexture): void;
  33118. /**
  33119. * Dispose the current allocated resources
  33120. */
  33121. dispose(): void;
  33122. }
  33123. }
  33124. declare module "babylonjs/Audio/analyser" {
  33125. import { Scene } from "babylonjs/scene";
  33126. /**
  33127. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33129. */
  33130. export class Analyser {
  33131. /**
  33132. * Gets or sets the smoothing
  33133. * @ignorenaming
  33134. */
  33135. SMOOTHING: number;
  33136. /**
  33137. * Gets or sets the FFT table size
  33138. * @ignorenaming
  33139. */
  33140. FFT_SIZE: number;
  33141. /**
  33142. * Gets or sets the bar graph amplitude
  33143. * @ignorenaming
  33144. */
  33145. BARGRAPHAMPLITUDE: number;
  33146. /**
  33147. * Gets or sets the position of the debug canvas
  33148. * @ignorenaming
  33149. */
  33150. DEBUGCANVASPOS: {
  33151. x: number;
  33152. y: number;
  33153. };
  33154. /**
  33155. * Gets or sets the debug canvas size
  33156. * @ignorenaming
  33157. */
  33158. DEBUGCANVASSIZE: {
  33159. width: number;
  33160. height: number;
  33161. };
  33162. private _byteFreqs;
  33163. private _byteTime;
  33164. private _floatFreqs;
  33165. private _webAudioAnalyser;
  33166. private _debugCanvas;
  33167. private _debugCanvasContext;
  33168. private _scene;
  33169. private _registerFunc;
  33170. private _audioEngine;
  33171. /**
  33172. * Creates a new analyser
  33173. * @param scene defines hosting scene
  33174. */
  33175. constructor(scene: Scene);
  33176. /**
  33177. * Get the number of data values you will have to play with for the visualization
  33178. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33179. * @returns a number
  33180. */
  33181. getFrequencyBinCount(): number;
  33182. /**
  33183. * Gets the current frequency data as a byte array
  33184. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33185. * @returns a Uint8Array
  33186. */
  33187. getByteFrequencyData(): Uint8Array;
  33188. /**
  33189. * Gets the current waveform as a byte array
  33190. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33191. * @returns a Uint8Array
  33192. */
  33193. getByteTimeDomainData(): Uint8Array;
  33194. /**
  33195. * Gets the current frequency data as a float array
  33196. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33197. * @returns a Float32Array
  33198. */
  33199. getFloatFrequencyData(): Float32Array;
  33200. /**
  33201. * Renders the debug canvas
  33202. */
  33203. drawDebugCanvas(): void;
  33204. /**
  33205. * Stops rendering the debug canvas and removes it
  33206. */
  33207. stopDebugCanvas(): void;
  33208. /**
  33209. * Connects two audio nodes
  33210. * @param inputAudioNode defines first node to connect
  33211. * @param outputAudioNode defines second node to connect
  33212. */
  33213. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33214. /**
  33215. * Releases all associated resources
  33216. */
  33217. dispose(): void;
  33218. }
  33219. }
  33220. declare module "babylonjs/Audio/audioEngine" {
  33221. import { IDisposable } from "babylonjs/scene";
  33222. import { Analyser } from "babylonjs/Audio/analyser";
  33223. import { Nullable } from "babylonjs/types";
  33224. import { Observable } from "babylonjs/Misc/observable";
  33225. /**
  33226. * This represents an audio engine and it is responsible
  33227. * to play, synchronize and analyse sounds throughout the application.
  33228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33229. */
  33230. export interface IAudioEngine extends IDisposable {
  33231. /**
  33232. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33233. */
  33234. readonly canUseWebAudio: boolean;
  33235. /**
  33236. * Gets the current AudioContext if available.
  33237. */
  33238. readonly audioContext: Nullable<AudioContext>;
  33239. /**
  33240. * The master gain node defines the global audio volume of your audio engine.
  33241. */
  33242. readonly masterGain: GainNode;
  33243. /**
  33244. * Gets whether or not mp3 are supported by your browser.
  33245. */
  33246. readonly isMP3supported: boolean;
  33247. /**
  33248. * Gets whether or not ogg are supported by your browser.
  33249. */
  33250. readonly isOGGsupported: boolean;
  33251. /**
  33252. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33253. * @ignoreNaming
  33254. */
  33255. WarnedWebAudioUnsupported: boolean;
  33256. /**
  33257. * Defines if the audio engine relies on a custom unlocked button.
  33258. * In this case, the embedded button will not be displayed.
  33259. */
  33260. useCustomUnlockedButton: boolean;
  33261. /**
  33262. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33263. */
  33264. readonly unlocked: boolean;
  33265. /**
  33266. * Event raised when audio has been unlocked on the browser.
  33267. */
  33268. onAudioUnlockedObservable: Observable<AudioEngine>;
  33269. /**
  33270. * Event raised when audio has been locked on the browser.
  33271. */
  33272. onAudioLockedObservable: Observable<AudioEngine>;
  33273. /**
  33274. * Flags the audio engine in Locked state.
  33275. * This happens due to new browser policies preventing audio to autoplay.
  33276. */
  33277. lock(): void;
  33278. /**
  33279. * Unlocks the audio engine once a user action has been done on the dom.
  33280. * This is helpful to resume play once browser policies have been satisfied.
  33281. */
  33282. unlock(): void;
  33283. }
  33284. /**
  33285. * This represents the default audio engine used in babylon.
  33286. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33288. */
  33289. export class AudioEngine implements IAudioEngine {
  33290. private _audioContext;
  33291. private _audioContextInitialized;
  33292. private _muteButton;
  33293. private _hostElement;
  33294. /**
  33295. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33296. */
  33297. canUseWebAudio: boolean;
  33298. /**
  33299. * The master gain node defines the global audio volume of your audio engine.
  33300. */
  33301. masterGain: GainNode;
  33302. /**
  33303. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33304. * @ignoreNaming
  33305. */
  33306. WarnedWebAudioUnsupported: boolean;
  33307. /**
  33308. * Gets whether or not mp3 are supported by your browser.
  33309. */
  33310. isMP3supported: boolean;
  33311. /**
  33312. * Gets whether or not ogg are supported by your browser.
  33313. */
  33314. isOGGsupported: boolean;
  33315. /**
  33316. * Gets whether audio has been unlocked on the device.
  33317. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33318. * a user interaction has happened.
  33319. */
  33320. unlocked: boolean;
  33321. /**
  33322. * Defines if the audio engine relies on a custom unlocked button.
  33323. * In this case, the embedded button will not be displayed.
  33324. */
  33325. useCustomUnlockedButton: boolean;
  33326. /**
  33327. * Event raised when audio has been unlocked on the browser.
  33328. */
  33329. onAudioUnlockedObservable: Observable<AudioEngine>;
  33330. /**
  33331. * Event raised when audio has been locked on the browser.
  33332. */
  33333. onAudioLockedObservable: Observable<AudioEngine>;
  33334. /**
  33335. * Gets the current AudioContext if available.
  33336. */
  33337. get audioContext(): Nullable<AudioContext>;
  33338. private _connectedAnalyser;
  33339. /**
  33340. * Instantiates a new audio engine.
  33341. *
  33342. * There should be only one per page as some browsers restrict the number
  33343. * of audio contexts you can create.
  33344. * @param hostElement defines the host element where to display the mute icon if necessary
  33345. */
  33346. constructor(hostElement?: Nullable<HTMLElement>);
  33347. /**
  33348. * Flags the audio engine in Locked state.
  33349. * This happens due to new browser policies preventing audio to autoplay.
  33350. */
  33351. lock(): void;
  33352. /**
  33353. * Unlocks the audio engine once a user action has been done on the dom.
  33354. * This is helpful to resume play once browser policies have been satisfied.
  33355. */
  33356. unlock(): void;
  33357. private _resumeAudioContext;
  33358. private _initializeAudioContext;
  33359. private _tryToRun;
  33360. private _triggerRunningState;
  33361. private _triggerSuspendedState;
  33362. private _displayMuteButton;
  33363. private _moveButtonToTopLeft;
  33364. private _onResize;
  33365. private _hideMuteButton;
  33366. /**
  33367. * Destroy and release the resources associated with the audio ccontext.
  33368. */
  33369. dispose(): void;
  33370. /**
  33371. * Gets the global volume sets on the master gain.
  33372. * @returns the global volume if set or -1 otherwise
  33373. */
  33374. getGlobalVolume(): number;
  33375. /**
  33376. * Sets the global volume of your experience (sets on the master gain).
  33377. * @param newVolume Defines the new global volume of the application
  33378. */
  33379. setGlobalVolume(newVolume: number): void;
  33380. /**
  33381. * Connect the audio engine to an audio analyser allowing some amazing
  33382. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33384. * @param analyser The analyser to connect to the engine
  33385. */
  33386. connectToAnalyser(analyser: Analyser): void;
  33387. }
  33388. }
  33389. declare module "babylonjs/Loading/loadingScreen" {
  33390. /**
  33391. * Interface used to present a loading screen while loading a scene
  33392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33393. */
  33394. export interface ILoadingScreen {
  33395. /**
  33396. * Function called to display the loading screen
  33397. */
  33398. displayLoadingUI: () => void;
  33399. /**
  33400. * Function called to hide the loading screen
  33401. */
  33402. hideLoadingUI: () => void;
  33403. /**
  33404. * Gets or sets the color to use for the background
  33405. */
  33406. loadingUIBackgroundColor: string;
  33407. /**
  33408. * Gets or sets the text to display while loading
  33409. */
  33410. loadingUIText: string;
  33411. }
  33412. /**
  33413. * Class used for the default loading screen
  33414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33415. */
  33416. export class DefaultLoadingScreen implements ILoadingScreen {
  33417. private _renderingCanvas;
  33418. private _loadingText;
  33419. private _loadingDivBackgroundColor;
  33420. private _loadingDiv;
  33421. private _loadingTextDiv;
  33422. /** Gets or sets the logo url to use for the default loading screen */
  33423. static DefaultLogoUrl: string;
  33424. /** Gets or sets the spinner url to use for the default loading screen */
  33425. static DefaultSpinnerUrl: string;
  33426. /**
  33427. * Creates a new default loading screen
  33428. * @param _renderingCanvas defines the canvas used to render the scene
  33429. * @param _loadingText defines the default text to display
  33430. * @param _loadingDivBackgroundColor defines the default background color
  33431. */
  33432. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33433. /**
  33434. * Function called to display the loading screen
  33435. */
  33436. displayLoadingUI(): void;
  33437. /**
  33438. * Function called to hide the loading screen
  33439. */
  33440. hideLoadingUI(): void;
  33441. /**
  33442. * Gets or sets the text to display while loading
  33443. */
  33444. set loadingUIText(text: string);
  33445. get loadingUIText(): string;
  33446. /**
  33447. * Gets or sets the color to use for the background
  33448. */
  33449. get loadingUIBackgroundColor(): string;
  33450. set loadingUIBackgroundColor(color: string);
  33451. private _resizeLoadingUI;
  33452. }
  33453. }
  33454. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33455. /**
  33456. * Interface for any object that can request an animation frame
  33457. */
  33458. export interface ICustomAnimationFrameRequester {
  33459. /**
  33460. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33461. */
  33462. renderFunction?: Function;
  33463. /**
  33464. * Called to request the next frame to render to
  33465. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33466. */
  33467. requestAnimationFrame: Function;
  33468. /**
  33469. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33470. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33471. */
  33472. requestID?: number;
  33473. }
  33474. }
  33475. declare module "babylonjs/Misc/performanceMonitor" {
  33476. /**
  33477. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33478. */
  33479. export class PerformanceMonitor {
  33480. private _enabled;
  33481. private _rollingFrameTime;
  33482. private _lastFrameTimeMs;
  33483. /**
  33484. * constructor
  33485. * @param frameSampleSize The number of samples required to saturate the sliding window
  33486. */
  33487. constructor(frameSampleSize?: number);
  33488. /**
  33489. * Samples current frame
  33490. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33491. */
  33492. sampleFrame(timeMs?: number): void;
  33493. /**
  33494. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33495. */
  33496. get averageFrameTime(): number;
  33497. /**
  33498. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33499. */
  33500. get averageFrameTimeVariance(): number;
  33501. /**
  33502. * Returns the frame time of the most recent frame
  33503. */
  33504. get instantaneousFrameTime(): number;
  33505. /**
  33506. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33507. */
  33508. get averageFPS(): number;
  33509. /**
  33510. * Returns the average framerate in frames per second using the most recent frame time
  33511. */
  33512. get instantaneousFPS(): number;
  33513. /**
  33514. * Returns true if enough samples have been taken to completely fill the sliding window
  33515. */
  33516. get isSaturated(): boolean;
  33517. /**
  33518. * Enables contributions to the sliding window sample set
  33519. */
  33520. enable(): void;
  33521. /**
  33522. * Disables contributions to the sliding window sample set
  33523. * Samples will not be interpolated over the disabled period
  33524. */
  33525. disable(): void;
  33526. /**
  33527. * Returns true if sampling is enabled
  33528. */
  33529. get isEnabled(): boolean;
  33530. /**
  33531. * Resets performance monitor
  33532. */
  33533. reset(): void;
  33534. }
  33535. /**
  33536. * RollingAverage
  33537. *
  33538. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33539. */
  33540. export class RollingAverage {
  33541. /**
  33542. * Current average
  33543. */
  33544. average: number;
  33545. /**
  33546. * Current variance
  33547. */
  33548. variance: number;
  33549. protected _samples: Array<number>;
  33550. protected _sampleCount: number;
  33551. protected _pos: number;
  33552. protected _m2: number;
  33553. /**
  33554. * constructor
  33555. * @param length The number of samples required to saturate the sliding window
  33556. */
  33557. constructor(length: number);
  33558. /**
  33559. * Adds a sample to the sample set
  33560. * @param v The sample value
  33561. */
  33562. add(v: number): void;
  33563. /**
  33564. * Returns previously added values or null if outside of history or outside the sliding window domain
  33565. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33566. * @return Value previously recorded with add() or null if outside of range
  33567. */
  33568. history(i: number): number;
  33569. /**
  33570. * Returns true if enough samples have been taken to completely fill the sliding window
  33571. * @return true if sample-set saturated
  33572. */
  33573. isSaturated(): boolean;
  33574. /**
  33575. * Resets the rolling average (equivalent to 0 samples taken so far)
  33576. */
  33577. reset(): void;
  33578. /**
  33579. * Wraps a value around the sample range boundaries
  33580. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33581. * @return Wrapped position in sample range
  33582. */
  33583. protected _wrapPosition(i: number): number;
  33584. }
  33585. }
  33586. declare module "babylonjs/Misc/perfCounter" {
  33587. /**
  33588. * This class is used to track a performance counter which is number based.
  33589. * The user has access to many properties which give statistics of different nature.
  33590. *
  33591. * The implementer can track two kinds of Performance Counter: time and count.
  33592. * 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.
  33593. * 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.
  33594. */
  33595. export class PerfCounter {
  33596. /**
  33597. * Gets or sets a global boolean to turn on and off all the counters
  33598. */
  33599. static Enabled: boolean;
  33600. /**
  33601. * Returns the smallest value ever
  33602. */
  33603. get min(): number;
  33604. /**
  33605. * Returns the biggest value ever
  33606. */
  33607. get max(): number;
  33608. /**
  33609. * Returns the average value since the performance counter is running
  33610. */
  33611. get average(): number;
  33612. /**
  33613. * Returns the average value of the last second the counter was monitored
  33614. */
  33615. get lastSecAverage(): number;
  33616. /**
  33617. * Returns the current value
  33618. */
  33619. get current(): number;
  33620. /**
  33621. * Gets the accumulated total
  33622. */
  33623. get total(): number;
  33624. /**
  33625. * Gets the total value count
  33626. */
  33627. get count(): number;
  33628. /**
  33629. * Creates a new counter
  33630. */
  33631. constructor();
  33632. /**
  33633. * Call this method to start monitoring a new frame.
  33634. * 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.
  33635. */
  33636. fetchNewFrame(): void;
  33637. /**
  33638. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33639. * @param newCount the count value to add to the monitored count
  33640. * @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.
  33641. */
  33642. addCount(newCount: number, fetchResult: boolean): void;
  33643. /**
  33644. * Start monitoring this performance counter
  33645. */
  33646. beginMonitoring(): void;
  33647. /**
  33648. * Compute the time lapsed since the previous beginMonitoring() call.
  33649. * @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
  33650. */
  33651. endMonitoring(newFrame?: boolean): void;
  33652. private _fetchResult;
  33653. private _startMonitoringTime;
  33654. private _min;
  33655. private _max;
  33656. private _average;
  33657. private _current;
  33658. private _totalValueCount;
  33659. private _totalAccumulated;
  33660. private _lastSecAverage;
  33661. private _lastSecAccumulated;
  33662. private _lastSecTime;
  33663. private _lastSecValueCount;
  33664. }
  33665. }
  33666. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33667. module "babylonjs/Engines/thinEngine" {
  33668. interface ThinEngine {
  33669. /**
  33670. * Sets alpha constants used by some alpha blending modes
  33671. * @param r defines the red component
  33672. * @param g defines the green component
  33673. * @param b defines the blue component
  33674. * @param a defines the alpha component
  33675. */
  33676. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33677. /**
  33678. * Sets the current alpha mode
  33679. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33680. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33682. */
  33683. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33684. /**
  33685. * Gets the current alpha mode
  33686. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33687. * @returns the current alpha mode
  33688. */
  33689. getAlphaMode(): number;
  33690. /**
  33691. * Sets the current alpha equation
  33692. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33693. */
  33694. setAlphaEquation(equation: number): void;
  33695. /**
  33696. * Gets the current alpha equation.
  33697. * @returns the current alpha equation
  33698. */
  33699. getAlphaEquation(): number;
  33700. }
  33701. }
  33702. }
  33703. declare module "babylonjs/Engines/engine" {
  33704. import { Observable } from "babylonjs/Misc/observable";
  33705. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33706. import { Scene } from "babylonjs/scene";
  33707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33708. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33709. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33710. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33711. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33712. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33713. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33714. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33715. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33717. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33719. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33720. import "babylonjs/Engines/Extensions/engine.alpha";
  33721. import { Material } from "babylonjs/Materials/material";
  33722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33723. /**
  33724. * Defines the interface used by display changed events
  33725. */
  33726. export interface IDisplayChangedEventArgs {
  33727. /** Gets the vrDisplay object (if any) */
  33728. vrDisplay: Nullable<any>;
  33729. /** Gets a boolean indicating if webVR is supported */
  33730. vrSupported: boolean;
  33731. }
  33732. /**
  33733. * Defines the interface used by objects containing a viewport (like a camera)
  33734. */
  33735. interface IViewportOwnerLike {
  33736. /**
  33737. * Gets or sets the viewport
  33738. */
  33739. viewport: IViewportLike;
  33740. }
  33741. /**
  33742. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33743. */
  33744. export class Engine extends ThinEngine {
  33745. /** Defines that alpha blending is disabled */
  33746. static readonly ALPHA_DISABLE: number;
  33747. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33748. static readonly ALPHA_ADD: number;
  33749. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33750. static readonly ALPHA_COMBINE: number;
  33751. /** Defines that alpha blending to DEST - SRC * DEST */
  33752. static readonly ALPHA_SUBTRACT: number;
  33753. /** Defines that alpha blending to SRC * DEST */
  33754. static readonly ALPHA_MULTIPLY: number;
  33755. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33756. static readonly ALPHA_MAXIMIZED: number;
  33757. /** Defines that alpha blending to SRC + DEST */
  33758. static readonly ALPHA_ONEONE: number;
  33759. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33760. static readonly ALPHA_PREMULTIPLIED: number;
  33761. /**
  33762. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33763. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33764. */
  33765. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33766. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33767. static readonly ALPHA_INTERPOLATE: number;
  33768. /**
  33769. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33770. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33771. */
  33772. static readonly ALPHA_SCREENMODE: number;
  33773. /** Defines that the ressource is not delayed*/
  33774. static readonly DELAYLOADSTATE_NONE: number;
  33775. /** Defines that the ressource was successfully delay loaded */
  33776. static readonly DELAYLOADSTATE_LOADED: number;
  33777. /** Defines that the ressource is currently delay loading */
  33778. static readonly DELAYLOADSTATE_LOADING: number;
  33779. /** Defines that the ressource is delayed and has not started loading */
  33780. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33781. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33782. static readonly NEVER: number;
  33783. /** 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 */
  33784. static readonly ALWAYS: number;
  33785. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33786. static readonly LESS: number;
  33787. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33788. static readonly EQUAL: number;
  33789. /** 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 */
  33790. static readonly LEQUAL: number;
  33791. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33792. static readonly GREATER: number;
  33793. /** 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 */
  33794. static readonly GEQUAL: number;
  33795. /** 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 */
  33796. static readonly NOTEQUAL: number;
  33797. /** Passed to stencilOperation to specify that stencil value must be kept */
  33798. static readonly KEEP: number;
  33799. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33800. static readonly REPLACE: number;
  33801. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33802. static readonly INCR: number;
  33803. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33804. static readonly DECR: number;
  33805. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33806. static readonly INVERT: number;
  33807. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33808. static readonly INCR_WRAP: number;
  33809. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33810. static readonly DECR_WRAP: number;
  33811. /** Texture is not repeating outside of 0..1 UVs */
  33812. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33813. /** Texture is repeating outside of 0..1 UVs */
  33814. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33815. /** Texture is repeating and mirrored */
  33816. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33817. /** ALPHA */
  33818. static readonly TEXTUREFORMAT_ALPHA: number;
  33819. /** LUMINANCE */
  33820. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33821. /** LUMINANCE_ALPHA */
  33822. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33823. /** RGB */
  33824. static readonly TEXTUREFORMAT_RGB: number;
  33825. /** RGBA */
  33826. static readonly TEXTUREFORMAT_RGBA: number;
  33827. /** RED */
  33828. static readonly TEXTUREFORMAT_RED: number;
  33829. /** RED (2nd reference) */
  33830. static readonly TEXTUREFORMAT_R: number;
  33831. /** RG */
  33832. static readonly TEXTUREFORMAT_RG: number;
  33833. /** RED_INTEGER */
  33834. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33835. /** RED_INTEGER (2nd reference) */
  33836. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33837. /** RG_INTEGER */
  33838. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33839. /** RGB_INTEGER */
  33840. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33841. /** RGBA_INTEGER */
  33842. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33843. /** UNSIGNED_BYTE */
  33844. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33845. /** UNSIGNED_BYTE (2nd reference) */
  33846. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33847. /** FLOAT */
  33848. static readonly TEXTURETYPE_FLOAT: number;
  33849. /** HALF_FLOAT */
  33850. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33851. /** BYTE */
  33852. static readonly TEXTURETYPE_BYTE: number;
  33853. /** SHORT */
  33854. static readonly TEXTURETYPE_SHORT: number;
  33855. /** UNSIGNED_SHORT */
  33856. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33857. /** INT */
  33858. static readonly TEXTURETYPE_INT: number;
  33859. /** UNSIGNED_INT */
  33860. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33861. /** UNSIGNED_SHORT_4_4_4_4 */
  33862. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33863. /** UNSIGNED_SHORT_5_5_5_1 */
  33864. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33865. /** UNSIGNED_SHORT_5_6_5 */
  33866. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33867. /** UNSIGNED_INT_2_10_10_10_REV */
  33868. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33869. /** UNSIGNED_INT_24_8 */
  33870. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33871. /** UNSIGNED_INT_10F_11F_11F_REV */
  33872. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33873. /** UNSIGNED_INT_5_9_9_9_REV */
  33874. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33875. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33876. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33877. /** nearest is mag = nearest and min = nearest and mip = linear */
  33878. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33880. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33881. /** Trilinear is mag = linear and min = linear and mip = linear */
  33882. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33883. /** nearest is mag = nearest and min = nearest and mip = linear */
  33884. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33885. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33886. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33887. /** Trilinear is mag = linear and min = linear and mip = linear */
  33888. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33889. /** mag = nearest and min = nearest and mip = nearest */
  33890. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33891. /** mag = nearest and min = linear and mip = nearest */
  33892. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33893. /** mag = nearest and min = linear and mip = linear */
  33894. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33895. /** mag = nearest and min = linear and mip = none */
  33896. static readonly TEXTURE_NEAREST_LINEAR: number;
  33897. /** mag = nearest and min = nearest and mip = none */
  33898. static readonly TEXTURE_NEAREST_NEAREST: number;
  33899. /** mag = linear and min = nearest and mip = nearest */
  33900. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33901. /** mag = linear and min = nearest and mip = linear */
  33902. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33903. /** mag = linear and min = linear and mip = none */
  33904. static readonly TEXTURE_LINEAR_LINEAR: number;
  33905. /** mag = linear and min = nearest and mip = none */
  33906. static readonly TEXTURE_LINEAR_NEAREST: number;
  33907. /** Explicit coordinates mode */
  33908. static readonly TEXTURE_EXPLICIT_MODE: number;
  33909. /** Spherical coordinates mode */
  33910. static readonly TEXTURE_SPHERICAL_MODE: number;
  33911. /** Planar coordinates mode */
  33912. static readonly TEXTURE_PLANAR_MODE: number;
  33913. /** Cubic coordinates mode */
  33914. static readonly TEXTURE_CUBIC_MODE: number;
  33915. /** Projection coordinates mode */
  33916. static readonly TEXTURE_PROJECTION_MODE: number;
  33917. /** Skybox coordinates mode */
  33918. static readonly TEXTURE_SKYBOX_MODE: number;
  33919. /** Inverse Cubic coordinates mode */
  33920. static readonly TEXTURE_INVCUBIC_MODE: number;
  33921. /** Equirectangular coordinates mode */
  33922. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33923. /** Equirectangular Fixed coordinates mode */
  33924. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33925. /** Equirectangular Fixed Mirrored coordinates mode */
  33926. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33927. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33928. static readonly SCALEMODE_FLOOR: number;
  33929. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33930. static readonly SCALEMODE_NEAREST: number;
  33931. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33932. static readonly SCALEMODE_CEILING: number;
  33933. /**
  33934. * Returns the current npm package of the sdk
  33935. */
  33936. static get NpmPackage(): string;
  33937. /**
  33938. * Returns the current version of the framework
  33939. */
  33940. static get Version(): string;
  33941. /** Gets the list of created engines */
  33942. static get Instances(): Engine[];
  33943. /**
  33944. * Gets the latest created engine
  33945. */
  33946. static get LastCreatedEngine(): Nullable<Engine>;
  33947. /**
  33948. * Gets the latest created scene
  33949. */
  33950. static get LastCreatedScene(): Nullable<Scene>;
  33951. /**
  33952. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33953. * @param flag defines which part of the materials must be marked as dirty
  33954. * @param predicate defines a predicate used to filter which materials should be affected
  33955. */
  33956. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33957. /**
  33958. * Method called to create the default loading screen.
  33959. * This can be overriden in your own app.
  33960. * @param canvas The rendering canvas element
  33961. * @returns The loading screen
  33962. */
  33963. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33964. /**
  33965. * Method called to create the default rescale post process on each engine.
  33966. */
  33967. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33968. /**
  33969. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33970. **/
  33971. enableOfflineSupport: boolean;
  33972. /**
  33973. * 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)
  33974. **/
  33975. disableManifestCheck: boolean;
  33976. /**
  33977. * Gets the list of created scenes
  33978. */
  33979. scenes: Scene[];
  33980. /**
  33981. * Event raised when a new scene is created
  33982. */
  33983. onNewSceneAddedObservable: Observable<Scene>;
  33984. /**
  33985. * Gets the list of created postprocesses
  33986. */
  33987. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33988. /**
  33989. * Gets a boolean indicating if the pointer is currently locked
  33990. */
  33991. isPointerLock: boolean;
  33992. /**
  33993. * Observable event triggered each time the rendering canvas is resized
  33994. */
  33995. onResizeObservable: Observable<Engine>;
  33996. /**
  33997. * Observable event triggered each time the canvas loses focus
  33998. */
  33999. onCanvasBlurObservable: Observable<Engine>;
  34000. /**
  34001. * Observable event triggered each time the canvas gains focus
  34002. */
  34003. onCanvasFocusObservable: Observable<Engine>;
  34004. /**
  34005. * Observable event triggered each time the canvas receives pointerout event
  34006. */
  34007. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34008. /**
  34009. * Observable raised when the engine begins a new frame
  34010. */
  34011. onBeginFrameObservable: Observable<Engine>;
  34012. /**
  34013. * If set, will be used to request the next animation frame for the render loop
  34014. */
  34015. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34016. /**
  34017. * Observable raised when the engine ends the current frame
  34018. */
  34019. onEndFrameObservable: Observable<Engine>;
  34020. /**
  34021. * Observable raised when the engine is about to compile a shader
  34022. */
  34023. onBeforeShaderCompilationObservable: Observable<Engine>;
  34024. /**
  34025. * Observable raised when the engine has jsut compiled a shader
  34026. */
  34027. onAfterShaderCompilationObservable: Observable<Engine>;
  34028. /**
  34029. * Gets the audio engine
  34030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34031. * @ignorenaming
  34032. */
  34033. static audioEngine: IAudioEngine;
  34034. /**
  34035. * Default AudioEngine factory responsible of creating the Audio Engine.
  34036. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34037. */
  34038. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34039. /**
  34040. * Default offline support factory responsible of creating a tool used to store data locally.
  34041. * By default, this will create a Database object if the workload has been embedded.
  34042. */
  34043. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34044. private _loadingScreen;
  34045. private _pointerLockRequested;
  34046. private _dummyFramebuffer;
  34047. private _rescalePostProcess;
  34048. private _deterministicLockstep;
  34049. private _lockstepMaxSteps;
  34050. private _timeStep;
  34051. protected get _supportsHardwareTextureRescaling(): boolean;
  34052. private _fps;
  34053. private _deltaTime;
  34054. /** @hidden */
  34055. _drawCalls: PerfCounter;
  34056. /**
  34057. * Turn this value on if you want to pause FPS computation when in background
  34058. */
  34059. disablePerformanceMonitorInBackground: boolean;
  34060. private _performanceMonitor;
  34061. /**
  34062. * Gets the performance monitor attached to this engine
  34063. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34064. */
  34065. get performanceMonitor(): PerformanceMonitor;
  34066. private _onFocus;
  34067. private _onBlur;
  34068. private _onCanvasPointerOut;
  34069. private _onCanvasBlur;
  34070. private _onCanvasFocus;
  34071. private _onFullscreenChange;
  34072. private _onPointerLockChange;
  34073. /**
  34074. * Gets the HTML element used to attach event listeners
  34075. * @returns a HTML element
  34076. */
  34077. getInputElement(): Nullable<HTMLElement>;
  34078. /**
  34079. * Creates a new engine
  34080. * @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
  34081. * @param antialias defines enable antialiasing (default: false)
  34082. * @param options defines further options to be sent to the getContext() function
  34083. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34084. */
  34085. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34086. /**
  34087. * Gets current aspect ratio
  34088. * @param viewportOwner defines the camera to use to get the aspect ratio
  34089. * @param useScreen defines if screen size must be used (or the current render target if any)
  34090. * @returns a number defining the aspect ratio
  34091. */
  34092. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34093. /**
  34094. * Gets current screen aspect ratio
  34095. * @returns a number defining the aspect ratio
  34096. */
  34097. getScreenAspectRatio(): number;
  34098. /**
  34099. * Gets the client rect of the HTML canvas attached with the current webGL context
  34100. * @returns a client rectanglee
  34101. */
  34102. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34103. /**
  34104. * Gets the client rect of the HTML element used for events
  34105. * @returns a client rectanglee
  34106. */
  34107. getInputElementClientRect(): Nullable<ClientRect>;
  34108. /**
  34109. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34111. * @returns true if engine is in deterministic lock step mode
  34112. */
  34113. isDeterministicLockStep(): boolean;
  34114. /**
  34115. * Gets the max steps when engine is running in deterministic lock step
  34116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34117. * @returns the max steps
  34118. */
  34119. getLockstepMaxSteps(): number;
  34120. /**
  34121. * Returns the time in ms between steps when using deterministic lock step.
  34122. * @returns time step in (ms)
  34123. */
  34124. getTimeStep(): number;
  34125. /**
  34126. * Force the mipmap generation for the given render target texture
  34127. * @param texture defines the render target texture to use
  34128. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34129. */
  34130. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34131. /** States */
  34132. /**
  34133. * Set various states to the webGL context
  34134. * @param culling defines backface culling state
  34135. * @param zOffset defines the value to apply to zOffset (0 by default)
  34136. * @param force defines if states must be applied even if cache is up to date
  34137. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34138. */
  34139. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34140. /**
  34141. * Set the z offset to apply to current rendering
  34142. * @param value defines the offset to apply
  34143. */
  34144. setZOffset(value: number): void;
  34145. /**
  34146. * Gets the current value of the zOffset
  34147. * @returns the current zOffset state
  34148. */
  34149. getZOffset(): number;
  34150. /**
  34151. * Enable or disable depth buffering
  34152. * @param enable defines the state to set
  34153. */
  34154. setDepthBuffer(enable: boolean): void;
  34155. /**
  34156. * Gets a boolean indicating if depth writing is enabled
  34157. * @returns the current depth writing state
  34158. */
  34159. getDepthWrite(): boolean;
  34160. /**
  34161. * Enable or disable depth writing
  34162. * @param enable defines the state to set
  34163. */
  34164. setDepthWrite(enable: boolean): void;
  34165. /**
  34166. * Gets a boolean indicating if stencil buffer is enabled
  34167. * @returns the current stencil buffer state
  34168. */
  34169. getStencilBuffer(): boolean;
  34170. /**
  34171. * Enable or disable the stencil buffer
  34172. * @param enable defines if the stencil buffer must be enabled or disabled
  34173. */
  34174. setStencilBuffer(enable: boolean): void;
  34175. /**
  34176. * Gets the current stencil mask
  34177. * @returns a number defining the new stencil mask to use
  34178. */
  34179. getStencilMask(): number;
  34180. /**
  34181. * Sets the current stencil mask
  34182. * @param mask defines the new stencil mask to use
  34183. */
  34184. setStencilMask(mask: number): void;
  34185. /**
  34186. * Gets the current stencil function
  34187. * @returns a number defining the stencil function to use
  34188. */
  34189. getStencilFunction(): number;
  34190. /**
  34191. * Gets the current stencil reference value
  34192. * @returns a number defining the stencil reference value to use
  34193. */
  34194. getStencilFunctionReference(): number;
  34195. /**
  34196. * Gets the current stencil mask
  34197. * @returns a number defining the stencil mask to use
  34198. */
  34199. getStencilFunctionMask(): number;
  34200. /**
  34201. * Sets the current stencil function
  34202. * @param stencilFunc defines the new stencil function to use
  34203. */
  34204. setStencilFunction(stencilFunc: number): void;
  34205. /**
  34206. * Sets the current stencil reference
  34207. * @param reference defines the new stencil reference to use
  34208. */
  34209. setStencilFunctionReference(reference: number): void;
  34210. /**
  34211. * Sets the current stencil mask
  34212. * @param mask defines the new stencil mask to use
  34213. */
  34214. setStencilFunctionMask(mask: number): void;
  34215. /**
  34216. * Gets the current stencil operation when stencil fails
  34217. * @returns a number defining stencil operation to use when stencil fails
  34218. */
  34219. getStencilOperationFail(): number;
  34220. /**
  34221. * Gets the current stencil operation when depth fails
  34222. * @returns a number defining stencil operation to use when depth fails
  34223. */
  34224. getStencilOperationDepthFail(): number;
  34225. /**
  34226. * Gets the current stencil operation when stencil passes
  34227. * @returns a number defining stencil operation to use when stencil passes
  34228. */
  34229. getStencilOperationPass(): number;
  34230. /**
  34231. * Sets the stencil operation to use when stencil fails
  34232. * @param operation defines the stencil operation to use when stencil fails
  34233. */
  34234. setStencilOperationFail(operation: number): void;
  34235. /**
  34236. * Sets the stencil operation to use when depth fails
  34237. * @param operation defines the stencil operation to use when depth fails
  34238. */
  34239. setStencilOperationDepthFail(operation: number): void;
  34240. /**
  34241. * Sets the stencil operation to use when stencil passes
  34242. * @param operation defines the stencil operation to use when stencil passes
  34243. */
  34244. setStencilOperationPass(operation: number): void;
  34245. /**
  34246. * Sets a boolean indicating if the dithering state is enabled or disabled
  34247. * @param value defines the dithering state
  34248. */
  34249. setDitheringState(value: boolean): void;
  34250. /**
  34251. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34252. * @param value defines the rasterizer state
  34253. */
  34254. setRasterizerState(value: boolean): void;
  34255. /**
  34256. * Gets the current depth function
  34257. * @returns a number defining the depth function
  34258. */
  34259. getDepthFunction(): Nullable<number>;
  34260. /**
  34261. * Sets the current depth function
  34262. * @param depthFunc defines the function to use
  34263. */
  34264. setDepthFunction(depthFunc: number): void;
  34265. /**
  34266. * Sets the current depth function to GREATER
  34267. */
  34268. setDepthFunctionToGreater(): void;
  34269. /**
  34270. * Sets the current depth function to GEQUAL
  34271. */
  34272. setDepthFunctionToGreaterOrEqual(): void;
  34273. /**
  34274. * Sets the current depth function to LESS
  34275. */
  34276. setDepthFunctionToLess(): void;
  34277. /**
  34278. * Sets the current depth function to LEQUAL
  34279. */
  34280. setDepthFunctionToLessOrEqual(): void;
  34281. private _cachedStencilBuffer;
  34282. private _cachedStencilFunction;
  34283. private _cachedStencilMask;
  34284. private _cachedStencilOperationPass;
  34285. private _cachedStencilOperationFail;
  34286. private _cachedStencilOperationDepthFail;
  34287. private _cachedStencilReference;
  34288. /**
  34289. * Caches the the state of the stencil buffer
  34290. */
  34291. cacheStencilState(): void;
  34292. /**
  34293. * Restores the state of the stencil buffer
  34294. */
  34295. restoreStencilState(): void;
  34296. /**
  34297. * Directly set the WebGL Viewport
  34298. * @param x defines the x coordinate of the viewport (in screen space)
  34299. * @param y defines the y coordinate of the viewport (in screen space)
  34300. * @param width defines the width of the viewport (in screen space)
  34301. * @param height defines the height of the viewport (in screen space)
  34302. * @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
  34303. */
  34304. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34305. /**
  34306. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34307. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34308. * @param y defines the y-coordinate of the corner of the clear rectangle
  34309. * @param width defines the width of the clear rectangle
  34310. * @param height defines the height of the clear rectangle
  34311. * @param clearColor defines the clear color
  34312. */
  34313. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34314. /**
  34315. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34316. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34317. * @param y defines the y-coordinate of the corner of the clear rectangle
  34318. * @param width defines the width of the clear rectangle
  34319. * @param height defines the height of the clear rectangle
  34320. */
  34321. enableScissor(x: number, y: number, width: number, height: number): void;
  34322. /**
  34323. * Disable previously set scissor test rectangle
  34324. */
  34325. disableScissor(): void;
  34326. protected _reportDrawCall(): void;
  34327. /**
  34328. * Initializes a webVR display and starts listening to display change events
  34329. * The onVRDisplayChangedObservable will be notified upon these changes
  34330. * @returns The onVRDisplayChangedObservable
  34331. */
  34332. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34333. /** @hidden */
  34334. _prepareVRComponent(): void;
  34335. /** @hidden */
  34336. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34337. /** @hidden */
  34338. _submitVRFrame(): void;
  34339. /**
  34340. * Call this function to leave webVR mode
  34341. * Will do nothing if webVR is not supported or if there is no webVR device
  34342. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34343. */
  34344. disableVR(): void;
  34345. /**
  34346. * Gets a boolean indicating that the system is in VR mode and is presenting
  34347. * @returns true if VR mode is engaged
  34348. */
  34349. isVRPresenting(): boolean;
  34350. /** @hidden */
  34351. _requestVRFrame(): void;
  34352. /** @hidden */
  34353. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34354. /**
  34355. * Gets the source code of the vertex shader associated with a specific webGL program
  34356. * @param program defines the program to use
  34357. * @returns a string containing the source code of the vertex shader associated with the program
  34358. */
  34359. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34360. /**
  34361. * Gets the source code of the fragment shader associated with a specific webGL program
  34362. * @param program defines the program to use
  34363. * @returns a string containing the source code of the fragment shader associated with the program
  34364. */
  34365. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34366. /**
  34367. * Sets a depth stencil texture from a render target to the according uniform.
  34368. * @param channel The texture channel
  34369. * @param uniform The uniform to set
  34370. * @param texture The render target texture containing the depth stencil texture to apply
  34371. */
  34372. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34373. /**
  34374. * Sets a texture to the webGL context from a postprocess
  34375. * @param channel defines the channel to use
  34376. * @param postProcess defines the source postprocess
  34377. */
  34378. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34379. /**
  34380. * Binds the output of the passed in post process to the texture channel specified
  34381. * @param channel The channel the texture should be bound to
  34382. * @param postProcess The post process which's output should be bound
  34383. */
  34384. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34385. /** @hidden */
  34386. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34387. protected _rebuildBuffers(): void;
  34388. /** @hidden */
  34389. _renderFrame(): void;
  34390. _renderLoop(): void;
  34391. /** @hidden */
  34392. _renderViews(): boolean;
  34393. /**
  34394. * Toggle full screen mode
  34395. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34396. */
  34397. switchFullscreen(requestPointerLock: boolean): void;
  34398. /**
  34399. * Enters full screen mode
  34400. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34401. */
  34402. enterFullscreen(requestPointerLock: boolean): void;
  34403. /**
  34404. * Exits full screen mode
  34405. */
  34406. exitFullscreen(): void;
  34407. /**
  34408. * Enters Pointerlock mode
  34409. */
  34410. enterPointerlock(): void;
  34411. /**
  34412. * Exits Pointerlock mode
  34413. */
  34414. exitPointerlock(): void;
  34415. /**
  34416. * Begin a new frame
  34417. */
  34418. beginFrame(): void;
  34419. /**
  34420. * Enf the current frame
  34421. */
  34422. endFrame(): void;
  34423. resize(): void;
  34424. /**
  34425. * Set the compressed texture format to use, based on the formats you have, and the formats
  34426. * supported by the hardware / browser.
  34427. *
  34428. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34429. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34430. * to API arguments needed to compressed textures. This puts the burden on the container
  34431. * generator to house the arcane code for determining these for current & future formats.
  34432. *
  34433. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34434. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34435. *
  34436. * Note: The result of this call is not taken into account when a texture is base64.
  34437. *
  34438. * @param formatsAvailable defines the list of those format families you have created
  34439. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34440. *
  34441. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34442. * @returns The extension selected.
  34443. */
  34444. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34445. /**
  34446. * Set the compressed texture extensions or file names to skip.
  34447. *
  34448. * @param skippedFiles defines the list of those texture files you want to skip
  34449. * Example: [".dds", ".env", "myfile.png"]
  34450. */
  34451. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34452. /**
  34453. * Force a specific size of the canvas
  34454. * @param width defines the new canvas' width
  34455. * @param height defines the new canvas' height
  34456. */
  34457. setSize(width: number, height: number): void;
  34458. /**
  34459. * Updates a dynamic vertex buffer.
  34460. * @param vertexBuffer the vertex buffer to update
  34461. * @param data the data used to update the vertex buffer
  34462. * @param byteOffset the byte offset of the data
  34463. * @param byteLength the byte length of the data
  34464. */
  34465. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34466. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34467. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34468. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34469. _releaseTexture(texture: InternalTexture): void;
  34470. /**
  34471. * @hidden
  34472. * Rescales a texture
  34473. * @param source input texutre
  34474. * @param destination destination texture
  34475. * @param scene scene to use to render the resize
  34476. * @param internalFormat format to use when resizing
  34477. * @param onComplete callback to be called when resize has completed
  34478. */
  34479. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34480. /**
  34481. * Gets the current framerate
  34482. * @returns a number representing the framerate
  34483. */
  34484. getFps(): number;
  34485. /**
  34486. * Gets the time spent between current and previous frame
  34487. * @returns a number representing the delta time in ms
  34488. */
  34489. getDeltaTime(): number;
  34490. private _measureFps;
  34491. /** @hidden */
  34492. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34493. /**
  34494. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34495. * @param renderTarget The render target to set the frame buffer for
  34496. */
  34497. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34498. /**
  34499. * Update a dynamic index buffer
  34500. * @param indexBuffer defines the target index buffer
  34501. * @param indices defines the data to update
  34502. * @param offset defines the offset in the target index buffer where update should start
  34503. */
  34504. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34505. /**
  34506. * Updates the sample count of a render target texture
  34507. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34508. * @param texture defines the texture to update
  34509. * @param samples defines the sample count to set
  34510. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34511. */
  34512. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34513. /**
  34514. * Updates a depth texture Comparison Mode and Function.
  34515. * If the comparison Function is equal to 0, the mode will be set to none.
  34516. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34517. * @param texture The texture to set the comparison function for
  34518. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34519. */
  34520. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34521. /**
  34522. * Creates a webGL buffer to use with instanciation
  34523. * @param capacity defines the size of the buffer
  34524. * @returns the webGL buffer
  34525. */
  34526. createInstancesBuffer(capacity: number): DataBuffer;
  34527. /**
  34528. * Delete a webGL buffer used with instanciation
  34529. * @param buffer defines the webGL buffer to delete
  34530. */
  34531. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34532. /** @hidden */
  34533. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34534. dispose(): void;
  34535. private _disableTouchAction;
  34536. /**
  34537. * Display the loading screen
  34538. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34539. */
  34540. displayLoadingUI(): void;
  34541. /**
  34542. * Hide the loading screen
  34543. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34544. */
  34545. hideLoadingUI(): void;
  34546. /**
  34547. * Gets the current loading screen object
  34548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34549. */
  34550. get loadingScreen(): ILoadingScreen;
  34551. /**
  34552. * Sets the current loading screen object
  34553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34554. */
  34555. set loadingScreen(loadingScreen: ILoadingScreen);
  34556. /**
  34557. * Sets the current loading screen text
  34558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34559. */
  34560. set loadingUIText(text: string);
  34561. /**
  34562. * Sets the current loading screen background color
  34563. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34564. */
  34565. set loadingUIBackgroundColor(color: string);
  34566. /** Pointerlock and fullscreen */
  34567. /**
  34568. * Ask the browser to promote the current element to pointerlock mode
  34569. * @param element defines the DOM element to promote
  34570. */
  34571. static _RequestPointerlock(element: HTMLElement): void;
  34572. /**
  34573. * Asks the browser to exit pointerlock mode
  34574. */
  34575. static _ExitPointerlock(): void;
  34576. /**
  34577. * Ask the browser to promote the current element to fullscreen rendering mode
  34578. * @param element defines the DOM element to promote
  34579. */
  34580. static _RequestFullscreen(element: HTMLElement): void;
  34581. /**
  34582. * Asks the browser to exit fullscreen mode
  34583. */
  34584. static _ExitFullscreen(): void;
  34585. }
  34586. }
  34587. declare module "babylonjs/Engines/engineStore" {
  34588. import { Nullable } from "babylonjs/types";
  34589. import { Engine } from "babylonjs/Engines/engine";
  34590. import { Scene } from "babylonjs/scene";
  34591. /**
  34592. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34593. * during the life time of the application.
  34594. */
  34595. export class EngineStore {
  34596. /** Gets the list of created engines */
  34597. static Instances: import("babylonjs/Engines/engine").Engine[];
  34598. /** @hidden */
  34599. static _LastCreatedScene: Nullable<Scene>;
  34600. /**
  34601. * Gets the latest created engine
  34602. */
  34603. static get LastCreatedEngine(): Nullable<Engine>;
  34604. /**
  34605. * Gets the latest created scene
  34606. */
  34607. static get LastCreatedScene(): Nullable<Scene>;
  34608. /**
  34609. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34610. * @ignorenaming
  34611. */
  34612. static UseFallbackTexture: boolean;
  34613. /**
  34614. * Texture content used if a texture cannot loaded
  34615. * @ignorenaming
  34616. */
  34617. static FallbackTexture: string;
  34618. }
  34619. }
  34620. declare module "babylonjs/Misc/promise" {
  34621. /**
  34622. * Helper class that provides a small promise polyfill
  34623. */
  34624. export class PromisePolyfill {
  34625. /**
  34626. * Static function used to check if the polyfill is required
  34627. * If this is the case then the function will inject the polyfill to window.Promise
  34628. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34629. */
  34630. static Apply(force?: boolean): void;
  34631. }
  34632. }
  34633. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34634. /**
  34635. * Interface for screenshot methods with describe argument called `size` as object with options
  34636. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34637. */
  34638. export interface IScreenshotSize {
  34639. /**
  34640. * number in pixels for canvas height
  34641. */
  34642. height?: number;
  34643. /**
  34644. * multiplier allowing render at a higher or lower resolution
  34645. * If value is defined then height and width will be ignored and taken from camera
  34646. */
  34647. precision?: number;
  34648. /**
  34649. * number in pixels for canvas width
  34650. */
  34651. width?: number;
  34652. }
  34653. }
  34654. declare module "babylonjs/Misc/tools" {
  34655. import { Nullable, float } from "babylonjs/types";
  34656. import { DomManagement } from "babylonjs/Misc/domManagement";
  34657. import { WebRequest } from "babylonjs/Misc/webRequest";
  34658. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34659. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34660. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34661. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34662. import { Camera } from "babylonjs/Cameras/camera";
  34663. import { Engine } from "babylonjs/Engines/engine";
  34664. interface IColor4Like {
  34665. r: float;
  34666. g: float;
  34667. b: float;
  34668. a: float;
  34669. }
  34670. /**
  34671. * Class containing a set of static utilities functions
  34672. */
  34673. export class Tools {
  34674. /**
  34675. * Gets or sets the base URL to use to load assets
  34676. */
  34677. static get BaseUrl(): string;
  34678. static set BaseUrl(value: string);
  34679. /**
  34680. * Enable/Disable Custom HTTP Request Headers globally.
  34681. * default = false
  34682. * @see CustomRequestHeaders
  34683. */
  34684. static UseCustomRequestHeaders: boolean;
  34685. /**
  34686. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34687. * i.e. when loading files, where the server/service expects an Authorization header
  34688. */
  34689. static CustomRequestHeaders: {
  34690. [key: string]: string;
  34691. };
  34692. /**
  34693. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34694. */
  34695. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34696. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34697. /**
  34698. * Default behaviour for cors in the application.
  34699. * It can be a string if the expected behavior is identical in the entire app.
  34700. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34701. */
  34702. static CorsBehavior: string | ((url: string | string[]) => string);
  34703. /**
  34704. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34705. * @ignorenaming
  34706. */
  34707. static get UseFallbackTexture(): boolean;
  34708. static set UseFallbackTexture(value: boolean);
  34709. /**
  34710. * Use this object to register external classes like custom textures or material
  34711. * to allow the laoders to instantiate them
  34712. */
  34713. static get RegisteredExternalClasses(): {
  34714. [key: string]: Object;
  34715. };
  34716. static set RegisteredExternalClasses(classes: {
  34717. [key: string]: Object;
  34718. });
  34719. /**
  34720. * Texture content used if a texture cannot loaded
  34721. * @ignorenaming
  34722. */
  34723. static get fallbackTexture(): string;
  34724. static set fallbackTexture(value: string);
  34725. /**
  34726. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34727. * @param u defines the coordinate on X axis
  34728. * @param v defines the coordinate on Y axis
  34729. * @param width defines the width of the source data
  34730. * @param height defines the height of the source data
  34731. * @param pixels defines the source byte array
  34732. * @param color defines the output color
  34733. */
  34734. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34735. /**
  34736. * Interpolates between a and b via alpha
  34737. * @param a The lower value (returned when alpha = 0)
  34738. * @param b The upper value (returned when alpha = 1)
  34739. * @param alpha The interpolation-factor
  34740. * @return The mixed value
  34741. */
  34742. static Mix(a: number, b: number, alpha: number): number;
  34743. /**
  34744. * Tries to instantiate a new object from a given class name
  34745. * @param className defines the class name to instantiate
  34746. * @returns the new object or null if the system was not able to do the instantiation
  34747. */
  34748. static Instantiate(className: string): any;
  34749. /**
  34750. * Provides a slice function that will work even on IE
  34751. * @param data defines the array to slice
  34752. * @param start defines the start of the data (optional)
  34753. * @param end defines the end of the data (optional)
  34754. * @returns the new sliced array
  34755. */
  34756. static Slice<T>(data: T, start?: number, end?: number): T;
  34757. /**
  34758. * Polyfill for setImmediate
  34759. * @param action defines the action to execute after the current execution block
  34760. */
  34761. static SetImmediate(action: () => void): void;
  34762. /**
  34763. * Function indicating if a number is an exponent of 2
  34764. * @param value defines the value to test
  34765. * @returns true if the value is an exponent of 2
  34766. */
  34767. static IsExponentOfTwo(value: number): boolean;
  34768. private static _tmpFloatArray;
  34769. /**
  34770. * Returns the nearest 32-bit single precision float representation of a Number
  34771. * @param value A Number. If the parameter is of a different type, it will get converted
  34772. * to a number or to NaN if it cannot be converted
  34773. * @returns number
  34774. */
  34775. static FloatRound(value: number): number;
  34776. /**
  34777. * Extracts the filename from a path
  34778. * @param path defines the path to use
  34779. * @returns the filename
  34780. */
  34781. static GetFilename(path: string): string;
  34782. /**
  34783. * Extracts the "folder" part of a path (everything before the filename).
  34784. * @param uri The URI to extract the info from
  34785. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34786. * @returns The "folder" part of the path
  34787. */
  34788. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34789. /**
  34790. * Extracts text content from a DOM element hierarchy
  34791. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34792. */
  34793. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34794. /**
  34795. * Convert an angle in radians to degrees
  34796. * @param angle defines the angle to convert
  34797. * @returns the angle in degrees
  34798. */
  34799. static ToDegrees(angle: number): number;
  34800. /**
  34801. * Convert an angle in degrees to radians
  34802. * @param angle defines the angle to convert
  34803. * @returns the angle in radians
  34804. */
  34805. static ToRadians(angle: number): number;
  34806. /**
  34807. * Returns an array if obj is not an array
  34808. * @param obj defines the object to evaluate as an array
  34809. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34810. * @returns either obj directly if obj is an array or a new array containing obj
  34811. */
  34812. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34813. /**
  34814. * Gets the pointer prefix to use
  34815. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34816. */
  34817. static GetPointerPrefix(): string;
  34818. /**
  34819. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34820. * @param url define the url we are trying
  34821. * @param element define the dom element where to configure the cors policy
  34822. */
  34823. static SetCorsBehavior(url: string | string[], element: {
  34824. crossOrigin: string | null;
  34825. }): void;
  34826. /**
  34827. * Removes unwanted characters from an url
  34828. * @param url defines the url to clean
  34829. * @returns the cleaned url
  34830. */
  34831. static CleanUrl(url: string): string;
  34832. /**
  34833. * Gets or sets a function used to pre-process url before using them to load assets
  34834. */
  34835. static get PreprocessUrl(): (url: string) => string;
  34836. static set PreprocessUrl(processor: (url: string) => string);
  34837. /**
  34838. * Loads an image as an HTMLImageElement.
  34839. * @param input url string, ArrayBuffer, or Blob to load
  34840. * @param onLoad callback called when the image successfully loads
  34841. * @param onError callback called when the image fails to load
  34842. * @param offlineProvider offline provider for caching
  34843. * @param mimeType optional mime type
  34844. * @returns the HTMLImageElement of the loaded image
  34845. */
  34846. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34847. /**
  34848. * Loads a file from a url
  34849. * @param url url string, ArrayBuffer, or Blob to load
  34850. * @param onSuccess callback called when the file successfully loads
  34851. * @param onProgress callback called while file is loading (if the server supports this mode)
  34852. * @param offlineProvider defines the offline provider for caching
  34853. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34854. * @param onError callback called when the file fails to load
  34855. * @returns a file request object
  34856. */
  34857. 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;
  34858. /**
  34859. * Loads a file from a url
  34860. * @param url the file url to load
  34861. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34862. */
  34863. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34864. /**
  34865. * Load a script (identified by an url). When the url returns, the
  34866. * content of this file is added into a new script element, attached to the DOM (body element)
  34867. * @param scriptUrl defines the url of the script to laod
  34868. * @param onSuccess defines the callback called when the script is loaded
  34869. * @param onError defines the callback to call if an error occurs
  34870. * @param scriptId defines the id of the script element
  34871. */
  34872. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34873. /**
  34874. * Load an asynchronous script (identified by an url). When the url returns, the
  34875. * content of this file is added into a new script element, attached to the DOM (body element)
  34876. * @param scriptUrl defines the url of the script to laod
  34877. * @param scriptId defines the id of the script element
  34878. * @returns a promise request object
  34879. */
  34880. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34881. /**
  34882. * Loads a file from a blob
  34883. * @param fileToLoad defines the blob to use
  34884. * @param callback defines the callback to call when data is loaded
  34885. * @param progressCallback defines the callback to call during loading process
  34886. * @returns a file request object
  34887. */
  34888. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34889. /**
  34890. * Reads a file from a File object
  34891. * @param file defines the file to load
  34892. * @param onSuccess defines the callback to call when data is loaded
  34893. * @param onProgress defines the callback to call during loading process
  34894. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34895. * @param onError defines the callback to call when an error occurs
  34896. * @returns a file request object
  34897. */
  34898. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34899. /**
  34900. * Creates a data url from a given string content
  34901. * @param content defines the content to convert
  34902. * @returns the new data url link
  34903. */
  34904. static FileAsURL(content: string): string;
  34905. /**
  34906. * Format the given number to a specific decimal format
  34907. * @param value defines the number to format
  34908. * @param decimals defines the number of decimals to use
  34909. * @returns the formatted string
  34910. */
  34911. static Format(value: number, decimals?: number): string;
  34912. /**
  34913. * Tries to copy an object by duplicating every property
  34914. * @param source defines the source object
  34915. * @param destination defines the target object
  34916. * @param doNotCopyList defines a list of properties to avoid
  34917. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34918. */
  34919. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34920. /**
  34921. * Gets a boolean indicating if the given object has no own property
  34922. * @param obj defines the object to test
  34923. * @returns true if object has no own property
  34924. */
  34925. static IsEmpty(obj: any): boolean;
  34926. /**
  34927. * Function used to register events at window level
  34928. * @param windowElement defines the Window object to use
  34929. * @param events defines the events to register
  34930. */
  34931. static RegisterTopRootEvents(windowElement: Window, events: {
  34932. name: string;
  34933. handler: Nullable<(e: FocusEvent) => any>;
  34934. }[]): void;
  34935. /**
  34936. * Function used to unregister events from window level
  34937. * @param windowElement defines the Window object to use
  34938. * @param events defines the events to unregister
  34939. */
  34940. static UnregisterTopRootEvents(windowElement: Window, events: {
  34941. name: string;
  34942. handler: Nullable<(e: FocusEvent) => any>;
  34943. }[]): void;
  34944. /**
  34945. * @ignore
  34946. */
  34947. static _ScreenshotCanvas: HTMLCanvasElement;
  34948. /**
  34949. * Dumps the current bound framebuffer
  34950. * @param width defines the rendering width
  34951. * @param height defines the rendering height
  34952. * @param engine defines the hosting engine
  34953. * @param successCallback defines the callback triggered once the data are available
  34954. * @param mimeType defines the mime type of the result
  34955. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34956. */
  34957. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34958. /**
  34959. * Converts the canvas data to blob.
  34960. * This acts as a polyfill for browsers not supporting the to blob function.
  34961. * @param canvas Defines the canvas to extract the data from
  34962. * @param successCallback Defines the callback triggered once the data are available
  34963. * @param mimeType Defines the mime type of the result
  34964. */
  34965. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34966. /**
  34967. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34968. * @param successCallback defines the callback triggered once the data are available
  34969. * @param mimeType defines the mime type of the result
  34970. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34971. */
  34972. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34973. /**
  34974. * Downloads a blob in the browser
  34975. * @param blob defines the blob to download
  34976. * @param fileName defines the name of the downloaded file
  34977. */
  34978. static Download(blob: Blob, fileName: string): void;
  34979. /**
  34980. * Captures a screenshot of the current rendering
  34981. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34982. * @param engine defines the rendering engine
  34983. * @param camera defines the source camera
  34984. * @param size This parameter can be set to a single number or to an object with the
  34985. * following (optional) properties: precision, width, height. If a single number is passed,
  34986. * it will be used for both width and height. If an object is passed, the screenshot size
  34987. * will be derived from the parameters. The precision property is a multiplier allowing
  34988. * rendering at a higher or lower resolution
  34989. * @param successCallback defines the callback receives a single parameter which contains the
  34990. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34991. * src parameter of an <img> to display it
  34992. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34993. * Check your browser for supported MIME types
  34994. */
  34995. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34996. /**
  34997. * Captures a screenshot of the current rendering
  34998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34999. * @param engine defines the rendering engine
  35000. * @param camera defines the source camera
  35001. * @param size This parameter can be set to a single number or to an object with the
  35002. * following (optional) properties: precision, width, height. If a single number is passed,
  35003. * it will be used for both width and height. If an object is passed, the screenshot size
  35004. * will be derived from the parameters. The precision property is a multiplier allowing
  35005. * rendering at a higher or lower resolution
  35006. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35007. * Check your browser for supported MIME types
  35008. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35009. * to the src parameter of an <img> to display it
  35010. */
  35011. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35012. /**
  35013. * Generates an image screenshot from the specified camera.
  35014. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35015. * @param engine The engine to use for rendering
  35016. * @param camera The camera to use for rendering
  35017. * @param size This parameter can be set to a single number or to an object with the
  35018. * following (optional) properties: precision, width, height. If a single number is passed,
  35019. * it will be used for both width and height. If an object is passed, the screenshot size
  35020. * will be derived from the parameters. The precision property is a multiplier allowing
  35021. * rendering at a higher or lower resolution
  35022. * @param successCallback The callback receives a single parameter which contains the
  35023. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35024. * src parameter of an <img> to display it
  35025. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35026. * Check your browser for supported MIME types
  35027. * @param samples Texture samples (default: 1)
  35028. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35029. * @param fileName A name for for the downloaded file.
  35030. */
  35031. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35032. /**
  35033. * Generates an image screenshot from the specified camera.
  35034. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35035. * @param engine The engine to use for rendering
  35036. * @param camera The camera to use for rendering
  35037. * @param size This parameter can be set to a single number or to an object with the
  35038. * following (optional) properties: precision, width, height. If a single number is passed,
  35039. * it will be used for both width and height. If an object is passed, the screenshot size
  35040. * will be derived from the parameters. The precision property is a multiplier allowing
  35041. * rendering at a higher or lower resolution
  35042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35043. * Check your browser for supported MIME types
  35044. * @param samples Texture samples (default: 1)
  35045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35046. * @param fileName A name for for the downloaded file.
  35047. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35048. * to the src parameter of an <img> to display it
  35049. */
  35050. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35051. /**
  35052. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35053. * Be aware Math.random() could cause collisions, but:
  35054. * "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"
  35055. * @returns a pseudo random id
  35056. */
  35057. static RandomId(): string;
  35058. /**
  35059. * Test if the given uri is a base64 string
  35060. * @param uri The uri to test
  35061. * @return True if the uri is a base64 string or false otherwise
  35062. */
  35063. static IsBase64(uri: string): boolean;
  35064. /**
  35065. * Decode the given base64 uri.
  35066. * @param uri The uri to decode
  35067. * @return The decoded base64 data.
  35068. */
  35069. static DecodeBase64(uri: string): ArrayBuffer;
  35070. /**
  35071. * Gets the absolute url.
  35072. * @param url the input url
  35073. * @return the absolute url
  35074. */
  35075. static GetAbsoluteUrl(url: string): string;
  35076. /**
  35077. * No log
  35078. */
  35079. static readonly NoneLogLevel: number;
  35080. /**
  35081. * Only message logs
  35082. */
  35083. static readonly MessageLogLevel: number;
  35084. /**
  35085. * Only warning logs
  35086. */
  35087. static readonly WarningLogLevel: number;
  35088. /**
  35089. * Only error logs
  35090. */
  35091. static readonly ErrorLogLevel: number;
  35092. /**
  35093. * All logs
  35094. */
  35095. static readonly AllLogLevel: number;
  35096. /**
  35097. * Gets a value indicating the number of loading errors
  35098. * @ignorenaming
  35099. */
  35100. static get errorsCount(): number;
  35101. /**
  35102. * Callback called when a new log is added
  35103. */
  35104. static OnNewCacheEntry: (entry: string) => void;
  35105. /**
  35106. * Log a message to the console
  35107. * @param message defines the message to log
  35108. */
  35109. static Log(message: string): void;
  35110. /**
  35111. * Write a warning message to the console
  35112. * @param message defines the message to log
  35113. */
  35114. static Warn(message: string): void;
  35115. /**
  35116. * Write an error message to the console
  35117. * @param message defines the message to log
  35118. */
  35119. static Error(message: string): void;
  35120. /**
  35121. * Gets current log cache (list of logs)
  35122. */
  35123. static get LogCache(): string;
  35124. /**
  35125. * Clears the log cache
  35126. */
  35127. static ClearLogCache(): void;
  35128. /**
  35129. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35130. */
  35131. static set LogLevels(level: number);
  35132. /**
  35133. * Checks if the window object exists
  35134. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35135. */
  35136. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35137. /**
  35138. * No performance log
  35139. */
  35140. static readonly PerformanceNoneLogLevel: number;
  35141. /**
  35142. * Use user marks to log performance
  35143. */
  35144. static readonly PerformanceUserMarkLogLevel: number;
  35145. /**
  35146. * Log performance to the console
  35147. */
  35148. static readonly PerformanceConsoleLogLevel: number;
  35149. private static _performance;
  35150. /**
  35151. * Sets the current performance log level
  35152. */
  35153. static set PerformanceLogLevel(level: number);
  35154. private static _StartPerformanceCounterDisabled;
  35155. private static _EndPerformanceCounterDisabled;
  35156. private static _StartUserMark;
  35157. private static _EndUserMark;
  35158. private static _StartPerformanceConsole;
  35159. private static _EndPerformanceConsole;
  35160. /**
  35161. * Starts a performance counter
  35162. */
  35163. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35164. /**
  35165. * Ends a specific performance coutner
  35166. */
  35167. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35168. /**
  35169. * Gets either window.performance.now() if supported or Date.now() else
  35170. */
  35171. static get Now(): number;
  35172. /**
  35173. * This method will return the name of the class used to create the instance of the given object.
  35174. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35175. * @param object the object to get the class name from
  35176. * @param isType defines if the object is actually a type
  35177. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35178. */
  35179. static GetClassName(object: any, isType?: boolean): string;
  35180. /**
  35181. * Gets the first element of an array satisfying a given predicate
  35182. * @param array defines the array to browse
  35183. * @param predicate defines the predicate to use
  35184. * @returns null if not found or the element
  35185. */
  35186. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35187. /**
  35188. * This method will return the name of the full name of the class, including its owning module (if any).
  35189. * 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).
  35190. * @param object the object to get the class name from
  35191. * @param isType defines if the object is actually a type
  35192. * @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.
  35193. * @ignorenaming
  35194. */
  35195. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35196. /**
  35197. * Returns a promise that resolves after the given amount of time.
  35198. * @param delay Number of milliseconds to delay
  35199. * @returns Promise that resolves after the given amount of time
  35200. */
  35201. static DelayAsync(delay: number): Promise<void>;
  35202. }
  35203. /**
  35204. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35205. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35206. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35207. * @param name The name of the class, case should be preserved
  35208. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35209. */
  35210. export function className(name: string, module?: string): (target: Object) => void;
  35211. /**
  35212. * An implementation of a loop for asynchronous functions.
  35213. */
  35214. export class AsyncLoop {
  35215. /**
  35216. * Defines the number of iterations for the loop
  35217. */
  35218. iterations: number;
  35219. /**
  35220. * Defines the current index of the loop.
  35221. */
  35222. index: number;
  35223. private _done;
  35224. private _fn;
  35225. private _successCallback;
  35226. /**
  35227. * Constructor.
  35228. * @param iterations the number of iterations.
  35229. * @param func the function to run each iteration
  35230. * @param successCallback the callback that will be called upon succesful execution
  35231. * @param offset starting offset.
  35232. */
  35233. constructor(
  35234. /**
  35235. * Defines the number of iterations for the loop
  35236. */
  35237. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35238. /**
  35239. * Execute the next iteration. Must be called after the last iteration was finished.
  35240. */
  35241. executeNext(): void;
  35242. /**
  35243. * Break the loop and run the success callback.
  35244. */
  35245. breakLoop(): void;
  35246. /**
  35247. * Create and run an async loop.
  35248. * @param iterations the number of iterations.
  35249. * @param fn the function to run each iteration
  35250. * @param successCallback the callback that will be called upon succesful execution
  35251. * @param offset starting offset.
  35252. * @returns the created async loop object
  35253. */
  35254. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35255. /**
  35256. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35257. * @param iterations total number of iterations
  35258. * @param syncedIterations number of synchronous iterations in each async iteration.
  35259. * @param fn the function to call each iteration.
  35260. * @param callback a success call back that will be called when iterating stops.
  35261. * @param breakFunction a break condition (optional)
  35262. * @param timeout timeout settings for the setTimeout function. default - 0.
  35263. * @returns the created async loop object
  35264. */
  35265. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35266. }
  35267. }
  35268. declare module "babylonjs/Misc/stringDictionary" {
  35269. import { Nullable } from "babylonjs/types";
  35270. /**
  35271. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35272. * The underlying implementation relies on an associative array to ensure the best performances.
  35273. * The value can be anything including 'null' but except 'undefined'
  35274. */
  35275. export class StringDictionary<T> {
  35276. /**
  35277. * This will clear this dictionary and copy the content from the 'source' one.
  35278. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35279. * @param source the dictionary to take the content from and copy to this dictionary
  35280. */
  35281. copyFrom(source: StringDictionary<T>): void;
  35282. /**
  35283. * Get a value based from its key
  35284. * @param key the given key to get the matching value from
  35285. * @return the value if found, otherwise undefined is returned
  35286. */
  35287. get(key: string): T | undefined;
  35288. /**
  35289. * Get a value from its key or add it if it doesn't exist.
  35290. * This method will ensure you that a given key/data will be present in the dictionary.
  35291. * @param key the given key to get the matching value from
  35292. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35293. * The factory will only be invoked if there's no data for the given key.
  35294. * @return the value corresponding to the key.
  35295. */
  35296. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35297. /**
  35298. * Get a value from its key if present in the dictionary otherwise add it
  35299. * @param key the key to get the value from
  35300. * @param val if there's no such key/value pair in the dictionary add it with this value
  35301. * @return the value corresponding to the key
  35302. */
  35303. getOrAdd(key: string, val: T): T;
  35304. /**
  35305. * Check if there's a given key in the dictionary
  35306. * @param key the key to check for
  35307. * @return true if the key is present, false otherwise
  35308. */
  35309. contains(key: string): boolean;
  35310. /**
  35311. * Add a new key and its corresponding value
  35312. * @param key the key to add
  35313. * @param value the value corresponding to the key
  35314. * @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
  35315. */
  35316. add(key: string, value: T): boolean;
  35317. /**
  35318. * Update a specific value associated to a key
  35319. * @param key defines the key to use
  35320. * @param value defines the value to store
  35321. * @returns true if the value was updated (or false if the key was not found)
  35322. */
  35323. set(key: string, value: T): boolean;
  35324. /**
  35325. * Get the element of the given key and remove it from the dictionary
  35326. * @param key defines the key to search
  35327. * @returns the value associated with the key or null if not found
  35328. */
  35329. getAndRemove(key: string): Nullable<T>;
  35330. /**
  35331. * Remove a key/value from the dictionary.
  35332. * @param key the key to remove
  35333. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35334. */
  35335. remove(key: string): boolean;
  35336. /**
  35337. * Clear the whole content of the dictionary
  35338. */
  35339. clear(): void;
  35340. /**
  35341. * Gets the current count
  35342. */
  35343. get count(): number;
  35344. /**
  35345. * Execute a callback on each key/val of the dictionary.
  35346. * Note that you can remove any element in this dictionary in the callback implementation
  35347. * @param callback the callback to execute on a given key/value pair
  35348. */
  35349. forEach(callback: (key: string, val: T) => void): void;
  35350. /**
  35351. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35352. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35353. * Note that you can remove any element in this dictionary in the callback implementation
  35354. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35355. * @returns the first item
  35356. */
  35357. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35358. private _count;
  35359. private _data;
  35360. }
  35361. }
  35362. declare module "babylonjs/Collisions/collisionCoordinator" {
  35363. import { Nullable } from "babylonjs/types";
  35364. import { Scene } from "babylonjs/scene";
  35365. import { Vector3 } from "babylonjs/Maths/math.vector";
  35366. import { Collider } from "babylonjs/Collisions/collider";
  35367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35368. /** @hidden */
  35369. export interface ICollisionCoordinator {
  35370. createCollider(): Collider;
  35371. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35372. init(scene: Scene): void;
  35373. }
  35374. /** @hidden */
  35375. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35376. private _scene;
  35377. private _scaledPosition;
  35378. private _scaledVelocity;
  35379. private _finalPosition;
  35380. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35381. createCollider(): Collider;
  35382. init(scene: Scene): void;
  35383. private _collideWithWorld;
  35384. }
  35385. }
  35386. declare module "babylonjs/Inputs/scene.inputManager" {
  35387. import { Nullable } from "babylonjs/types";
  35388. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35389. import { Vector2 } from "babylonjs/Maths/math.vector";
  35390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35391. import { Scene } from "babylonjs/scene";
  35392. /**
  35393. * Class used to manage all inputs for the scene.
  35394. */
  35395. export class InputManager {
  35396. /** The distance in pixel that you have to move to prevent some events */
  35397. static DragMovementThreshold: number;
  35398. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35399. static LongPressDelay: number;
  35400. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35401. static DoubleClickDelay: number;
  35402. /** If you need to check double click without raising a single click at first click, enable this flag */
  35403. static ExclusiveDoubleClickMode: boolean;
  35404. private _wheelEventName;
  35405. private _onPointerMove;
  35406. private _onPointerDown;
  35407. private _onPointerUp;
  35408. private _initClickEvent;
  35409. private _initActionManager;
  35410. private _delayedSimpleClick;
  35411. private _delayedSimpleClickTimeout;
  35412. private _previousDelayedSimpleClickTimeout;
  35413. private _meshPickProceed;
  35414. private _previousButtonPressed;
  35415. private _currentPickResult;
  35416. private _previousPickResult;
  35417. private _totalPointersPressed;
  35418. private _doubleClickOccured;
  35419. private _pointerOverMesh;
  35420. private _pickedDownMesh;
  35421. private _pickedUpMesh;
  35422. private _pointerX;
  35423. private _pointerY;
  35424. private _unTranslatedPointerX;
  35425. private _unTranslatedPointerY;
  35426. private _startingPointerPosition;
  35427. private _previousStartingPointerPosition;
  35428. private _startingPointerTime;
  35429. private _previousStartingPointerTime;
  35430. private _pointerCaptures;
  35431. private _onKeyDown;
  35432. private _onKeyUp;
  35433. private _onCanvasFocusObserver;
  35434. private _onCanvasBlurObserver;
  35435. private _scene;
  35436. /**
  35437. * Creates a new InputManager
  35438. * @param scene defines the hosting scene
  35439. */
  35440. constructor(scene: Scene);
  35441. /**
  35442. * Gets the mesh that is currently under the pointer
  35443. */
  35444. get meshUnderPointer(): Nullable<AbstractMesh>;
  35445. /**
  35446. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35447. */
  35448. get unTranslatedPointer(): Vector2;
  35449. /**
  35450. * Gets or sets the current on-screen X position of the pointer
  35451. */
  35452. get pointerX(): number;
  35453. set pointerX(value: number);
  35454. /**
  35455. * Gets or sets the current on-screen Y position of the pointer
  35456. */
  35457. get pointerY(): number;
  35458. set pointerY(value: number);
  35459. private _updatePointerPosition;
  35460. private _processPointerMove;
  35461. private _setRayOnPointerInfo;
  35462. private _checkPrePointerObservable;
  35463. /**
  35464. * Use this method to simulate a pointer move on a mesh
  35465. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35466. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35467. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35468. */
  35469. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35470. /**
  35471. * Use this method to simulate a pointer down on a mesh
  35472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35475. */
  35476. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35477. private _processPointerDown;
  35478. /** @hidden */
  35479. _isPointerSwiping(): boolean;
  35480. /**
  35481. * Use this method to simulate a pointer up on a mesh
  35482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35485. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35486. */
  35487. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35488. private _processPointerUp;
  35489. /**
  35490. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35491. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35492. * @returns true if the pointer was captured
  35493. */
  35494. isPointerCaptured(pointerId?: number): boolean;
  35495. /**
  35496. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35497. * @param attachUp defines if you want to attach events to pointerup
  35498. * @param attachDown defines if you want to attach events to pointerdown
  35499. * @param attachMove defines if you want to attach events to pointermove
  35500. */
  35501. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35502. /**
  35503. * Detaches all event handlers
  35504. */
  35505. detachControl(): void;
  35506. /**
  35507. * Force the value of meshUnderPointer
  35508. * @param mesh defines the mesh to use
  35509. */
  35510. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35511. /**
  35512. * Gets the mesh under the pointer
  35513. * @returns a Mesh or null if no mesh is under the pointer
  35514. */
  35515. getPointerOverMesh(): Nullable<AbstractMesh>;
  35516. }
  35517. }
  35518. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35519. /**
  35520. * Helper class used to generate session unique ID
  35521. */
  35522. export class UniqueIdGenerator {
  35523. private static _UniqueIdCounter;
  35524. /**
  35525. * Gets an unique (relatively to the current scene) Id
  35526. */
  35527. static get UniqueId(): number;
  35528. }
  35529. }
  35530. declare module "babylonjs/Animations/animationGroup" {
  35531. import { Animatable } from "babylonjs/Animations/animatable";
  35532. import { Animation } from "babylonjs/Animations/animation";
  35533. import { Scene, IDisposable } from "babylonjs/scene";
  35534. import { Observable } from "babylonjs/Misc/observable";
  35535. import { Nullable } from "babylonjs/types";
  35536. import "babylonjs/Animations/animatable";
  35537. /**
  35538. * This class defines the direct association between an animation and a target
  35539. */
  35540. export class TargetedAnimation {
  35541. /**
  35542. * Animation to perform
  35543. */
  35544. animation: Animation;
  35545. /**
  35546. * Target to animate
  35547. */
  35548. target: any;
  35549. /**
  35550. * Serialize the object
  35551. * @returns the JSON object representing the current entity
  35552. */
  35553. serialize(): any;
  35554. }
  35555. /**
  35556. * Use this class to create coordinated animations on multiple targets
  35557. */
  35558. export class AnimationGroup implements IDisposable {
  35559. /** The name of the animation group */
  35560. name: string;
  35561. private _scene;
  35562. private _targetedAnimations;
  35563. private _animatables;
  35564. private _from;
  35565. private _to;
  35566. private _isStarted;
  35567. private _isPaused;
  35568. private _speedRatio;
  35569. private _loopAnimation;
  35570. /**
  35571. * Gets or sets the unique id of the node
  35572. */
  35573. uniqueId: number;
  35574. /**
  35575. * This observable will notify when one animation have ended
  35576. */
  35577. onAnimationEndObservable: Observable<TargetedAnimation>;
  35578. /**
  35579. * Observer raised when one animation loops
  35580. */
  35581. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35582. /**
  35583. * Observer raised when all animations have looped
  35584. */
  35585. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35586. /**
  35587. * This observable will notify when all animations have ended.
  35588. */
  35589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35590. /**
  35591. * This observable will notify when all animations have paused.
  35592. */
  35593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35594. /**
  35595. * This observable will notify when all animations are playing.
  35596. */
  35597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35598. /**
  35599. * Gets the first frame
  35600. */
  35601. get from(): number;
  35602. /**
  35603. * Gets the last frame
  35604. */
  35605. get to(): number;
  35606. /**
  35607. * Define if the animations are started
  35608. */
  35609. get isStarted(): boolean;
  35610. /**
  35611. * Gets a value indicating that the current group is playing
  35612. */
  35613. get isPlaying(): boolean;
  35614. /**
  35615. * Gets or sets the speed ratio to use for all animations
  35616. */
  35617. get speedRatio(): number;
  35618. /**
  35619. * Gets or sets the speed ratio to use for all animations
  35620. */
  35621. set speedRatio(value: number);
  35622. /**
  35623. * Gets or sets if all animations should loop or not
  35624. */
  35625. get loopAnimation(): boolean;
  35626. set loopAnimation(value: boolean);
  35627. /**
  35628. * Gets the targeted animations for this animation group
  35629. */
  35630. get targetedAnimations(): Array<TargetedAnimation>;
  35631. /**
  35632. * returning the list of animatables controlled by this animation group.
  35633. */
  35634. get animatables(): Array<Animatable>;
  35635. /**
  35636. * Instantiates a new Animation Group.
  35637. * This helps managing several animations at once.
  35638. * @see http://doc.babylonjs.com/how_to/group
  35639. * @param name Defines the name of the group
  35640. * @param scene Defines the scene the group belongs to
  35641. */
  35642. constructor(
  35643. /** The name of the animation group */
  35644. name: string, scene?: Nullable<Scene>);
  35645. /**
  35646. * Add an animation (with its target) in the group
  35647. * @param animation defines the animation we want to add
  35648. * @param target defines the target of the animation
  35649. * @returns the TargetedAnimation object
  35650. */
  35651. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35652. /**
  35653. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35654. * It can add constant keys at begin or end
  35655. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35656. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35657. * @returns the animation group
  35658. */
  35659. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35660. private _animationLoopCount;
  35661. private _animationLoopFlags;
  35662. private _processLoop;
  35663. /**
  35664. * Start all animations on given targets
  35665. * @param loop defines if animations must loop
  35666. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35667. * @param from defines the from key (optional)
  35668. * @param to defines the to key (optional)
  35669. * @returns the current animation group
  35670. */
  35671. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35672. /**
  35673. * Pause all animations
  35674. * @returns the animation group
  35675. */
  35676. pause(): AnimationGroup;
  35677. /**
  35678. * Play all animations to initial state
  35679. * This function will start() the animations if they were not started or will restart() them if they were paused
  35680. * @param loop defines if animations must loop
  35681. * @returns the animation group
  35682. */
  35683. play(loop?: boolean): AnimationGroup;
  35684. /**
  35685. * Reset all animations to initial state
  35686. * @returns the animation group
  35687. */
  35688. reset(): AnimationGroup;
  35689. /**
  35690. * Restart animations from key 0
  35691. * @returns the animation group
  35692. */
  35693. restart(): AnimationGroup;
  35694. /**
  35695. * Stop all animations
  35696. * @returns the animation group
  35697. */
  35698. stop(): AnimationGroup;
  35699. /**
  35700. * Set animation weight for all animatables
  35701. * @param weight defines the weight to use
  35702. * @return the animationGroup
  35703. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35704. */
  35705. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35706. /**
  35707. * Synchronize and normalize all animatables with a source animatable
  35708. * @param root defines the root animatable to synchronize with
  35709. * @return the animationGroup
  35710. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35711. */
  35712. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35713. /**
  35714. * Goes to a specific frame in this animation group
  35715. * @param frame the frame number to go to
  35716. * @return the animationGroup
  35717. */
  35718. goToFrame(frame: number): AnimationGroup;
  35719. /**
  35720. * Dispose all associated resources
  35721. */
  35722. dispose(): void;
  35723. private _checkAnimationGroupEnded;
  35724. /**
  35725. * Clone the current animation group and returns a copy
  35726. * @param newName defines the name of the new group
  35727. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35728. * @returns the new aniamtion group
  35729. */
  35730. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35731. /**
  35732. * Serializes the animationGroup to an object
  35733. * @returns Serialized object
  35734. */
  35735. serialize(): any;
  35736. /**
  35737. * Returns a new AnimationGroup object parsed from the source provided.
  35738. * @param parsedAnimationGroup defines the source
  35739. * @param scene defines the scene that will receive the animationGroup
  35740. * @returns a new AnimationGroup
  35741. */
  35742. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35743. /**
  35744. * Returns the string "AnimationGroup"
  35745. * @returns "AnimationGroup"
  35746. */
  35747. getClassName(): string;
  35748. /**
  35749. * Creates a detailled string about the object
  35750. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35751. * @returns a string representing the object
  35752. */
  35753. toString(fullDetails?: boolean): string;
  35754. }
  35755. }
  35756. declare module "babylonjs/scene" {
  35757. import { Nullable } from "babylonjs/types";
  35758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35759. import { Observable } from "babylonjs/Misc/observable";
  35760. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35761. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35762. import { Geometry } from "babylonjs/Meshes/geometry";
  35763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35764. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35766. import { Mesh } from "babylonjs/Meshes/mesh";
  35767. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35768. import { Bone } from "babylonjs/Bones/bone";
  35769. import { Skeleton } from "babylonjs/Bones/skeleton";
  35770. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35771. import { Camera } from "babylonjs/Cameras/camera";
  35772. import { AbstractScene } from "babylonjs/abstractScene";
  35773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35775. import { Material } from "babylonjs/Materials/material";
  35776. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35777. import { Effect } from "babylonjs/Materials/effect";
  35778. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35779. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35780. import { Light } from "babylonjs/Lights/light";
  35781. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35782. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35783. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35784. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35786. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35787. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35788. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35789. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35790. import { Engine } from "babylonjs/Engines/engine";
  35791. import { Node } from "babylonjs/node";
  35792. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35793. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35794. import { WebRequest } from "babylonjs/Misc/webRequest";
  35795. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35796. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35797. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35798. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35799. import { Plane } from "babylonjs/Maths/math.plane";
  35800. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35801. import { Ray } from "babylonjs/Culling/ray";
  35802. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35803. import { Animation } from "babylonjs/Animations/animation";
  35804. import { Animatable } from "babylonjs/Animations/animatable";
  35805. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35806. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35807. import { Collider } from "babylonjs/Collisions/collider";
  35808. /**
  35809. * Define an interface for all classes that will hold resources
  35810. */
  35811. export interface IDisposable {
  35812. /**
  35813. * Releases all held resources
  35814. */
  35815. dispose(): void;
  35816. }
  35817. /** Interface defining initialization parameters for Scene class */
  35818. export interface SceneOptions {
  35819. /**
  35820. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35821. * It will improve performance when the number of geometries becomes important.
  35822. */
  35823. useGeometryUniqueIdsMap?: boolean;
  35824. /**
  35825. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35826. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35827. */
  35828. useMaterialMeshMap?: boolean;
  35829. /**
  35830. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35831. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35832. */
  35833. useClonedMeshhMap?: boolean;
  35834. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35835. virtual?: boolean;
  35836. }
  35837. /**
  35838. * Represents a scene to be rendered by the engine.
  35839. * @see http://doc.babylonjs.com/features/scene
  35840. */
  35841. export class Scene extends AbstractScene implements IAnimatable {
  35842. /** The fog is deactivated */
  35843. static readonly FOGMODE_NONE: number;
  35844. /** The fog density is following an exponential function */
  35845. static readonly FOGMODE_EXP: number;
  35846. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35847. static readonly FOGMODE_EXP2: number;
  35848. /** The fog density is following a linear function. */
  35849. static readonly FOGMODE_LINEAR: number;
  35850. /**
  35851. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35852. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35853. */
  35854. static MinDeltaTime: number;
  35855. /**
  35856. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35858. */
  35859. static MaxDeltaTime: number;
  35860. /**
  35861. * Factory used to create the default material.
  35862. * @param name The name of the material to create
  35863. * @param scene The scene to create the material for
  35864. * @returns The default material
  35865. */
  35866. static DefaultMaterialFactory(scene: Scene): Material;
  35867. /**
  35868. * Factory used to create the a collision coordinator.
  35869. * @returns The collision coordinator
  35870. */
  35871. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35872. /** @hidden */
  35873. _inputManager: InputManager;
  35874. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35875. cameraToUseForPointers: Nullable<Camera>;
  35876. /** @hidden */
  35877. readonly _isScene: boolean;
  35878. /**
  35879. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35880. */
  35881. autoClear: boolean;
  35882. /**
  35883. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35884. */
  35885. autoClearDepthAndStencil: boolean;
  35886. /**
  35887. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35888. */
  35889. clearColor: Color4;
  35890. /**
  35891. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35892. */
  35893. ambientColor: Color3;
  35894. /**
  35895. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35896. * It should only be one of the following (if not the default embedded one):
  35897. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35898. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35899. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35900. * The material properties need to be setup according to the type of texture in use.
  35901. */
  35902. environmentBRDFTexture: BaseTexture;
  35903. /** @hidden */
  35904. protected _environmentTexture: Nullable<BaseTexture>;
  35905. /**
  35906. * Texture used in all pbr material as the reflection texture.
  35907. * As in the majority of the scene they are the same (exception for multi room and so on),
  35908. * this is easier to reference from here than from all the materials.
  35909. */
  35910. get environmentTexture(): Nullable<BaseTexture>;
  35911. /**
  35912. * Texture used in all pbr material as the reflection texture.
  35913. * As in the majority of the scene they are the same (exception for multi room and so on),
  35914. * this is easier to set here than in all the materials.
  35915. */
  35916. set environmentTexture(value: Nullable<BaseTexture>);
  35917. /** @hidden */
  35918. protected _environmentIntensity: number;
  35919. /**
  35920. * Intensity of the environment in all pbr material.
  35921. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35922. * As in the majority of the scene they are the same (exception for multi room and so on),
  35923. * this is easier to reference from here than from all the materials.
  35924. */
  35925. get environmentIntensity(): number;
  35926. /**
  35927. * Intensity of the environment in all pbr material.
  35928. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35929. * As in the majority of the scene they are the same (exception for multi room and so on),
  35930. * this is easier to set here than in all the materials.
  35931. */
  35932. set environmentIntensity(value: number);
  35933. /** @hidden */
  35934. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35935. /**
  35936. * Default image processing configuration used either in the rendering
  35937. * Forward main pass or through the imageProcessingPostProcess if present.
  35938. * As in the majority of the scene they are the same (exception for multi camera),
  35939. * this is easier to reference from here than from all the materials and post process.
  35940. *
  35941. * No setter as we it is a shared configuration, you can set the values instead.
  35942. */
  35943. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35944. private _forceWireframe;
  35945. /**
  35946. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35947. */
  35948. set forceWireframe(value: boolean);
  35949. get forceWireframe(): boolean;
  35950. private _forcePointsCloud;
  35951. /**
  35952. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35953. */
  35954. set forcePointsCloud(value: boolean);
  35955. get forcePointsCloud(): boolean;
  35956. /**
  35957. * Gets or sets the active clipplane 1
  35958. */
  35959. clipPlane: Nullable<Plane>;
  35960. /**
  35961. * Gets or sets the active clipplane 2
  35962. */
  35963. clipPlane2: Nullable<Plane>;
  35964. /**
  35965. * Gets or sets the active clipplane 3
  35966. */
  35967. clipPlane3: Nullable<Plane>;
  35968. /**
  35969. * Gets or sets the active clipplane 4
  35970. */
  35971. clipPlane4: Nullable<Plane>;
  35972. /**
  35973. * Gets or sets a boolean indicating if animations are enabled
  35974. */
  35975. animationsEnabled: boolean;
  35976. private _animationPropertiesOverride;
  35977. /**
  35978. * Gets or sets the animation properties override
  35979. */
  35980. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35981. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35982. /**
  35983. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35984. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35985. */
  35986. useConstantAnimationDeltaTime: boolean;
  35987. /**
  35988. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35989. * Please note that it requires to run a ray cast through the scene on every frame
  35990. */
  35991. constantlyUpdateMeshUnderPointer: boolean;
  35992. /**
  35993. * Defines the HTML cursor to use when hovering over interactive elements
  35994. */
  35995. hoverCursor: string;
  35996. /**
  35997. * Defines the HTML default cursor to use (empty by default)
  35998. */
  35999. defaultCursor: string;
  36000. /**
  36001. * Defines wether cursors are handled by the scene.
  36002. */
  36003. doNotHandleCursors: boolean;
  36004. /**
  36005. * This is used to call preventDefault() on pointer down
  36006. * in order to block unwanted artifacts like system double clicks
  36007. */
  36008. preventDefaultOnPointerDown: boolean;
  36009. /**
  36010. * This is used to call preventDefault() on pointer up
  36011. * in order to block unwanted artifacts like system double clicks
  36012. */
  36013. preventDefaultOnPointerUp: boolean;
  36014. /**
  36015. * Gets or sets user defined metadata
  36016. */
  36017. metadata: any;
  36018. /**
  36019. * For internal use only. Please do not use.
  36020. */
  36021. reservedDataStore: any;
  36022. /**
  36023. * Gets the name of the plugin used to load this scene (null by default)
  36024. */
  36025. loadingPluginName: string;
  36026. /**
  36027. * Use this array to add regular expressions used to disable offline support for specific urls
  36028. */
  36029. disableOfflineSupportExceptionRules: RegExp[];
  36030. /**
  36031. * An event triggered when the scene is disposed.
  36032. */
  36033. onDisposeObservable: Observable<Scene>;
  36034. private _onDisposeObserver;
  36035. /** Sets a function to be executed when this scene is disposed. */
  36036. set onDispose(callback: () => void);
  36037. /**
  36038. * An event triggered before rendering the scene (right after animations and physics)
  36039. */
  36040. onBeforeRenderObservable: Observable<Scene>;
  36041. private _onBeforeRenderObserver;
  36042. /** Sets a function to be executed before rendering this scene */
  36043. set beforeRender(callback: Nullable<() => void>);
  36044. /**
  36045. * An event triggered after rendering the scene
  36046. */
  36047. onAfterRenderObservable: Observable<Scene>;
  36048. /**
  36049. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36050. */
  36051. onAfterRenderCameraObservable: Observable<Camera>;
  36052. private _onAfterRenderObserver;
  36053. /** Sets a function to be executed after rendering this scene */
  36054. set afterRender(callback: Nullable<() => void>);
  36055. /**
  36056. * An event triggered before animating the scene
  36057. */
  36058. onBeforeAnimationsObservable: Observable<Scene>;
  36059. /**
  36060. * An event triggered after animations processing
  36061. */
  36062. onAfterAnimationsObservable: Observable<Scene>;
  36063. /**
  36064. * An event triggered before draw calls are ready to be sent
  36065. */
  36066. onBeforeDrawPhaseObservable: Observable<Scene>;
  36067. /**
  36068. * An event triggered after draw calls have been sent
  36069. */
  36070. onAfterDrawPhaseObservable: Observable<Scene>;
  36071. /**
  36072. * An event triggered when the scene is ready
  36073. */
  36074. onReadyObservable: Observable<Scene>;
  36075. /**
  36076. * An event triggered before rendering a camera
  36077. */
  36078. onBeforeCameraRenderObservable: Observable<Camera>;
  36079. private _onBeforeCameraRenderObserver;
  36080. /** Sets a function to be executed before rendering a camera*/
  36081. set beforeCameraRender(callback: () => void);
  36082. /**
  36083. * An event triggered after rendering a camera
  36084. */
  36085. onAfterCameraRenderObservable: Observable<Camera>;
  36086. private _onAfterCameraRenderObserver;
  36087. /** Sets a function to be executed after rendering a camera*/
  36088. set afterCameraRender(callback: () => void);
  36089. /**
  36090. * An event triggered when active meshes evaluation is about to start
  36091. */
  36092. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36093. /**
  36094. * An event triggered when active meshes evaluation is done
  36095. */
  36096. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36097. /**
  36098. * An event triggered when particles rendering is about to start
  36099. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36100. */
  36101. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36102. /**
  36103. * An event triggered when particles rendering is done
  36104. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36105. */
  36106. onAfterParticlesRenderingObservable: Observable<Scene>;
  36107. /**
  36108. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36109. */
  36110. onDataLoadedObservable: Observable<Scene>;
  36111. /**
  36112. * An event triggered when a camera is created
  36113. */
  36114. onNewCameraAddedObservable: Observable<Camera>;
  36115. /**
  36116. * An event triggered when a camera is removed
  36117. */
  36118. onCameraRemovedObservable: Observable<Camera>;
  36119. /**
  36120. * An event triggered when a light is created
  36121. */
  36122. onNewLightAddedObservable: Observable<Light>;
  36123. /**
  36124. * An event triggered when a light is removed
  36125. */
  36126. onLightRemovedObservable: Observable<Light>;
  36127. /**
  36128. * An event triggered when a geometry is created
  36129. */
  36130. onNewGeometryAddedObservable: Observable<Geometry>;
  36131. /**
  36132. * An event triggered when a geometry is removed
  36133. */
  36134. onGeometryRemovedObservable: Observable<Geometry>;
  36135. /**
  36136. * An event triggered when a transform node is created
  36137. */
  36138. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36139. /**
  36140. * An event triggered when a transform node is removed
  36141. */
  36142. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36143. /**
  36144. * An event triggered when a mesh is created
  36145. */
  36146. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36147. /**
  36148. * An event triggered when a mesh is removed
  36149. */
  36150. onMeshRemovedObservable: Observable<AbstractMesh>;
  36151. /**
  36152. * An event triggered when a skeleton is created
  36153. */
  36154. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36155. /**
  36156. * An event triggered when a skeleton is removed
  36157. */
  36158. onSkeletonRemovedObservable: Observable<Skeleton>;
  36159. /**
  36160. * An event triggered when a material is created
  36161. */
  36162. onNewMaterialAddedObservable: Observable<Material>;
  36163. /**
  36164. * An event triggered when a material is removed
  36165. */
  36166. onMaterialRemovedObservable: Observable<Material>;
  36167. /**
  36168. * An event triggered when a texture is created
  36169. */
  36170. onNewTextureAddedObservable: Observable<BaseTexture>;
  36171. /**
  36172. * An event triggered when a texture is removed
  36173. */
  36174. onTextureRemovedObservable: Observable<BaseTexture>;
  36175. /**
  36176. * An event triggered when render targets are about to be rendered
  36177. * Can happen multiple times per frame.
  36178. */
  36179. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36180. /**
  36181. * An event triggered when render targets were rendered.
  36182. * Can happen multiple times per frame.
  36183. */
  36184. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36185. /**
  36186. * An event triggered before calculating deterministic simulation step
  36187. */
  36188. onBeforeStepObservable: Observable<Scene>;
  36189. /**
  36190. * An event triggered after calculating deterministic simulation step
  36191. */
  36192. onAfterStepObservable: Observable<Scene>;
  36193. /**
  36194. * An event triggered when the activeCamera property is updated
  36195. */
  36196. onActiveCameraChanged: Observable<Scene>;
  36197. /**
  36198. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36199. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36200. * 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)
  36201. */
  36202. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36203. /**
  36204. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36205. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36206. * 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)
  36207. */
  36208. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36209. /**
  36210. * This Observable will when a mesh has been imported into the scene.
  36211. */
  36212. onMeshImportedObservable: Observable<AbstractMesh>;
  36213. /**
  36214. * This Observable will when an animation file has been imported into the scene.
  36215. */
  36216. onAnimationFileImportedObservable: Observable<Scene>;
  36217. /**
  36218. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36219. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36220. */
  36221. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36222. /** @hidden */
  36223. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36224. /**
  36225. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36226. */
  36227. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36228. /**
  36229. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36230. */
  36231. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36232. /**
  36233. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36234. */
  36235. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36236. /** Callback called when a pointer move is detected */
  36237. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36238. /** Callback called when a pointer down is detected */
  36239. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36240. /** Callback called when a pointer up is detected */
  36241. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36242. /** Callback called when a pointer pick is detected */
  36243. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36244. /**
  36245. * 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).
  36246. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36247. */
  36248. onPrePointerObservable: Observable<PointerInfoPre>;
  36249. /**
  36250. * Observable event triggered each time an input event is received from the rendering canvas
  36251. */
  36252. onPointerObservable: Observable<PointerInfo>;
  36253. /**
  36254. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36255. */
  36256. get unTranslatedPointer(): Vector2;
  36257. /**
  36258. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36259. */
  36260. static get DragMovementThreshold(): number;
  36261. static set DragMovementThreshold(value: number);
  36262. /**
  36263. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36264. */
  36265. static get LongPressDelay(): number;
  36266. static set LongPressDelay(value: number);
  36267. /**
  36268. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36269. */
  36270. static get DoubleClickDelay(): number;
  36271. static set DoubleClickDelay(value: number);
  36272. /** If you need to check double click without raising a single click at first click, enable this flag */
  36273. static get ExclusiveDoubleClickMode(): boolean;
  36274. static set ExclusiveDoubleClickMode(value: boolean);
  36275. /** @hidden */
  36276. _mirroredCameraPosition: Nullable<Vector3>;
  36277. /**
  36278. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36279. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36280. */
  36281. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36282. /**
  36283. * Observable event triggered each time an keyboard event is received from the hosting window
  36284. */
  36285. onKeyboardObservable: Observable<KeyboardInfo>;
  36286. private _useRightHandedSystem;
  36287. /**
  36288. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36289. */
  36290. set useRightHandedSystem(value: boolean);
  36291. get useRightHandedSystem(): boolean;
  36292. private _timeAccumulator;
  36293. private _currentStepId;
  36294. private _currentInternalStep;
  36295. /**
  36296. * Sets the step Id used by deterministic lock step
  36297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36298. * @param newStepId defines the step Id
  36299. */
  36300. setStepId(newStepId: number): void;
  36301. /**
  36302. * Gets the step Id used by deterministic lock step
  36303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36304. * @returns the step Id
  36305. */
  36306. getStepId(): number;
  36307. /**
  36308. * Gets the internal step used by deterministic lock step
  36309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36310. * @returns the internal step
  36311. */
  36312. getInternalStep(): number;
  36313. private _fogEnabled;
  36314. /**
  36315. * Gets or sets a boolean indicating if fog is enabled on this scene
  36316. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36317. * (Default is true)
  36318. */
  36319. set fogEnabled(value: boolean);
  36320. get fogEnabled(): boolean;
  36321. private _fogMode;
  36322. /**
  36323. * Gets or sets the fog mode to use
  36324. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36325. * | mode | value |
  36326. * | --- | --- |
  36327. * | FOGMODE_NONE | 0 |
  36328. * | FOGMODE_EXP | 1 |
  36329. * | FOGMODE_EXP2 | 2 |
  36330. * | FOGMODE_LINEAR | 3 |
  36331. */
  36332. set fogMode(value: number);
  36333. get fogMode(): number;
  36334. /**
  36335. * Gets or sets the fog color to use
  36336. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36337. * (Default is Color3(0.2, 0.2, 0.3))
  36338. */
  36339. fogColor: Color3;
  36340. /**
  36341. * Gets or sets the fog density to use
  36342. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36343. * (Default is 0.1)
  36344. */
  36345. fogDensity: number;
  36346. /**
  36347. * Gets or sets the fog start distance to use
  36348. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36349. * (Default is 0)
  36350. */
  36351. fogStart: number;
  36352. /**
  36353. * Gets or sets the fog end distance to use
  36354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36355. * (Default is 1000)
  36356. */
  36357. fogEnd: number;
  36358. private _shadowsEnabled;
  36359. /**
  36360. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36361. */
  36362. set shadowsEnabled(value: boolean);
  36363. get shadowsEnabled(): boolean;
  36364. private _lightsEnabled;
  36365. /**
  36366. * Gets or sets a boolean indicating if lights are enabled on this scene
  36367. */
  36368. set lightsEnabled(value: boolean);
  36369. get lightsEnabled(): boolean;
  36370. /** All of the active cameras added to this scene. */
  36371. activeCameras: Camera[];
  36372. /** @hidden */
  36373. _activeCamera: Nullable<Camera>;
  36374. /** Gets or sets the current active camera */
  36375. get activeCamera(): Nullable<Camera>;
  36376. set activeCamera(value: Nullable<Camera>);
  36377. private _defaultMaterial;
  36378. /** The default material used on meshes when no material is affected */
  36379. get defaultMaterial(): Material;
  36380. /** The default material used on meshes when no material is affected */
  36381. set defaultMaterial(value: Material);
  36382. private _texturesEnabled;
  36383. /**
  36384. * Gets or sets a boolean indicating if textures are enabled on this scene
  36385. */
  36386. set texturesEnabled(value: boolean);
  36387. get texturesEnabled(): boolean;
  36388. /**
  36389. * Gets or sets a boolean indicating if particles are enabled on this scene
  36390. */
  36391. particlesEnabled: boolean;
  36392. /**
  36393. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36394. */
  36395. spritesEnabled: boolean;
  36396. private _skeletonsEnabled;
  36397. /**
  36398. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36399. */
  36400. set skeletonsEnabled(value: boolean);
  36401. get skeletonsEnabled(): boolean;
  36402. /**
  36403. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36404. */
  36405. lensFlaresEnabled: boolean;
  36406. /**
  36407. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36409. */
  36410. collisionsEnabled: boolean;
  36411. private _collisionCoordinator;
  36412. /** @hidden */
  36413. get collisionCoordinator(): ICollisionCoordinator;
  36414. /**
  36415. * Defines the gravity applied to this scene (used only for collisions)
  36416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36417. */
  36418. gravity: Vector3;
  36419. /**
  36420. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36421. */
  36422. postProcessesEnabled: boolean;
  36423. /**
  36424. * The list of postprocesses added to the scene
  36425. */
  36426. postProcesses: PostProcess[];
  36427. /**
  36428. * Gets the current postprocess manager
  36429. */
  36430. postProcessManager: PostProcessManager;
  36431. /**
  36432. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36433. */
  36434. renderTargetsEnabled: boolean;
  36435. /**
  36436. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36437. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36438. */
  36439. dumpNextRenderTargets: boolean;
  36440. /**
  36441. * The list of user defined render targets added to the scene
  36442. */
  36443. customRenderTargets: RenderTargetTexture[];
  36444. /**
  36445. * Defines if texture loading must be delayed
  36446. * If true, textures will only be loaded when they need to be rendered
  36447. */
  36448. useDelayedTextureLoading: boolean;
  36449. /**
  36450. * Gets the list of meshes imported to the scene through SceneLoader
  36451. */
  36452. importedMeshesFiles: String[];
  36453. /**
  36454. * Gets or sets a boolean indicating if probes are enabled on this scene
  36455. */
  36456. probesEnabled: boolean;
  36457. /**
  36458. * Gets or sets the current offline provider to use to store scene data
  36459. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36460. */
  36461. offlineProvider: IOfflineProvider;
  36462. /**
  36463. * Gets or sets the action manager associated with the scene
  36464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36465. */
  36466. actionManager: AbstractActionManager;
  36467. private _meshesForIntersections;
  36468. /**
  36469. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36470. */
  36471. proceduralTexturesEnabled: boolean;
  36472. private _engine;
  36473. private _totalVertices;
  36474. /** @hidden */
  36475. _activeIndices: PerfCounter;
  36476. /** @hidden */
  36477. _activeParticles: PerfCounter;
  36478. /** @hidden */
  36479. _activeBones: PerfCounter;
  36480. private _animationRatio;
  36481. /** @hidden */
  36482. _animationTimeLast: number;
  36483. /** @hidden */
  36484. _animationTime: number;
  36485. /**
  36486. * Gets or sets a general scale for animation speed
  36487. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36488. */
  36489. animationTimeScale: number;
  36490. /** @hidden */
  36491. _cachedMaterial: Nullable<Material>;
  36492. /** @hidden */
  36493. _cachedEffect: Nullable<Effect>;
  36494. /** @hidden */
  36495. _cachedVisibility: Nullable<number>;
  36496. private _renderId;
  36497. private _frameId;
  36498. private _executeWhenReadyTimeoutId;
  36499. private _intermediateRendering;
  36500. private _viewUpdateFlag;
  36501. private _projectionUpdateFlag;
  36502. /** @hidden */
  36503. _toBeDisposed: Nullable<IDisposable>[];
  36504. private _activeRequests;
  36505. /** @hidden */
  36506. _pendingData: any[];
  36507. private _isDisposed;
  36508. /**
  36509. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36510. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36511. */
  36512. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36513. private _activeMeshes;
  36514. private _processedMaterials;
  36515. private _renderTargets;
  36516. /** @hidden */
  36517. _activeParticleSystems: SmartArray<IParticleSystem>;
  36518. private _activeSkeletons;
  36519. private _softwareSkinnedMeshes;
  36520. private _renderingManager;
  36521. /** @hidden */
  36522. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36523. private _transformMatrix;
  36524. private _sceneUbo;
  36525. /** @hidden */
  36526. _viewMatrix: Matrix;
  36527. private _projectionMatrix;
  36528. /** @hidden */
  36529. _forcedViewPosition: Nullable<Vector3>;
  36530. /** @hidden */
  36531. _frustumPlanes: Plane[];
  36532. /**
  36533. * Gets the list of frustum planes (built from the active camera)
  36534. */
  36535. get frustumPlanes(): Plane[];
  36536. /**
  36537. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36538. * This is useful if there are more lights that the maximum simulteanous authorized
  36539. */
  36540. requireLightSorting: boolean;
  36541. /** @hidden */
  36542. readonly useMaterialMeshMap: boolean;
  36543. /** @hidden */
  36544. readonly useClonedMeshhMap: boolean;
  36545. private _externalData;
  36546. private _uid;
  36547. /**
  36548. * @hidden
  36549. * Backing store of defined scene components.
  36550. */
  36551. _components: ISceneComponent[];
  36552. /**
  36553. * @hidden
  36554. * Backing store of defined scene components.
  36555. */
  36556. _serializableComponents: ISceneSerializableComponent[];
  36557. /**
  36558. * List of components to register on the next registration step.
  36559. */
  36560. private _transientComponents;
  36561. /**
  36562. * Registers the transient components if needed.
  36563. */
  36564. private _registerTransientComponents;
  36565. /**
  36566. * @hidden
  36567. * Add a component to the scene.
  36568. * Note that the ccomponent could be registered on th next frame if this is called after
  36569. * the register component stage.
  36570. * @param component Defines the component to add to the scene
  36571. */
  36572. _addComponent(component: ISceneComponent): void;
  36573. /**
  36574. * @hidden
  36575. * Gets a component from the scene.
  36576. * @param name defines the name of the component to retrieve
  36577. * @returns the component or null if not present
  36578. */
  36579. _getComponent(name: string): Nullable<ISceneComponent>;
  36580. /**
  36581. * @hidden
  36582. * Defines the actions happening before camera updates.
  36583. */
  36584. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36585. /**
  36586. * @hidden
  36587. * Defines the actions happening before clear the canvas.
  36588. */
  36589. _beforeClearStage: Stage<SimpleStageAction>;
  36590. /**
  36591. * @hidden
  36592. * Defines the actions when collecting render targets for the frame.
  36593. */
  36594. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36595. /**
  36596. * @hidden
  36597. * Defines the actions happening for one camera in the frame.
  36598. */
  36599. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36600. /**
  36601. * @hidden
  36602. * Defines the actions happening during the per mesh ready checks.
  36603. */
  36604. _isReadyForMeshStage: Stage<MeshStageAction>;
  36605. /**
  36606. * @hidden
  36607. * Defines the actions happening before evaluate active mesh checks.
  36608. */
  36609. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36610. /**
  36611. * @hidden
  36612. * Defines the actions happening during the evaluate sub mesh checks.
  36613. */
  36614. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36615. /**
  36616. * @hidden
  36617. * Defines the actions happening during the active mesh stage.
  36618. */
  36619. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36620. /**
  36621. * @hidden
  36622. * Defines the actions happening during the per camera render target step.
  36623. */
  36624. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36625. /**
  36626. * @hidden
  36627. * Defines the actions happening just before the active camera is drawing.
  36628. */
  36629. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36630. /**
  36631. * @hidden
  36632. * Defines the actions happening just before a render target is drawing.
  36633. */
  36634. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36635. /**
  36636. * @hidden
  36637. * Defines the actions happening just before a rendering group is drawing.
  36638. */
  36639. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36640. /**
  36641. * @hidden
  36642. * Defines the actions happening just before a mesh is drawing.
  36643. */
  36644. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36645. /**
  36646. * @hidden
  36647. * Defines the actions happening just after a mesh has been drawn.
  36648. */
  36649. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36650. /**
  36651. * @hidden
  36652. * Defines the actions happening just after a rendering group has been drawn.
  36653. */
  36654. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36655. /**
  36656. * @hidden
  36657. * Defines the actions happening just after the active camera has been drawn.
  36658. */
  36659. _afterCameraDrawStage: Stage<CameraStageAction>;
  36660. /**
  36661. * @hidden
  36662. * Defines the actions happening just after a render target has been drawn.
  36663. */
  36664. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36665. /**
  36666. * @hidden
  36667. * Defines the actions happening just after rendering all cameras and computing intersections.
  36668. */
  36669. _afterRenderStage: Stage<SimpleStageAction>;
  36670. /**
  36671. * @hidden
  36672. * Defines the actions happening when a pointer move event happens.
  36673. */
  36674. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36675. /**
  36676. * @hidden
  36677. * Defines the actions happening when a pointer down event happens.
  36678. */
  36679. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36680. /**
  36681. * @hidden
  36682. * Defines the actions happening when a pointer up event happens.
  36683. */
  36684. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36685. /**
  36686. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36687. */
  36688. private geometriesByUniqueId;
  36689. /**
  36690. * Creates a new Scene
  36691. * @param engine defines the engine to use to render this scene
  36692. * @param options defines the scene options
  36693. */
  36694. constructor(engine: Engine, options?: SceneOptions);
  36695. /**
  36696. * Gets a string idenfifying the name of the class
  36697. * @returns "Scene" string
  36698. */
  36699. getClassName(): string;
  36700. private _defaultMeshCandidates;
  36701. /**
  36702. * @hidden
  36703. */
  36704. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36705. private _defaultSubMeshCandidates;
  36706. /**
  36707. * @hidden
  36708. */
  36709. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36710. /**
  36711. * Sets the default candidate providers for the scene.
  36712. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36713. * and getCollidingSubMeshCandidates to their default function
  36714. */
  36715. setDefaultCandidateProviders(): void;
  36716. /**
  36717. * Gets the mesh that is currently under the pointer
  36718. */
  36719. get meshUnderPointer(): Nullable<AbstractMesh>;
  36720. /**
  36721. * Gets or sets the current on-screen X position of the pointer
  36722. */
  36723. get pointerX(): number;
  36724. set pointerX(value: number);
  36725. /**
  36726. * Gets or sets the current on-screen Y position of the pointer
  36727. */
  36728. get pointerY(): number;
  36729. set pointerY(value: number);
  36730. /**
  36731. * Gets the cached material (ie. the latest rendered one)
  36732. * @returns the cached material
  36733. */
  36734. getCachedMaterial(): Nullable<Material>;
  36735. /**
  36736. * Gets the cached effect (ie. the latest rendered one)
  36737. * @returns the cached effect
  36738. */
  36739. getCachedEffect(): Nullable<Effect>;
  36740. /**
  36741. * Gets the cached visibility state (ie. the latest rendered one)
  36742. * @returns the cached visibility state
  36743. */
  36744. getCachedVisibility(): Nullable<number>;
  36745. /**
  36746. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36747. * @param material defines the current material
  36748. * @param effect defines the current effect
  36749. * @param visibility defines the current visibility state
  36750. * @returns true if one parameter is not cached
  36751. */
  36752. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36753. /**
  36754. * Gets the engine associated with the scene
  36755. * @returns an Engine
  36756. */
  36757. getEngine(): Engine;
  36758. /**
  36759. * Gets the total number of vertices rendered per frame
  36760. * @returns the total number of vertices rendered per frame
  36761. */
  36762. getTotalVertices(): number;
  36763. /**
  36764. * Gets the performance counter for total vertices
  36765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36766. */
  36767. get totalVerticesPerfCounter(): PerfCounter;
  36768. /**
  36769. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36770. * @returns the total number of active indices rendered per frame
  36771. */
  36772. getActiveIndices(): number;
  36773. /**
  36774. * Gets the performance counter for active indices
  36775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36776. */
  36777. get totalActiveIndicesPerfCounter(): PerfCounter;
  36778. /**
  36779. * Gets the total number of active particles rendered per frame
  36780. * @returns the total number of active particles rendered per frame
  36781. */
  36782. getActiveParticles(): number;
  36783. /**
  36784. * Gets the performance counter for active particles
  36785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36786. */
  36787. get activeParticlesPerfCounter(): PerfCounter;
  36788. /**
  36789. * Gets the total number of active bones rendered per frame
  36790. * @returns the total number of active bones rendered per frame
  36791. */
  36792. getActiveBones(): number;
  36793. /**
  36794. * Gets the performance counter for active bones
  36795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36796. */
  36797. get activeBonesPerfCounter(): PerfCounter;
  36798. /**
  36799. * Gets the array of active meshes
  36800. * @returns an array of AbstractMesh
  36801. */
  36802. getActiveMeshes(): SmartArray<AbstractMesh>;
  36803. /**
  36804. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36805. * @returns a number
  36806. */
  36807. getAnimationRatio(): number;
  36808. /**
  36809. * Gets an unique Id for the current render phase
  36810. * @returns a number
  36811. */
  36812. getRenderId(): number;
  36813. /**
  36814. * Gets an unique Id for the current frame
  36815. * @returns a number
  36816. */
  36817. getFrameId(): number;
  36818. /** Call this function if you want to manually increment the render Id*/
  36819. incrementRenderId(): void;
  36820. private _createUbo;
  36821. /**
  36822. * Use this method to simulate a pointer move on a mesh
  36823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36826. * @returns the current scene
  36827. */
  36828. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36829. /**
  36830. * Use this method to simulate a pointer down on a mesh
  36831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36834. * @returns the current scene
  36835. */
  36836. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36837. /**
  36838. * Use this method to simulate a pointer up on a mesh
  36839. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36840. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36841. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36842. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36843. * @returns the current scene
  36844. */
  36845. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36846. /**
  36847. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36848. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36849. * @returns true if the pointer was captured
  36850. */
  36851. isPointerCaptured(pointerId?: number): boolean;
  36852. /**
  36853. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36854. * @param attachUp defines if you want to attach events to pointerup
  36855. * @param attachDown defines if you want to attach events to pointerdown
  36856. * @param attachMove defines if you want to attach events to pointermove
  36857. */
  36858. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36859. /** Detaches all event handlers*/
  36860. detachControl(): void;
  36861. /**
  36862. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36863. * Delay loaded resources are not taking in account
  36864. * @return true if all required resources are ready
  36865. */
  36866. isReady(): boolean;
  36867. /** Resets all cached information relative to material (including effect and visibility) */
  36868. resetCachedMaterial(): void;
  36869. /**
  36870. * Registers a function to be called before every frame render
  36871. * @param func defines the function to register
  36872. */
  36873. registerBeforeRender(func: () => void): void;
  36874. /**
  36875. * Unregisters a function called before every frame render
  36876. * @param func defines the function to unregister
  36877. */
  36878. unregisterBeforeRender(func: () => void): void;
  36879. /**
  36880. * Registers a function to be called after every frame render
  36881. * @param func defines the function to register
  36882. */
  36883. registerAfterRender(func: () => void): void;
  36884. /**
  36885. * Unregisters a function called after every frame render
  36886. * @param func defines the function to unregister
  36887. */
  36888. unregisterAfterRender(func: () => void): void;
  36889. private _executeOnceBeforeRender;
  36890. /**
  36891. * The provided function will run before render once and will be disposed afterwards.
  36892. * A timeout delay can be provided so that the function will be executed in N ms.
  36893. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36894. * @param func The function to be executed.
  36895. * @param timeout optional delay in ms
  36896. */
  36897. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36898. /** @hidden */
  36899. _addPendingData(data: any): void;
  36900. /** @hidden */
  36901. _removePendingData(data: any): void;
  36902. /**
  36903. * Returns the number of items waiting to be loaded
  36904. * @returns the number of items waiting to be loaded
  36905. */
  36906. getWaitingItemsCount(): number;
  36907. /**
  36908. * Returns a boolean indicating if the scene is still loading data
  36909. */
  36910. get isLoading(): boolean;
  36911. /**
  36912. * Registers a function to be executed when the scene is ready
  36913. * @param {Function} func - the function to be executed
  36914. */
  36915. executeWhenReady(func: () => void): void;
  36916. /**
  36917. * Returns a promise that resolves when the scene is ready
  36918. * @returns A promise that resolves when the scene is ready
  36919. */
  36920. whenReadyAsync(): Promise<void>;
  36921. /** @hidden */
  36922. _checkIsReady(): void;
  36923. /**
  36924. * Gets all animatable attached to the scene
  36925. */
  36926. get animatables(): Animatable[];
  36927. /**
  36928. * Resets the last animation time frame.
  36929. * Useful to override when animations start running when loading a scene for the first time.
  36930. */
  36931. resetLastAnimationTimeFrame(): void;
  36932. /**
  36933. * Gets the current view matrix
  36934. * @returns a Matrix
  36935. */
  36936. getViewMatrix(): Matrix;
  36937. /**
  36938. * Gets the current projection matrix
  36939. * @returns a Matrix
  36940. */
  36941. getProjectionMatrix(): Matrix;
  36942. /**
  36943. * Gets the current transform matrix
  36944. * @returns a Matrix made of View * Projection
  36945. */
  36946. getTransformMatrix(): Matrix;
  36947. /**
  36948. * Sets the current transform matrix
  36949. * @param viewL defines the View matrix to use
  36950. * @param projectionL defines the Projection matrix to use
  36951. * @param viewR defines the right View matrix to use (if provided)
  36952. * @param projectionR defines the right Projection matrix to use (if provided)
  36953. */
  36954. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36955. /**
  36956. * Gets the uniform buffer used to store scene data
  36957. * @returns a UniformBuffer
  36958. */
  36959. getSceneUniformBuffer(): UniformBuffer;
  36960. /**
  36961. * Gets an unique (relatively to the current scene) Id
  36962. * @returns an unique number for the scene
  36963. */
  36964. getUniqueId(): number;
  36965. /**
  36966. * Add a mesh to the list of scene's meshes
  36967. * @param newMesh defines the mesh to add
  36968. * @param recursive if all child meshes should also be added to the scene
  36969. */
  36970. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36971. /**
  36972. * Remove a mesh for the list of scene's meshes
  36973. * @param toRemove defines the mesh to remove
  36974. * @param recursive if all child meshes should also be removed from the scene
  36975. * @returns the index where the mesh was in the mesh list
  36976. */
  36977. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36978. /**
  36979. * Add a transform node to the list of scene's transform nodes
  36980. * @param newTransformNode defines the transform node to add
  36981. */
  36982. addTransformNode(newTransformNode: TransformNode): void;
  36983. /**
  36984. * Remove a transform node for the list of scene's transform nodes
  36985. * @param toRemove defines the transform node to remove
  36986. * @returns the index where the transform node was in the transform node list
  36987. */
  36988. removeTransformNode(toRemove: TransformNode): number;
  36989. /**
  36990. * Remove a skeleton for the list of scene's skeletons
  36991. * @param toRemove defines the skeleton to remove
  36992. * @returns the index where the skeleton was in the skeleton list
  36993. */
  36994. removeSkeleton(toRemove: Skeleton): number;
  36995. /**
  36996. * Remove a morph target for the list of scene's morph targets
  36997. * @param toRemove defines the morph target to remove
  36998. * @returns the index where the morph target was in the morph target list
  36999. */
  37000. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37001. /**
  37002. * Remove a light for the list of scene's lights
  37003. * @param toRemove defines the light to remove
  37004. * @returns the index where the light was in the light list
  37005. */
  37006. removeLight(toRemove: Light): number;
  37007. /**
  37008. * Remove a camera for the list of scene's cameras
  37009. * @param toRemove defines the camera to remove
  37010. * @returns the index where the camera was in the camera list
  37011. */
  37012. removeCamera(toRemove: Camera): number;
  37013. /**
  37014. * Remove a particle system for the list of scene's particle systems
  37015. * @param toRemove defines the particle system to remove
  37016. * @returns the index where the particle system was in the particle system list
  37017. */
  37018. removeParticleSystem(toRemove: IParticleSystem): number;
  37019. /**
  37020. * Remove a animation for the list of scene's animations
  37021. * @param toRemove defines the animation to remove
  37022. * @returns the index where the animation was in the animation list
  37023. */
  37024. removeAnimation(toRemove: Animation): number;
  37025. /**
  37026. * Will stop the animation of the given target
  37027. * @param target - the target
  37028. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37029. * @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)
  37030. */
  37031. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37032. /**
  37033. * Removes the given animation group from this scene.
  37034. * @param toRemove The animation group to remove
  37035. * @returns The index of the removed animation group
  37036. */
  37037. removeAnimationGroup(toRemove: AnimationGroup): number;
  37038. /**
  37039. * Removes the given multi-material from this scene.
  37040. * @param toRemove The multi-material to remove
  37041. * @returns The index of the removed multi-material
  37042. */
  37043. removeMultiMaterial(toRemove: MultiMaterial): number;
  37044. /**
  37045. * Removes the given material from this scene.
  37046. * @param toRemove The material to remove
  37047. * @returns The index of the removed material
  37048. */
  37049. removeMaterial(toRemove: Material): number;
  37050. /**
  37051. * Removes the given action manager from this scene.
  37052. * @param toRemove The action manager to remove
  37053. * @returns The index of the removed action manager
  37054. */
  37055. removeActionManager(toRemove: AbstractActionManager): number;
  37056. /**
  37057. * Removes the given texture from this scene.
  37058. * @param toRemove The texture to remove
  37059. * @returns The index of the removed texture
  37060. */
  37061. removeTexture(toRemove: BaseTexture): number;
  37062. /**
  37063. * Adds the given light to this scene
  37064. * @param newLight The light to add
  37065. */
  37066. addLight(newLight: Light): void;
  37067. /**
  37068. * Sorts the list list based on light priorities
  37069. */
  37070. sortLightsByPriority(): void;
  37071. /**
  37072. * Adds the given camera to this scene
  37073. * @param newCamera The camera to add
  37074. */
  37075. addCamera(newCamera: Camera): void;
  37076. /**
  37077. * Adds the given skeleton to this scene
  37078. * @param newSkeleton The skeleton to add
  37079. */
  37080. addSkeleton(newSkeleton: Skeleton): void;
  37081. /**
  37082. * Adds the given particle system to this scene
  37083. * @param newParticleSystem The particle system to add
  37084. */
  37085. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37086. /**
  37087. * Adds the given animation to this scene
  37088. * @param newAnimation The animation to add
  37089. */
  37090. addAnimation(newAnimation: Animation): void;
  37091. /**
  37092. * Adds the given animation group to this scene.
  37093. * @param newAnimationGroup The animation group to add
  37094. */
  37095. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37096. /**
  37097. * Adds the given multi-material to this scene
  37098. * @param newMultiMaterial The multi-material to add
  37099. */
  37100. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37101. /**
  37102. * Adds the given material to this scene
  37103. * @param newMaterial The material to add
  37104. */
  37105. addMaterial(newMaterial: Material): void;
  37106. /**
  37107. * Adds the given morph target to this scene
  37108. * @param newMorphTargetManager The morph target to add
  37109. */
  37110. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37111. /**
  37112. * Adds the given geometry to this scene
  37113. * @param newGeometry The geometry to add
  37114. */
  37115. addGeometry(newGeometry: Geometry): void;
  37116. /**
  37117. * Adds the given action manager to this scene
  37118. * @param newActionManager The action manager to add
  37119. */
  37120. addActionManager(newActionManager: AbstractActionManager): void;
  37121. /**
  37122. * Adds the given texture to this scene.
  37123. * @param newTexture The texture to add
  37124. */
  37125. addTexture(newTexture: BaseTexture): void;
  37126. /**
  37127. * Switch active camera
  37128. * @param newCamera defines the new active camera
  37129. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37130. */
  37131. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37132. /**
  37133. * sets the active camera of the scene using its ID
  37134. * @param id defines the camera's ID
  37135. * @return the new active camera or null if none found.
  37136. */
  37137. setActiveCameraByID(id: string): Nullable<Camera>;
  37138. /**
  37139. * sets the active camera of the scene using its name
  37140. * @param name defines the camera's name
  37141. * @returns the new active camera or null if none found.
  37142. */
  37143. setActiveCameraByName(name: string): Nullable<Camera>;
  37144. /**
  37145. * get an animation group using its name
  37146. * @param name defines the material's name
  37147. * @return the animation group or null if none found.
  37148. */
  37149. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37150. /**
  37151. * Get a material using its unique id
  37152. * @param uniqueId defines the material's unique id
  37153. * @return the material or null if none found.
  37154. */
  37155. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37156. /**
  37157. * get a material using its id
  37158. * @param id defines the material's ID
  37159. * @return the material or null if none found.
  37160. */
  37161. getMaterialByID(id: string): Nullable<Material>;
  37162. /**
  37163. * Gets a the last added material using a given id
  37164. * @param id defines the material's ID
  37165. * @return the last material with the given id or null if none found.
  37166. */
  37167. getLastMaterialByID(id: string): Nullable<Material>;
  37168. /**
  37169. * Gets a material using its name
  37170. * @param name defines the material's name
  37171. * @return the material or null if none found.
  37172. */
  37173. getMaterialByName(name: string): Nullable<Material>;
  37174. /**
  37175. * Get a texture using its unique id
  37176. * @param uniqueId defines the texture's unique id
  37177. * @return the texture or null if none found.
  37178. */
  37179. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37180. /**
  37181. * Gets a camera using its id
  37182. * @param id defines the id to look for
  37183. * @returns the camera or null if not found
  37184. */
  37185. getCameraByID(id: string): Nullable<Camera>;
  37186. /**
  37187. * Gets a camera using its unique id
  37188. * @param uniqueId defines the unique id to look for
  37189. * @returns the camera or null if not found
  37190. */
  37191. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37192. /**
  37193. * Gets a camera using its name
  37194. * @param name defines the camera's name
  37195. * @return the camera or null if none found.
  37196. */
  37197. getCameraByName(name: string): Nullable<Camera>;
  37198. /**
  37199. * Gets a bone using its id
  37200. * @param id defines the bone's id
  37201. * @return the bone or null if not found
  37202. */
  37203. getBoneByID(id: string): Nullable<Bone>;
  37204. /**
  37205. * Gets a bone using its id
  37206. * @param name defines the bone's name
  37207. * @return the bone or null if not found
  37208. */
  37209. getBoneByName(name: string): Nullable<Bone>;
  37210. /**
  37211. * Gets a light node using its name
  37212. * @param name defines the the light's name
  37213. * @return the light or null if none found.
  37214. */
  37215. getLightByName(name: string): Nullable<Light>;
  37216. /**
  37217. * Gets a light node using its id
  37218. * @param id defines the light's id
  37219. * @return the light or null if none found.
  37220. */
  37221. getLightByID(id: string): Nullable<Light>;
  37222. /**
  37223. * Gets a light node using its scene-generated unique ID
  37224. * @param uniqueId defines the light's unique id
  37225. * @return the light or null if none found.
  37226. */
  37227. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37228. /**
  37229. * Gets a particle system by id
  37230. * @param id defines the particle system id
  37231. * @return the corresponding system or null if none found
  37232. */
  37233. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37234. /**
  37235. * Gets a geometry using its ID
  37236. * @param id defines the geometry's id
  37237. * @return the geometry or null if none found.
  37238. */
  37239. getGeometryByID(id: string): Nullable<Geometry>;
  37240. private _getGeometryByUniqueID;
  37241. /**
  37242. * Add a new geometry to this scene
  37243. * @param geometry defines the geometry to be added to the scene.
  37244. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37245. * @return a boolean defining if the geometry was added or not
  37246. */
  37247. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37248. /**
  37249. * Removes an existing geometry
  37250. * @param geometry defines the geometry to be removed from the scene
  37251. * @return a boolean defining if the geometry was removed or not
  37252. */
  37253. removeGeometry(geometry: Geometry): boolean;
  37254. /**
  37255. * Gets the list of geometries attached to the scene
  37256. * @returns an array of Geometry
  37257. */
  37258. getGeometries(): Geometry[];
  37259. /**
  37260. * Gets the first added mesh found of a given ID
  37261. * @param id defines the id to search for
  37262. * @return the mesh found or null if not found at all
  37263. */
  37264. getMeshByID(id: string): Nullable<AbstractMesh>;
  37265. /**
  37266. * Gets a list of meshes using their id
  37267. * @param id defines the id to search for
  37268. * @returns a list of meshes
  37269. */
  37270. getMeshesByID(id: string): Array<AbstractMesh>;
  37271. /**
  37272. * Gets the first added transform node found of a given ID
  37273. * @param id defines the id to search for
  37274. * @return the found transform node or null if not found at all.
  37275. */
  37276. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37277. /**
  37278. * Gets a transform node with its auto-generated unique id
  37279. * @param uniqueId efines the unique id to search for
  37280. * @return the found transform node or null if not found at all.
  37281. */
  37282. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37283. /**
  37284. * Gets a list of transform nodes using their id
  37285. * @param id defines the id to search for
  37286. * @returns a list of transform nodes
  37287. */
  37288. getTransformNodesByID(id: string): Array<TransformNode>;
  37289. /**
  37290. * Gets a mesh with its auto-generated unique id
  37291. * @param uniqueId defines the unique id to search for
  37292. * @return the found mesh or null if not found at all.
  37293. */
  37294. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37295. /**
  37296. * Gets a the last added mesh using a given id
  37297. * @param id defines the id to search for
  37298. * @return the found mesh or null if not found at all.
  37299. */
  37300. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37301. /**
  37302. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37303. * @param id defines the id to search for
  37304. * @return the found node or null if not found at all
  37305. */
  37306. getLastEntryByID(id: string): Nullable<Node>;
  37307. /**
  37308. * Gets a node (Mesh, Camera, Light) using a given id
  37309. * @param id defines the id to search for
  37310. * @return the found node or null if not found at all
  37311. */
  37312. getNodeByID(id: string): Nullable<Node>;
  37313. /**
  37314. * Gets a node (Mesh, Camera, Light) using a given name
  37315. * @param name defines the name to search for
  37316. * @return the found node or null if not found at all.
  37317. */
  37318. getNodeByName(name: string): Nullable<Node>;
  37319. /**
  37320. * Gets a mesh using a given name
  37321. * @param name defines the name to search for
  37322. * @return the found mesh or null if not found at all.
  37323. */
  37324. getMeshByName(name: string): Nullable<AbstractMesh>;
  37325. /**
  37326. * Gets a transform node using a given name
  37327. * @param name defines the name to search for
  37328. * @return the found transform node or null if not found at all.
  37329. */
  37330. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37331. /**
  37332. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37333. * @param id defines the id to search for
  37334. * @return the found skeleton or null if not found at all.
  37335. */
  37336. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37337. /**
  37338. * Gets a skeleton using a given auto generated unique id
  37339. * @param uniqueId defines the unique id to search for
  37340. * @return the found skeleton or null if not found at all.
  37341. */
  37342. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37343. /**
  37344. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37345. * @param id defines the id to search for
  37346. * @return the found skeleton or null if not found at all.
  37347. */
  37348. getSkeletonById(id: string): Nullable<Skeleton>;
  37349. /**
  37350. * Gets a skeleton using a given name
  37351. * @param name defines the name to search for
  37352. * @return the found skeleton or null if not found at all.
  37353. */
  37354. getSkeletonByName(name: string): Nullable<Skeleton>;
  37355. /**
  37356. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37357. * @param id defines the id to search for
  37358. * @return the found morph target manager or null if not found at all.
  37359. */
  37360. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37361. /**
  37362. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37363. * @param id defines the id to search for
  37364. * @return the found morph target or null if not found at all.
  37365. */
  37366. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37367. /**
  37368. * Gets a boolean indicating if the given mesh is active
  37369. * @param mesh defines the mesh to look for
  37370. * @returns true if the mesh is in the active list
  37371. */
  37372. isActiveMesh(mesh: AbstractMesh): boolean;
  37373. /**
  37374. * Return a unique id as a string which can serve as an identifier for the scene
  37375. */
  37376. get uid(): string;
  37377. /**
  37378. * Add an externaly attached data from its key.
  37379. * This method call will fail and return false, if such key already exists.
  37380. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37381. * @param key the unique key that identifies the data
  37382. * @param data the data object to associate to the key for this Engine instance
  37383. * @return true if no such key were already present and the data was added successfully, false otherwise
  37384. */
  37385. addExternalData<T>(key: string, data: T): boolean;
  37386. /**
  37387. * Get an externaly attached data from its key
  37388. * @param key the unique key that identifies the data
  37389. * @return the associated data, if present (can be null), or undefined if not present
  37390. */
  37391. getExternalData<T>(key: string): Nullable<T>;
  37392. /**
  37393. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37394. * @param key the unique key that identifies the data
  37395. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37396. * @return the associated data, can be null if the factory returned null.
  37397. */
  37398. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37399. /**
  37400. * Remove an externaly attached data from the Engine instance
  37401. * @param key the unique key that identifies the data
  37402. * @return true if the data was successfully removed, false if it doesn't exist
  37403. */
  37404. removeExternalData(key: string): boolean;
  37405. private _evaluateSubMesh;
  37406. /**
  37407. * Clear the processed materials smart array preventing retention point in material dispose.
  37408. */
  37409. freeProcessedMaterials(): void;
  37410. private _preventFreeActiveMeshesAndRenderingGroups;
  37411. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37412. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37413. * when disposing several meshes in a row or a hierarchy of meshes.
  37414. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37415. */
  37416. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37417. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37418. /**
  37419. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37420. */
  37421. freeActiveMeshes(): void;
  37422. /**
  37423. * Clear the info related to rendering groups preventing retention points during dispose.
  37424. */
  37425. freeRenderingGroups(): void;
  37426. /** @hidden */
  37427. _isInIntermediateRendering(): boolean;
  37428. /**
  37429. * Lambda returning the list of potentially active meshes.
  37430. */
  37431. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37432. /**
  37433. * Lambda returning the list of potentially active sub meshes.
  37434. */
  37435. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37436. /**
  37437. * Lambda returning the list of potentially intersecting sub meshes.
  37438. */
  37439. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37440. /**
  37441. * Lambda returning the list of potentially colliding sub meshes.
  37442. */
  37443. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37444. private _activeMeshesFrozen;
  37445. private _skipEvaluateActiveMeshesCompletely;
  37446. /**
  37447. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37448. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37449. * @returns the current scene
  37450. */
  37451. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37452. /**
  37453. * Use this function to restart evaluating active meshes on every frame
  37454. * @returns the current scene
  37455. */
  37456. unfreezeActiveMeshes(): Scene;
  37457. private _evaluateActiveMeshes;
  37458. private _activeMesh;
  37459. /**
  37460. * Update the transform matrix to update from the current active camera
  37461. * @param force defines a boolean used to force the update even if cache is up to date
  37462. */
  37463. updateTransformMatrix(force?: boolean): void;
  37464. private _bindFrameBuffer;
  37465. /** @hidden */
  37466. _allowPostProcessClearColor: boolean;
  37467. /** @hidden */
  37468. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37469. private _processSubCameras;
  37470. private _checkIntersections;
  37471. /** @hidden */
  37472. _advancePhysicsEngineStep(step: number): void;
  37473. /**
  37474. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37475. */
  37476. getDeterministicFrameTime: () => number;
  37477. /** @hidden */
  37478. _animate(): void;
  37479. /** Execute all animations (for a frame) */
  37480. animate(): void;
  37481. /**
  37482. * Render the scene
  37483. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37484. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37485. */
  37486. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37487. /**
  37488. * Freeze all materials
  37489. * A frozen material will not be updatable but should be faster to render
  37490. */
  37491. freezeMaterials(): void;
  37492. /**
  37493. * Unfreeze all materials
  37494. * A frozen material will not be updatable but should be faster to render
  37495. */
  37496. unfreezeMaterials(): void;
  37497. /**
  37498. * Releases all held ressources
  37499. */
  37500. dispose(): void;
  37501. /**
  37502. * Gets if the scene is already disposed
  37503. */
  37504. get isDisposed(): boolean;
  37505. /**
  37506. * Call this function to reduce memory footprint of the scene.
  37507. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37508. */
  37509. clearCachedVertexData(): void;
  37510. /**
  37511. * This function will remove the local cached buffer data from texture.
  37512. * It will save memory but will prevent the texture from being rebuilt
  37513. */
  37514. cleanCachedTextureBuffer(): void;
  37515. /**
  37516. * Get the world extend vectors with an optional filter
  37517. *
  37518. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37519. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37520. */
  37521. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37522. min: Vector3;
  37523. max: Vector3;
  37524. };
  37525. /**
  37526. * Creates a ray that can be used to pick in the scene
  37527. * @param x defines the x coordinate of the origin (on-screen)
  37528. * @param y defines the y coordinate of the origin (on-screen)
  37529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37530. * @param camera defines the camera to use for the picking
  37531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37532. * @returns a Ray
  37533. */
  37534. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37535. /**
  37536. * Creates a ray that can be used to pick in the scene
  37537. * @param x defines the x coordinate of the origin (on-screen)
  37538. * @param y defines the y coordinate of the origin (on-screen)
  37539. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37540. * @param result defines the ray where to store the picking ray
  37541. * @param camera defines the camera to use for the picking
  37542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37543. * @returns the current scene
  37544. */
  37545. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37546. /**
  37547. * Creates a ray that can be used to pick in the scene
  37548. * @param x defines the x coordinate of the origin (on-screen)
  37549. * @param y defines the y coordinate of the origin (on-screen)
  37550. * @param camera defines the camera to use for the picking
  37551. * @returns a Ray
  37552. */
  37553. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37554. /**
  37555. * Creates a ray that can be used to pick in the scene
  37556. * @param x defines the x coordinate of the origin (on-screen)
  37557. * @param y defines the y coordinate of the origin (on-screen)
  37558. * @param result defines the ray where to store the picking ray
  37559. * @param camera defines the camera to use for the picking
  37560. * @returns the current scene
  37561. */
  37562. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37563. /** Launch a ray to try to pick a mesh in the scene
  37564. * @param x position on screen
  37565. * @param y position on screen
  37566. * @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
  37567. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37568. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37570. * @returns a PickingInfo
  37571. */
  37572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37573. /** Use the given ray to pick a mesh in the scene
  37574. * @param ray The ray to use to pick meshes
  37575. * @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
  37576. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37577. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37578. * @returns a PickingInfo
  37579. */
  37580. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37581. /**
  37582. * Launch a ray to try to pick a mesh in the scene
  37583. * @param x X position on screen
  37584. * @param y Y position on screen
  37585. * @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
  37586. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37588. * @returns an array of PickingInfo
  37589. */
  37590. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37591. /**
  37592. * Launch a ray to try to pick a mesh in the scene
  37593. * @param ray Ray to use
  37594. * @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
  37595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37596. * @returns an array of PickingInfo
  37597. */
  37598. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37599. /**
  37600. * Force the value of meshUnderPointer
  37601. * @param mesh defines the mesh to use
  37602. */
  37603. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37604. /**
  37605. * Gets the mesh under the pointer
  37606. * @returns a Mesh or null if no mesh is under the pointer
  37607. */
  37608. getPointerOverMesh(): Nullable<AbstractMesh>;
  37609. /** @hidden */
  37610. _rebuildGeometries(): void;
  37611. /** @hidden */
  37612. _rebuildTextures(): void;
  37613. private _getByTags;
  37614. /**
  37615. * Get a list of meshes by tags
  37616. * @param tagsQuery defines the tags query to use
  37617. * @param forEach defines a predicate used to filter results
  37618. * @returns an array of Mesh
  37619. */
  37620. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37621. /**
  37622. * Get a list of cameras by tags
  37623. * @param tagsQuery defines the tags query to use
  37624. * @param forEach defines a predicate used to filter results
  37625. * @returns an array of Camera
  37626. */
  37627. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37628. /**
  37629. * Get a list of lights by tags
  37630. * @param tagsQuery defines the tags query to use
  37631. * @param forEach defines a predicate used to filter results
  37632. * @returns an array of Light
  37633. */
  37634. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37635. /**
  37636. * Get a list of materials by tags
  37637. * @param tagsQuery defines the tags query to use
  37638. * @param forEach defines a predicate used to filter results
  37639. * @returns an array of Material
  37640. */
  37641. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37642. /**
  37643. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37644. * This allowed control for front to back rendering or reversly depending of the special needs.
  37645. *
  37646. * @param renderingGroupId The rendering group id corresponding to its index
  37647. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37648. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37649. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37650. */
  37651. 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;
  37652. /**
  37653. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37654. *
  37655. * @param renderingGroupId The rendering group id corresponding to its index
  37656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37657. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37658. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37659. */
  37660. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37661. /**
  37662. * Gets the current auto clear configuration for one rendering group of the rendering
  37663. * manager.
  37664. * @param index the rendering group index to get the information for
  37665. * @returns The auto clear setup for the requested rendering group
  37666. */
  37667. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37668. private _blockMaterialDirtyMechanism;
  37669. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37670. get blockMaterialDirtyMechanism(): boolean;
  37671. set blockMaterialDirtyMechanism(value: boolean);
  37672. /**
  37673. * Will flag all materials as dirty to trigger new shader compilation
  37674. * @param flag defines the flag used to specify which material part must be marked as dirty
  37675. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37676. */
  37677. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37678. /** @hidden */
  37679. _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;
  37680. /** @hidden */
  37681. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37682. /** @hidden */
  37683. _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;
  37684. /** @hidden */
  37685. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37686. /** @hidden */
  37687. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37688. /** @hidden */
  37689. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37690. }
  37691. }
  37692. declare module "babylonjs/assetContainer" {
  37693. import { AbstractScene } from "babylonjs/abstractScene";
  37694. import { Scene } from "babylonjs/scene";
  37695. import { Mesh } from "babylonjs/Meshes/mesh";
  37696. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37697. import { Skeleton } from "babylonjs/Bones/skeleton";
  37698. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37699. import { Animatable } from "babylonjs/Animations/animatable";
  37700. import { Nullable } from "babylonjs/types";
  37701. import { Node } from "babylonjs/node";
  37702. /**
  37703. * Set of assets to keep when moving a scene into an asset container.
  37704. */
  37705. export class KeepAssets extends AbstractScene {
  37706. }
  37707. /**
  37708. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37709. */
  37710. export class InstantiatedEntries {
  37711. /**
  37712. * List of new root nodes (eg. nodes with no parent)
  37713. */
  37714. rootNodes: TransformNode[];
  37715. /**
  37716. * List of new skeletons
  37717. */
  37718. skeletons: Skeleton[];
  37719. /**
  37720. * List of new animation groups
  37721. */
  37722. animationGroups: AnimationGroup[];
  37723. }
  37724. /**
  37725. * Container with a set of assets that can be added or removed from a scene.
  37726. */
  37727. export class AssetContainer extends AbstractScene {
  37728. /**
  37729. * The scene the AssetContainer belongs to.
  37730. */
  37731. scene: Scene;
  37732. /**
  37733. * Instantiates an AssetContainer.
  37734. * @param scene The scene the AssetContainer belongs to.
  37735. */
  37736. constructor(scene: Scene);
  37737. /**
  37738. * Instantiate or clone all meshes and add the new ones to the scene.
  37739. * Skeletons and animation groups will all be cloned
  37740. * @param nameFunction defines an optional function used to get new names for clones
  37741. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37742. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37743. */
  37744. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37745. /**
  37746. * Adds all the assets from the container to the scene.
  37747. */
  37748. addAllToScene(): void;
  37749. /**
  37750. * Removes all the assets in the container from the scene
  37751. */
  37752. removeAllFromScene(): void;
  37753. /**
  37754. * Disposes all the assets in the container
  37755. */
  37756. dispose(): void;
  37757. private _moveAssets;
  37758. /**
  37759. * Removes all the assets contained in the scene and adds them to the container.
  37760. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37761. */
  37762. moveAllFromScene(keepAssets?: KeepAssets): void;
  37763. /**
  37764. * 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.
  37765. * @returns the root mesh
  37766. */
  37767. createRootMesh(): Mesh;
  37768. /**
  37769. * Merge animations from this asset container into a scene
  37770. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37771. * @param animatables set of animatables to retarget to a node from the scene
  37772. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37773. */
  37774. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37775. }
  37776. }
  37777. declare module "babylonjs/abstractScene" {
  37778. import { Scene } from "babylonjs/scene";
  37779. import { Nullable } from "babylonjs/types";
  37780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37781. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37782. import { Geometry } from "babylonjs/Meshes/geometry";
  37783. import { Skeleton } from "babylonjs/Bones/skeleton";
  37784. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37785. import { AssetContainer } from "babylonjs/assetContainer";
  37786. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37787. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37789. import { Material } from "babylonjs/Materials/material";
  37790. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37791. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37792. import { Camera } from "babylonjs/Cameras/camera";
  37793. import { Light } from "babylonjs/Lights/light";
  37794. import { Node } from "babylonjs/node";
  37795. import { Animation } from "babylonjs/Animations/animation";
  37796. /**
  37797. * Defines how the parser contract is defined.
  37798. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37799. */
  37800. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37801. /**
  37802. * Defines how the individual parser contract is defined.
  37803. * These parser can parse an individual asset
  37804. */
  37805. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37806. /**
  37807. * Base class of the scene acting as a container for the different elements composing a scene.
  37808. * This class is dynamically extended by the different components of the scene increasing
  37809. * flexibility and reducing coupling
  37810. */
  37811. export abstract class AbstractScene {
  37812. /**
  37813. * Stores the list of available parsers in the application.
  37814. */
  37815. private static _BabylonFileParsers;
  37816. /**
  37817. * Stores the list of available individual parsers in the application.
  37818. */
  37819. private static _IndividualBabylonFileParsers;
  37820. /**
  37821. * Adds a parser in the list of available ones
  37822. * @param name Defines the name of the parser
  37823. * @param parser Defines the parser to add
  37824. */
  37825. static AddParser(name: string, parser: BabylonFileParser): void;
  37826. /**
  37827. * Gets a general parser from the list of avaialble ones
  37828. * @param name Defines the name of the parser
  37829. * @returns the requested parser or null
  37830. */
  37831. static GetParser(name: string): Nullable<BabylonFileParser>;
  37832. /**
  37833. * Adds n individual parser in the list of available ones
  37834. * @param name Defines the name of the parser
  37835. * @param parser Defines the parser to add
  37836. */
  37837. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37838. /**
  37839. * Gets an individual parser from the list of avaialble ones
  37840. * @param name Defines the name of the parser
  37841. * @returns the requested parser or null
  37842. */
  37843. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37844. /**
  37845. * Parser json data and populate both a scene and its associated container object
  37846. * @param jsonData Defines the data to parse
  37847. * @param scene Defines the scene to parse the data for
  37848. * @param container Defines the container attached to the parsing sequence
  37849. * @param rootUrl Defines the root url of the data
  37850. */
  37851. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37852. /**
  37853. * Gets the list of root nodes (ie. nodes with no parent)
  37854. */
  37855. rootNodes: Node[];
  37856. /** All of the cameras added to this scene
  37857. * @see http://doc.babylonjs.com/babylon101/cameras
  37858. */
  37859. cameras: Camera[];
  37860. /**
  37861. * All of the lights added to this scene
  37862. * @see http://doc.babylonjs.com/babylon101/lights
  37863. */
  37864. lights: Light[];
  37865. /**
  37866. * All of the (abstract) meshes added to this scene
  37867. */
  37868. meshes: AbstractMesh[];
  37869. /**
  37870. * The list of skeletons added to the scene
  37871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37872. */
  37873. skeletons: Skeleton[];
  37874. /**
  37875. * All of the particle systems added to this scene
  37876. * @see http://doc.babylonjs.com/babylon101/particles
  37877. */
  37878. particleSystems: IParticleSystem[];
  37879. /**
  37880. * Gets a list of Animations associated with the scene
  37881. */
  37882. animations: Animation[];
  37883. /**
  37884. * All of the animation groups added to this scene
  37885. * @see http://doc.babylonjs.com/how_to/group
  37886. */
  37887. animationGroups: AnimationGroup[];
  37888. /**
  37889. * All of the multi-materials added to this scene
  37890. * @see http://doc.babylonjs.com/how_to/multi_materials
  37891. */
  37892. multiMaterials: MultiMaterial[];
  37893. /**
  37894. * All of the materials added to this scene
  37895. * In the context of a Scene, it is not supposed to be modified manually.
  37896. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37897. * Note also that the order of the Material within the array is not significant and might change.
  37898. * @see http://doc.babylonjs.com/babylon101/materials
  37899. */
  37900. materials: Material[];
  37901. /**
  37902. * The list of morph target managers added to the scene
  37903. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37904. */
  37905. morphTargetManagers: MorphTargetManager[];
  37906. /**
  37907. * The list of geometries used in the scene.
  37908. */
  37909. geometries: Geometry[];
  37910. /**
  37911. * All of the tranform nodes added to this scene
  37912. * In the context of a Scene, it is not supposed to be modified manually.
  37913. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37914. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37915. * @see http://doc.babylonjs.com/how_to/transformnode
  37916. */
  37917. transformNodes: TransformNode[];
  37918. /**
  37919. * ActionManagers available on the scene.
  37920. */
  37921. actionManagers: AbstractActionManager[];
  37922. /**
  37923. * Textures to keep.
  37924. */
  37925. textures: BaseTexture[];
  37926. /**
  37927. * Environment texture for the scene
  37928. */
  37929. environmentTexture: Nullable<BaseTexture>;
  37930. /**
  37931. * @returns all meshes, lights, cameras, transformNodes and bones
  37932. */
  37933. getNodes(): Array<Node>;
  37934. }
  37935. }
  37936. declare module "babylonjs/Audio/sound" {
  37937. import { Observable } from "babylonjs/Misc/observable";
  37938. import { Vector3 } from "babylonjs/Maths/math.vector";
  37939. import { Nullable } from "babylonjs/types";
  37940. import { Scene } from "babylonjs/scene";
  37941. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37942. /**
  37943. * Interface used to define options for Sound class
  37944. */
  37945. export interface ISoundOptions {
  37946. /**
  37947. * Does the sound autoplay once loaded.
  37948. */
  37949. autoplay?: boolean;
  37950. /**
  37951. * Does the sound loop after it finishes playing once.
  37952. */
  37953. loop?: boolean;
  37954. /**
  37955. * Sound's volume
  37956. */
  37957. volume?: number;
  37958. /**
  37959. * Is it a spatial sound?
  37960. */
  37961. spatialSound?: boolean;
  37962. /**
  37963. * Maximum distance to hear that sound
  37964. */
  37965. maxDistance?: number;
  37966. /**
  37967. * Uses user defined attenuation function
  37968. */
  37969. useCustomAttenuation?: boolean;
  37970. /**
  37971. * Define the roll off factor of spatial sounds.
  37972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37973. */
  37974. rolloffFactor?: number;
  37975. /**
  37976. * Define the reference distance the sound should be heard perfectly.
  37977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37978. */
  37979. refDistance?: number;
  37980. /**
  37981. * Define the distance attenuation model the sound will follow.
  37982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37983. */
  37984. distanceModel?: string;
  37985. /**
  37986. * Defines the playback speed (1 by default)
  37987. */
  37988. playbackRate?: number;
  37989. /**
  37990. * Defines if the sound is from a streaming source
  37991. */
  37992. streaming?: boolean;
  37993. /**
  37994. * Defines an optional length (in seconds) inside the sound file
  37995. */
  37996. length?: number;
  37997. /**
  37998. * Defines an optional offset (in seconds) inside the sound file
  37999. */
  38000. offset?: number;
  38001. /**
  38002. * If true, URLs will not be required to state the audio file codec to use.
  38003. */
  38004. skipCodecCheck?: boolean;
  38005. }
  38006. /**
  38007. * Defines a sound that can be played in the application.
  38008. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38010. */
  38011. export class Sound {
  38012. /**
  38013. * The name of the sound in the scene.
  38014. */
  38015. name: string;
  38016. /**
  38017. * Does the sound autoplay once loaded.
  38018. */
  38019. autoplay: boolean;
  38020. /**
  38021. * Does the sound loop after it finishes playing once.
  38022. */
  38023. loop: boolean;
  38024. /**
  38025. * Does the sound use a custom attenuation curve to simulate the falloff
  38026. * happening when the source gets further away from the camera.
  38027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38028. */
  38029. useCustomAttenuation: boolean;
  38030. /**
  38031. * The sound track id this sound belongs to.
  38032. */
  38033. soundTrackId: number;
  38034. /**
  38035. * Is this sound currently played.
  38036. */
  38037. isPlaying: boolean;
  38038. /**
  38039. * Is this sound currently paused.
  38040. */
  38041. isPaused: boolean;
  38042. /**
  38043. * Does this sound enables spatial sound.
  38044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38045. */
  38046. spatialSound: boolean;
  38047. /**
  38048. * Define the reference distance the sound should be heard perfectly.
  38049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38050. */
  38051. refDistance: number;
  38052. /**
  38053. * Define the roll off factor of spatial sounds.
  38054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38055. */
  38056. rolloffFactor: number;
  38057. /**
  38058. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38060. */
  38061. maxDistance: number;
  38062. /**
  38063. * Define the distance attenuation model the sound will follow.
  38064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38065. */
  38066. distanceModel: string;
  38067. /**
  38068. * @hidden
  38069. * Back Compat
  38070. **/
  38071. onended: () => any;
  38072. /**
  38073. * Observable event when the current playing sound finishes.
  38074. */
  38075. onEndedObservable: Observable<Sound>;
  38076. private _panningModel;
  38077. private _playbackRate;
  38078. private _streaming;
  38079. private _startTime;
  38080. private _startOffset;
  38081. private _position;
  38082. /** @hidden */
  38083. _positionInEmitterSpace: boolean;
  38084. private _localDirection;
  38085. private _volume;
  38086. private _isReadyToPlay;
  38087. private _isDirectional;
  38088. private _readyToPlayCallback;
  38089. private _audioBuffer;
  38090. private _soundSource;
  38091. private _streamingSource;
  38092. private _soundPanner;
  38093. private _soundGain;
  38094. private _inputAudioNode;
  38095. private _outputAudioNode;
  38096. private _coneInnerAngle;
  38097. private _coneOuterAngle;
  38098. private _coneOuterGain;
  38099. private _scene;
  38100. private _connectedTransformNode;
  38101. private _customAttenuationFunction;
  38102. private _registerFunc;
  38103. private _isOutputConnected;
  38104. private _htmlAudioElement;
  38105. private _urlType;
  38106. private _length?;
  38107. private _offset?;
  38108. /** @hidden */
  38109. static _SceneComponentInitialization: (scene: Scene) => void;
  38110. /**
  38111. * Create a sound and attach it to a scene
  38112. * @param name Name of your sound
  38113. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38114. * @param scene defines the scene the sound belongs to
  38115. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38116. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38117. */
  38118. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38119. /**
  38120. * Release the sound and its associated resources
  38121. */
  38122. dispose(): void;
  38123. /**
  38124. * Gets if the sounds is ready to be played or not.
  38125. * @returns true if ready, otherwise false
  38126. */
  38127. isReady(): boolean;
  38128. private _soundLoaded;
  38129. /**
  38130. * Sets the data of the sound from an audiobuffer
  38131. * @param audioBuffer The audioBuffer containing the data
  38132. */
  38133. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38134. /**
  38135. * Updates the current sounds options such as maxdistance, loop...
  38136. * @param options A JSON object containing values named as the object properties
  38137. */
  38138. updateOptions(options: ISoundOptions): void;
  38139. private _createSpatialParameters;
  38140. private _updateSpatialParameters;
  38141. /**
  38142. * Switch the panning model to HRTF:
  38143. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38145. */
  38146. switchPanningModelToHRTF(): void;
  38147. /**
  38148. * Switch the panning model to Equal Power:
  38149. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38151. */
  38152. switchPanningModelToEqualPower(): void;
  38153. private _switchPanningModel;
  38154. /**
  38155. * Connect this sound to a sound track audio node like gain...
  38156. * @param soundTrackAudioNode the sound track audio node to connect to
  38157. */
  38158. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38159. /**
  38160. * Transform this sound into a directional source
  38161. * @param coneInnerAngle Size of the inner cone in degree
  38162. * @param coneOuterAngle Size of the outer cone in degree
  38163. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38164. */
  38165. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38166. /**
  38167. * Gets or sets the inner angle for the directional cone.
  38168. */
  38169. get directionalConeInnerAngle(): number;
  38170. /**
  38171. * Gets or sets the inner angle for the directional cone.
  38172. */
  38173. set directionalConeInnerAngle(value: number);
  38174. /**
  38175. * Gets or sets the outer angle for the directional cone.
  38176. */
  38177. get directionalConeOuterAngle(): number;
  38178. /**
  38179. * Gets or sets the outer angle for the directional cone.
  38180. */
  38181. set directionalConeOuterAngle(value: number);
  38182. /**
  38183. * Sets the position of the emitter if spatial sound is enabled
  38184. * @param newPosition Defines the new posisiton
  38185. */
  38186. setPosition(newPosition: Vector3): void;
  38187. /**
  38188. * Sets the local direction of the emitter if spatial sound is enabled
  38189. * @param newLocalDirection Defines the new local direction
  38190. */
  38191. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38192. private _updateDirection;
  38193. /** @hidden */
  38194. updateDistanceFromListener(): void;
  38195. /**
  38196. * Sets a new custom attenuation function for the sound.
  38197. * @param callback Defines the function used for the attenuation
  38198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38199. */
  38200. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38201. /**
  38202. * Play the sound
  38203. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38204. * @param offset (optional) Start the sound at a specific time in seconds
  38205. * @param length (optional) Sound duration (in seconds)
  38206. */
  38207. play(time?: number, offset?: number, length?: number): void;
  38208. private _onended;
  38209. /**
  38210. * Stop the sound
  38211. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38212. */
  38213. stop(time?: number): void;
  38214. /**
  38215. * Put the sound in pause
  38216. */
  38217. pause(): void;
  38218. /**
  38219. * Sets a dedicated volume for this sounds
  38220. * @param newVolume Define the new volume of the sound
  38221. * @param time Define time for gradual change to new volume
  38222. */
  38223. setVolume(newVolume: number, time?: number): void;
  38224. /**
  38225. * Set the sound play back rate
  38226. * @param newPlaybackRate Define the playback rate the sound should be played at
  38227. */
  38228. setPlaybackRate(newPlaybackRate: number): void;
  38229. /**
  38230. * Gets the volume of the sound.
  38231. * @returns the volume of the sound
  38232. */
  38233. getVolume(): number;
  38234. /**
  38235. * Attach the sound to a dedicated mesh
  38236. * @param transformNode The transform node to connect the sound with
  38237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38238. */
  38239. attachToMesh(transformNode: TransformNode): void;
  38240. /**
  38241. * Detach the sound from the previously attached mesh
  38242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38243. */
  38244. detachFromMesh(): void;
  38245. private _onRegisterAfterWorldMatrixUpdate;
  38246. /**
  38247. * Clone the current sound in the scene.
  38248. * @returns the new sound clone
  38249. */
  38250. clone(): Nullable<Sound>;
  38251. /**
  38252. * Gets the current underlying audio buffer containing the data
  38253. * @returns the audio buffer
  38254. */
  38255. getAudioBuffer(): Nullable<AudioBuffer>;
  38256. /**
  38257. * Serializes the Sound in a JSON representation
  38258. * @returns the JSON representation of the sound
  38259. */
  38260. serialize(): any;
  38261. /**
  38262. * Parse a JSON representation of a sound to innstantiate in a given scene
  38263. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38264. * @param scene Define the scene the new parsed sound should be created in
  38265. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38266. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38267. * @returns the newly parsed sound
  38268. */
  38269. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38270. }
  38271. }
  38272. declare module "babylonjs/Actions/directAudioActions" {
  38273. import { Action } from "babylonjs/Actions/action";
  38274. import { Condition } from "babylonjs/Actions/condition";
  38275. import { Sound } from "babylonjs/Audio/sound";
  38276. /**
  38277. * This defines an action helpful to play a defined sound on a triggered action.
  38278. */
  38279. export class PlaySoundAction extends Action {
  38280. private _sound;
  38281. /**
  38282. * Instantiate the action
  38283. * @param triggerOptions defines the trigger options
  38284. * @param sound defines the sound to play
  38285. * @param condition defines the trigger related conditions
  38286. */
  38287. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38288. /** @hidden */
  38289. _prepare(): void;
  38290. /**
  38291. * Execute the action and play the sound.
  38292. */
  38293. execute(): void;
  38294. /**
  38295. * Serializes the actions and its related information.
  38296. * @param parent defines the object to serialize in
  38297. * @returns the serialized object
  38298. */
  38299. serialize(parent: any): any;
  38300. }
  38301. /**
  38302. * This defines an action helpful to stop a defined sound on a triggered action.
  38303. */
  38304. export class StopSoundAction extends Action {
  38305. private _sound;
  38306. /**
  38307. * Instantiate the action
  38308. * @param triggerOptions defines the trigger options
  38309. * @param sound defines the sound to stop
  38310. * @param condition defines the trigger related conditions
  38311. */
  38312. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38313. /** @hidden */
  38314. _prepare(): void;
  38315. /**
  38316. * Execute the action and stop the sound.
  38317. */
  38318. execute(): void;
  38319. /**
  38320. * Serializes the actions and its related information.
  38321. * @param parent defines the object to serialize in
  38322. * @returns the serialized object
  38323. */
  38324. serialize(parent: any): any;
  38325. }
  38326. }
  38327. declare module "babylonjs/Actions/interpolateValueAction" {
  38328. import { Action } from "babylonjs/Actions/action";
  38329. import { Condition } from "babylonjs/Actions/condition";
  38330. import { Observable } from "babylonjs/Misc/observable";
  38331. /**
  38332. * This defines an action responsible to change the value of a property
  38333. * by interpolating between its current value and the newly set one once triggered.
  38334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38335. */
  38336. export class InterpolateValueAction extends Action {
  38337. /**
  38338. * Defines the path of the property where the value should be interpolated
  38339. */
  38340. propertyPath: string;
  38341. /**
  38342. * Defines the target value at the end of the interpolation.
  38343. */
  38344. value: any;
  38345. /**
  38346. * Defines the time it will take for the property to interpolate to the value.
  38347. */
  38348. duration: number;
  38349. /**
  38350. * Defines if the other scene animations should be stopped when the action has been triggered
  38351. */
  38352. stopOtherAnimations?: boolean;
  38353. /**
  38354. * Defines a callback raised once the interpolation animation has been done.
  38355. */
  38356. onInterpolationDone?: () => void;
  38357. /**
  38358. * Observable triggered once the interpolation animation has been done.
  38359. */
  38360. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38361. private _target;
  38362. private _effectiveTarget;
  38363. private _property;
  38364. /**
  38365. * Instantiate the action
  38366. * @param triggerOptions defines the trigger options
  38367. * @param target defines the object containing the value to interpolate
  38368. * @param propertyPath defines the path to the property in the target object
  38369. * @param value defines the target value at the end of the interpolation
  38370. * @param duration deines the time it will take for the property to interpolate to the value.
  38371. * @param condition defines the trigger related conditions
  38372. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38373. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38374. */
  38375. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38376. /** @hidden */
  38377. _prepare(): void;
  38378. /**
  38379. * Execute the action starts the value interpolation.
  38380. */
  38381. execute(): void;
  38382. /**
  38383. * Serializes the actions and its related information.
  38384. * @param parent defines the object to serialize in
  38385. * @returns the serialized object
  38386. */
  38387. serialize(parent: any): any;
  38388. }
  38389. }
  38390. declare module "babylonjs/Actions/index" {
  38391. export * from "babylonjs/Actions/abstractActionManager";
  38392. export * from "babylonjs/Actions/action";
  38393. export * from "babylonjs/Actions/actionEvent";
  38394. export * from "babylonjs/Actions/actionManager";
  38395. export * from "babylonjs/Actions/condition";
  38396. export * from "babylonjs/Actions/directActions";
  38397. export * from "babylonjs/Actions/directAudioActions";
  38398. export * from "babylonjs/Actions/interpolateValueAction";
  38399. }
  38400. declare module "babylonjs/Animations/index" {
  38401. export * from "babylonjs/Animations/animatable";
  38402. export * from "babylonjs/Animations/animation";
  38403. export * from "babylonjs/Animations/animationGroup";
  38404. export * from "babylonjs/Animations/animationPropertiesOverride";
  38405. export * from "babylonjs/Animations/easing";
  38406. export * from "babylonjs/Animations/runtimeAnimation";
  38407. export * from "babylonjs/Animations/animationEvent";
  38408. export * from "babylonjs/Animations/animationGroup";
  38409. export * from "babylonjs/Animations/animationKey";
  38410. export * from "babylonjs/Animations/animationRange";
  38411. export * from "babylonjs/Animations/animatable.interface";
  38412. }
  38413. declare module "babylonjs/Audio/soundTrack" {
  38414. import { Sound } from "babylonjs/Audio/sound";
  38415. import { Analyser } from "babylonjs/Audio/analyser";
  38416. import { Scene } from "babylonjs/scene";
  38417. /**
  38418. * Options allowed during the creation of a sound track.
  38419. */
  38420. export interface ISoundTrackOptions {
  38421. /**
  38422. * The volume the sound track should take during creation
  38423. */
  38424. volume?: number;
  38425. /**
  38426. * Define if the sound track is the main sound track of the scene
  38427. */
  38428. mainTrack?: boolean;
  38429. }
  38430. /**
  38431. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38432. * It will be also used in a future release to apply effects on a specific track.
  38433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38434. */
  38435. export class SoundTrack {
  38436. /**
  38437. * The unique identifier of the sound track in the scene.
  38438. */
  38439. id: number;
  38440. /**
  38441. * The list of sounds included in the sound track.
  38442. */
  38443. soundCollection: Array<Sound>;
  38444. private _outputAudioNode;
  38445. private _scene;
  38446. private _connectedAnalyser;
  38447. private _options;
  38448. private _isInitialized;
  38449. /**
  38450. * Creates a new sound track.
  38451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38452. * @param scene Define the scene the sound track belongs to
  38453. * @param options
  38454. */
  38455. constructor(scene: Scene, options?: ISoundTrackOptions);
  38456. private _initializeSoundTrackAudioGraph;
  38457. /**
  38458. * Release the sound track and its associated resources
  38459. */
  38460. dispose(): void;
  38461. /**
  38462. * Adds a sound to this sound track
  38463. * @param sound define the cound to add
  38464. * @ignoreNaming
  38465. */
  38466. AddSound(sound: Sound): void;
  38467. /**
  38468. * Removes a sound to this sound track
  38469. * @param sound define the cound to remove
  38470. * @ignoreNaming
  38471. */
  38472. RemoveSound(sound: Sound): void;
  38473. /**
  38474. * Set a global volume for the full sound track.
  38475. * @param newVolume Define the new volume of the sound track
  38476. */
  38477. setVolume(newVolume: number): void;
  38478. /**
  38479. * Switch the panning model to HRTF:
  38480. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38482. */
  38483. switchPanningModelToHRTF(): void;
  38484. /**
  38485. * Switch the panning model to Equal Power:
  38486. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38488. */
  38489. switchPanningModelToEqualPower(): void;
  38490. /**
  38491. * Connect the sound track to an audio analyser allowing some amazing
  38492. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38494. * @param analyser The analyser to connect to the engine
  38495. */
  38496. connectToAnalyser(analyser: Analyser): void;
  38497. }
  38498. }
  38499. declare module "babylonjs/Audio/audioSceneComponent" {
  38500. import { Sound } from "babylonjs/Audio/sound";
  38501. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38502. import { Nullable } from "babylonjs/types";
  38503. import { Vector3 } from "babylonjs/Maths/math.vector";
  38504. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38505. import { Scene } from "babylonjs/scene";
  38506. import { AbstractScene } from "babylonjs/abstractScene";
  38507. import "babylonjs/Audio/audioEngine";
  38508. module "babylonjs/abstractScene" {
  38509. interface AbstractScene {
  38510. /**
  38511. * The list of sounds used in the scene.
  38512. */
  38513. sounds: Nullable<Array<Sound>>;
  38514. }
  38515. }
  38516. module "babylonjs/scene" {
  38517. interface Scene {
  38518. /**
  38519. * @hidden
  38520. * Backing field
  38521. */
  38522. _mainSoundTrack: SoundTrack;
  38523. /**
  38524. * The main sound track played by the scene.
  38525. * It cotains your primary collection of sounds.
  38526. */
  38527. mainSoundTrack: SoundTrack;
  38528. /**
  38529. * The list of sound tracks added to the scene
  38530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38531. */
  38532. soundTracks: Nullable<Array<SoundTrack>>;
  38533. /**
  38534. * Gets a sound using a given name
  38535. * @param name defines the name to search for
  38536. * @return the found sound or null if not found at all.
  38537. */
  38538. getSoundByName(name: string): Nullable<Sound>;
  38539. /**
  38540. * Gets or sets if audio support is enabled
  38541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38542. */
  38543. audioEnabled: boolean;
  38544. /**
  38545. * Gets or sets if audio will be output to headphones
  38546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38547. */
  38548. headphone: boolean;
  38549. /**
  38550. * Gets or sets custom audio listener position provider
  38551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38552. */
  38553. audioListenerPositionProvider: Nullable<() => Vector3>;
  38554. /**
  38555. * Gets or sets a refresh rate when using 3D audio positioning
  38556. */
  38557. audioPositioningRefreshRate: number;
  38558. }
  38559. }
  38560. /**
  38561. * Defines the sound scene component responsible to manage any sounds
  38562. * in a given scene.
  38563. */
  38564. export class AudioSceneComponent implements ISceneSerializableComponent {
  38565. /**
  38566. * The component name helpfull to identify the component in the list of scene components.
  38567. */
  38568. readonly name: string;
  38569. /**
  38570. * The scene the component belongs to.
  38571. */
  38572. scene: Scene;
  38573. private _audioEnabled;
  38574. /**
  38575. * Gets whether audio is enabled or not.
  38576. * Please use related enable/disable method to switch state.
  38577. */
  38578. get audioEnabled(): boolean;
  38579. private _headphone;
  38580. /**
  38581. * Gets whether audio is outputing to headphone or not.
  38582. * Please use the according Switch methods to change output.
  38583. */
  38584. get headphone(): boolean;
  38585. /**
  38586. * Gets or sets a refresh rate when using 3D audio positioning
  38587. */
  38588. audioPositioningRefreshRate: number;
  38589. private _audioListenerPositionProvider;
  38590. /**
  38591. * Gets the current audio listener position provider
  38592. */
  38593. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38594. /**
  38595. * Sets a custom listener position for all sounds in the scene
  38596. * By default, this is the position of the first active camera
  38597. */
  38598. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38599. /**
  38600. * Creates a new instance of the component for the given scene
  38601. * @param scene Defines the scene to register the component in
  38602. */
  38603. constructor(scene: Scene);
  38604. /**
  38605. * Registers the component in a given scene
  38606. */
  38607. register(): void;
  38608. /**
  38609. * Rebuilds the elements related to this component in case of
  38610. * context lost for instance.
  38611. */
  38612. rebuild(): void;
  38613. /**
  38614. * Serializes the component data to the specified json object
  38615. * @param serializationObject The object to serialize to
  38616. */
  38617. serialize(serializationObject: any): void;
  38618. /**
  38619. * Adds all the elements from the container to the scene
  38620. * @param container the container holding the elements
  38621. */
  38622. addFromContainer(container: AbstractScene): void;
  38623. /**
  38624. * Removes all the elements in the container from the scene
  38625. * @param container contains the elements to remove
  38626. * @param dispose if the removed element should be disposed (default: false)
  38627. */
  38628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38629. /**
  38630. * Disposes the component and the associated ressources.
  38631. */
  38632. dispose(): void;
  38633. /**
  38634. * Disables audio in the associated scene.
  38635. */
  38636. disableAudio(): void;
  38637. /**
  38638. * Enables audio in the associated scene.
  38639. */
  38640. enableAudio(): void;
  38641. /**
  38642. * Switch audio to headphone output.
  38643. */
  38644. switchAudioModeForHeadphones(): void;
  38645. /**
  38646. * Switch audio to normal speakers.
  38647. */
  38648. switchAudioModeForNormalSpeakers(): void;
  38649. private _cachedCameraDirection;
  38650. private _cachedCameraPosition;
  38651. private _lastCheck;
  38652. private _afterRender;
  38653. }
  38654. }
  38655. declare module "babylonjs/Audio/weightedsound" {
  38656. import { Sound } from "babylonjs/Audio/sound";
  38657. /**
  38658. * Wraps one or more Sound objects and selects one with random weight for playback.
  38659. */
  38660. export class WeightedSound {
  38661. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38662. loop: boolean;
  38663. private _coneInnerAngle;
  38664. private _coneOuterAngle;
  38665. private _volume;
  38666. /** A Sound is currently playing. */
  38667. isPlaying: boolean;
  38668. /** A Sound is currently paused. */
  38669. isPaused: boolean;
  38670. private _sounds;
  38671. private _weights;
  38672. private _currentIndex?;
  38673. /**
  38674. * Creates a new WeightedSound from the list of sounds given.
  38675. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38676. * @param sounds Array of Sounds that will be selected from.
  38677. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38678. */
  38679. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38680. /**
  38681. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38682. */
  38683. get directionalConeInnerAngle(): number;
  38684. /**
  38685. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38686. */
  38687. set directionalConeInnerAngle(value: number);
  38688. /**
  38689. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38690. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38691. */
  38692. get directionalConeOuterAngle(): number;
  38693. /**
  38694. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38695. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38696. */
  38697. set directionalConeOuterAngle(value: number);
  38698. /**
  38699. * Playback volume.
  38700. */
  38701. get volume(): number;
  38702. /**
  38703. * Playback volume.
  38704. */
  38705. set volume(value: number);
  38706. private _onended;
  38707. /**
  38708. * Suspend playback
  38709. */
  38710. pause(): void;
  38711. /**
  38712. * Stop playback
  38713. */
  38714. stop(): void;
  38715. /**
  38716. * Start playback.
  38717. * @param startOffset Position the clip head at a specific time in seconds.
  38718. */
  38719. play(startOffset?: number): void;
  38720. }
  38721. }
  38722. declare module "babylonjs/Audio/index" {
  38723. export * from "babylonjs/Audio/analyser";
  38724. export * from "babylonjs/Audio/audioEngine";
  38725. export * from "babylonjs/Audio/audioSceneComponent";
  38726. export * from "babylonjs/Audio/sound";
  38727. export * from "babylonjs/Audio/soundTrack";
  38728. export * from "babylonjs/Audio/weightedsound";
  38729. }
  38730. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38731. import { Behavior } from "babylonjs/Behaviors/behavior";
  38732. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38733. import { BackEase } from "babylonjs/Animations/easing";
  38734. /**
  38735. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38737. */
  38738. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38739. /**
  38740. * Gets the name of the behavior.
  38741. */
  38742. get name(): string;
  38743. /**
  38744. * The easing function used by animations
  38745. */
  38746. static EasingFunction: BackEase;
  38747. /**
  38748. * The easing mode used by animations
  38749. */
  38750. static EasingMode: number;
  38751. /**
  38752. * The duration of the animation, in milliseconds
  38753. */
  38754. transitionDuration: number;
  38755. /**
  38756. * Length of the distance animated by the transition when lower radius is reached
  38757. */
  38758. lowerRadiusTransitionRange: number;
  38759. /**
  38760. * Length of the distance animated by the transition when upper radius is reached
  38761. */
  38762. upperRadiusTransitionRange: number;
  38763. private _autoTransitionRange;
  38764. /**
  38765. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38766. */
  38767. get autoTransitionRange(): boolean;
  38768. /**
  38769. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38770. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38771. */
  38772. set autoTransitionRange(value: boolean);
  38773. private _attachedCamera;
  38774. private _onAfterCheckInputsObserver;
  38775. private _onMeshTargetChangedObserver;
  38776. /**
  38777. * Initializes the behavior.
  38778. */
  38779. init(): void;
  38780. /**
  38781. * Attaches the behavior to its arc rotate camera.
  38782. * @param camera Defines the camera to attach the behavior to
  38783. */
  38784. attach(camera: ArcRotateCamera): void;
  38785. /**
  38786. * Detaches the behavior from its current arc rotate camera.
  38787. */
  38788. detach(): void;
  38789. private _radiusIsAnimating;
  38790. private _radiusBounceTransition;
  38791. private _animatables;
  38792. private _cachedWheelPrecision;
  38793. /**
  38794. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38795. * @param radiusLimit The limit to check against.
  38796. * @return Bool to indicate if at limit.
  38797. */
  38798. private _isRadiusAtLimit;
  38799. /**
  38800. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38801. * @param radiusDelta The delta by which to animate to. Can be negative.
  38802. */
  38803. private _applyBoundRadiusAnimation;
  38804. /**
  38805. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38806. */
  38807. protected _clearAnimationLocks(): void;
  38808. /**
  38809. * Stops and removes all animations that have been applied to the camera
  38810. */
  38811. stopAllAnimations(): void;
  38812. }
  38813. }
  38814. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38815. import { Behavior } from "babylonjs/Behaviors/behavior";
  38816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38817. import { ExponentialEase } from "babylonjs/Animations/easing";
  38818. import { Nullable } from "babylonjs/types";
  38819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38820. import { Vector3 } from "babylonjs/Maths/math.vector";
  38821. /**
  38822. * 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.
  38823. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38824. */
  38825. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38826. /**
  38827. * Gets the name of the behavior.
  38828. */
  38829. get name(): string;
  38830. private _mode;
  38831. private _radiusScale;
  38832. private _positionScale;
  38833. private _defaultElevation;
  38834. private _elevationReturnTime;
  38835. private _elevationReturnWaitTime;
  38836. private _zoomStopsAnimation;
  38837. private _framingTime;
  38838. /**
  38839. * The easing function used by animations
  38840. */
  38841. static EasingFunction: ExponentialEase;
  38842. /**
  38843. * The easing mode used by animations
  38844. */
  38845. static EasingMode: number;
  38846. /**
  38847. * Sets the current mode used by the behavior
  38848. */
  38849. set mode(mode: number);
  38850. /**
  38851. * Gets current mode used by the behavior.
  38852. */
  38853. get mode(): number;
  38854. /**
  38855. * Sets the scale applied to the radius (1 by default)
  38856. */
  38857. set radiusScale(radius: number);
  38858. /**
  38859. * Gets the scale applied to the radius
  38860. */
  38861. get radiusScale(): number;
  38862. /**
  38863. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38864. */
  38865. set positionScale(scale: number);
  38866. /**
  38867. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38868. */
  38869. get positionScale(): number;
  38870. /**
  38871. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38872. * behaviour is triggered, in radians.
  38873. */
  38874. set defaultElevation(elevation: number);
  38875. /**
  38876. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38877. * behaviour is triggered, in radians.
  38878. */
  38879. get defaultElevation(): number;
  38880. /**
  38881. * Sets the time (in milliseconds) taken to return to the default beta position.
  38882. * Negative value indicates camera should not return to default.
  38883. */
  38884. set elevationReturnTime(speed: number);
  38885. /**
  38886. * Gets the time (in milliseconds) taken to return to the default beta position.
  38887. * Negative value indicates camera should not return to default.
  38888. */
  38889. get elevationReturnTime(): number;
  38890. /**
  38891. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38892. */
  38893. set elevationReturnWaitTime(time: number);
  38894. /**
  38895. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38896. */
  38897. get elevationReturnWaitTime(): number;
  38898. /**
  38899. * Sets the flag that indicates if user zooming should stop animation.
  38900. */
  38901. set zoomStopsAnimation(flag: boolean);
  38902. /**
  38903. * Gets the flag that indicates if user zooming should stop animation.
  38904. */
  38905. get zoomStopsAnimation(): boolean;
  38906. /**
  38907. * Sets the transition time when framing the mesh, in milliseconds
  38908. */
  38909. set framingTime(time: number);
  38910. /**
  38911. * Gets the transition time when framing the mesh, in milliseconds
  38912. */
  38913. get framingTime(): number;
  38914. /**
  38915. * Define if the behavior should automatically change the configured
  38916. * camera limits and sensibilities.
  38917. */
  38918. autoCorrectCameraLimitsAndSensibility: boolean;
  38919. private _onPrePointerObservableObserver;
  38920. private _onAfterCheckInputsObserver;
  38921. private _onMeshTargetChangedObserver;
  38922. private _attachedCamera;
  38923. private _isPointerDown;
  38924. private _lastInteractionTime;
  38925. /**
  38926. * Initializes the behavior.
  38927. */
  38928. init(): void;
  38929. /**
  38930. * Attaches the behavior to its arc rotate camera.
  38931. * @param camera Defines the camera to attach the behavior to
  38932. */
  38933. attach(camera: ArcRotateCamera): void;
  38934. /**
  38935. * Detaches the behavior from its current arc rotate camera.
  38936. */
  38937. detach(): void;
  38938. private _animatables;
  38939. private _betaIsAnimating;
  38940. private _betaTransition;
  38941. private _radiusTransition;
  38942. private _vectorTransition;
  38943. /**
  38944. * Targets the given mesh and updates zoom level accordingly.
  38945. * @param mesh The mesh to target.
  38946. * @param radius Optional. If a cached radius position already exists, overrides default.
  38947. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38948. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38949. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38950. */
  38951. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38952. /**
  38953. * Targets the given mesh with its children and updates zoom level accordingly.
  38954. * @param mesh The mesh to target.
  38955. * @param radius Optional. If a cached radius position already exists, overrides default.
  38956. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38957. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38958. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38959. */
  38960. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38961. /**
  38962. * Targets the given meshes with their children and updates zoom level accordingly.
  38963. * @param meshes The mesh to target.
  38964. * @param radius Optional. If a cached radius position already exists, overrides default.
  38965. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38968. */
  38969. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38970. /**
  38971. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38972. * @param minimumWorld Determines the smaller position of the bounding box extend
  38973. * @param maximumWorld Determines the bigger position of the bounding box extend
  38974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38976. */
  38977. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38978. /**
  38979. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38980. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38981. * frustum width.
  38982. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38983. * to fully enclose the mesh in the viewing frustum.
  38984. */
  38985. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38986. /**
  38987. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38988. * is automatically returned to its default position (expected to be above ground plane).
  38989. */
  38990. private _maintainCameraAboveGround;
  38991. /**
  38992. * Returns the frustum slope based on the canvas ratio and camera FOV
  38993. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38994. */
  38995. private _getFrustumSlope;
  38996. /**
  38997. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38998. */
  38999. private _clearAnimationLocks;
  39000. /**
  39001. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39002. */
  39003. private _applyUserInteraction;
  39004. /**
  39005. * Stops and removes all animations that have been applied to the camera
  39006. */
  39007. stopAllAnimations(): void;
  39008. /**
  39009. * Gets a value indicating if the user is moving the camera
  39010. */
  39011. get isUserIsMoving(): boolean;
  39012. /**
  39013. * The camera can move all the way towards the mesh.
  39014. */
  39015. static IgnoreBoundsSizeMode: number;
  39016. /**
  39017. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39018. */
  39019. static FitFrustumSidesMode: number;
  39020. }
  39021. }
  39022. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39023. import { Nullable } from "babylonjs/types";
  39024. import { Camera } from "babylonjs/Cameras/camera";
  39025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39026. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39027. /**
  39028. * Base class for Camera Pointer Inputs.
  39029. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39030. * for example usage.
  39031. */
  39032. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39033. /**
  39034. * Defines the camera the input is attached to.
  39035. */
  39036. abstract camera: Camera;
  39037. /**
  39038. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39039. */
  39040. protected _altKey: boolean;
  39041. protected _ctrlKey: boolean;
  39042. protected _metaKey: boolean;
  39043. protected _shiftKey: boolean;
  39044. /**
  39045. * Which mouse buttons were pressed at time of last mouse event.
  39046. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39047. */
  39048. protected _buttonsPressed: number;
  39049. /**
  39050. * Defines the buttons associated with the input to handle camera move.
  39051. */
  39052. buttons: number[];
  39053. /**
  39054. * Attach the input controls to a specific dom element to get the input from.
  39055. * @param element Defines the element the controls should be listened from
  39056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39057. */
  39058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39059. /**
  39060. * Detach the current controls from the specified dom element.
  39061. * @param element Defines the element to stop listening the inputs from
  39062. */
  39063. detachControl(element: Nullable<HTMLElement>): void;
  39064. /**
  39065. * Gets the class name of the current input.
  39066. * @returns the class name
  39067. */
  39068. getClassName(): string;
  39069. /**
  39070. * Get the friendly name associated with the input class.
  39071. * @returns the input friendly name
  39072. */
  39073. getSimpleName(): string;
  39074. /**
  39075. * Called on pointer POINTERDOUBLETAP event.
  39076. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39077. */
  39078. protected onDoubleTap(type: string): void;
  39079. /**
  39080. * Called on pointer POINTERMOVE event if only a single touch is active.
  39081. * Override this method to provide functionality.
  39082. */
  39083. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39084. /**
  39085. * Called on pointer POINTERMOVE event if multiple touches are active.
  39086. * Override this method to provide functionality.
  39087. */
  39088. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39089. /**
  39090. * Called on JS contextmenu event.
  39091. * Override this method to provide functionality.
  39092. */
  39093. protected onContextMenu(evt: PointerEvent): void;
  39094. /**
  39095. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39096. * press.
  39097. * Override this method to provide functionality.
  39098. */
  39099. protected onButtonDown(evt: PointerEvent): void;
  39100. /**
  39101. * Called each time a new POINTERUP event occurs. Ie, for each button
  39102. * release.
  39103. * Override this method to provide functionality.
  39104. */
  39105. protected onButtonUp(evt: PointerEvent): void;
  39106. /**
  39107. * Called when window becomes inactive.
  39108. * Override this method to provide functionality.
  39109. */
  39110. protected onLostFocus(): void;
  39111. private _pointerInput;
  39112. private _observer;
  39113. private _onLostFocus;
  39114. private pointA;
  39115. private pointB;
  39116. }
  39117. }
  39118. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39119. import { Nullable } from "babylonjs/types";
  39120. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39121. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39122. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39123. /**
  39124. * Manage the pointers inputs to control an arc rotate camera.
  39125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39126. */
  39127. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39128. /**
  39129. * Defines the camera the input is attached to.
  39130. */
  39131. camera: ArcRotateCamera;
  39132. /**
  39133. * Gets the class name of the current input.
  39134. * @returns the class name
  39135. */
  39136. getClassName(): string;
  39137. /**
  39138. * Defines the buttons associated with the input to handle camera move.
  39139. */
  39140. buttons: number[];
  39141. /**
  39142. * Defines the pointer angular sensibility along the X axis or how fast is
  39143. * the camera rotating.
  39144. */
  39145. angularSensibilityX: number;
  39146. /**
  39147. * Defines the pointer angular sensibility along the Y axis or how fast is
  39148. * the camera rotating.
  39149. */
  39150. angularSensibilityY: number;
  39151. /**
  39152. * Defines the pointer pinch precision or how fast is the camera zooming.
  39153. */
  39154. pinchPrecision: number;
  39155. /**
  39156. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39157. * from 0.
  39158. * It defines the percentage of current camera.radius to use as delta when
  39159. * pinch zoom is used.
  39160. */
  39161. pinchDeltaPercentage: number;
  39162. /**
  39163. * Defines the pointer panning sensibility or how fast is the camera moving.
  39164. */
  39165. panningSensibility: number;
  39166. /**
  39167. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39168. */
  39169. multiTouchPanning: boolean;
  39170. /**
  39171. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39172. * zoom (pinch) through multitouch.
  39173. */
  39174. multiTouchPanAndZoom: boolean;
  39175. /**
  39176. * Revers pinch action direction.
  39177. */
  39178. pinchInwards: boolean;
  39179. private _isPanClick;
  39180. private _twoFingerActivityCount;
  39181. private _isPinching;
  39182. /**
  39183. * Called on pointer POINTERMOVE event if only a single touch is active.
  39184. */
  39185. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39186. /**
  39187. * Called on pointer POINTERDOUBLETAP event.
  39188. */
  39189. protected onDoubleTap(type: string): void;
  39190. /**
  39191. * Called on pointer POINTERMOVE event if multiple touches are active.
  39192. */
  39193. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39194. /**
  39195. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39196. * press.
  39197. */
  39198. protected onButtonDown(evt: PointerEvent): void;
  39199. /**
  39200. * Called each time a new POINTERUP event occurs. Ie, for each button
  39201. * release.
  39202. */
  39203. protected onButtonUp(evt: PointerEvent): void;
  39204. /**
  39205. * Called when window becomes inactive.
  39206. */
  39207. protected onLostFocus(): void;
  39208. }
  39209. }
  39210. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39211. import { Nullable } from "babylonjs/types";
  39212. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39213. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39214. /**
  39215. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39217. */
  39218. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39219. /**
  39220. * Defines the camera the input is attached to.
  39221. */
  39222. camera: ArcRotateCamera;
  39223. /**
  39224. * Defines the list of key codes associated with the up action (increase alpha)
  39225. */
  39226. keysUp: number[];
  39227. /**
  39228. * Defines the list of key codes associated with the down action (decrease alpha)
  39229. */
  39230. keysDown: number[];
  39231. /**
  39232. * Defines the list of key codes associated with the left action (increase beta)
  39233. */
  39234. keysLeft: number[];
  39235. /**
  39236. * Defines the list of key codes associated with the right action (decrease beta)
  39237. */
  39238. keysRight: number[];
  39239. /**
  39240. * Defines the list of key codes associated with the reset action.
  39241. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39242. */
  39243. keysReset: number[];
  39244. /**
  39245. * Defines the panning sensibility of the inputs.
  39246. * (How fast is the camera paning)
  39247. */
  39248. panningSensibility: number;
  39249. /**
  39250. * Defines the zooming sensibility of the inputs.
  39251. * (How fast is the camera zooming)
  39252. */
  39253. zoomingSensibility: number;
  39254. /**
  39255. * Defines wether maintaining the alt key down switch the movement mode from
  39256. * orientation to zoom.
  39257. */
  39258. useAltToZoom: boolean;
  39259. /**
  39260. * Rotation speed of the camera
  39261. */
  39262. angularSpeed: number;
  39263. private _keys;
  39264. private _ctrlPressed;
  39265. private _altPressed;
  39266. private _onCanvasBlurObserver;
  39267. private _onKeyboardObserver;
  39268. private _engine;
  39269. private _scene;
  39270. /**
  39271. * Attach the input controls to a specific dom element to get the input from.
  39272. * @param element Defines the element the controls should be listened from
  39273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39274. */
  39275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39276. /**
  39277. * Detach the current controls from the specified dom element.
  39278. * @param element Defines the element to stop listening the inputs from
  39279. */
  39280. detachControl(element: Nullable<HTMLElement>): void;
  39281. /**
  39282. * Update the current camera state depending on the inputs that have been used this frame.
  39283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39284. */
  39285. checkInputs(): void;
  39286. /**
  39287. * Gets the class name of the current intput.
  39288. * @returns the class name
  39289. */
  39290. getClassName(): string;
  39291. /**
  39292. * Get the friendly name associated with the input class.
  39293. * @returns the input friendly name
  39294. */
  39295. getSimpleName(): string;
  39296. }
  39297. }
  39298. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39299. import { Nullable } from "babylonjs/types";
  39300. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39301. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39302. /**
  39303. * Manage the mouse wheel inputs to control an arc rotate camera.
  39304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39305. */
  39306. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39307. /**
  39308. * Defines the camera the input is attached to.
  39309. */
  39310. camera: ArcRotateCamera;
  39311. /**
  39312. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39313. */
  39314. wheelPrecision: number;
  39315. /**
  39316. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39317. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39318. */
  39319. wheelDeltaPercentage: number;
  39320. private _wheel;
  39321. private _observer;
  39322. private computeDeltaFromMouseWheelLegacyEvent;
  39323. /**
  39324. * Attach the input controls to a specific dom element to get the input from.
  39325. * @param element Defines the element the controls should be listened from
  39326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39327. */
  39328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39329. /**
  39330. * Detach the current controls from the specified dom element.
  39331. * @param element Defines the element to stop listening the inputs from
  39332. */
  39333. detachControl(element: Nullable<HTMLElement>): void;
  39334. /**
  39335. * Gets the class name of the current intput.
  39336. * @returns the class name
  39337. */
  39338. getClassName(): string;
  39339. /**
  39340. * Get the friendly name associated with the input class.
  39341. * @returns the input friendly name
  39342. */
  39343. getSimpleName(): string;
  39344. }
  39345. }
  39346. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39348. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39349. /**
  39350. * Default Inputs manager for the ArcRotateCamera.
  39351. * It groups all the default supported inputs for ease of use.
  39352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39353. */
  39354. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39355. /**
  39356. * Instantiates a new ArcRotateCameraInputsManager.
  39357. * @param camera Defines the camera the inputs belong to
  39358. */
  39359. constructor(camera: ArcRotateCamera);
  39360. /**
  39361. * Add mouse wheel input support to the input manager.
  39362. * @returns the current input manager
  39363. */
  39364. addMouseWheel(): ArcRotateCameraInputsManager;
  39365. /**
  39366. * Add pointers input support to the input manager.
  39367. * @returns the current input manager
  39368. */
  39369. addPointers(): ArcRotateCameraInputsManager;
  39370. /**
  39371. * Add keyboard input support to the input manager.
  39372. * @returns the current input manager
  39373. */
  39374. addKeyboard(): ArcRotateCameraInputsManager;
  39375. }
  39376. }
  39377. declare module "babylonjs/Cameras/arcRotateCamera" {
  39378. import { Observable } from "babylonjs/Misc/observable";
  39379. import { Nullable } from "babylonjs/types";
  39380. import { Scene } from "babylonjs/scene";
  39381. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39383. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39384. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39385. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39386. import { Camera } from "babylonjs/Cameras/camera";
  39387. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39388. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39389. import { Collider } from "babylonjs/Collisions/collider";
  39390. /**
  39391. * This represents an orbital type of camera.
  39392. *
  39393. * 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.
  39394. * 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.
  39395. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39396. */
  39397. export class ArcRotateCamera extends TargetCamera {
  39398. /**
  39399. * Defines the rotation angle of the camera along the longitudinal axis.
  39400. */
  39401. alpha: number;
  39402. /**
  39403. * Defines the rotation angle of the camera along the latitudinal axis.
  39404. */
  39405. beta: number;
  39406. /**
  39407. * Defines the radius of the camera from it s target point.
  39408. */
  39409. radius: number;
  39410. protected _target: Vector3;
  39411. protected _targetHost: Nullable<AbstractMesh>;
  39412. /**
  39413. * Defines the target point of the camera.
  39414. * The camera looks towards it form the radius distance.
  39415. */
  39416. get target(): Vector3;
  39417. set target(value: Vector3);
  39418. /**
  39419. * Define the current local position of the camera in the scene
  39420. */
  39421. get position(): Vector3;
  39422. set position(newPosition: Vector3);
  39423. protected _upVector: Vector3;
  39424. protected _upToYMatrix: Matrix;
  39425. protected _YToUpMatrix: Matrix;
  39426. /**
  39427. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39428. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39429. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39430. */
  39431. set upVector(vec: Vector3);
  39432. get upVector(): Vector3;
  39433. /**
  39434. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39435. */
  39436. setMatUp(): void;
  39437. /**
  39438. * Current inertia value on the longitudinal axis.
  39439. * The bigger this number the longer it will take for the camera to stop.
  39440. */
  39441. inertialAlphaOffset: number;
  39442. /**
  39443. * Current inertia value on the latitudinal axis.
  39444. * The bigger this number the longer it will take for the camera to stop.
  39445. */
  39446. inertialBetaOffset: number;
  39447. /**
  39448. * Current inertia value on the radius axis.
  39449. * The bigger this number the longer it will take for the camera to stop.
  39450. */
  39451. inertialRadiusOffset: number;
  39452. /**
  39453. * Minimum allowed angle on the longitudinal axis.
  39454. * This can help limiting how the Camera is able to move in the scene.
  39455. */
  39456. lowerAlphaLimit: Nullable<number>;
  39457. /**
  39458. * Maximum allowed angle on the longitudinal axis.
  39459. * This can help limiting how the Camera is able to move in the scene.
  39460. */
  39461. upperAlphaLimit: Nullable<number>;
  39462. /**
  39463. * Minimum allowed angle on the latitudinal axis.
  39464. * This can help limiting how the Camera is able to move in the scene.
  39465. */
  39466. lowerBetaLimit: number;
  39467. /**
  39468. * Maximum allowed angle on the latitudinal axis.
  39469. * This can help limiting how the Camera is able to move in the scene.
  39470. */
  39471. upperBetaLimit: number;
  39472. /**
  39473. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39474. * This can help limiting how the Camera is able to move in the scene.
  39475. */
  39476. lowerRadiusLimit: Nullable<number>;
  39477. /**
  39478. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39479. * This can help limiting how the Camera is able to move in the scene.
  39480. */
  39481. upperRadiusLimit: Nullable<number>;
  39482. /**
  39483. * Defines the current inertia value used during panning of the camera along the X axis.
  39484. */
  39485. inertialPanningX: number;
  39486. /**
  39487. * Defines the current inertia value used during panning of the camera along the Y axis.
  39488. */
  39489. inertialPanningY: number;
  39490. /**
  39491. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39492. * Basically if your fingers moves away from more than this distance you will be considered
  39493. * in pinch mode.
  39494. */
  39495. pinchToPanMaxDistance: number;
  39496. /**
  39497. * Defines the maximum distance the camera can pan.
  39498. * This could help keeping the cammera always in your scene.
  39499. */
  39500. panningDistanceLimit: Nullable<number>;
  39501. /**
  39502. * Defines the target of the camera before paning.
  39503. */
  39504. panningOriginTarget: Vector3;
  39505. /**
  39506. * Defines the value of the inertia used during panning.
  39507. * 0 would mean stop inertia and one would mean no decelleration at all.
  39508. */
  39509. panningInertia: number;
  39510. /**
  39511. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39512. */
  39513. get angularSensibilityX(): number;
  39514. set angularSensibilityX(value: number);
  39515. /**
  39516. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39517. */
  39518. get angularSensibilityY(): number;
  39519. set angularSensibilityY(value: number);
  39520. /**
  39521. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39522. */
  39523. get pinchPrecision(): number;
  39524. set pinchPrecision(value: number);
  39525. /**
  39526. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39527. * It will be used instead of pinchDeltaPrecision if different from 0.
  39528. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39529. */
  39530. get pinchDeltaPercentage(): number;
  39531. set pinchDeltaPercentage(value: number);
  39532. /**
  39533. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39534. */
  39535. get panningSensibility(): number;
  39536. set panningSensibility(value: number);
  39537. /**
  39538. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39539. */
  39540. get keysUp(): number[];
  39541. set keysUp(value: number[]);
  39542. /**
  39543. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39544. */
  39545. get keysDown(): number[];
  39546. set keysDown(value: number[]);
  39547. /**
  39548. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39549. */
  39550. get keysLeft(): number[];
  39551. set keysLeft(value: number[]);
  39552. /**
  39553. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39554. */
  39555. get keysRight(): number[];
  39556. set keysRight(value: number[]);
  39557. /**
  39558. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39559. */
  39560. get wheelPrecision(): number;
  39561. set wheelPrecision(value: number);
  39562. /**
  39563. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39564. * It will be used instead of pinchDeltaPrecision if different from 0.
  39565. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39566. */
  39567. get wheelDeltaPercentage(): number;
  39568. set wheelDeltaPercentage(value: number);
  39569. /**
  39570. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39571. */
  39572. zoomOnFactor: number;
  39573. /**
  39574. * Defines a screen offset for the camera position.
  39575. */
  39576. targetScreenOffset: Vector2;
  39577. /**
  39578. * Allows the camera to be completely reversed.
  39579. * If false the camera can not arrive upside down.
  39580. */
  39581. allowUpsideDown: boolean;
  39582. /**
  39583. * Define if double tap/click is used to restore the previously saved state of the camera.
  39584. */
  39585. useInputToRestoreState: boolean;
  39586. /** @hidden */
  39587. _viewMatrix: Matrix;
  39588. /** @hidden */
  39589. _useCtrlForPanning: boolean;
  39590. /** @hidden */
  39591. _panningMouseButton: number;
  39592. /**
  39593. * Defines the input associated to the camera.
  39594. */
  39595. inputs: ArcRotateCameraInputsManager;
  39596. /** @hidden */
  39597. _reset: () => void;
  39598. /**
  39599. * Defines the allowed panning axis.
  39600. */
  39601. panningAxis: Vector3;
  39602. protected _localDirection: Vector3;
  39603. protected _transformedDirection: Vector3;
  39604. private _bouncingBehavior;
  39605. /**
  39606. * Gets the bouncing behavior of the camera if it has been enabled.
  39607. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39608. */
  39609. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39610. /**
  39611. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39612. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39613. */
  39614. get useBouncingBehavior(): boolean;
  39615. set useBouncingBehavior(value: boolean);
  39616. private _framingBehavior;
  39617. /**
  39618. * Gets the framing behavior of the camera if it has been enabled.
  39619. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39620. */
  39621. get framingBehavior(): Nullable<FramingBehavior>;
  39622. /**
  39623. * Defines if the framing behavior of the camera is enabled on the camera.
  39624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39625. */
  39626. get useFramingBehavior(): boolean;
  39627. set useFramingBehavior(value: boolean);
  39628. private _autoRotationBehavior;
  39629. /**
  39630. * Gets the auto rotation behavior of the camera if it has been enabled.
  39631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39632. */
  39633. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39634. /**
  39635. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39636. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39637. */
  39638. get useAutoRotationBehavior(): boolean;
  39639. set useAutoRotationBehavior(value: boolean);
  39640. /**
  39641. * Observable triggered when the mesh target has been changed on the camera.
  39642. */
  39643. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39644. /**
  39645. * Event raised when the camera is colliding with a mesh.
  39646. */
  39647. onCollide: (collidedMesh: AbstractMesh) => void;
  39648. /**
  39649. * Defines whether the camera should check collision with the objects oh the scene.
  39650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39651. */
  39652. checkCollisions: boolean;
  39653. /**
  39654. * Defines the collision radius of the camera.
  39655. * This simulates a sphere around the camera.
  39656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39657. */
  39658. collisionRadius: Vector3;
  39659. protected _collider: Collider;
  39660. protected _previousPosition: Vector3;
  39661. protected _collisionVelocity: Vector3;
  39662. protected _newPosition: Vector3;
  39663. protected _previousAlpha: number;
  39664. protected _previousBeta: number;
  39665. protected _previousRadius: number;
  39666. protected _collisionTriggered: boolean;
  39667. protected _targetBoundingCenter: Nullable<Vector3>;
  39668. private _computationVector;
  39669. /**
  39670. * Instantiates a new ArcRotateCamera in a given scene
  39671. * @param name Defines the name of the camera
  39672. * @param alpha Defines the camera rotation along the logitudinal axis
  39673. * @param beta Defines the camera rotation along the latitudinal axis
  39674. * @param radius Defines the camera distance from its target
  39675. * @param target Defines the camera target
  39676. * @param scene Defines the scene the camera belongs to
  39677. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39678. */
  39679. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39680. /** @hidden */
  39681. _initCache(): void;
  39682. /** @hidden */
  39683. _updateCache(ignoreParentClass?: boolean): void;
  39684. protected _getTargetPosition(): Vector3;
  39685. private _storedAlpha;
  39686. private _storedBeta;
  39687. private _storedRadius;
  39688. private _storedTarget;
  39689. private _storedTargetScreenOffset;
  39690. /**
  39691. * Stores the current state of the camera (alpha, beta, radius and target)
  39692. * @returns the camera itself
  39693. */
  39694. storeState(): Camera;
  39695. /**
  39696. * @hidden
  39697. * Restored camera state. You must call storeState() first
  39698. */
  39699. _restoreStateValues(): boolean;
  39700. /** @hidden */
  39701. _isSynchronizedViewMatrix(): boolean;
  39702. /**
  39703. * Attached controls to the current camera.
  39704. * @param element Defines the element the controls should be listened from
  39705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39706. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39707. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39708. */
  39709. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39710. /**
  39711. * Detach the current controls from the camera.
  39712. * The camera will stop reacting to inputs.
  39713. * @param element Defines the element to stop listening the inputs from
  39714. */
  39715. detachControl(element: HTMLElement): void;
  39716. /** @hidden */
  39717. _checkInputs(): void;
  39718. protected _checkLimits(): void;
  39719. /**
  39720. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39721. */
  39722. rebuildAnglesAndRadius(): void;
  39723. /**
  39724. * Use a position to define the current camera related information like alpha, beta and radius
  39725. * @param position Defines the position to set the camera at
  39726. */
  39727. setPosition(position: Vector3): void;
  39728. /**
  39729. * Defines the target the camera should look at.
  39730. * This will automatically adapt alpha beta and radius to fit within the new target.
  39731. * @param target Defines the new target as a Vector or a mesh
  39732. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39733. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39734. */
  39735. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39736. /** @hidden */
  39737. _getViewMatrix(): Matrix;
  39738. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39739. /**
  39740. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39741. * @param meshes Defines the mesh to zoom on
  39742. * @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)
  39743. */
  39744. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39745. /**
  39746. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39747. * The target will be changed but the radius
  39748. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39749. * @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)
  39750. */
  39751. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39752. min: Vector3;
  39753. max: Vector3;
  39754. distance: number;
  39755. }, doNotUpdateMaxZ?: boolean): void;
  39756. /**
  39757. * @override
  39758. * Override Camera.createRigCamera
  39759. */
  39760. createRigCamera(name: string, cameraIndex: number): Camera;
  39761. /**
  39762. * @hidden
  39763. * @override
  39764. * Override Camera._updateRigCameras
  39765. */
  39766. _updateRigCameras(): void;
  39767. /**
  39768. * Destroy the camera and release the current resources hold by it.
  39769. */
  39770. dispose(): void;
  39771. /**
  39772. * Gets the current object class name.
  39773. * @return the class name
  39774. */
  39775. getClassName(): string;
  39776. }
  39777. }
  39778. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39779. import { Behavior } from "babylonjs/Behaviors/behavior";
  39780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39781. /**
  39782. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39783. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39784. */
  39785. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39786. /**
  39787. * Gets the name of the behavior.
  39788. */
  39789. get name(): string;
  39790. private _zoomStopsAnimation;
  39791. private _idleRotationSpeed;
  39792. private _idleRotationWaitTime;
  39793. private _idleRotationSpinupTime;
  39794. /**
  39795. * Sets the flag that indicates if user zooming should stop animation.
  39796. */
  39797. set zoomStopsAnimation(flag: boolean);
  39798. /**
  39799. * Gets the flag that indicates if user zooming should stop animation.
  39800. */
  39801. get zoomStopsAnimation(): boolean;
  39802. /**
  39803. * Sets the default speed at which the camera rotates around the model.
  39804. */
  39805. set idleRotationSpeed(speed: number);
  39806. /**
  39807. * Gets the default speed at which the camera rotates around the model.
  39808. */
  39809. get idleRotationSpeed(): number;
  39810. /**
  39811. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39812. */
  39813. set idleRotationWaitTime(time: number);
  39814. /**
  39815. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39816. */
  39817. get idleRotationWaitTime(): number;
  39818. /**
  39819. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39820. */
  39821. set idleRotationSpinupTime(time: number);
  39822. /**
  39823. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39824. */
  39825. get idleRotationSpinupTime(): number;
  39826. /**
  39827. * Gets a value indicating if the camera is currently rotating because of this behavior
  39828. */
  39829. get rotationInProgress(): boolean;
  39830. private _onPrePointerObservableObserver;
  39831. private _onAfterCheckInputsObserver;
  39832. private _attachedCamera;
  39833. private _isPointerDown;
  39834. private _lastFrameTime;
  39835. private _lastInteractionTime;
  39836. private _cameraRotationSpeed;
  39837. /**
  39838. * Initializes the behavior.
  39839. */
  39840. init(): void;
  39841. /**
  39842. * Attaches the behavior to its arc rotate camera.
  39843. * @param camera Defines the camera to attach the behavior to
  39844. */
  39845. attach(camera: ArcRotateCamera): void;
  39846. /**
  39847. * Detaches the behavior from its current arc rotate camera.
  39848. */
  39849. detach(): void;
  39850. /**
  39851. * Returns true if user is scrolling.
  39852. * @return true if user is scrolling.
  39853. */
  39854. private _userIsZooming;
  39855. private _lastFrameRadius;
  39856. private _shouldAnimationStopForInteraction;
  39857. /**
  39858. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39859. */
  39860. private _applyUserInteraction;
  39861. private _userIsMoving;
  39862. }
  39863. }
  39864. declare module "babylonjs/Behaviors/Cameras/index" {
  39865. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39866. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39867. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39868. }
  39869. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39870. import { Mesh } from "babylonjs/Meshes/mesh";
  39871. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39872. import { Behavior } from "babylonjs/Behaviors/behavior";
  39873. /**
  39874. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39875. */
  39876. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39877. private ui;
  39878. /**
  39879. * The name of the behavior
  39880. */
  39881. name: string;
  39882. /**
  39883. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39884. */
  39885. distanceAwayFromFace: number;
  39886. /**
  39887. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39888. */
  39889. distanceAwayFromBottomOfFace: number;
  39890. private _faceVectors;
  39891. private _target;
  39892. private _scene;
  39893. private _onRenderObserver;
  39894. private _tmpMatrix;
  39895. private _tmpVector;
  39896. /**
  39897. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39898. * @param ui The transform node that should be attched to the mesh
  39899. */
  39900. constructor(ui: TransformNode);
  39901. /**
  39902. * Initializes the behavior
  39903. */
  39904. init(): void;
  39905. private _closestFace;
  39906. private _zeroVector;
  39907. private _lookAtTmpMatrix;
  39908. private _lookAtToRef;
  39909. /**
  39910. * Attaches the AttachToBoxBehavior to the passed in mesh
  39911. * @param target The mesh that the specified node will be attached to
  39912. */
  39913. attach(target: Mesh): void;
  39914. /**
  39915. * Detaches the behavior from the mesh
  39916. */
  39917. detach(): void;
  39918. }
  39919. }
  39920. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39921. import { Behavior } from "babylonjs/Behaviors/behavior";
  39922. import { Mesh } from "babylonjs/Meshes/mesh";
  39923. /**
  39924. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39925. */
  39926. export class FadeInOutBehavior implements Behavior<Mesh> {
  39927. /**
  39928. * Time in milliseconds to delay before fading in (Default: 0)
  39929. */
  39930. delay: number;
  39931. /**
  39932. * Time in milliseconds for the mesh to fade in (Default: 300)
  39933. */
  39934. fadeInTime: number;
  39935. private _millisecondsPerFrame;
  39936. private _hovered;
  39937. private _hoverValue;
  39938. private _ownerNode;
  39939. /**
  39940. * Instatiates the FadeInOutBehavior
  39941. */
  39942. constructor();
  39943. /**
  39944. * The name of the behavior
  39945. */
  39946. get name(): string;
  39947. /**
  39948. * Initializes the behavior
  39949. */
  39950. init(): void;
  39951. /**
  39952. * Attaches the fade behavior on the passed in mesh
  39953. * @param ownerNode The mesh that will be faded in/out once attached
  39954. */
  39955. attach(ownerNode: Mesh): void;
  39956. /**
  39957. * Detaches the behavior from the mesh
  39958. */
  39959. detach(): void;
  39960. /**
  39961. * Triggers the mesh to begin fading in or out
  39962. * @param value if the object should fade in or out (true to fade in)
  39963. */
  39964. fadeIn(value: boolean): void;
  39965. private _update;
  39966. private _setAllVisibility;
  39967. }
  39968. }
  39969. declare module "babylonjs/Misc/pivotTools" {
  39970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39971. /**
  39972. * Class containing a set of static utilities functions for managing Pivots
  39973. * @hidden
  39974. */
  39975. export class PivotTools {
  39976. private static _PivotCached;
  39977. private static _OldPivotPoint;
  39978. private static _PivotTranslation;
  39979. private static _PivotTmpVector;
  39980. /** @hidden */
  39981. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39982. /** @hidden */
  39983. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39984. }
  39985. }
  39986. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39987. import { Scene } from "babylonjs/scene";
  39988. import { Vector4 } from "babylonjs/Maths/math.vector";
  39989. import { Mesh } from "babylonjs/Meshes/mesh";
  39990. import { Nullable } from "babylonjs/types";
  39991. import { Plane } from "babylonjs/Maths/math.plane";
  39992. /**
  39993. * Class containing static functions to help procedurally build meshes
  39994. */
  39995. export class PlaneBuilder {
  39996. /**
  39997. * Creates a plane mesh
  39998. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39999. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40000. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40004. * @param name defines the name of the mesh
  40005. * @param options defines the options used to create the mesh
  40006. * @param scene defines the hosting scene
  40007. * @returns the plane mesh
  40008. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40009. */
  40010. static CreatePlane(name: string, options: {
  40011. size?: number;
  40012. width?: number;
  40013. height?: number;
  40014. sideOrientation?: number;
  40015. frontUVs?: Vector4;
  40016. backUVs?: Vector4;
  40017. updatable?: boolean;
  40018. sourcePlane?: Plane;
  40019. }, scene?: Nullable<Scene>): Mesh;
  40020. }
  40021. }
  40022. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40023. import { Behavior } from "babylonjs/Behaviors/behavior";
  40024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40025. import { Observable } from "babylonjs/Misc/observable";
  40026. import { Vector3 } from "babylonjs/Maths/math.vector";
  40027. import { Ray } from "babylonjs/Culling/ray";
  40028. import "babylonjs/Meshes/Builders/planeBuilder";
  40029. /**
  40030. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40031. */
  40032. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40033. private static _AnyMouseID;
  40034. /**
  40035. * Abstract mesh the behavior is set on
  40036. */
  40037. attachedNode: AbstractMesh;
  40038. private _dragPlane;
  40039. private _scene;
  40040. private _pointerObserver;
  40041. private _beforeRenderObserver;
  40042. private static _planeScene;
  40043. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40044. /**
  40045. * 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)
  40046. */
  40047. maxDragAngle: number;
  40048. /**
  40049. * @hidden
  40050. */
  40051. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40052. /**
  40053. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40054. */
  40055. currentDraggingPointerID: number;
  40056. /**
  40057. * The last position where the pointer hit the drag plane in world space
  40058. */
  40059. lastDragPosition: Vector3;
  40060. /**
  40061. * If the behavior is currently in a dragging state
  40062. */
  40063. dragging: boolean;
  40064. /**
  40065. * 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)
  40066. */
  40067. dragDeltaRatio: number;
  40068. /**
  40069. * If the drag plane orientation should be updated during the dragging (Default: true)
  40070. */
  40071. updateDragPlane: boolean;
  40072. private _debugMode;
  40073. private _moving;
  40074. /**
  40075. * Fires each time the attached mesh is dragged with the pointer
  40076. * * delta between last drag position and current drag position in world space
  40077. * * dragDistance along the drag axis
  40078. * * dragPlaneNormal normal of the current drag plane used during the drag
  40079. * * dragPlanePoint in world space where the drag intersects the drag plane
  40080. */
  40081. onDragObservable: Observable<{
  40082. delta: Vector3;
  40083. dragPlanePoint: Vector3;
  40084. dragPlaneNormal: Vector3;
  40085. dragDistance: number;
  40086. pointerId: number;
  40087. }>;
  40088. /**
  40089. * Fires each time a drag begins (eg. mouse down on mesh)
  40090. */
  40091. onDragStartObservable: Observable<{
  40092. dragPlanePoint: Vector3;
  40093. pointerId: number;
  40094. }>;
  40095. /**
  40096. * Fires each time a drag ends (eg. mouse release after drag)
  40097. */
  40098. onDragEndObservable: Observable<{
  40099. dragPlanePoint: Vector3;
  40100. pointerId: number;
  40101. }>;
  40102. /**
  40103. * If the attached mesh should be moved when dragged
  40104. */
  40105. moveAttached: boolean;
  40106. /**
  40107. * If the drag behavior will react to drag events (Default: true)
  40108. */
  40109. enabled: boolean;
  40110. /**
  40111. * If pointer events should start and release the drag (Default: true)
  40112. */
  40113. startAndReleaseDragOnPointerEvents: boolean;
  40114. /**
  40115. * If camera controls should be detached during the drag
  40116. */
  40117. detachCameraControls: boolean;
  40118. /**
  40119. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40120. */
  40121. useObjectOrienationForDragging: boolean;
  40122. private _options;
  40123. /**
  40124. * Gets the options used by the behavior
  40125. */
  40126. get options(): {
  40127. dragAxis?: Vector3;
  40128. dragPlaneNormal?: Vector3;
  40129. };
  40130. /**
  40131. * Sets the options used by the behavior
  40132. */
  40133. set options(options: {
  40134. dragAxis?: Vector3;
  40135. dragPlaneNormal?: Vector3;
  40136. });
  40137. /**
  40138. * Creates a pointer drag behavior that can be attached to a mesh
  40139. * @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)
  40140. */
  40141. constructor(options?: {
  40142. dragAxis?: Vector3;
  40143. dragPlaneNormal?: Vector3;
  40144. });
  40145. /**
  40146. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40147. */
  40148. validateDrag: (targetPosition: Vector3) => boolean;
  40149. /**
  40150. * The name of the behavior
  40151. */
  40152. get name(): string;
  40153. /**
  40154. * Initializes the behavior
  40155. */
  40156. init(): void;
  40157. private _tmpVector;
  40158. private _alternatePickedPoint;
  40159. private _worldDragAxis;
  40160. private _targetPosition;
  40161. private _attachedElement;
  40162. /**
  40163. * Attaches the drag behavior the passed in mesh
  40164. * @param ownerNode The mesh that will be dragged around once attached
  40165. * @param predicate Predicate to use for pick filtering
  40166. */
  40167. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40168. /**
  40169. * Force relase the drag action by code.
  40170. */
  40171. releaseDrag(): void;
  40172. private _startDragRay;
  40173. private _lastPointerRay;
  40174. /**
  40175. * Simulates the start of a pointer drag event on the behavior
  40176. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40177. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40178. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40179. */
  40180. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40181. private _startDrag;
  40182. private _dragDelta;
  40183. private _moveDrag;
  40184. private _pickWithRayOnDragPlane;
  40185. private _pointA;
  40186. private _pointB;
  40187. private _pointC;
  40188. private _lineA;
  40189. private _lineB;
  40190. private _localAxis;
  40191. private _lookAt;
  40192. private _updateDragPlanePosition;
  40193. /**
  40194. * Detaches the behavior from the mesh
  40195. */
  40196. detach(): void;
  40197. }
  40198. }
  40199. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40200. import { Mesh } from "babylonjs/Meshes/mesh";
  40201. import { Behavior } from "babylonjs/Behaviors/behavior";
  40202. /**
  40203. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40204. */
  40205. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40206. private _dragBehaviorA;
  40207. private _dragBehaviorB;
  40208. private _startDistance;
  40209. private _initialScale;
  40210. private _targetScale;
  40211. private _ownerNode;
  40212. private _sceneRenderObserver;
  40213. /**
  40214. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40215. */
  40216. constructor();
  40217. /**
  40218. * The name of the behavior
  40219. */
  40220. get name(): string;
  40221. /**
  40222. * Initializes the behavior
  40223. */
  40224. init(): void;
  40225. private _getCurrentDistance;
  40226. /**
  40227. * Attaches the scale behavior the passed in mesh
  40228. * @param ownerNode The mesh that will be scaled around once attached
  40229. */
  40230. attach(ownerNode: Mesh): void;
  40231. /**
  40232. * Detaches the behavior from the mesh
  40233. */
  40234. detach(): void;
  40235. }
  40236. }
  40237. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40238. import { Behavior } from "babylonjs/Behaviors/behavior";
  40239. import { Mesh } from "babylonjs/Meshes/mesh";
  40240. import { Observable } from "babylonjs/Misc/observable";
  40241. /**
  40242. * 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
  40243. */
  40244. export class SixDofDragBehavior implements Behavior<Mesh> {
  40245. private static _virtualScene;
  40246. private _ownerNode;
  40247. private _sceneRenderObserver;
  40248. private _scene;
  40249. private _targetPosition;
  40250. private _virtualOriginMesh;
  40251. private _virtualDragMesh;
  40252. private _pointerObserver;
  40253. private _moving;
  40254. private _startingOrientation;
  40255. /**
  40256. * 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)
  40257. */
  40258. private zDragFactor;
  40259. /**
  40260. * If the object should rotate to face the drag origin
  40261. */
  40262. rotateDraggedObject: boolean;
  40263. /**
  40264. * If the behavior is currently in a dragging state
  40265. */
  40266. dragging: boolean;
  40267. /**
  40268. * 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)
  40269. */
  40270. dragDeltaRatio: number;
  40271. /**
  40272. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40273. */
  40274. currentDraggingPointerID: number;
  40275. /**
  40276. * If camera controls should be detached during the drag
  40277. */
  40278. detachCameraControls: boolean;
  40279. /**
  40280. * Fires each time a drag starts
  40281. */
  40282. onDragStartObservable: Observable<{}>;
  40283. /**
  40284. * Fires each time a drag ends (eg. mouse release after drag)
  40285. */
  40286. onDragEndObservable: Observable<{}>;
  40287. /**
  40288. * 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
  40289. */
  40290. constructor();
  40291. /**
  40292. * The name of the behavior
  40293. */
  40294. get name(): string;
  40295. /**
  40296. * Initializes the behavior
  40297. */
  40298. init(): void;
  40299. /**
  40300. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40301. */
  40302. private get _pointerCamera();
  40303. /**
  40304. * Attaches the scale behavior the passed in mesh
  40305. * @param ownerNode The mesh that will be scaled around once attached
  40306. */
  40307. attach(ownerNode: Mesh): void;
  40308. /**
  40309. * Detaches the behavior from the mesh
  40310. */
  40311. detach(): void;
  40312. }
  40313. }
  40314. declare module "babylonjs/Behaviors/Meshes/index" {
  40315. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40316. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40317. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40318. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40319. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40320. }
  40321. declare module "babylonjs/Behaviors/index" {
  40322. export * from "babylonjs/Behaviors/behavior";
  40323. export * from "babylonjs/Behaviors/Cameras/index";
  40324. export * from "babylonjs/Behaviors/Meshes/index";
  40325. }
  40326. declare module "babylonjs/Bones/boneIKController" {
  40327. import { Bone } from "babylonjs/Bones/bone";
  40328. import { Vector3 } from "babylonjs/Maths/math.vector";
  40329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40330. import { Nullable } from "babylonjs/types";
  40331. /**
  40332. * Class used to apply inverse kinematics to bones
  40333. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40334. */
  40335. export class BoneIKController {
  40336. private static _tmpVecs;
  40337. private static _tmpQuat;
  40338. private static _tmpMats;
  40339. /**
  40340. * Gets or sets the target mesh
  40341. */
  40342. targetMesh: AbstractMesh;
  40343. /** Gets or sets the mesh used as pole */
  40344. poleTargetMesh: AbstractMesh;
  40345. /**
  40346. * Gets or sets the bone used as pole
  40347. */
  40348. poleTargetBone: Nullable<Bone>;
  40349. /**
  40350. * Gets or sets the target position
  40351. */
  40352. targetPosition: Vector3;
  40353. /**
  40354. * Gets or sets the pole target position
  40355. */
  40356. poleTargetPosition: Vector3;
  40357. /**
  40358. * Gets or sets the pole target local offset
  40359. */
  40360. poleTargetLocalOffset: Vector3;
  40361. /**
  40362. * Gets or sets the pole angle
  40363. */
  40364. poleAngle: number;
  40365. /**
  40366. * Gets or sets the mesh associated with the controller
  40367. */
  40368. mesh: AbstractMesh;
  40369. /**
  40370. * 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)
  40371. */
  40372. slerpAmount: number;
  40373. private _bone1Quat;
  40374. private _bone1Mat;
  40375. private _bone2Ang;
  40376. private _bone1;
  40377. private _bone2;
  40378. private _bone1Length;
  40379. private _bone2Length;
  40380. private _maxAngle;
  40381. private _maxReach;
  40382. private _rightHandedSystem;
  40383. private _bendAxis;
  40384. private _slerping;
  40385. private _adjustRoll;
  40386. /**
  40387. * Gets or sets maximum allowed angle
  40388. */
  40389. get maxAngle(): number;
  40390. set maxAngle(value: number);
  40391. /**
  40392. * Creates a new BoneIKController
  40393. * @param mesh defines the mesh to control
  40394. * @param bone defines the bone to control
  40395. * @param options defines options to set up the controller
  40396. */
  40397. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40398. targetMesh?: AbstractMesh;
  40399. poleTargetMesh?: AbstractMesh;
  40400. poleTargetBone?: Bone;
  40401. poleTargetLocalOffset?: Vector3;
  40402. poleAngle?: number;
  40403. bendAxis?: Vector3;
  40404. maxAngle?: number;
  40405. slerpAmount?: number;
  40406. });
  40407. private _setMaxAngle;
  40408. /**
  40409. * Force the controller to update the bones
  40410. */
  40411. update(): void;
  40412. }
  40413. }
  40414. declare module "babylonjs/Bones/boneLookController" {
  40415. import { Vector3 } from "babylonjs/Maths/math.vector";
  40416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40417. import { Bone } from "babylonjs/Bones/bone";
  40418. import { Space } from "babylonjs/Maths/math.axis";
  40419. /**
  40420. * Class used to make a bone look toward a point in space
  40421. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40422. */
  40423. export class BoneLookController {
  40424. private static _tmpVecs;
  40425. private static _tmpQuat;
  40426. private static _tmpMats;
  40427. /**
  40428. * The target Vector3 that the bone will look at
  40429. */
  40430. target: Vector3;
  40431. /**
  40432. * The mesh that the bone is attached to
  40433. */
  40434. mesh: AbstractMesh;
  40435. /**
  40436. * The bone that will be looking to the target
  40437. */
  40438. bone: Bone;
  40439. /**
  40440. * The up axis of the coordinate system that is used when the bone is rotated
  40441. */
  40442. upAxis: Vector3;
  40443. /**
  40444. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40445. */
  40446. upAxisSpace: Space;
  40447. /**
  40448. * Used to make an adjustment to the yaw of the bone
  40449. */
  40450. adjustYaw: number;
  40451. /**
  40452. * Used to make an adjustment to the pitch of the bone
  40453. */
  40454. adjustPitch: number;
  40455. /**
  40456. * Used to make an adjustment to the roll of the bone
  40457. */
  40458. adjustRoll: number;
  40459. /**
  40460. * 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)
  40461. */
  40462. slerpAmount: number;
  40463. private _minYaw;
  40464. private _maxYaw;
  40465. private _minPitch;
  40466. private _maxPitch;
  40467. private _minYawSin;
  40468. private _minYawCos;
  40469. private _maxYawSin;
  40470. private _maxYawCos;
  40471. private _midYawConstraint;
  40472. private _minPitchTan;
  40473. private _maxPitchTan;
  40474. private _boneQuat;
  40475. private _slerping;
  40476. private _transformYawPitch;
  40477. private _transformYawPitchInv;
  40478. private _firstFrameSkipped;
  40479. private _yawRange;
  40480. private _fowardAxis;
  40481. /**
  40482. * Gets or sets the minimum yaw angle that the bone can look to
  40483. */
  40484. get minYaw(): number;
  40485. set minYaw(value: number);
  40486. /**
  40487. * Gets or sets the maximum yaw angle that the bone can look to
  40488. */
  40489. get maxYaw(): number;
  40490. set maxYaw(value: number);
  40491. /**
  40492. * Gets or sets the minimum pitch angle that the bone can look to
  40493. */
  40494. get minPitch(): number;
  40495. set minPitch(value: number);
  40496. /**
  40497. * Gets or sets the maximum pitch angle that the bone can look to
  40498. */
  40499. get maxPitch(): number;
  40500. set maxPitch(value: number);
  40501. /**
  40502. * Create a BoneLookController
  40503. * @param mesh the mesh that the bone belongs to
  40504. * @param bone the bone that will be looking to the target
  40505. * @param target the target Vector3 to look at
  40506. * @param options optional settings:
  40507. * * maxYaw: the maximum angle the bone will yaw to
  40508. * * minYaw: the minimum angle the bone will yaw to
  40509. * * maxPitch: the maximum angle the bone will pitch to
  40510. * * minPitch: the minimum angle the bone will yaw to
  40511. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40512. * * upAxis: the up axis of the coordinate system
  40513. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40514. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40515. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40516. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40517. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40518. * * adjustRoll: used to make an adjustment to the roll of the bone
  40519. **/
  40520. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40521. maxYaw?: number;
  40522. minYaw?: number;
  40523. maxPitch?: number;
  40524. minPitch?: number;
  40525. slerpAmount?: number;
  40526. upAxis?: Vector3;
  40527. upAxisSpace?: Space;
  40528. yawAxis?: Vector3;
  40529. pitchAxis?: Vector3;
  40530. adjustYaw?: number;
  40531. adjustPitch?: number;
  40532. adjustRoll?: number;
  40533. });
  40534. /**
  40535. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40536. */
  40537. update(): void;
  40538. private _getAngleDiff;
  40539. private _getAngleBetween;
  40540. private _isAngleBetween;
  40541. }
  40542. }
  40543. declare module "babylonjs/Bones/index" {
  40544. export * from "babylonjs/Bones/bone";
  40545. export * from "babylonjs/Bones/boneIKController";
  40546. export * from "babylonjs/Bones/boneLookController";
  40547. export * from "babylonjs/Bones/skeleton";
  40548. }
  40549. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40550. import { Nullable } from "babylonjs/types";
  40551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40552. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40553. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40554. /**
  40555. * Manage the gamepad inputs to control an arc rotate camera.
  40556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40557. */
  40558. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40559. /**
  40560. * Defines the camera the input is attached to.
  40561. */
  40562. camera: ArcRotateCamera;
  40563. /**
  40564. * Defines the gamepad the input is gathering event from.
  40565. */
  40566. gamepad: Nullable<Gamepad>;
  40567. /**
  40568. * Defines the gamepad rotation sensiblity.
  40569. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40570. */
  40571. gamepadRotationSensibility: number;
  40572. /**
  40573. * Defines the gamepad move sensiblity.
  40574. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40575. */
  40576. gamepadMoveSensibility: number;
  40577. private _yAxisScale;
  40578. /**
  40579. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40580. */
  40581. get invertYAxis(): boolean;
  40582. set invertYAxis(value: boolean);
  40583. private _onGamepadConnectedObserver;
  40584. private _onGamepadDisconnectedObserver;
  40585. /**
  40586. * Attach the input controls to a specific dom element to get the input from.
  40587. * @param element Defines the element the controls should be listened from
  40588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40589. */
  40590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40591. /**
  40592. * Detach the current controls from the specified dom element.
  40593. * @param element Defines the element to stop listening the inputs from
  40594. */
  40595. detachControl(element: Nullable<HTMLElement>): void;
  40596. /**
  40597. * Update the current camera state depending on the inputs that have been used this frame.
  40598. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40599. */
  40600. checkInputs(): void;
  40601. /**
  40602. * Gets the class name of the current intput.
  40603. * @returns the class name
  40604. */
  40605. getClassName(): string;
  40606. /**
  40607. * Get the friendly name associated with the input class.
  40608. * @returns the input friendly name
  40609. */
  40610. getSimpleName(): string;
  40611. }
  40612. }
  40613. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40614. import { Nullable } from "babylonjs/types";
  40615. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40617. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40618. interface ArcRotateCameraInputsManager {
  40619. /**
  40620. * Add orientation input support to the input manager.
  40621. * @returns the current input manager
  40622. */
  40623. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40624. }
  40625. }
  40626. /**
  40627. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40629. */
  40630. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40631. /**
  40632. * Defines the camera the input is attached to.
  40633. */
  40634. camera: ArcRotateCamera;
  40635. /**
  40636. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40637. */
  40638. alphaCorrection: number;
  40639. /**
  40640. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40641. */
  40642. gammaCorrection: number;
  40643. private _alpha;
  40644. private _gamma;
  40645. private _dirty;
  40646. private _deviceOrientationHandler;
  40647. /**
  40648. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40649. */
  40650. constructor();
  40651. /**
  40652. * Attach the input controls to a specific dom element to get the input from.
  40653. * @param element Defines the element the controls should be listened from
  40654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40655. */
  40656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40657. /** @hidden */
  40658. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40659. /**
  40660. * Update the current camera state depending on the inputs that have been used this frame.
  40661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40662. */
  40663. checkInputs(): void;
  40664. /**
  40665. * Detach the current controls from the specified dom element.
  40666. * @param element Defines the element to stop listening the inputs from
  40667. */
  40668. detachControl(element: Nullable<HTMLElement>): void;
  40669. /**
  40670. * Gets the class name of the current intput.
  40671. * @returns the class name
  40672. */
  40673. getClassName(): string;
  40674. /**
  40675. * Get the friendly name associated with the input class.
  40676. * @returns the input friendly name
  40677. */
  40678. getSimpleName(): string;
  40679. }
  40680. }
  40681. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40682. import { Nullable } from "babylonjs/types";
  40683. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40684. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40685. /**
  40686. * Listen to mouse events to control the camera.
  40687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40688. */
  40689. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40690. /**
  40691. * Defines the camera the input is attached to.
  40692. */
  40693. camera: FlyCamera;
  40694. /**
  40695. * Defines if touch is enabled. (Default is true.)
  40696. */
  40697. touchEnabled: boolean;
  40698. /**
  40699. * Defines the buttons associated with the input to handle camera rotation.
  40700. */
  40701. buttons: number[];
  40702. /**
  40703. * Assign buttons for Yaw control.
  40704. */
  40705. buttonsYaw: number[];
  40706. /**
  40707. * Assign buttons for Pitch control.
  40708. */
  40709. buttonsPitch: number[];
  40710. /**
  40711. * Assign buttons for Roll control.
  40712. */
  40713. buttonsRoll: number[];
  40714. /**
  40715. * Detect if any button is being pressed while mouse is moved.
  40716. * -1 = Mouse locked.
  40717. * 0 = Left button.
  40718. * 1 = Middle Button.
  40719. * 2 = Right Button.
  40720. */
  40721. activeButton: number;
  40722. /**
  40723. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40724. * Higher values reduce its sensitivity.
  40725. */
  40726. angularSensibility: number;
  40727. private _mousemoveCallback;
  40728. private _observer;
  40729. private _rollObserver;
  40730. private previousPosition;
  40731. private noPreventDefault;
  40732. private element;
  40733. /**
  40734. * Listen to mouse events to control the camera.
  40735. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40737. */
  40738. constructor(touchEnabled?: boolean);
  40739. /**
  40740. * Attach the mouse control to the HTML DOM element.
  40741. * @param element Defines the element that listens to the input events.
  40742. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40743. */
  40744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40745. /**
  40746. * Detach the current controls from the specified dom element.
  40747. * @param element Defines the element to stop listening the inputs from
  40748. */
  40749. detachControl(element: Nullable<HTMLElement>): void;
  40750. /**
  40751. * Gets the class name of the current input.
  40752. * @returns the class name.
  40753. */
  40754. getClassName(): string;
  40755. /**
  40756. * Get the friendly name associated with the input class.
  40757. * @returns the input's friendly name.
  40758. */
  40759. getSimpleName(): string;
  40760. private _pointerInput;
  40761. private _onMouseMove;
  40762. /**
  40763. * Rotate camera by mouse offset.
  40764. */
  40765. private rotateCamera;
  40766. }
  40767. }
  40768. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40769. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40770. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40771. /**
  40772. * Default Inputs manager for the FlyCamera.
  40773. * It groups all the default supported inputs for ease of use.
  40774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40775. */
  40776. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40777. /**
  40778. * Instantiates a new FlyCameraInputsManager.
  40779. * @param camera Defines the camera the inputs belong to.
  40780. */
  40781. constructor(camera: FlyCamera);
  40782. /**
  40783. * Add keyboard input support to the input manager.
  40784. * @returns the new FlyCameraKeyboardMoveInput().
  40785. */
  40786. addKeyboard(): FlyCameraInputsManager;
  40787. /**
  40788. * Add mouse input support to the input manager.
  40789. * @param touchEnabled Enable touch screen support.
  40790. * @returns the new FlyCameraMouseInput().
  40791. */
  40792. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40793. }
  40794. }
  40795. declare module "babylonjs/Cameras/flyCamera" {
  40796. import { Scene } from "babylonjs/scene";
  40797. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40799. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40800. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40801. /**
  40802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40803. * such as in a 3D Space Shooter or a Flight Simulator.
  40804. */
  40805. export class FlyCamera extends TargetCamera {
  40806. /**
  40807. * Define the collision ellipsoid of the camera.
  40808. * This is helpful for simulating a camera body, like a player's body.
  40809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40810. */
  40811. ellipsoid: Vector3;
  40812. /**
  40813. * Define an offset for the position of the ellipsoid around the camera.
  40814. * This can be helpful if the camera is attached away from the player's body center,
  40815. * such as at its head.
  40816. */
  40817. ellipsoidOffset: Vector3;
  40818. /**
  40819. * Enable or disable collisions of the camera with the rest of the scene objects.
  40820. */
  40821. checkCollisions: boolean;
  40822. /**
  40823. * Enable or disable gravity on the camera.
  40824. */
  40825. applyGravity: boolean;
  40826. /**
  40827. * Define the current direction the camera is moving to.
  40828. */
  40829. cameraDirection: Vector3;
  40830. /**
  40831. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40832. * This overrides and empties cameraRotation.
  40833. */
  40834. rotationQuaternion: Quaternion;
  40835. /**
  40836. * Track Roll to maintain the wanted Rolling when looking around.
  40837. */
  40838. _trackRoll: number;
  40839. /**
  40840. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40841. */
  40842. rollCorrect: number;
  40843. /**
  40844. * Mimic a banked turn, Rolling the camera when Yawing.
  40845. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40846. */
  40847. bankedTurn: boolean;
  40848. /**
  40849. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40850. */
  40851. bankedTurnLimit: number;
  40852. /**
  40853. * Value of 0 disables the banked Roll.
  40854. * Value of 1 is equal to the Yaw angle in radians.
  40855. */
  40856. bankedTurnMultiplier: number;
  40857. /**
  40858. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40859. */
  40860. inputs: FlyCameraInputsManager;
  40861. /**
  40862. * Gets the input sensibility for mouse input.
  40863. * Higher values reduce sensitivity.
  40864. */
  40865. get angularSensibility(): number;
  40866. /**
  40867. * Sets the input sensibility for a mouse input.
  40868. * Higher values reduce sensitivity.
  40869. */
  40870. set angularSensibility(value: number);
  40871. /**
  40872. * Get the keys for camera movement forward.
  40873. */
  40874. get keysForward(): number[];
  40875. /**
  40876. * Set the keys for camera movement forward.
  40877. */
  40878. set keysForward(value: number[]);
  40879. /**
  40880. * Get the keys for camera movement backward.
  40881. */
  40882. get keysBackward(): number[];
  40883. set keysBackward(value: number[]);
  40884. /**
  40885. * Get the keys for camera movement up.
  40886. */
  40887. get keysUp(): number[];
  40888. /**
  40889. * Set the keys for camera movement up.
  40890. */
  40891. set keysUp(value: number[]);
  40892. /**
  40893. * Get the keys for camera movement down.
  40894. */
  40895. get keysDown(): number[];
  40896. /**
  40897. * Set the keys for camera movement down.
  40898. */
  40899. set keysDown(value: number[]);
  40900. /**
  40901. * Get the keys for camera movement left.
  40902. */
  40903. get keysLeft(): number[];
  40904. /**
  40905. * Set the keys for camera movement left.
  40906. */
  40907. set keysLeft(value: number[]);
  40908. /**
  40909. * Set the keys for camera movement right.
  40910. */
  40911. get keysRight(): number[];
  40912. /**
  40913. * Set the keys for camera movement right.
  40914. */
  40915. set keysRight(value: number[]);
  40916. /**
  40917. * Event raised when the camera collides with a mesh in the scene.
  40918. */
  40919. onCollide: (collidedMesh: AbstractMesh) => void;
  40920. private _collider;
  40921. private _needMoveForGravity;
  40922. private _oldPosition;
  40923. private _diffPosition;
  40924. private _newPosition;
  40925. /** @hidden */
  40926. _localDirection: Vector3;
  40927. /** @hidden */
  40928. _transformedDirection: Vector3;
  40929. /**
  40930. * Instantiates a FlyCamera.
  40931. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40932. * such as in a 3D Space Shooter or a Flight Simulator.
  40933. * @param name Define the name of the camera in the scene.
  40934. * @param position Define the starting position of the camera in the scene.
  40935. * @param scene Define the scene the camera belongs to.
  40936. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40937. */
  40938. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40939. /**
  40940. * Attach a control to the HTML DOM element.
  40941. * @param element Defines the element that listens to the input events.
  40942. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40943. */
  40944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40945. /**
  40946. * Detach a control from the HTML DOM element.
  40947. * The camera will stop reacting to that input.
  40948. * @param element Defines the element that listens to the input events.
  40949. */
  40950. detachControl(element: HTMLElement): void;
  40951. private _collisionMask;
  40952. /**
  40953. * Get the mask that the camera ignores in collision events.
  40954. */
  40955. get collisionMask(): number;
  40956. /**
  40957. * Set the mask that the camera ignores in collision events.
  40958. */
  40959. set collisionMask(mask: number);
  40960. /** @hidden */
  40961. _collideWithWorld(displacement: Vector3): void;
  40962. /** @hidden */
  40963. private _onCollisionPositionChange;
  40964. /** @hidden */
  40965. _checkInputs(): void;
  40966. /** @hidden */
  40967. _decideIfNeedsToMove(): boolean;
  40968. /** @hidden */
  40969. _updatePosition(): void;
  40970. /**
  40971. * Restore the Roll to its target value at the rate specified.
  40972. * @param rate - Higher means slower restoring.
  40973. * @hidden
  40974. */
  40975. restoreRoll(rate: number): void;
  40976. /**
  40977. * Destroy the camera and release the current resources held by it.
  40978. */
  40979. dispose(): void;
  40980. /**
  40981. * Get the current object class name.
  40982. * @returns the class name.
  40983. */
  40984. getClassName(): string;
  40985. }
  40986. }
  40987. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40988. import { Nullable } from "babylonjs/types";
  40989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40990. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40991. /**
  40992. * Listen to keyboard events to control the camera.
  40993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40994. */
  40995. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40996. /**
  40997. * Defines the camera the input is attached to.
  40998. */
  40999. camera: FlyCamera;
  41000. /**
  41001. * The list of keyboard keys used to control the forward move of the camera.
  41002. */
  41003. keysForward: number[];
  41004. /**
  41005. * The list of keyboard keys used to control the backward move of the camera.
  41006. */
  41007. keysBackward: number[];
  41008. /**
  41009. * The list of keyboard keys used to control the forward move of the camera.
  41010. */
  41011. keysUp: number[];
  41012. /**
  41013. * The list of keyboard keys used to control the backward move of the camera.
  41014. */
  41015. keysDown: number[];
  41016. /**
  41017. * The list of keyboard keys used to control the right strafe move of the camera.
  41018. */
  41019. keysRight: number[];
  41020. /**
  41021. * The list of keyboard keys used to control the left strafe move of the camera.
  41022. */
  41023. keysLeft: number[];
  41024. private _keys;
  41025. private _onCanvasBlurObserver;
  41026. private _onKeyboardObserver;
  41027. private _engine;
  41028. private _scene;
  41029. /**
  41030. * Attach the input controls to a specific dom element to get the input from.
  41031. * @param element Defines the element the controls should be listened from
  41032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41033. */
  41034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41035. /**
  41036. * Detach the current controls from the specified dom element.
  41037. * @param element Defines the element to stop listening the inputs from
  41038. */
  41039. detachControl(element: Nullable<HTMLElement>): void;
  41040. /**
  41041. * Gets the class name of the current intput.
  41042. * @returns the class name
  41043. */
  41044. getClassName(): string;
  41045. /** @hidden */
  41046. _onLostFocus(e: FocusEvent): void;
  41047. /**
  41048. * Get the friendly name associated with the input class.
  41049. * @returns the input friendly name
  41050. */
  41051. getSimpleName(): string;
  41052. /**
  41053. * Update the current camera state depending on the inputs that have been used this frame.
  41054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41055. */
  41056. checkInputs(): void;
  41057. }
  41058. }
  41059. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41060. import { Nullable } from "babylonjs/types";
  41061. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41062. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41063. /**
  41064. * Manage the mouse wheel inputs to control a follow camera.
  41065. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41066. */
  41067. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41068. /**
  41069. * Defines the camera the input is attached to.
  41070. */
  41071. camera: FollowCamera;
  41072. /**
  41073. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41074. */
  41075. axisControlRadius: boolean;
  41076. /**
  41077. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41078. */
  41079. axisControlHeight: boolean;
  41080. /**
  41081. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41082. */
  41083. axisControlRotation: boolean;
  41084. /**
  41085. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41086. * relation to mouseWheel events.
  41087. */
  41088. wheelPrecision: number;
  41089. /**
  41090. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41091. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41092. */
  41093. wheelDeltaPercentage: number;
  41094. private _wheel;
  41095. private _observer;
  41096. /**
  41097. * Attach the input controls to a specific dom element to get the input from.
  41098. * @param element Defines the element the controls should be listened from
  41099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41100. */
  41101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41102. /**
  41103. * Detach the current controls from the specified dom element.
  41104. * @param element Defines the element to stop listening the inputs from
  41105. */
  41106. detachControl(element: Nullable<HTMLElement>): void;
  41107. /**
  41108. * Gets the class name of the current intput.
  41109. * @returns the class name
  41110. */
  41111. getClassName(): string;
  41112. /**
  41113. * Get the friendly name associated with the input class.
  41114. * @returns the input friendly name
  41115. */
  41116. getSimpleName(): string;
  41117. }
  41118. }
  41119. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41120. import { Nullable } from "babylonjs/types";
  41121. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41122. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41123. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41124. /**
  41125. * Manage the pointers inputs to control an follow camera.
  41126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41127. */
  41128. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41129. /**
  41130. * Defines the camera the input is attached to.
  41131. */
  41132. camera: FollowCamera;
  41133. /**
  41134. * Gets the class name of the current input.
  41135. * @returns the class name
  41136. */
  41137. getClassName(): string;
  41138. /**
  41139. * Defines the pointer angular sensibility along the X axis or how fast is
  41140. * the camera rotating.
  41141. * A negative number will reverse the axis direction.
  41142. */
  41143. angularSensibilityX: number;
  41144. /**
  41145. * Defines the pointer angular sensibility along the Y axis or how fast is
  41146. * the camera rotating.
  41147. * A negative number will reverse the axis direction.
  41148. */
  41149. angularSensibilityY: number;
  41150. /**
  41151. * Defines the pointer pinch precision or how fast is the camera zooming.
  41152. * A negative number will reverse the axis direction.
  41153. */
  41154. pinchPrecision: number;
  41155. /**
  41156. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41157. * from 0.
  41158. * It defines the percentage of current camera.radius to use as delta when
  41159. * pinch zoom is used.
  41160. */
  41161. pinchDeltaPercentage: number;
  41162. /**
  41163. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41164. */
  41165. axisXControlRadius: boolean;
  41166. /**
  41167. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41168. */
  41169. axisXControlHeight: boolean;
  41170. /**
  41171. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41172. */
  41173. axisXControlRotation: boolean;
  41174. /**
  41175. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41176. */
  41177. axisYControlRadius: boolean;
  41178. /**
  41179. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41180. */
  41181. axisYControlHeight: boolean;
  41182. /**
  41183. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41184. */
  41185. axisYControlRotation: boolean;
  41186. /**
  41187. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41188. */
  41189. axisPinchControlRadius: boolean;
  41190. /**
  41191. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41192. */
  41193. axisPinchControlHeight: boolean;
  41194. /**
  41195. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41196. */
  41197. axisPinchControlRotation: boolean;
  41198. /**
  41199. * Log error messages if basic misconfiguration has occurred.
  41200. */
  41201. warningEnable: boolean;
  41202. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41203. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41204. private _warningCounter;
  41205. private _warning;
  41206. }
  41207. }
  41208. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41209. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41210. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41211. /**
  41212. * Default Inputs manager for the FollowCamera.
  41213. * It groups all the default supported inputs for ease of use.
  41214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41215. */
  41216. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41217. /**
  41218. * Instantiates a new FollowCameraInputsManager.
  41219. * @param camera Defines the camera the inputs belong to
  41220. */
  41221. constructor(camera: FollowCamera);
  41222. /**
  41223. * Add keyboard input support to the input manager.
  41224. * @returns the current input manager
  41225. */
  41226. addKeyboard(): FollowCameraInputsManager;
  41227. /**
  41228. * Add mouse wheel input support to the input manager.
  41229. * @returns the current input manager
  41230. */
  41231. addMouseWheel(): FollowCameraInputsManager;
  41232. /**
  41233. * Add pointers input support to the input manager.
  41234. * @returns the current input manager
  41235. */
  41236. addPointers(): FollowCameraInputsManager;
  41237. /**
  41238. * Add orientation input support to the input manager.
  41239. * @returns the current input manager
  41240. */
  41241. addVRDeviceOrientation(): FollowCameraInputsManager;
  41242. }
  41243. }
  41244. declare module "babylonjs/Cameras/followCamera" {
  41245. import { Nullable } from "babylonjs/types";
  41246. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41247. import { Scene } from "babylonjs/scene";
  41248. import { Vector3 } from "babylonjs/Maths/math.vector";
  41249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41250. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41251. /**
  41252. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41253. * an arc rotate version arcFollowCamera are available.
  41254. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41255. */
  41256. export class FollowCamera extends TargetCamera {
  41257. /**
  41258. * Distance the follow camera should follow an object at
  41259. */
  41260. radius: number;
  41261. /**
  41262. * Minimum allowed distance of the camera to the axis of rotation
  41263. * (The camera can not get closer).
  41264. * This can help limiting how the Camera is able to move in the scene.
  41265. */
  41266. lowerRadiusLimit: Nullable<number>;
  41267. /**
  41268. * Maximum allowed distance of the camera to the axis of rotation
  41269. * (The camera can not get further).
  41270. * This can help limiting how the Camera is able to move in the scene.
  41271. */
  41272. upperRadiusLimit: Nullable<number>;
  41273. /**
  41274. * Define a rotation offset between the camera and the object it follows
  41275. */
  41276. rotationOffset: number;
  41277. /**
  41278. * Minimum allowed angle to camera position relative to target object.
  41279. * This can help limiting how the Camera is able to move in the scene.
  41280. */
  41281. lowerRotationOffsetLimit: Nullable<number>;
  41282. /**
  41283. * Maximum allowed angle to camera position relative to target object.
  41284. * This can help limiting how the Camera is able to move in the scene.
  41285. */
  41286. upperRotationOffsetLimit: Nullable<number>;
  41287. /**
  41288. * Define a height offset between the camera and the object it follows.
  41289. * It can help following an object from the top (like a car chaing a plane)
  41290. */
  41291. heightOffset: number;
  41292. /**
  41293. * Minimum allowed height of camera position relative to target object.
  41294. * This can help limiting how the Camera is able to move in the scene.
  41295. */
  41296. lowerHeightOffsetLimit: Nullable<number>;
  41297. /**
  41298. * Maximum allowed height of camera position relative to target object.
  41299. * This can help limiting how the Camera is able to move in the scene.
  41300. */
  41301. upperHeightOffsetLimit: Nullable<number>;
  41302. /**
  41303. * Define how fast the camera can accelerate to follow it s target.
  41304. */
  41305. cameraAcceleration: number;
  41306. /**
  41307. * Define the speed limit of the camera following an object.
  41308. */
  41309. maxCameraSpeed: number;
  41310. /**
  41311. * Define the target of the camera.
  41312. */
  41313. lockedTarget: Nullable<AbstractMesh>;
  41314. /**
  41315. * Defines the input associated with the camera.
  41316. */
  41317. inputs: FollowCameraInputsManager;
  41318. /**
  41319. * Instantiates the follow camera.
  41320. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41321. * @param name Define the name of the camera in the scene
  41322. * @param position Define the position of the camera
  41323. * @param scene Define the scene the camera belong to
  41324. * @param lockedTarget Define the target of the camera
  41325. */
  41326. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41327. private _follow;
  41328. /**
  41329. * Attached controls to the current camera.
  41330. * @param element Defines the element the controls should be listened from
  41331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41332. */
  41333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41334. /**
  41335. * Detach the current controls from the camera.
  41336. * The camera will stop reacting to inputs.
  41337. * @param element Defines the element to stop listening the inputs from
  41338. */
  41339. detachControl(element: HTMLElement): void;
  41340. /** @hidden */
  41341. _checkInputs(): void;
  41342. private _checkLimits;
  41343. /**
  41344. * Gets the camera class name.
  41345. * @returns the class name
  41346. */
  41347. getClassName(): string;
  41348. }
  41349. /**
  41350. * Arc Rotate version of the follow camera.
  41351. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41352. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41353. */
  41354. export class ArcFollowCamera extends TargetCamera {
  41355. /** The longitudinal angle of the camera */
  41356. alpha: number;
  41357. /** The latitudinal angle of the camera */
  41358. beta: number;
  41359. /** The radius of the camera from its target */
  41360. radius: number;
  41361. /** Define the camera target (the messh it should follow) */
  41362. target: Nullable<AbstractMesh>;
  41363. private _cartesianCoordinates;
  41364. /**
  41365. * Instantiates a new ArcFollowCamera
  41366. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41367. * @param name Define the name of the camera
  41368. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41369. * @param beta Define the rotation angle of the camera around the elevation axis
  41370. * @param radius Define the radius of the camera from its target point
  41371. * @param target Define the target of the camera
  41372. * @param scene Define the scene the camera belongs to
  41373. */
  41374. constructor(name: string,
  41375. /** The longitudinal angle of the camera */
  41376. alpha: number,
  41377. /** The latitudinal angle of the camera */
  41378. beta: number,
  41379. /** The radius of the camera from its target */
  41380. radius: number,
  41381. /** Define the camera target (the messh it should follow) */
  41382. target: Nullable<AbstractMesh>, scene: Scene);
  41383. private _follow;
  41384. /** @hidden */
  41385. _checkInputs(): void;
  41386. /**
  41387. * Returns the class name of the object.
  41388. * It is mostly used internally for serialization purposes.
  41389. */
  41390. getClassName(): string;
  41391. }
  41392. }
  41393. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41394. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41395. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41396. import { Nullable } from "babylonjs/types";
  41397. /**
  41398. * Manage the keyboard inputs to control the movement of a follow camera.
  41399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41400. */
  41401. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41402. /**
  41403. * Defines the camera the input is attached to.
  41404. */
  41405. camera: FollowCamera;
  41406. /**
  41407. * Defines the list of key codes associated with the up action (increase heightOffset)
  41408. */
  41409. keysHeightOffsetIncr: number[];
  41410. /**
  41411. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41412. */
  41413. keysHeightOffsetDecr: number[];
  41414. /**
  41415. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41416. */
  41417. keysHeightOffsetModifierAlt: boolean;
  41418. /**
  41419. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41420. */
  41421. keysHeightOffsetModifierCtrl: boolean;
  41422. /**
  41423. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41424. */
  41425. keysHeightOffsetModifierShift: boolean;
  41426. /**
  41427. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41428. */
  41429. keysRotationOffsetIncr: number[];
  41430. /**
  41431. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41432. */
  41433. keysRotationOffsetDecr: number[];
  41434. /**
  41435. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41436. */
  41437. keysRotationOffsetModifierAlt: boolean;
  41438. /**
  41439. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41440. */
  41441. keysRotationOffsetModifierCtrl: boolean;
  41442. /**
  41443. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41444. */
  41445. keysRotationOffsetModifierShift: boolean;
  41446. /**
  41447. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41448. */
  41449. keysRadiusIncr: number[];
  41450. /**
  41451. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41452. */
  41453. keysRadiusDecr: number[];
  41454. /**
  41455. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41456. */
  41457. keysRadiusModifierAlt: boolean;
  41458. /**
  41459. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41460. */
  41461. keysRadiusModifierCtrl: boolean;
  41462. /**
  41463. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41464. */
  41465. keysRadiusModifierShift: boolean;
  41466. /**
  41467. * Defines the rate of change of heightOffset.
  41468. */
  41469. heightSensibility: number;
  41470. /**
  41471. * Defines the rate of change of rotationOffset.
  41472. */
  41473. rotationSensibility: number;
  41474. /**
  41475. * Defines the rate of change of radius.
  41476. */
  41477. radiusSensibility: number;
  41478. private _keys;
  41479. private _ctrlPressed;
  41480. private _altPressed;
  41481. private _shiftPressed;
  41482. private _onCanvasBlurObserver;
  41483. private _onKeyboardObserver;
  41484. private _engine;
  41485. private _scene;
  41486. /**
  41487. * Attach the input controls to a specific dom element to get the input from.
  41488. * @param element Defines the element the controls should be listened from
  41489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41490. */
  41491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41492. /**
  41493. * Detach the current controls from the specified dom element.
  41494. * @param element Defines the element to stop listening the inputs from
  41495. */
  41496. detachControl(element: Nullable<HTMLElement>): void;
  41497. /**
  41498. * Update the current camera state depending on the inputs that have been used this frame.
  41499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41500. */
  41501. checkInputs(): void;
  41502. /**
  41503. * Gets the class name of the current input.
  41504. * @returns the class name
  41505. */
  41506. getClassName(): string;
  41507. /**
  41508. * Get the friendly name associated with the input class.
  41509. * @returns the input friendly name
  41510. */
  41511. getSimpleName(): string;
  41512. /**
  41513. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41514. * allow modification of the heightOffset value.
  41515. */
  41516. private _modifierHeightOffset;
  41517. /**
  41518. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41519. * allow modification of the rotationOffset value.
  41520. */
  41521. private _modifierRotationOffset;
  41522. /**
  41523. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41524. * allow modification of the radius value.
  41525. */
  41526. private _modifierRadius;
  41527. }
  41528. }
  41529. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41530. import { Nullable } from "babylonjs/types";
  41531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41533. import { Observable } from "babylonjs/Misc/observable";
  41534. module "babylonjs/Cameras/freeCameraInputsManager" {
  41535. interface FreeCameraInputsManager {
  41536. /**
  41537. * @hidden
  41538. */
  41539. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41540. /**
  41541. * Add orientation input support to the input manager.
  41542. * @returns the current input manager
  41543. */
  41544. addDeviceOrientation(): FreeCameraInputsManager;
  41545. }
  41546. }
  41547. /**
  41548. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41549. * Screen rotation is taken into account.
  41550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41551. */
  41552. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41553. private _camera;
  41554. private _screenOrientationAngle;
  41555. private _constantTranform;
  41556. private _screenQuaternion;
  41557. private _alpha;
  41558. private _beta;
  41559. private _gamma;
  41560. /**
  41561. * Can be used to detect if a device orientation sensor is available on a device
  41562. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41563. * @returns a promise that will resolve on orientation change
  41564. */
  41565. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41566. /**
  41567. * @hidden
  41568. */
  41569. _onDeviceOrientationChangedObservable: Observable<void>;
  41570. /**
  41571. * Instantiates a new input
  41572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41573. */
  41574. constructor();
  41575. /**
  41576. * Define the camera controlled by the input.
  41577. */
  41578. get camera(): FreeCamera;
  41579. set camera(camera: FreeCamera);
  41580. /**
  41581. * Attach the input controls to a specific dom element to get the input from.
  41582. * @param element Defines the element the controls should be listened from
  41583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41584. */
  41585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41586. private _orientationChanged;
  41587. private _deviceOrientation;
  41588. /**
  41589. * Detach the current controls from the specified dom element.
  41590. * @param element Defines the element to stop listening the inputs from
  41591. */
  41592. detachControl(element: Nullable<HTMLElement>): void;
  41593. /**
  41594. * Update the current camera state depending on the inputs that have been used this frame.
  41595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41596. */
  41597. checkInputs(): void;
  41598. /**
  41599. * Gets the class name of the current intput.
  41600. * @returns the class name
  41601. */
  41602. getClassName(): string;
  41603. /**
  41604. * Get the friendly name associated with the input class.
  41605. * @returns the input friendly name
  41606. */
  41607. getSimpleName(): string;
  41608. }
  41609. }
  41610. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41611. import { Nullable } from "babylonjs/types";
  41612. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41613. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41614. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41615. /**
  41616. * Manage the gamepad inputs to control a free camera.
  41617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41618. */
  41619. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41620. /**
  41621. * Define the camera the input is attached to.
  41622. */
  41623. camera: FreeCamera;
  41624. /**
  41625. * Define the Gamepad controlling the input
  41626. */
  41627. gamepad: Nullable<Gamepad>;
  41628. /**
  41629. * Defines the gamepad rotation sensiblity.
  41630. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41631. */
  41632. gamepadAngularSensibility: number;
  41633. /**
  41634. * Defines the gamepad move sensiblity.
  41635. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41636. */
  41637. gamepadMoveSensibility: number;
  41638. private _yAxisScale;
  41639. /**
  41640. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41641. */
  41642. get invertYAxis(): boolean;
  41643. set invertYAxis(value: boolean);
  41644. private _onGamepadConnectedObserver;
  41645. private _onGamepadDisconnectedObserver;
  41646. private _cameraTransform;
  41647. private _deltaTransform;
  41648. private _vector3;
  41649. private _vector2;
  41650. /**
  41651. * Attach the input controls to a specific dom element to get the input from.
  41652. * @param element Defines the element the controls should be listened from
  41653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41654. */
  41655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41656. /**
  41657. * Detach the current controls from the specified dom element.
  41658. * @param element Defines the element to stop listening the inputs from
  41659. */
  41660. detachControl(element: Nullable<HTMLElement>): void;
  41661. /**
  41662. * Update the current camera state depending on the inputs that have been used this frame.
  41663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41664. */
  41665. checkInputs(): void;
  41666. /**
  41667. * Gets the class name of the current intput.
  41668. * @returns the class name
  41669. */
  41670. getClassName(): string;
  41671. /**
  41672. * Get the friendly name associated with the input class.
  41673. * @returns the input friendly name
  41674. */
  41675. getSimpleName(): string;
  41676. }
  41677. }
  41678. declare module "babylonjs/Misc/virtualJoystick" {
  41679. import { Nullable } from "babylonjs/types";
  41680. import { Vector3 } from "babylonjs/Maths/math.vector";
  41681. /**
  41682. * Defines the potential axis of a Joystick
  41683. */
  41684. export enum JoystickAxis {
  41685. /** X axis */
  41686. X = 0,
  41687. /** Y axis */
  41688. Y = 1,
  41689. /** Z axis */
  41690. Z = 2
  41691. }
  41692. /**
  41693. * Class used to define virtual joystick (used in touch mode)
  41694. */
  41695. export class VirtualJoystick {
  41696. /**
  41697. * Gets or sets a boolean indicating that left and right values must be inverted
  41698. */
  41699. reverseLeftRight: boolean;
  41700. /**
  41701. * Gets or sets a boolean indicating that up and down values must be inverted
  41702. */
  41703. reverseUpDown: boolean;
  41704. /**
  41705. * Gets the offset value for the position (ie. the change of the position value)
  41706. */
  41707. deltaPosition: Vector3;
  41708. /**
  41709. * Gets a boolean indicating if the virtual joystick was pressed
  41710. */
  41711. pressed: boolean;
  41712. /**
  41713. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41714. */
  41715. static Canvas: Nullable<HTMLCanvasElement>;
  41716. private static _globalJoystickIndex;
  41717. private static vjCanvasContext;
  41718. private static vjCanvasWidth;
  41719. private static vjCanvasHeight;
  41720. private static halfWidth;
  41721. private _action;
  41722. private _axisTargetedByLeftAndRight;
  41723. private _axisTargetedByUpAndDown;
  41724. private _joystickSensibility;
  41725. private _inversedSensibility;
  41726. private _joystickPointerID;
  41727. private _joystickColor;
  41728. private _joystickPointerPos;
  41729. private _joystickPreviousPointerPos;
  41730. private _joystickPointerStartPos;
  41731. private _deltaJoystickVector;
  41732. private _leftJoystick;
  41733. private _touches;
  41734. private _onPointerDownHandlerRef;
  41735. private _onPointerMoveHandlerRef;
  41736. private _onPointerUpHandlerRef;
  41737. private _onResize;
  41738. /**
  41739. * Creates a new virtual joystick
  41740. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41741. */
  41742. constructor(leftJoystick?: boolean);
  41743. /**
  41744. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41745. * @param newJoystickSensibility defines the new sensibility
  41746. */
  41747. setJoystickSensibility(newJoystickSensibility: number): void;
  41748. private _onPointerDown;
  41749. private _onPointerMove;
  41750. private _onPointerUp;
  41751. /**
  41752. * Change the color of the virtual joystick
  41753. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41754. */
  41755. setJoystickColor(newColor: string): void;
  41756. /**
  41757. * Defines a callback to call when the joystick is touched
  41758. * @param action defines the callback
  41759. */
  41760. setActionOnTouch(action: () => any): void;
  41761. /**
  41762. * Defines which axis you'd like to control for left & right
  41763. * @param axis defines the axis to use
  41764. */
  41765. setAxisForLeftRight(axis: JoystickAxis): void;
  41766. /**
  41767. * Defines which axis you'd like to control for up & down
  41768. * @param axis defines the axis to use
  41769. */
  41770. setAxisForUpDown(axis: JoystickAxis): void;
  41771. private _drawVirtualJoystick;
  41772. /**
  41773. * Release internal HTML canvas
  41774. */
  41775. releaseCanvas(): void;
  41776. }
  41777. }
  41778. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41779. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41780. import { Nullable } from "babylonjs/types";
  41781. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41783. module "babylonjs/Cameras/freeCameraInputsManager" {
  41784. interface FreeCameraInputsManager {
  41785. /**
  41786. * Add virtual joystick input support to the input manager.
  41787. * @returns the current input manager
  41788. */
  41789. addVirtualJoystick(): FreeCameraInputsManager;
  41790. }
  41791. }
  41792. /**
  41793. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41795. */
  41796. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41797. /**
  41798. * Defines the camera the input is attached to.
  41799. */
  41800. camera: FreeCamera;
  41801. private _leftjoystick;
  41802. private _rightjoystick;
  41803. /**
  41804. * Gets the left stick of the virtual joystick.
  41805. * @returns The virtual Joystick
  41806. */
  41807. getLeftJoystick(): VirtualJoystick;
  41808. /**
  41809. * Gets the right stick of the virtual joystick.
  41810. * @returns The virtual Joystick
  41811. */
  41812. getRightJoystick(): VirtualJoystick;
  41813. /**
  41814. * Update the current camera state depending on the inputs that have been used this frame.
  41815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41816. */
  41817. checkInputs(): void;
  41818. /**
  41819. * Attach the input controls to a specific dom element to get the input from.
  41820. * @param element Defines the element the controls should be listened from
  41821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41822. */
  41823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41824. /**
  41825. * Detach the current controls from the specified dom element.
  41826. * @param element Defines the element to stop listening the inputs from
  41827. */
  41828. detachControl(element: Nullable<HTMLElement>): void;
  41829. /**
  41830. * Gets the class name of the current intput.
  41831. * @returns the class name
  41832. */
  41833. getClassName(): string;
  41834. /**
  41835. * Get the friendly name associated with the input class.
  41836. * @returns the input friendly name
  41837. */
  41838. getSimpleName(): string;
  41839. }
  41840. }
  41841. declare module "babylonjs/Cameras/Inputs/index" {
  41842. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41843. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41844. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41845. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41846. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41847. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41848. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41849. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41850. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41851. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41852. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41853. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41854. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41855. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41856. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41857. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41858. }
  41859. declare module "babylonjs/Cameras/touchCamera" {
  41860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41861. import { Scene } from "babylonjs/scene";
  41862. import { Vector3 } from "babylonjs/Maths/math.vector";
  41863. /**
  41864. * This represents a FPS type of camera controlled by touch.
  41865. * This is like a universal camera minus the Gamepad controls.
  41866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41867. */
  41868. export class TouchCamera extends FreeCamera {
  41869. /**
  41870. * Defines the touch sensibility for rotation.
  41871. * The higher the faster.
  41872. */
  41873. get touchAngularSensibility(): number;
  41874. set touchAngularSensibility(value: number);
  41875. /**
  41876. * Defines the touch sensibility for move.
  41877. * The higher the faster.
  41878. */
  41879. get touchMoveSensibility(): number;
  41880. set touchMoveSensibility(value: number);
  41881. /**
  41882. * Instantiates a new touch camera.
  41883. * This represents a FPS type of camera controlled by touch.
  41884. * This is like a universal camera minus the Gamepad controls.
  41885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41886. * @param name Define the name of the camera in the scene
  41887. * @param position Define the start position of the camera in the scene
  41888. * @param scene Define the scene the camera belongs to
  41889. */
  41890. constructor(name: string, position: Vector3, scene: Scene);
  41891. /**
  41892. * Gets the current object class name.
  41893. * @return the class name
  41894. */
  41895. getClassName(): string;
  41896. /** @hidden */
  41897. _setupInputs(): void;
  41898. }
  41899. }
  41900. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41901. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41902. import { Scene } from "babylonjs/scene";
  41903. import { Vector3 } from "babylonjs/Maths/math.vector";
  41904. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41905. import { Axis } from "babylonjs/Maths/math.axis";
  41906. /**
  41907. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41908. * being tilted forward or back and left or right.
  41909. */
  41910. export class DeviceOrientationCamera extends FreeCamera {
  41911. private _initialQuaternion;
  41912. private _quaternionCache;
  41913. private _tmpDragQuaternion;
  41914. private _disablePointerInputWhenUsingDeviceOrientation;
  41915. /**
  41916. * Creates a new device orientation camera
  41917. * @param name The name of the camera
  41918. * @param position The start position camera
  41919. * @param scene The scene the camera belongs to
  41920. */
  41921. constructor(name: string, position: Vector3, scene: Scene);
  41922. /**
  41923. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41924. */
  41925. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41926. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41927. private _dragFactor;
  41928. /**
  41929. * Enabled turning on the y axis when the orientation sensor is active
  41930. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41931. */
  41932. enableHorizontalDragging(dragFactor?: number): void;
  41933. /**
  41934. * Gets the current instance class name ("DeviceOrientationCamera").
  41935. * This helps avoiding instanceof at run time.
  41936. * @returns the class name
  41937. */
  41938. getClassName(): string;
  41939. /**
  41940. * @hidden
  41941. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41942. */
  41943. _checkInputs(): void;
  41944. /**
  41945. * Reset the camera to its default orientation on the specified axis only.
  41946. * @param axis The axis to reset
  41947. */
  41948. resetToCurrentRotation(axis?: Axis): void;
  41949. }
  41950. }
  41951. declare module "babylonjs/Gamepads/xboxGamepad" {
  41952. import { Observable } from "babylonjs/Misc/observable";
  41953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41954. /**
  41955. * Defines supported buttons for XBox360 compatible gamepads
  41956. */
  41957. export enum Xbox360Button {
  41958. /** A */
  41959. A = 0,
  41960. /** B */
  41961. B = 1,
  41962. /** X */
  41963. X = 2,
  41964. /** Y */
  41965. Y = 3,
  41966. /** Start */
  41967. Start = 4,
  41968. /** Back */
  41969. Back = 5,
  41970. /** Left button */
  41971. LB = 6,
  41972. /** Right button */
  41973. RB = 7,
  41974. /** Left stick */
  41975. LeftStick = 8,
  41976. /** Right stick */
  41977. RightStick = 9
  41978. }
  41979. /** Defines values for XBox360 DPad */
  41980. export enum Xbox360Dpad {
  41981. /** Up */
  41982. Up = 0,
  41983. /** Down */
  41984. Down = 1,
  41985. /** Left */
  41986. Left = 2,
  41987. /** Right */
  41988. Right = 3
  41989. }
  41990. /**
  41991. * Defines a XBox360 gamepad
  41992. */
  41993. export class Xbox360Pad extends Gamepad {
  41994. private _leftTrigger;
  41995. private _rightTrigger;
  41996. private _onlefttriggerchanged;
  41997. private _onrighttriggerchanged;
  41998. private _onbuttondown;
  41999. private _onbuttonup;
  42000. private _ondpaddown;
  42001. private _ondpadup;
  42002. /** Observable raised when a button is pressed */
  42003. onButtonDownObservable: Observable<Xbox360Button>;
  42004. /** Observable raised when a button is released */
  42005. onButtonUpObservable: Observable<Xbox360Button>;
  42006. /** Observable raised when a pad is pressed */
  42007. onPadDownObservable: Observable<Xbox360Dpad>;
  42008. /** Observable raised when a pad is released */
  42009. onPadUpObservable: Observable<Xbox360Dpad>;
  42010. private _buttonA;
  42011. private _buttonB;
  42012. private _buttonX;
  42013. private _buttonY;
  42014. private _buttonBack;
  42015. private _buttonStart;
  42016. private _buttonLB;
  42017. private _buttonRB;
  42018. private _buttonLeftStick;
  42019. private _buttonRightStick;
  42020. private _dPadUp;
  42021. private _dPadDown;
  42022. private _dPadLeft;
  42023. private _dPadRight;
  42024. private _isXboxOnePad;
  42025. /**
  42026. * Creates a new XBox360 gamepad object
  42027. * @param id defines the id of this gamepad
  42028. * @param index defines its index
  42029. * @param gamepad defines the internal HTML gamepad object
  42030. * @param xboxOne defines if it is a XBox One gamepad
  42031. */
  42032. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42033. /**
  42034. * Defines the callback to call when left trigger is pressed
  42035. * @param callback defines the callback to use
  42036. */
  42037. onlefttriggerchanged(callback: (value: number) => void): void;
  42038. /**
  42039. * Defines the callback to call when right trigger is pressed
  42040. * @param callback defines the callback to use
  42041. */
  42042. onrighttriggerchanged(callback: (value: number) => void): void;
  42043. /**
  42044. * Gets the left trigger value
  42045. */
  42046. get leftTrigger(): number;
  42047. /**
  42048. * Sets the left trigger value
  42049. */
  42050. set leftTrigger(newValue: number);
  42051. /**
  42052. * Gets the right trigger value
  42053. */
  42054. get rightTrigger(): number;
  42055. /**
  42056. * Sets the right trigger value
  42057. */
  42058. set rightTrigger(newValue: number);
  42059. /**
  42060. * Defines the callback to call when a button is pressed
  42061. * @param callback defines the callback to use
  42062. */
  42063. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42064. /**
  42065. * Defines the callback to call when a button is released
  42066. * @param callback defines the callback to use
  42067. */
  42068. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42069. /**
  42070. * Defines the callback to call when a pad is pressed
  42071. * @param callback defines the callback to use
  42072. */
  42073. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42074. /**
  42075. * Defines the callback to call when a pad is released
  42076. * @param callback defines the callback to use
  42077. */
  42078. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42079. private _setButtonValue;
  42080. private _setDPadValue;
  42081. /**
  42082. * Gets the value of the `A` button
  42083. */
  42084. get buttonA(): number;
  42085. /**
  42086. * Sets the value of the `A` button
  42087. */
  42088. set buttonA(value: number);
  42089. /**
  42090. * Gets the value of the `B` button
  42091. */
  42092. get buttonB(): number;
  42093. /**
  42094. * Sets the value of the `B` button
  42095. */
  42096. set buttonB(value: number);
  42097. /**
  42098. * Gets the value of the `X` button
  42099. */
  42100. get buttonX(): number;
  42101. /**
  42102. * Sets the value of the `X` button
  42103. */
  42104. set buttonX(value: number);
  42105. /**
  42106. * Gets the value of the `Y` button
  42107. */
  42108. get buttonY(): number;
  42109. /**
  42110. * Sets the value of the `Y` button
  42111. */
  42112. set buttonY(value: number);
  42113. /**
  42114. * Gets the value of the `Start` button
  42115. */
  42116. get buttonStart(): number;
  42117. /**
  42118. * Sets the value of the `Start` button
  42119. */
  42120. set buttonStart(value: number);
  42121. /**
  42122. * Gets the value of the `Back` button
  42123. */
  42124. get buttonBack(): number;
  42125. /**
  42126. * Sets the value of the `Back` button
  42127. */
  42128. set buttonBack(value: number);
  42129. /**
  42130. * Gets the value of the `Left` button
  42131. */
  42132. get buttonLB(): number;
  42133. /**
  42134. * Sets the value of the `Left` button
  42135. */
  42136. set buttonLB(value: number);
  42137. /**
  42138. * Gets the value of the `Right` button
  42139. */
  42140. get buttonRB(): number;
  42141. /**
  42142. * Sets the value of the `Right` button
  42143. */
  42144. set buttonRB(value: number);
  42145. /**
  42146. * Gets the value of the Left joystick
  42147. */
  42148. get buttonLeftStick(): number;
  42149. /**
  42150. * Sets the value of the Left joystick
  42151. */
  42152. set buttonLeftStick(value: number);
  42153. /**
  42154. * Gets the value of the Right joystick
  42155. */
  42156. get buttonRightStick(): number;
  42157. /**
  42158. * Sets the value of the Right joystick
  42159. */
  42160. set buttonRightStick(value: number);
  42161. /**
  42162. * Gets the value of D-pad up
  42163. */
  42164. get dPadUp(): number;
  42165. /**
  42166. * Sets the value of D-pad up
  42167. */
  42168. set dPadUp(value: number);
  42169. /**
  42170. * Gets the value of D-pad down
  42171. */
  42172. get dPadDown(): number;
  42173. /**
  42174. * Sets the value of D-pad down
  42175. */
  42176. set dPadDown(value: number);
  42177. /**
  42178. * Gets the value of D-pad left
  42179. */
  42180. get dPadLeft(): number;
  42181. /**
  42182. * Sets the value of D-pad left
  42183. */
  42184. set dPadLeft(value: number);
  42185. /**
  42186. * Gets the value of D-pad right
  42187. */
  42188. get dPadRight(): number;
  42189. /**
  42190. * Sets the value of D-pad right
  42191. */
  42192. set dPadRight(value: number);
  42193. /**
  42194. * Force the gamepad to synchronize with device values
  42195. */
  42196. update(): void;
  42197. /**
  42198. * Disposes the gamepad
  42199. */
  42200. dispose(): void;
  42201. }
  42202. }
  42203. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42204. import { Observable } from "babylonjs/Misc/observable";
  42205. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42206. /**
  42207. * Defines supported buttons for DualShock compatible gamepads
  42208. */
  42209. export enum DualShockButton {
  42210. /** Cross */
  42211. Cross = 0,
  42212. /** Circle */
  42213. Circle = 1,
  42214. /** Square */
  42215. Square = 2,
  42216. /** Triangle */
  42217. Triangle = 3,
  42218. /** Options */
  42219. Options = 4,
  42220. /** Share */
  42221. Share = 5,
  42222. /** L1 */
  42223. L1 = 6,
  42224. /** R1 */
  42225. R1 = 7,
  42226. /** Left stick */
  42227. LeftStick = 8,
  42228. /** Right stick */
  42229. RightStick = 9
  42230. }
  42231. /** Defines values for DualShock DPad */
  42232. export enum DualShockDpad {
  42233. /** Up */
  42234. Up = 0,
  42235. /** Down */
  42236. Down = 1,
  42237. /** Left */
  42238. Left = 2,
  42239. /** Right */
  42240. Right = 3
  42241. }
  42242. /**
  42243. * Defines a DualShock gamepad
  42244. */
  42245. export class DualShockPad extends Gamepad {
  42246. private _leftTrigger;
  42247. private _rightTrigger;
  42248. private _onlefttriggerchanged;
  42249. private _onrighttriggerchanged;
  42250. private _onbuttondown;
  42251. private _onbuttonup;
  42252. private _ondpaddown;
  42253. private _ondpadup;
  42254. /** Observable raised when a button is pressed */
  42255. onButtonDownObservable: Observable<DualShockButton>;
  42256. /** Observable raised when a button is released */
  42257. onButtonUpObservable: Observable<DualShockButton>;
  42258. /** Observable raised when a pad is pressed */
  42259. onPadDownObservable: Observable<DualShockDpad>;
  42260. /** Observable raised when a pad is released */
  42261. onPadUpObservable: Observable<DualShockDpad>;
  42262. private _buttonCross;
  42263. private _buttonCircle;
  42264. private _buttonSquare;
  42265. private _buttonTriangle;
  42266. private _buttonShare;
  42267. private _buttonOptions;
  42268. private _buttonL1;
  42269. private _buttonR1;
  42270. private _buttonLeftStick;
  42271. private _buttonRightStick;
  42272. private _dPadUp;
  42273. private _dPadDown;
  42274. private _dPadLeft;
  42275. private _dPadRight;
  42276. /**
  42277. * Creates a new DualShock gamepad object
  42278. * @param id defines the id of this gamepad
  42279. * @param index defines its index
  42280. * @param gamepad defines the internal HTML gamepad object
  42281. */
  42282. constructor(id: string, index: number, gamepad: any);
  42283. /**
  42284. * Defines the callback to call when left trigger is pressed
  42285. * @param callback defines the callback to use
  42286. */
  42287. onlefttriggerchanged(callback: (value: number) => void): void;
  42288. /**
  42289. * Defines the callback to call when right trigger is pressed
  42290. * @param callback defines the callback to use
  42291. */
  42292. onrighttriggerchanged(callback: (value: number) => void): void;
  42293. /**
  42294. * Gets the left trigger value
  42295. */
  42296. get leftTrigger(): number;
  42297. /**
  42298. * Sets the left trigger value
  42299. */
  42300. set leftTrigger(newValue: number);
  42301. /**
  42302. * Gets the right trigger value
  42303. */
  42304. get rightTrigger(): number;
  42305. /**
  42306. * Sets the right trigger value
  42307. */
  42308. set rightTrigger(newValue: number);
  42309. /**
  42310. * Defines the callback to call when a button is pressed
  42311. * @param callback defines the callback to use
  42312. */
  42313. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42314. /**
  42315. * Defines the callback to call when a button is released
  42316. * @param callback defines the callback to use
  42317. */
  42318. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42319. /**
  42320. * Defines the callback to call when a pad is pressed
  42321. * @param callback defines the callback to use
  42322. */
  42323. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42324. /**
  42325. * Defines the callback to call when a pad is released
  42326. * @param callback defines the callback to use
  42327. */
  42328. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42329. private _setButtonValue;
  42330. private _setDPadValue;
  42331. /**
  42332. * Gets the value of the `Cross` button
  42333. */
  42334. get buttonCross(): number;
  42335. /**
  42336. * Sets the value of the `Cross` button
  42337. */
  42338. set buttonCross(value: number);
  42339. /**
  42340. * Gets the value of the `Circle` button
  42341. */
  42342. get buttonCircle(): number;
  42343. /**
  42344. * Sets the value of the `Circle` button
  42345. */
  42346. set buttonCircle(value: number);
  42347. /**
  42348. * Gets the value of the `Square` button
  42349. */
  42350. get buttonSquare(): number;
  42351. /**
  42352. * Sets the value of the `Square` button
  42353. */
  42354. set buttonSquare(value: number);
  42355. /**
  42356. * Gets the value of the `Triangle` button
  42357. */
  42358. get buttonTriangle(): number;
  42359. /**
  42360. * Sets the value of the `Triangle` button
  42361. */
  42362. set buttonTriangle(value: number);
  42363. /**
  42364. * Gets the value of the `Options` button
  42365. */
  42366. get buttonOptions(): number;
  42367. /**
  42368. * Sets the value of the `Options` button
  42369. */
  42370. set buttonOptions(value: number);
  42371. /**
  42372. * Gets the value of the `Share` button
  42373. */
  42374. get buttonShare(): number;
  42375. /**
  42376. * Sets the value of the `Share` button
  42377. */
  42378. set buttonShare(value: number);
  42379. /**
  42380. * Gets the value of the `L1` button
  42381. */
  42382. get buttonL1(): number;
  42383. /**
  42384. * Sets the value of the `L1` button
  42385. */
  42386. set buttonL1(value: number);
  42387. /**
  42388. * Gets the value of the `R1` button
  42389. */
  42390. get buttonR1(): number;
  42391. /**
  42392. * Sets the value of the `R1` button
  42393. */
  42394. set buttonR1(value: number);
  42395. /**
  42396. * Gets the value of the Left joystick
  42397. */
  42398. get buttonLeftStick(): number;
  42399. /**
  42400. * Sets the value of the Left joystick
  42401. */
  42402. set buttonLeftStick(value: number);
  42403. /**
  42404. * Gets the value of the Right joystick
  42405. */
  42406. get buttonRightStick(): number;
  42407. /**
  42408. * Sets the value of the Right joystick
  42409. */
  42410. set buttonRightStick(value: number);
  42411. /**
  42412. * Gets the value of D-pad up
  42413. */
  42414. get dPadUp(): number;
  42415. /**
  42416. * Sets the value of D-pad up
  42417. */
  42418. set dPadUp(value: number);
  42419. /**
  42420. * Gets the value of D-pad down
  42421. */
  42422. get dPadDown(): number;
  42423. /**
  42424. * Sets the value of D-pad down
  42425. */
  42426. set dPadDown(value: number);
  42427. /**
  42428. * Gets the value of D-pad left
  42429. */
  42430. get dPadLeft(): number;
  42431. /**
  42432. * Sets the value of D-pad left
  42433. */
  42434. set dPadLeft(value: number);
  42435. /**
  42436. * Gets the value of D-pad right
  42437. */
  42438. get dPadRight(): number;
  42439. /**
  42440. * Sets the value of D-pad right
  42441. */
  42442. set dPadRight(value: number);
  42443. /**
  42444. * Force the gamepad to synchronize with device values
  42445. */
  42446. update(): void;
  42447. /**
  42448. * Disposes the gamepad
  42449. */
  42450. dispose(): void;
  42451. }
  42452. }
  42453. declare module "babylonjs/Gamepads/gamepadManager" {
  42454. import { Observable } from "babylonjs/Misc/observable";
  42455. import { Nullable } from "babylonjs/types";
  42456. import { Scene } from "babylonjs/scene";
  42457. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42458. /**
  42459. * Manager for handling gamepads
  42460. */
  42461. export class GamepadManager {
  42462. private _scene?;
  42463. private _babylonGamepads;
  42464. private _oneGamepadConnected;
  42465. /** @hidden */
  42466. _isMonitoring: boolean;
  42467. private _gamepadEventSupported;
  42468. private _gamepadSupport?;
  42469. /**
  42470. * observable to be triggered when the gamepad controller has been connected
  42471. */
  42472. onGamepadConnectedObservable: Observable<Gamepad>;
  42473. /**
  42474. * observable to be triggered when the gamepad controller has been disconnected
  42475. */
  42476. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42477. private _onGamepadConnectedEvent;
  42478. private _onGamepadDisconnectedEvent;
  42479. /**
  42480. * Initializes the gamepad manager
  42481. * @param _scene BabylonJS scene
  42482. */
  42483. constructor(_scene?: Scene | undefined);
  42484. /**
  42485. * The gamepads in the game pad manager
  42486. */
  42487. get gamepads(): Gamepad[];
  42488. /**
  42489. * Get the gamepad controllers based on type
  42490. * @param type The type of gamepad controller
  42491. * @returns Nullable gamepad
  42492. */
  42493. getGamepadByType(type?: number): Nullable<Gamepad>;
  42494. /**
  42495. * Disposes the gamepad manager
  42496. */
  42497. dispose(): void;
  42498. private _addNewGamepad;
  42499. private _startMonitoringGamepads;
  42500. private _stopMonitoringGamepads;
  42501. /** @hidden */
  42502. _checkGamepadsStatus(): void;
  42503. private _updateGamepadObjects;
  42504. }
  42505. }
  42506. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42507. import { Nullable } from "babylonjs/types";
  42508. import { Scene } from "babylonjs/scene";
  42509. import { ISceneComponent } from "babylonjs/sceneComponent";
  42510. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42511. module "babylonjs/scene" {
  42512. interface Scene {
  42513. /** @hidden */
  42514. _gamepadManager: Nullable<GamepadManager>;
  42515. /**
  42516. * Gets the gamepad manager associated with the scene
  42517. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42518. */
  42519. gamepadManager: GamepadManager;
  42520. }
  42521. }
  42522. module "babylonjs/Cameras/freeCameraInputsManager" {
  42523. /**
  42524. * Interface representing a free camera inputs manager
  42525. */
  42526. interface FreeCameraInputsManager {
  42527. /**
  42528. * Adds gamepad input support to the FreeCameraInputsManager.
  42529. * @returns the FreeCameraInputsManager
  42530. */
  42531. addGamepad(): FreeCameraInputsManager;
  42532. }
  42533. }
  42534. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42535. /**
  42536. * Interface representing an arc rotate camera inputs manager
  42537. */
  42538. interface ArcRotateCameraInputsManager {
  42539. /**
  42540. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42541. * @returns the camera inputs manager
  42542. */
  42543. addGamepad(): ArcRotateCameraInputsManager;
  42544. }
  42545. }
  42546. /**
  42547. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42548. */
  42549. export class GamepadSystemSceneComponent implements ISceneComponent {
  42550. /**
  42551. * The component name helpfull to identify the component in the list of scene components.
  42552. */
  42553. readonly name: string;
  42554. /**
  42555. * The scene the component belongs to.
  42556. */
  42557. scene: Scene;
  42558. /**
  42559. * Creates a new instance of the component for the given scene
  42560. * @param scene Defines the scene to register the component in
  42561. */
  42562. constructor(scene: Scene);
  42563. /**
  42564. * Registers the component in a given scene
  42565. */
  42566. register(): void;
  42567. /**
  42568. * Rebuilds the elements related to this component in case of
  42569. * context lost for instance.
  42570. */
  42571. rebuild(): void;
  42572. /**
  42573. * Disposes the component and the associated ressources
  42574. */
  42575. dispose(): void;
  42576. private _beforeCameraUpdate;
  42577. }
  42578. }
  42579. declare module "babylonjs/Cameras/universalCamera" {
  42580. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42581. import { Scene } from "babylonjs/scene";
  42582. import { Vector3 } from "babylonjs/Maths/math.vector";
  42583. import "babylonjs/Gamepads/gamepadSceneComponent";
  42584. /**
  42585. * 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,
  42586. * which still works and will still be found in many Playgrounds.
  42587. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42588. */
  42589. export class UniversalCamera extends TouchCamera {
  42590. /**
  42591. * Defines the gamepad rotation sensiblity.
  42592. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42593. */
  42594. get gamepadAngularSensibility(): number;
  42595. set gamepadAngularSensibility(value: number);
  42596. /**
  42597. * Defines the gamepad move sensiblity.
  42598. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42599. */
  42600. get gamepadMoveSensibility(): number;
  42601. set gamepadMoveSensibility(value: number);
  42602. /**
  42603. * 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,
  42604. * which still works and will still be found in many Playgrounds.
  42605. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42606. * @param name Define the name of the camera in the scene
  42607. * @param position Define the start position of the camera in the scene
  42608. * @param scene Define the scene the camera belongs to
  42609. */
  42610. constructor(name: string, position: Vector3, scene: Scene);
  42611. /**
  42612. * Gets the current object class name.
  42613. * @return the class name
  42614. */
  42615. getClassName(): string;
  42616. }
  42617. }
  42618. declare module "babylonjs/Cameras/gamepadCamera" {
  42619. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42620. import { Scene } from "babylonjs/scene";
  42621. import { Vector3 } from "babylonjs/Maths/math.vector";
  42622. /**
  42623. * This represents a FPS type of camera. This is only here for back compat purpose.
  42624. * Please use the UniversalCamera instead as both are identical.
  42625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42626. */
  42627. export class GamepadCamera extends UniversalCamera {
  42628. /**
  42629. * Instantiates a new Gamepad Camera
  42630. * This represents a FPS type of camera. This is only here for back compat purpose.
  42631. * Please use the UniversalCamera instead as both are identical.
  42632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42633. * @param name Define the name of the camera in the scene
  42634. * @param position Define the start position of the camera in the scene
  42635. * @param scene Define the scene the camera belongs to
  42636. */
  42637. constructor(name: string, position: Vector3, scene: Scene);
  42638. /**
  42639. * Gets the current object class name.
  42640. * @return the class name
  42641. */
  42642. getClassName(): string;
  42643. }
  42644. }
  42645. declare module "babylonjs/Shaders/pass.fragment" {
  42646. /** @hidden */
  42647. export var passPixelShader: {
  42648. name: string;
  42649. shader: string;
  42650. };
  42651. }
  42652. declare module "babylonjs/Shaders/passCube.fragment" {
  42653. /** @hidden */
  42654. export var passCubePixelShader: {
  42655. name: string;
  42656. shader: string;
  42657. };
  42658. }
  42659. declare module "babylonjs/PostProcesses/passPostProcess" {
  42660. import { Nullable } from "babylonjs/types";
  42661. import { Camera } from "babylonjs/Cameras/camera";
  42662. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42663. import { Engine } from "babylonjs/Engines/engine";
  42664. import "babylonjs/Shaders/pass.fragment";
  42665. import "babylonjs/Shaders/passCube.fragment";
  42666. /**
  42667. * PassPostProcess which produces an output the same as it's input
  42668. */
  42669. export class PassPostProcess extends PostProcess {
  42670. /**
  42671. * Creates the PassPostProcess
  42672. * @param name The name of the effect.
  42673. * @param options The required width/height ratio to downsize to before computing the render pass.
  42674. * @param camera The camera to apply the render pass to.
  42675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42676. * @param engine The engine which the post process will be applied. (default: current engine)
  42677. * @param reusable If the post process can be reused on the same frame. (default: false)
  42678. * @param textureType The type of texture to be used when performing the post processing.
  42679. * @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)
  42680. */
  42681. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42682. }
  42683. /**
  42684. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42685. */
  42686. export class PassCubePostProcess extends PostProcess {
  42687. private _face;
  42688. /**
  42689. * Gets or sets the cube face to display.
  42690. * * 0 is +X
  42691. * * 1 is -X
  42692. * * 2 is +Y
  42693. * * 3 is -Y
  42694. * * 4 is +Z
  42695. * * 5 is -Z
  42696. */
  42697. get face(): number;
  42698. set face(value: number);
  42699. /**
  42700. * Creates the PassCubePostProcess
  42701. * @param name The name of the effect.
  42702. * @param options The required width/height ratio to downsize to before computing the render pass.
  42703. * @param camera The camera to apply the render pass to.
  42704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42705. * @param engine The engine which the post process will be applied. (default: current engine)
  42706. * @param reusable If the post process can be reused on the same frame. (default: false)
  42707. * @param textureType The type of texture to be used when performing the post processing.
  42708. * @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)
  42709. */
  42710. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42711. }
  42712. }
  42713. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42714. /** @hidden */
  42715. export var anaglyphPixelShader: {
  42716. name: string;
  42717. shader: string;
  42718. };
  42719. }
  42720. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42721. import { Engine } from "babylonjs/Engines/engine";
  42722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42723. import { Camera } from "babylonjs/Cameras/camera";
  42724. import "babylonjs/Shaders/anaglyph.fragment";
  42725. /**
  42726. * Postprocess used to generate anaglyphic rendering
  42727. */
  42728. export class AnaglyphPostProcess extends PostProcess {
  42729. private _passedProcess;
  42730. /**
  42731. * Creates a new AnaglyphPostProcess
  42732. * @param name defines postprocess name
  42733. * @param options defines creation options or target ratio scale
  42734. * @param rigCameras defines cameras using this postprocess
  42735. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42736. * @param engine defines hosting engine
  42737. * @param reusable defines if the postprocess will be reused multiple times per frame
  42738. */
  42739. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42743. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42744. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42745. import { Scene } from "babylonjs/scene";
  42746. import { Vector3 } from "babylonjs/Maths/math.vector";
  42747. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42748. /**
  42749. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42750. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42751. */
  42752. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42753. /**
  42754. * Creates a new AnaglyphArcRotateCamera
  42755. * @param name defines camera name
  42756. * @param alpha defines alpha angle (in radians)
  42757. * @param beta defines beta angle (in radians)
  42758. * @param radius defines radius
  42759. * @param target defines camera target
  42760. * @param interaxialDistance defines distance between each color axis
  42761. * @param scene defines the hosting scene
  42762. */
  42763. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42764. /**
  42765. * Gets camera class name
  42766. * @returns AnaglyphArcRotateCamera
  42767. */
  42768. getClassName(): string;
  42769. }
  42770. }
  42771. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42772. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42773. import { Scene } from "babylonjs/scene";
  42774. import { Vector3 } from "babylonjs/Maths/math.vector";
  42775. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42776. /**
  42777. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42779. */
  42780. export class AnaglyphFreeCamera extends FreeCamera {
  42781. /**
  42782. * Creates a new AnaglyphFreeCamera
  42783. * @param name defines camera name
  42784. * @param position defines initial position
  42785. * @param interaxialDistance defines distance between each color axis
  42786. * @param scene defines the hosting scene
  42787. */
  42788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42789. /**
  42790. * Gets camera class name
  42791. * @returns AnaglyphFreeCamera
  42792. */
  42793. getClassName(): string;
  42794. }
  42795. }
  42796. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42797. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42798. import { Scene } from "babylonjs/scene";
  42799. import { Vector3 } from "babylonjs/Maths/math.vector";
  42800. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42801. /**
  42802. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42804. */
  42805. export class AnaglyphGamepadCamera extends GamepadCamera {
  42806. /**
  42807. * Creates a new AnaglyphGamepadCamera
  42808. * @param name defines camera name
  42809. * @param position defines initial position
  42810. * @param interaxialDistance defines distance between each color axis
  42811. * @param scene defines the hosting scene
  42812. */
  42813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42814. /**
  42815. * Gets camera class name
  42816. * @returns AnaglyphGamepadCamera
  42817. */
  42818. getClassName(): string;
  42819. }
  42820. }
  42821. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42822. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42823. import { Scene } from "babylonjs/scene";
  42824. import { Vector3 } from "babylonjs/Maths/math.vector";
  42825. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42826. /**
  42827. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42828. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42829. */
  42830. export class AnaglyphUniversalCamera extends UniversalCamera {
  42831. /**
  42832. * Creates a new AnaglyphUniversalCamera
  42833. * @param name defines camera name
  42834. * @param position defines initial position
  42835. * @param interaxialDistance defines distance between each color axis
  42836. * @param scene defines the hosting scene
  42837. */
  42838. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42839. /**
  42840. * Gets camera class name
  42841. * @returns AnaglyphUniversalCamera
  42842. */
  42843. getClassName(): string;
  42844. }
  42845. }
  42846. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42847. /** @hidden */
  42848. export var stereoscopicInterlacePixelShader: {
  42849. name: string;
  42850. shader: string;
  42851. };
  42852. }
  42853. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42854. import { Camera } from "babylonjs/Cameras/camera";
  42855. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42856. import { Engine } from "babylonjs/Engines/engine";
  42857. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42858. /**
  42859. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42860. */
  42861. export class StereoscopicInterlacePostProcess extends PostProcess {
  42862. private _stepSize;
  42863. private _passedProcess;
  42864. /**
  42865. * Initializes a StereoscopicInterlacePostProcess
  42866. * @param name The name of the effect.
  42867. * @param rigCameras The rig cameras to be appled to the post process
  42868. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42870. * @param engine The engine which the post process will be applied. (default: current engine)
  42871. * @param reusable If the post process can be reused on the same frame. (default: false)
  42872. */
  42873. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42874. }
  42875. }
  42876. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42877. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42878. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42879. import { Scene } from "babylonjs/scene";
  42880. import { Vector3 } from "babylonjs/Maths/math.vector";
  42881. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42882. /**
  42883. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42884. * @see http://doc.babylonjs.com/features/cameras
  42885. */
  42886. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42887. /**
  42888. * Creates a new StereoscopicArcRotateCamera
  42889. * @param name defines camera name
  42890. * @param alpha defines alpha angle (in radians)
  42891. * @param beta defines beta angle (in radians)
  42892. * @param radius defines radius
  42893. * @param target defines camera target
  42894. * @param interaxialDistance defines distance between each color axis
  42895. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42896. * @param scene defines the hosting scene
  42897. */
  42898. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42899. /**
  42900. * Gets camera class name
  42901. * @returns StereoscopicArcRotateCamera
  42902. */
  42903. getClassName(): string;
  42904. }
  42905. }
  42906. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42907. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42908. import { Scene } from "babylonjs/scene";
  42909. import { Vector3 } from "babylonjs/Maths/math.vector";
  42910. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42911. /**
  42912. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42913. * @see http://doc.babylonjs.com/features/cameras
  42914. */
  42915. export class StereoscopicFreeCamera extends FreeCamera {
  42916. /**
  42917. * Creates a new StereoscopicFreeCamera
  42918. * @param name defines camera name
  42919. * @param position defines initial position
  42920. * @param interaxialDistance defines distance between each color axis
  42921. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42922. * @param scene defines the hosting scene
  42923. */
  42924. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42925. /**
  42926. * Gets camera class name
  42927. * @returns StereoscopicFreeCamera
  42928. */
  42929. getClassName(): string;
  42930. }
  42931. }
  42932. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42933. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42934. import { Scene } from "babylonjs/scene";
  42935. import { Vector3 } from "babylonjs/Maths/math.vector";
  42936. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42937. /**
  42938. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42939. * @see http://doc.babylonjs.com/features/cameras
  42940. */
  42941. export class StereoscopicGamepadCamera extends GamepadCamera {
  42942. /**
  42943. * Creates a new StereoscopicGamepadCamera
  42944. * @param name defines camera name
  42945. * @param position defines initial position
  42946. * @param interaxialDistance defines distance between each color axis
  42947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42948. * @param scene defines the hosting scene
  42949. */
  42950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42951. /**
  42952. * Gets camera class name
  42953. * @returns StereoscopicGamepadCamera
  42954. */
  42955. getClassName(): string;
  42956. }
  42957. }
  42958. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42959. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42960. import { Scene } from "babylonjs/scene";
  42961. import { Vector3 } from "babylonjs/Maths/math.vector";
  42962. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42963. /**
  42964. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42965. * @see http://doc.babylonjs.com/features/cameras
  42966. */
  42967. export class StereoscopicUniversalCamera extends UniversalCamera {
  42968. /**
  42969. * Creates a new StereoscopicUniversalCamera
  42970. * @param name defines camera name
  42971. * @param position defines initial position
  42972. * @param interaxialDistance defines distance between each color axis
  42973. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42974. * @param scene defines the hosting scene
  42975. */
  42976. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42977. /**
  42978. * Gets camera class name
  42979. * @returns StereoscopicUniversalCamera
  42980. */
  42981. getClassName(): string;
  42982. }
  42983. }
  42984. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42985. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42986. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42987. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42988. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42989. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42990. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42991. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42992. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42993. }
  42994. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42995. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42996. import { Scene } from "babylonjs/scene";
  42997. import { Vector3 } from "babylonjs/Maths/math.vector";
  42998. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42999. /**
  43000. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43001. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43002. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43003. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43004. */
  43005. export class VirtualJoysticksCamera extends FreeCamera {
  43006. /**
  43007. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43008. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43009. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43010. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43011. * @param name Define the name of the camera in the scene
  43012. * @param position Define the start position of the camera in the scene
  43013. * @param scene Define the scene the camera belongs to
  43014. */
  43015. constructor(name: string, position: Vector3, scene: Scene);
  43016. /**
  43017. * Gets the current object class name.
  43018. * @return the class name
  43019. */
  43020. getClassName(): string;
  43021. }
  43022. }
  43023. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43024. import { Matrix } from "babylonjs/Maths/math.vector";
  43025. /**
  43026. * This represents all the required metrics to create a VR camera.
  43027. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43028. */
  43029. export class VRCameraMetrics {
  43030. /**
  43031. * Define the horizontal resolution off the screen.
  43032. */
  43033. hResolution: number;
  43034. /**
  43035. * Define the vertical resolution off the screen.
  43036. */
  43037. vResolution: number;
  43038. /**
  43039. * Define the horizontal screen size.
  43040. */
  43041. hScreenSize: number;
  43042. /**
  43043. * Define the vertical screen size.
  43044. */
  43045. vScreenSize: number;
  43046. /**
  43047. * Define the vertical screen center position.
  43048. */
  43049. vScreenCenter: number;
  43050. /**
  43051. * Define the distance of the eyes to the screen.
  43052. */
  43053. eyeToScreenDistance: number;
  43054. /**
  43055. * Define the distance between both lenses
  43056. */
  43057. lensSeparationDistance: number;
  43058. /**
  43059. * Define the distance between both viewer's eyes.
  43060. */
  43061. interpupillaryDistance: number;
  43062. /**
  43063. * Define the distortion factor of the VR postprocess.
  43064. * Please, touch with care.
  43065. */
  43066. distortionK: number[];
  43067. /**
  43068. * Define the chromatic aberration correction factors for the VR post process.
  43069. */
  43070. chromaAbCorrection: number[];
  43071. /**
  43072. * Define the scale factor of the post process.
  43073. * The smaller the better but the slower.
  43074. */
  43075. postProcessScaleFactor: number;
  43076. /**
  43077. * Define an offset for the lens center.
  43078. */
  43079. lensCenterOffset: number;
  43080. /**
  43081. * Define if the current vr camera should compensate the distortion of the lense or not.
  43082. */
  43083. compensateDistortion: boolean;
  43084. /**
  43085. * Defines if multiview should be enabled when rendering (Default: false)
  43086. */
  43087. multiviewEnabled: boolean;
  43088. /**
  43089. * Gets the rendering aspect ratio based on the provided resolutions.
  43090. */
  43091. get aspectRatio(): number;
  43092. /**
  43093. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43094. */
  43095. get aspectRatioFov(): number;
  43096. /**
  43097. * @hidden
  43098. */
  43099. get leftHMatrix(): Matrix;
  43100. /**
  43101. * @hidden
  43102. */
  43103. get rightHMatrix(): Matrix;
  43104. /**
  43105. * @hidden
  43106. */
  43107. get leftPreViewMatrix(): Matrix;
  43108. /**
  43109. * @hidden
  43110. */
  43111. get rightPreViewMatrix(): Matrix;
  43112. /**
  43113. * Get the default VRMetrics based on the most generic setup.
  43114. * @returns the default vr metrics
  43115. */
  43116. static GetDefault(): VRCameraMetrics;
  43117. }
  43118. }
  43119. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43120. /** @hidden */
  43121. export var vrDistortionCorrectionPixelShader: {
  43122. name: string;
  43123. shader: string;
  43124. };
  43125. }
  43126. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43127. import { Camera } from "babylonjs/Cameras/camera";
  43128. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43129. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43130. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43131. /**
  43132. * VRDistortionCorrectionPostProcess used for mobile VR
  43133. */
  43134. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43135. private _isRightEye;
  43136. private _distortionFactors;
  43137. private _postProcessScaleFactor;
  43138. private _lensCenterOffset;
  43139. private _scaleIn;
  43140. private _scaleFactor;
  43141. private _lensCenter;
  43142. /**
  43143. * Initializes the VRDistortionCorrectionPostProcess
  43144. * @param name The name of the effect.
  43145. * @param camera The camera to apply the render pass to.
  43146. * @param isRightEye If this is for the right eye distortion
  43147. * @param vrMetrics All the required metrics for the VR camera
  43148. */
  43149. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43150. }
  43151. }
  43152. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43153. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43154. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43155. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43156. import { Scene } from "babylonjs/scene";
  43157. import { Vector3 } from "babylonjs/Maths/math.vector";
  43158. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43159. import "babylonjs/Cameras/RigModes/vrRigMode";
  43160. /**
  43161. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43162. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43163. */
  43164. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43165. /**
  43166. * Creates a new VRDeviceOrientationArcRotateCamera
  43167. * @param name defines camera name
  43168. * @param alpha defines the camera rotation along the logitudinal axis
  43169. * @param beta defines the camera rotation along the latitudinal axis
  43170. * @param radius defines the camera distance from its target
  43171. * @param target defines the camera target
  43172. * @param scene defines the scene the camera belongs to
  43173. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43174. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43175. */
  43176. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43177. /**
  43178. * Gets camera class name
  43179. * @returns VRDeviceOrientationArcRotateCamera
  43180. */
  43181. getClassName(): string;
  43182. }
  43183. }
  43184. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43185. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43186. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43187. import { Scene } from "babylonjs/scene";
  43188. import { Vector3 } from "babylonjs/Maths/math.vector";
  43189. import "babylonjs/Cameras/RigModes/vrRigMode";
  43190. /**
  43191. * Camera used to simulate VR rendering (based on FreeCamera)
  43192. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43193. */
  43194. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43195. /**
  43196. * Creates a new VRDeviceOrientationFreeCamera
  43197. * @param name defines camera name
  43198. * @param position defines the start position of the camera
  43199. * @param scene defines the scene the camera belongs to
  43200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43202. */
  43203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43204. /**
  43205. * Gets camera class name
  43206. * @returns VRDeviceOrientationFreeCamera
  43207. */
  43208. getClassName(): string;
  43209. }
  43210. }
  43211. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43212. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43213. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43214. import { Scene } from "babylonjs/scene";
  43215. import { Vector3 } from "babylonjs/Maths/math.vector";
  43216. import "babylonjs/Gamepads/gamepadSceneComponent";
  43217. /**
  43218. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43219. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43220. */
  43221. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43222. /**
  43223. * Creates a new VRDeviceOrientationGamepadCamera
  43224. * @param name defines camera name
  43225. * @param position defines the start position of the camera
  43226. * @param scene defines the scene the camera belongs to
  43227. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43228. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43229. */
  43230. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43231. /**
  43232. * Gets camera class name
  43233. * @returns VRDeviceOrientationGamepadCamera
  43234. */
  43235. getClassName(): string;
  43236. }
  43237. }
  43238. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43239. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43240. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43241. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43242. /** @hidden */
  43243. export var imageProcessingPixelShader: {
  43244. name: string;
  43245. shader: string;
  43246. };
  43247. }
  43248. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43249. import { Nullable } from "babylonjs/types";
  43250. import { Color4 } from "babylonjs/Maths/math.color";
  43251. import { Camera } from "babylonjs/Cameras/camera";
  43252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43253. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43254. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43255. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43256. import { Engine } from "babylonjs/Engines/engine";
  43257. import "babylonjs/Shaders/imageProcessing.fragment";
  43258. import "babylonjs/Shaders/postprocess.vertex";
  43259. /**
  43260. * ImageProcessingPostProcess
  43261. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43262. */
  43263. export class ImageProcessingPostProcess extends PostProcess {
  43264. /**
  43265. * Default configuration related to image processing available in the PBR Material.
  43266. */
  43267. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43268. /**
  43269. * Gets the image processing configuration used either in this material.
  43270. */
  43271. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43272. /**
  43273. * Sets the Default image processing configuration used either in the this material.
  43274. *
  43275. * If sets to null, the scene one is in use.
  43276. */
  43277. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43278. /**
  43279. * Keep track of the image processing observer to allow dispose and replace.
  43280. */
  43281. private _imageProcessingObserver;
  43282. /**
  43283. * Attaches a new image processing configuration to the PBR Material.
  43284. * @param configuration
  43285. */
  43286. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43287. /**
  43288. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43289. */
  43290. get colorCurves(): Nullable<ColorCurves>;
  43291. /**
  43292. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43293. */
  43294. set colorCurves(value: Nullable<ColorCurves>);
  43295. /**
  43296. * Gets wether the color curves effect is enabled.
  43297. */
  43298. get colorCurvesEnabled(): boolean;
  43299. /**
  43300. * Sets wether the color curves effect is enabled.
  43301. */
  43302. set colorCurvesEnabled(value: boolean);
  43303. /**
  43304. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43305. */
  43306. get colorGradingTexture(): Nullable<BaseTexture>;
  43307. /**
  43308. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43309. */
  43310. set colorGradingTexture(value: Nullable<BaseTexture>);
  43311. /**
  43312. * Gets wether the color grading effect is enabled.
  43313. */
  43314. get colorGradingEnabled(): boolean;
  43315. /**
  43316. * Gets wether the color grading effect is enabled.
  43317. */
  43318. set colorGradingEnabled(value: boolean);
  43319. /**
  43320. * Gets exposure used in the effect.
  43321. */
  43322. get exposure(): number;
  43323. /**
  43324. * Sets exposure used in the effect.
  43325. */
  43326. set exposure(value: number);
  43327. /**
  43328. * Gets wether tonemapping is enabled or not.
  43329. */
  43330. get toneMappingEnabled(): boolean;
  43331. /**
  43332. * Sets wether tonemapping is enabled or not
  43333. */
  43334. set toneMappingEnabled(value: boolean);
  43335. /**
  43336. * Gets the type of tone mapping effect.
  43337. */
  43338. get toneMappingType(): number;
  43339. /**
  43340. * Sets the type of tone mapping effect.
  43341. */
  43342. set toneMappingType(value: number);
  43343. /**
  43344. * Gets contrast used in the effect.
  43345. */
  43346. get contrast(): number;
  43347. /**
  43348. * Sets contrast used in the effect.
  43349. */
  43350. set contrast(value: number);
  43351. /**
  43352. * Gets Vignette stretch size.
  43353. */
  43354. get vignetteStretch(): number;
  43355. /**
  43356. * Sets Vignette stretch size.
  43357. */
  43358. set vignetteStretch(value: number);
  43359. /**
  43360. * Gets Vignette centre X Offset.
  43361. */
  43362. get vignetteCentreX(): number;
  43363. /**
  43364. * Sets Vignette centre X Offset.
  43365. */
  43366. set vignetteCentreX(value: number);
  43367. /**
  43368. * Gets Vignette centre Y Offset.
  43369. */
  43370. get vignetteCentreY(): number;
  43371. /**
  43372. * Sets Vignette centre Y Offset.
  43373. */
  43374. set vignetteCentreY(value: number);
  43375. /**
  43376. * Gets Vignette weight or intensity of the vignette effect.
  43377. */
  43378. get vignetteWeight(): number;
  43379. /**
  43380. * Sets Vignette weight or intensity of the vignette effect.
  43381. */
  43382. set vignetteWeight(value: number);
  43383. /**
  43384. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43385. * if vignetteEnabled is set to true.
  43386. */
  43387. get vignetteColor(): Color4;
  43388. /**
  43389. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43390. * if vignetteEnabled is set to true.
  43391. */
  43392. set vignetteColor(value: Color4);
  43393. /**
  43394. * Gets Camera field of view used by the Vignette effect.
  43395. */
  43396. get vignetteCameraFov(): number;
  43397. /**
  43398. * Sets Camera field of view used by the Vignette effect.
  43399. */
  43400. set vignetteCameraFov(value: number);
  43401. /**
  43402. * Gets the vignette blend mode allowing different kind of effect.
  43403. */
  43404. get vignetteBlendMode(): number;
  43405. /**
  43406. * Sets the vignette blend mode allowing different kind of effect.
  43407. */
  43408. set vignetteBlendMode(value: number);
  43409. /**
  43410. * Gets wether the vignette effect is enabled.
  43411. */
  43412. get vignetteEnabled(): boolean;
  43413. /**
  43414. * Sets wether the vignette effect is enabled.
  43415. */
  43416. set vignetteEnabled(value: boolean);
  43417. private _fromLinearSpace;
  43418. /**
  43419. * Gets wether the input of the processing is in Gamma or Linear Space.
  43420. */
  43421. get fromLinearSpace(): boolean;
  43422. /**
  43423. * Sets wether the input of the processing is in Gamma or Linear Space.
  43424. */
  43425. set fromLinearSpace(value: boolean);
  43426. /**
  43427. * Defines cache preventing GC.
  43428. */
  43429. private _defines;
  43430. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43431. /**
  43432. * "ImageProcessingPostProcess"
  43433. * @returns "ImageProcessingPostProcess"
  43434. */
  43435. getClassName(): string;
  43436. protected _updateParameters(): void;
  43437. dispose(camera?: Camera): void;
  43438. }
  43439. }
  43440. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43441. import { Scene } from "babylonjs/scene";
  43442. import { Color3 } from "babylonjs/Maths/math.color";
  43443. import { Mesh } from "babylonjs/Meshes/mesh";
  43444. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43445. import { Nullable } from "babylonjs/types";
  43446. /**
  43447. * Class containing static functions to help procedurally build meshes
  43448. */
  43449. export class GroundBuilder {
  43450. /**
  43451. * Creates a ground mesh
  43452. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43453. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43455. * @param name defines the name of the mesh
  43456. * @param options defines the options used to create the mesh
  43457. * @param scene defines the hosting scene
  43458. * @returns the ground mesh
  43459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43460. */
  43461. static CreateGround(name: string, options: {
  43462. width?: number;
  43463. height?: number;
  43464. subdivisions?: number;
  43465. subdivisionsX?: number;
  43466. subdivisionsY?: number;
  43467. updatable?: boolean;
  43468. }, scene: any): Mesh;
  43469. /**
  43470. * Creates a tiled ground mesh
  43471. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43472. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43473. * * 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
  43474. * * 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
  43475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43476. * @param name defines the name of the mesh
  43477. * @param options defines the options used to create the mesh
  43478. * @param scene defines the hosting scene
  43479. * @returns the tiled ground mesh
  43480. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43481. */
  43482. static CreateTiledGround(name: string, options: {
  43483. xmin: number;
  43484. zmin: number;
  43485. xmax: number;
  43486. zmax: number;
  43487. subdivisions?: {
  43488. w: number;
  43489. h: number;
  43490. };
  43491. precision?: {
  43492. w: number;
  43493. h: number;
  43494. };
  43495. updatable?: boolean;
  43496. }, scene?: Nullable<Scene>): Mesh;
  43497. /**
  43498. * Creates a ground mesh from a height map
  43499. * * The parameter `url` sets the URL of the height map image resource.
  43500. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43501. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43502. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43503. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43504. * * 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.
  43505. * * 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).
  43506. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43508. * @param name defines the name of the mesh
  43509. * @param url defines the url to the height map
  43510. * @param options defines the options used to create the mesh
  43511. * @param scene defines the hosting scene
  43512. * @returns the ground mesh
  43513. * @see https://doc.babylonjs.com/babylon101/height_map
  43514. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43515. */
  43516. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43517. width?: number;
  43518. height?: number;
  43519. subdivisions?: number;
  43520. minHeight?: number;
  43521. maxHeight?: number;
  43522. colorFilter?: Color3;
  43523. alphaFilter?: number;
  43524. updatable?: boolean;
  43525. onReady?: (mesh: GroundMesh) => void;
  43526. }, scene?: Nullable<Scene>): GroundMesh;
  43527. }
  43528. }
  43529. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43530. import { Vector4 } from "babylonjs/Maths/math.vector";
  43531. import { Mesh } from "babylonjs/Meshes/mesh";
  43532. /**
  43533. * Class containing static functions to help procedurally build meshes
  43534. */
  43535. export class TorusBuilder {
  43536. /**
  43537. * Creates a torus mesh
  43538. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43539. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43540. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43544. * @param name defines the name of the mesh
  43545. * @param options defines the options used to create the mesh
  43546. * @param scene defines the hosting scene
  43547. * @returns the torus mesh
  43548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43549. */
  43550. static CreateTorus(name: string, options: {
  43551. diameter?: number;
  43552. thickness?: number;
  43553. tessellation?: number;
  43554. updatable?: boolean;
  43555. sideOrientation?: number;
  43556. frontUVs?: Vector4;
  43557. backUVs?: Vector4;
  43558. }, scene: any): Mesh;
  43559. }
  43560. }
  43561. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43562. import { Vector4 } from "babylonjs/Maths/math.vector";
  43563. import { Color4 } from "babylonjs/Maths/math.color";
  43564. import { Mesh } from "babylonjs/Meshes/mesh";
  43565. /**
  43566. * Class containing static functions to help procedurally build meshes
  43567. */
  43568. export class CylinderBuilder {
  43569. /**
  43570. * Creates a cylinder or a cone mesh
  43571. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43572. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43573. * * 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.
  43574. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43575. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43576. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43577. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43578. * * 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).
  43579. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43580. * * 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).
  43581. * * 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
  43582. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43583. * * 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
  43584. * * 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.
  43585. * * If `enclose` is false, a ring surface is one element.
  43586. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43587. * * 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
  43588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43591. * @param name defines the name of the mesh
  43592. * @param options defines the options used to create the mesh
  43593. * @param scene defines the hosting scene
  43594. * @returns the cylinder mesh
  43595. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43596. */
  43597. static CreateCylinder(name: string, options: {
  43598. height?: number;
  43599. diameterTop?: number;
  43600. diameterBottom?: number;
  43601. diameter?: number;
  43602. tessellation?: number;
  43603. subdivisions?: number;
  43604. arc?: number;
  43605. faceColors?: Color4[];
  43606. faceUV?: Vector4[];
  43607. updatable?: boolean;
  43608. hasRings?: boolean;
  43609. enclose?: boolean;
  43610. cap?: number;
  43611. sideOrientation?: number;
  43612. frontUVs?: Vector4;
  43613. backUVs?: Vector4;
  43614. }, scene: any): Mesh;
  43615. }
  43616. }
  43617. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43618. import { Nullable } from "babylonjs/types";
  43619. import { IDisposable } from "babylonjs/scene";
  43620. /**
  43621. * States of the webXR experience
  43622. */
  43623. export enum WebXRState {
  43624. /**
  43625. * Transitioning to being in XR mode
  43626. */
  43627. ENTERING_XR = 0,
  43628. /**
  43629. * Transitioning to non XR mode
  43630. */
  43631. EXITING_XR = 1,
  43632. /**
  43633. * In XR mode and presenting
  43634. */
  43635. IN_XR = 2,
  43636. /**
  43637. * Not entered XR mode
  43638. */
  43639. NOT_IN_XR = 3
  43640. }
  43641. /**
  43642. * Abstraction of the XR render target
  43643. */
  43644. export interface WebXRRenderTarget extends IDisposable {
  43645. /**
  43646. * xrpresent context of the canvas which can be used to display/mirror xr content
  43647. */
  43648. canvasContext: WebGLRenderingContext;
  43649. /**
  43650. * xr layer for the canvas
  43651. */
  43652. xrLayer: Nullable<XRWebGLLayer>;
  43653. /**
  43654. * Initializes the xr layer for the session
  43655. * @param xrSession xr session
  43656. * @returns a promise that will resolve once the XR Layer has been created
  43657. */
  43658. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43659. }
  43660. }
  43661. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43662. import { Nullable } from "babylonjs/types";
  43663. import { Observable } from "babylonjs/Misc/observable";
  43664. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43665. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43666. /**
  43667. * COnfiguration object for WebXR output canvas
  43668. */
  43669. export class WebXRManagedOutputCanvasOptions {
  43670. /**
  43671. * Options for this XR Layer output
  43672. */
  43673. canvasOptions: XRWebGLLayerOptions;
  43674. /**
  43675. * CSS styling for a newly created canvas (if not provided)
  43676. */
  43677. newCanvasCssStyle?: string;
  43678. /**
  43679. * Get the default values of the configuration object
  43680. * @returns default values of this configuration object
  43681. */
  43682. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43683. }
  43684. /**
  43685. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43686. */
  43687. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43688. private configuration;
  43689. private _engine;
  43690. private _canvas;
  43691. /**
  43692. * xrpresent context of the canvas which can be used to display/mirror xr content
  43693. */
  43694. canvasContext: WebGLRenderingContext;
  43695. /**
  43696. * xr layer for the canvas
  43697. */
  43698. xrLayer: Nullable<XRWebGLLayer>;
  43699. /**
  43700. * Initializes the xr layer for the session
  43701. * @param xrSession xr session
  43702. * @returns a promise that will resolve once the XR Layer has been created
  43703. */
  43704. initializeXRLayerAsync(xrSession: any): any;
  43705. /**
  43706. * Initializes the canvas to be added/removed upon entering/exiting xr
  43707. * @param engine the Babylon engine
  43708. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43709. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43710. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43711. */
  43712. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43713. /**
  43714. * Disposes of the object
  43715. */
  43716. dispose(): void;
  43717. private _setManagedOutputCanvas;
  43718. private _addCanvas;
  43719. private _removeCanvas;
  43720. }
  43721. }
  43722. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43723. import { Observable } from "babylonjs/Misc/observable";
  43724. import { Nullable } from "babylonjs/types";
  43725. import { IDisposable, Scene } from "babylonjs/scene";
  43726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43727. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43728. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43729. /**
  43730. * Manages an XRSession to work with Babylon's engine
  43731. * @see https://doc.babylonjs.com/how_to/webxr
  43732. */
  43733. export class WebXRSessionManager implements IDisposable {
  43734. /** The scene which the session should be created for */
  43735. scene: Scene;
  43736. /**
  43737. * Fires every time a new xrFrame arrives which can be used to update the camera
  43738. */
  43739. onXRFrameObservable: Observable<XRFrame>;
  43740. /**
  43741. * Fires when the xr session is ended either by the device or manually done
  43742. */
  43743. onXRSessionEnded: Observable<any>;
  43744. /**
  43745. * Fires when the xr session is ended either by the device or manually done
  43746. */
  43747. onXRSessionInit: Observable<XRSession>;
  43748. /**
  43749. * Underlying xr session
  43750. */
  43751. session: XRSession;
  43752. /**
  43753. * Type of reference space used when creating the session
  43754. */
  43755. referenceSpace: XRReferenceSpace;
  43756. /**
  43757. * Current XR frame
  43758. */
  43759. currentFrame: Nullable<XRFrame>;
  43760. /** WebXR timestamp updated every frame */
  43761. currentTimestamp: number;
  43762. private _xrNavigator;
  43763. private baseLayer;
  43764. private _rttProvider;
  43765. private _sessionEnded;
  43766. /**
  43767. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43768. * @param scene The scene which the session should be created for
  43769. */
  43770. constructor(
  43771. /** The scene which the session should be created for */
  43772. scene: Scene);
  43773. /**
  43774. * Initializes the manager
  43775. * After initialization enterXR can be called to start an XR session
  43776. * @returns Promise which resolves after it is initialized
  43777. */
  43778. initializeAsync(): Promise<void>;
  43779. /**
  43780. * Initializes an xr session
  43781. * @param xrSessionMode mode to initialize
  43782. * @param optionalFeatures defines optional values to pass to the session builder
  43783. * @returns a promise which will resolve once the session has been initialized
  43784. */
  43785. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43786. /**
  43787. * Sets the reference space on the xr session
  43788. * @param referenceSpace space to set
  43789. * @returns a promise that will resolve once the reference space has been set
  43790. */
  43791. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43792. /**
  43793. * Updates the render state of the session
  43794. * @param state state to set
  43795. * @returns a promise that resolves once the render state has been updated
  43796. */
  43797. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43798. /**
  43799. * Starts rendering to the xr layer
  43800. * @returns a promise that will resolve once rendering has started
  43801. */
  43802. startRenderingToXRAsync(): Promise<void>;
  43803. /**
  43804. * Gets the correct render target texture to be rendered this frame for this eye
  43805. * @param eye the eye for which to get the render target
  43806. * @returns the render target for the specified eye
  43807. */
  43808. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43809. /**
  43810. * Stops the xrSession and restores the renderloop
  43811. * @returns Promise which resolves after it exits XR
  43812. */
  43813. exitXRAsync(): Promise<void>;
  43814. /**
  43815. * Checks if a session would be supported for the creation options specified
  43816. * @param sessionMode session mode to check if supported eg. immersive-vr
  43817. * @returns true if supported
  43818. */
  43819. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43820. /**
  43821. * Creates a WebXRRenderTarget object for the XR session
  43822. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43823. * @param options optional options to provide when creating a new render target
  43824. * @returns a WebXR render target to which the session can render
  43825. */
  43826. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43827. /**
  43828. * @hidden
  43829. * Converts the render layer of xrSession to a render target
  43830. * @param session session to create render target for
  43831. * @param scene scene the new render target should be created for
  43832. * @param baseLayer the webgl layer to create the render target for
  43833. */
  43834. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43835. /**
  43836. * Disposes of the session manager
  43837. */
  43838. dispose(): void;
  43839. /**
  43840. * Gets a promise returning true when fullfiled if the given session mode is supported
  43841. * @param sessionMode defines the session to test
  43842. * @returns a promise
  43843. */
  43844. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43845. }
  43846. }
  43847. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43848. import { Scene } from "babylonjs/scene";
  43849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43850. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43851. /**
  43852. * WebXR Camera which holds the views for the xrSession
  43853. * @see https://doc.babylonjs.com/how_to/webxr
  43854. */
  43855. export class WebXRCamera extends FreeCamera {
  43856. /**
  43857. * Is the camera in debug mode. Used when using an emulator
  43858. */
  43859. debugMode: boolean;
  43860. /**
  43861. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43862. * @param name the name of the camera
  43863. * @param scene the scene to add the camera to
  43864. */
  43865. constructor(name: string, scene: Scene);
  43866. private _updateNumberOfRigCameras;
  43867. /** @hidden */
  43868. _updateForDualEyeDebugging(): void;
  43869. /**
  43870. * Updates the cameras position from the current pose information of the XR session
  43871. * @param xrSessionManager the session containing pose information
  43872. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43873. */
  43874. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43875. }
  43876. }
  43877. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43878. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43879. import { IDisposable } from "babylonjs/scene";
  43880. /**
  43881. * Defining the interface required for a (webxr) feature
  43882. */
  43883. export interface IWebXRFeature extends IDisposable {
  43884. /**
  43885. * Attach the feature to the session
  43886. * Will usually be called by the features manager
  43887. *
  43888. * @returns true if successful.
  43889. */
  43890. attach(): boolean;
  43891. /**
  43892. * Detach the feature from the session
  43893. * Will usually be called by the features manager
  43894. *
  43895. * @returns true if successful.
  43896. */
  43897. detach(): boolean;
  43898. }
  43899. /**
  43900. * Defining the constructor of a feature. Used to register the modules.
  43901. */
  43902. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43903. /**
  43904. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43905. * It is mainly used in AR sessions.
  43906. *
  43907. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43908. */
  43909. export class WebXRFeaturesManager implements IDisposable {
  43910. private _xrSessionManager;
  43911. private static readonly _AvailableFeatures;
  43912. /**
  43913. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43914. * Mainly used internally.
  43915. *
  43916. * @param featureName the name of the feature to register
  43917. * @param constructorFunction the function used to construct the module
  43918. * @param version the (babylon) version of the module
  43919. * @param stable is that a stable version of this module
  43920. */
  43921. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43922. /**
  43923. * Returns a constructor of a specific feature.
  43924. *
  43925. * @param featureName the name of the feature to construct
  43926. * @param version the version of the feature to load
  43927. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43928. * @param options optional options provided to the module.
  43929. * @returns a function that, when called, will return a new instance of this feature
  43930. */
  43931. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43932. /**
  43933. * Return the latest unstable version of this feature
  43934. * @param featureName the name of the feature to search
  43935. * @returns the version number. if not found will return -1
  43936. */
  43937. static GetLatestVersionOfFeature(featureName: string): number;
  43938. /**
  43939. * Return the latest stable version of this feature
  43940. * @param featureName the name of the feature to search
  43941. * @returns the version number. if not found will return -1
  43942. */
  43943. static GetStableVersionOfFeature(featureName: string): number;
  43944. /**
  43945. * Can be used to return the list of features currently registered
  43946. *
  43947. * @returns an Array of available features
  43948. */
  43949. static GetAvailableFeatures(): string[];
  43950. /**
  43951. * Gets the versions available for a specific feature
  43952. * @param featureName the name of the feature
  43953. * @returns an array with the available versions
  43954. */
  43955. static GetAvailableVersions(featureName: string): string[];
  43956. private _features;
  43957. /**
  43958. * constructs a new features manages.
  43959. *
  43960. * @param _xrSessionManager an instance of WebXRSessionManager
  43961. */
  43962. constructor(_xrSessionManager: WebXRSessionManager);
  43963. /**
  43964. * 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.
  43965. *
  43966. * @param featureName the name of the feature to load or the class of the feature
  43967. * @param version optional version to load. if not provided the latest version will be enabled
  43968. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43969. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43970. * @returns a new constructed feature or throws an error if feature not found.
  43971. */
  43972. enableFeature(featureName: string | {
  43973. Name: string;
  43974. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43975. /**
  43976. * Used to disable an already-enabled feature
  43977. * @param featureName the feature to disable
  43978. * @returns true if disable was successful
  43979. */
  43980. disableFeature(featureName: string | {
  43981. Name: string;
  43982. }): boolean;
  43983. /**
  43984. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43985. * Can be used during a session to start a feature
  43986. * @param featureName the name of feature to attach
  43987. */
  43988. attachFeature(featureName: string): void;
  43989. /**
  43990. * Can be used inside a session or when the session ends to detach a specific feature
  43991. * @param featureName the name of the feature to detach
  43992. */
  43993. detachFeature(featureName: string): void;
  43994. /**
  43995. * Get the list of enabled features
  43996. * @returns an array of enabled features
  43997. */
  43998. getEnabledFeatures(): string[];
  43999. /**
  44000. * get the implementation of an enabled feature.
  44001. * @param featureName the name of the feature to load
  44002. * @returns the feature class, if found
  44003. */
  44004. getEnabledFeature(featureName: string): IWebXRFeature;
  44005. /**
  44006. * dispose this features manager
  44007. */
  44008. dispose(): void;
  44009. }
  44010. }
  44011. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44012. import { Observable } from "babylonjs/Misc/observable";
  44013. import { IDisposable, Scene } from "babylonjs/scene";
  44014. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44016. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44017. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44018. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44019. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44020. /**
  44021. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44022. * @see https://doc.babylonjs.com/how_to/webxr
  44023. */
  44024. export class WebXRExperienceHelper implements IDisposable {
  44025. private scene;
  44026. /**
  44027. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  44028. */
  44029. container: AbstractMesh;
  44030. /**
  44031. * Camera used to render xr content
  44032. */
  44033. camera: WebXRCamera;
  44034. /**
  44035. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44036. */
  44037. state: WebXRState;
  44038. private _setState;
  44039. private static _TmpVector;
  44040. /**
  44041. * Fires when the state of the experience helper has changed
  44042. */
  44043. onStateChangedObservable: Observable<WebXRState>;
  44044. /** Session manager used to keep track of xr session */
  44045. sessionManager: WebXRSessionManager;
  44046. /** A features manager for this xr session */
  44047. featuresManager: WebXRFeaturesManager;
  44048. private _nonVRCamera;
  44049. private _originalSceneAutoClear;
  44050. private _supported;
  44051. /**
  44052. * Creates the experience helper
  44053. * @param scene the scene to attach the experience helper to
  44054. * @returns a promise for the experience helper
  44055. */
  44056. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44057. /**
  44058. * Creates a WebXRExperienceHelper
  44059. * @param scene The scene the helper should be created in
  44060. */
  44061. private constructor();
  44062. /**
  44063. * Exits XR mode and returns the scene to its original state
  44064. * @returns promise that resolves after xr mode has exited
  44065. */
  44066. exitXRAsync(): Promise<void>;
  44067. /**
  44068. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44069. * @param sessionMode options for the XR session
  44070. * @param referenceSpaceType frame of reference of the XR session
  44071. * @param renderTarget the output canvas that will be used to enter XR mode
  44072. * @returns promise that resolves after xr mode has entered
  44073. */
  44074. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44075. /**
  44076. * Updates the global position of the camera by moving the camera's container
  44077. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44078. * @param position The desired global position of the camera
  44079. */
  44080. setPositionOfCameraUsingContainer(position: Vector3): void;
  44081. /**
  44082. * Rotates the xr camera by rotating the camera's container around the camera's position
  44083. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44084. * @param rotation the desired quaternion rotation to apply to the camera
  44085. */
  44086. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44087. /**
  44088. * Disposes of the experience helper
  44089. */
  44090. dispose(): void;
  44091. }
  44092. }
  44093. declare module "babylonjs/Cameras/XR/webXRController" {
  44094. import { Nullable } from "babylonjs/types";
  44095. import { Observable } from "babylonjs/Misc/observable";
  44096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44097. import { Ray } from "babylonjs/Culling/ray";
  44098. import { Scene } from "babylonjs/scene";
  44099. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44100. /**
  44101. * Represents an XR input
  44102. */
  44103. export class WebXRController {
  44104. private scene;
  44105. /** The underlying input source for the controller */
  44106. inputSource: XRInputSource;
  44107. private parentContainer;
  44108. /**
  44109. * 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
  44110. */
  44111. grip?: AbstractMesh;
  44112. /**
  44113. * Pointer which can be used to select objects or attach a visible laser to
  44114. */
  44115. pointer: AbstractMesh;
  44116. private _gamepadMode;
  44117. /**
  44118. * If available, this is the gamepad object related to this controller.
  44119. * Using this object it is possible to get click events and trackpad changes of the
  44120. * webxr controller that is currently being used.
  44121. */
  44122. gamepadController?: WebVRController;
  44123. /**
  44124. * Event that fires when the controller is removed/disposed
  44125. */
  44126. onDisposeObservable: Observable<{}>;
  44127. private _tmpQuaternion;
  44128. private _tmpVector;
  44129. /**
  44130. * Creates the controller
  44131. * @see https://doc.babylonjs.com/how_to/webxr
  44132. * @param scene the scene which the controller should be associated to
  44133. * @param inputSource the underlying input source for the controller
  44134. * @param parentContainer parent that the controller meshes should be children of
  44135. */
  44136. constructor(scene: Scene,
  44137. /** The underlying input source for the controller */
  44138. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44139. /**
  44140. * Updates the controller pose based on the given XRFrame
  44141. * @param xrFrame xr frame to update the pose with
  44142. * @param referenceSpace reference space to use
  44143. */
  44144. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44145. /**
  44146. * Gets a world space ray coming from the controller
  44147. * @param result the resulting ray
  44148. */
  44149. getWorldPointerRayToRef(result: Ray): void;
  44150. /**
  44151. * Get the scene associated with this controller
  44152. * @returns the scene object
  44153. */
  44154. getScene(): Scene;
  44155. /**
  44156. * Disposes of the object
  44157. */
  44158. dispose(): void;
  44159. }
  44160. }
  44161. declare module "babylonjs/Cameras/XR/webXRInput" {
  44162. import { Observable } from "babylonjs/Misc/observable";
  44163. import { IDisposable } from "babylonjs/scene";
  44164. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44165. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44166. /**
  44167. * XR input used to track XR inputs such as controllers/rays
  44168. */
  44169. export class WebXRInput implements IDisposable {
  44170. /**
  44171. * Base experience the input listens to
  44172. */
  44173. baseExperience: WebXRExperienceHelper;
  44174. /**
  44175. * XR controllers being tracked
  44176. */
  44177. controllers: Array<WebXRController>;
  44178. private _frameObserver;
  44179. private _stateObserver;
  44180. /**
  44181. * Event when a controller has been connected/added
  44182. */
  44183. onControllerAddedObservable: Observable<WebXRController>;
  44184. /**
  44185. * Event when a controller has been removed/disconnected
  44186. */
  44187. onControllerRemovedObservable: Observable<WebXRController>;
  44188. /**
  44189. * Initializes the WebXRInput
  44190. * @param baseExperience experience helper which the input should be created for
  44191. */
  44192. constructor(
  44193. /**
  44194. * Base experience the input listens to
  44195. */
  44196. baseExperience: WebXRExperienceHelper);
  44197. private _onInputSourcesChange;
  44198. private _addAndRemoveControllers;
  44199. /**
  44200. * Disposes of the object
  44201. */
  44202. dispose(): void;
  44203. }
  44204. }
  44205. declare module "babylonjs/Loading/sceneLoader" {
  44206. import { Observable } from "babylonjs/Misc/observable";
  44207. import { Nullable } from "babylonjs/types";
  44208. import { Scene } from "babylonjs/scene";
  44209. import { Engine } from "babylonjs/Engines/engine";
  44210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44211. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44212. import { AssetContainer } from "babylonjs/assetContainer";
  44213. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44214. import { Skeleton } from "babylonjs/Bones/skeleton";
  44215. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44216. import { WebRequest } from "babylonjs/Misc/webRequest";
  44217. /**
  44218. * Class used to represent data loading progression
  44219. */
  44220. export class SceneLoaderProgressEvent {
  44221. /** defines if data length to load can be evaluated */
  44222. readonly lengthComputable: boolean;
  44223. /** defines the loaded data length */
  44224. readonly loaded: number;
  44225. /** defines the data length to load */
  44226. readonly total: number;
  44227. /**
  44228. * Create a new progress event
  44229. * @param lengthComputable defines if data length to load can be evaluated
  44230. * @param loaded defines the loaded data length
  44231. * @param total defines the data length to load
  44232. */
  44233. constructor(
  44234. /** defines if data length to load can be evaluated */
  44235. lengthComputable: boolean,
  44236. /** defines the loaded data length */
  44237. loaded: number,
  44238. /** defines the data length to load */
  44239. total: number);
  44240. /**
  44241. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44242. * @param event defines the source event
  44243. * @returns a new SceneLoaderProgressEvent
  44244. */
  44245. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44246. }
  44247. /**
  44248. * Interface used by SceneLoader plugins to define supported file extensions
  44249. */
  44250. export interface ISceneLoaderPluginExtensions {
  44251. /**
  44252. * Defines the list of supported extensions
  44253. */
  44254. [extension: string]: {
  44255. isBinary: boolean;
  44256. };
  44257. }
  44258. /**
  44259. * Interface used by SceneLoader plugin factory
  44260. */
  44261. export interface ISceneLoaderPluginFactory {
  44262. /**
  44263. * Defines the name of the factory
  44264. */
  44265. name: string;
  44266. /**
  44267. * Function called to create a new plugin
  44268. * @return the new plugin
  44269. */
  44270. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44271. /**
  44272. * The callback that returns true if the data can be directly loaded.
  44273. * @param data string containing the file data
  44274. * @returns if the data can be loaded directly
  44275. */
  44276. canDirectLoad?(data: string): boolean;
  44277. }
  44278. /**
  44279. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44280. */
  44281. export interface ISceneLoaderPluginBase {
  44282. /**
  44283. * The friendly name of this plugin.
  44284. */
  44285. name: string;
  44286. /**
  44287. * The file extensions supported by this plugin.
  44288. */
  44289. extensions: string | ISceneLoaderPluginExtensions;
  44290. /**
  44291. * The callback called when loading from a url.
  44292. * @param scene scene loading this url
  44293. * @param url url to load
  44294. * @param onSuccess callback called when the file successfully loads
  44295. * @param onProgress callback called while file is loading (if the server supports this mode)
  44296. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44297. * @param onError callback called when the file fails to load
  44298. * @returns a file request object
  44299. */
  44300. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44301. /**
  44302. * The callback called when loading from a file object.
  44303. * @param scene scene loading this file
  44304. * @param file defines the file to load
  44305. * @param onSuccess defines the callback to call when data is loaded
  44306. * @param onProgress defines the callback to call during loading process
  44307. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44308. * @param onError defines the callback to call when an error occurs
  44309. * @returns a file request object
  44310. */
  44311. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44312. /**
  44313. * The callback that returns true if the data can be directly loaded.
  44314. * @param data string containing the file data
  44315. * @returns if the data can be loaded directly
  44316. */
  44317. canDirectLoad?(data: string): boolean;
  44318. /**
  44319. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44320. * @param scene scene loading this data
  44321. * @param data string containing the data
  44322. * @returns data to pass to the plugin
  44323. */
  44324. directLoad?(scene: Scene, data: string): any;
  44325. /**
  44326. * The callback that allows custom handling of the root url based on the response url.
  44327. * @param rootUrl the original root url
  44328. * @param responseURL the response url if available
  44329. * @returns the new root url
  44330. */
  44331. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44332. }
  44333. /**
  44334. * Interface used to define a SceneLoader plugin
  44335. */
  44336. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44337. /**
  44338. * Import meshes into a scene.
  44339. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44340. * @param scene The scene to import into
  44341. * @param data The data to import
  44342. * @param rootUrl The root url for scene and resources
  44343. * @param meshes The meshes array to import into
  44344. * @param particleSystems The particle systems array to import into
  44345. * @param skeletons The skeletons array to import into
  44346. * @param onError The callback when import fails
  44347. * @returns True if successful or false otherwise
  44348. */
  44349. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44350. /**
  44351. * Load into a scene.
  44352. * @param scene The scene to load into
  44353. * @param data The data to import
  44354. * @param rootUrl The root url for scene and resources
  44355. * @param onError The callback when import fails
  44356. * @returns True if successful or false otherwise
  44357. */
  44358. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44359. /**
  44360. * Load into an asset container.
  44361. * @param scene The scene to load into
  44362. * @param data The data to import
  44363. * @param rootUrl The root url for scene and resources
  44364. * @param onError The callback when import fails
  44365. * @returns The loaded asset container
  44366. */
  44367. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44368. }
  44369. /**
  44370. * Interface used to define an async SceneLoader plugin
  44371. */
  44372. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44373. /**
  44374. * Import meshes into a scene.
  44375. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44376. * @param scene The scene to import into
  44377. * @param data The data to import
  44378. * @param rootUrl The root url for scene and resources
  44379. * @param onProgress The callback when the load progresses
  44380. * @param fileName Defines the name of the file to load
  44381. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44382. */
  44383. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44384. meshes: AbstractMesh[];
  44385. particleSystems: IParticleSystem[];
  44386. skeletons: Skeleton[];
  44387. animationGroups: AnimationGroup[];
  44388. }>;
  44389. /**
  44390. * Load into a scene.
  44391. * @param scene The scene to load into
  44392. * @param data The data to import
  44393. * @param rootUrl The root url for scene and resources
  44394. * @param onProgress The callback when the load progresses
  44395. * @param fileName Defines the name of the file to load
  44396. * @returns Nothing
  44397. */
  44398. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44399. /**
  44400. * Load into an asset container.
  44401. * @param scene The scene to load into
  44402. * @param data The data to import
  44403. * @param rootUrl The root url for scene and resources
  44404. * @param onProgress The callback when the load progresses
  44405. * @param fileName Defines the name of the file to load
  44406. * @returns The loaded asset container
  44407. */
  44408. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44409. }
  44410. /**
  44411. * Mode that determines how to handle old animation groups before loading new ones.
  44412. */
  44413. export enum SceneLoaderAnimationGroupLoadingMode {
  44414. /**
  44415. * Reset all old animations to initial state then dispose them.
  44416. */
  44417. Clean = 0,
  44418. /**
  44419. * Stop all old animations.
  44420. */
  44421. Stop = 1,
  44422. /**
  44423. * Restart old animations from first frame.
  44424. */
  44425. Sync = 2,
  44426. /**
  44427. * Old animations remains untouched.
  44428. */
  44429. NoSync = 3
  44430. }
  44431. /**
  44432. * Class used to load scene from various file formats using registered plugins
  44433. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44434. */
  44435. export class SceneLoader {
  44436. /**
  44437. * No logging while loading
  44438. */
  44439. static readonly NO_LOGGING: number;
  44440. /**
  44441. * Minimal logging while loading
  44442. */
  44443. static readonly MINIMAL_LOGGING: number;
  44444. /**
  44445. * Summary logging while loading
  44446. */
  44447. static readonly SUMMARY_LOGGING: number;
  44448. /**
  44449. * Detailled logging while loading
  44450. */
  44451. static readonly DETAILED_LOGGING: number;
  44452. /**
  44453. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44454. */
  44455. static get ForceFullSceneLoadingForIncremental(): boolean;
  44456. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44457. /**
  44458. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44459. */
  44460. static get ShowLoadingScreen(): boolean;
  44461. static set ShowLoadingScreen(value: boolean);
  44462. /**
  44463. * Defines the current logging level (while loading the scene)
  44464. * @ignorenaming
  44465. */
  44466. static get loggingLevel(): number;
  44467. static set loggingLevel(value: number);
  44468. /**
  44469. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44470. */
  44471. static get CleanBoneMatrixWeights(): boolean;
  44472. static set CleanBoneMatrixWeights(value: boolean);
  44473. /**
  44474. * Event raised when a plugin is used to load a scene
  44475. */
  44476. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44477. private static _registeredPlugins;
  44478. private static _getDefaultPlugin;
  44479. private static _getPluginForExtension;
  44480. private static _getPluginForDirectLoad;
  44481. private static _getPluginForFilename;
  44482. private static _getDirectLoad;
  44483. private static _loadData;
  44484. private static _getFileInfo;
  44485. /**
  44486. * Gets a plugin that can load the given extension
  44487. * @param extension defines the extension to load
  44488. * @returns a plugin or null if none works
  44489. */
  44490. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44491. /**
  44492. * Gets a boolean indicating that the given extension can be loaded
  44493. * @param extension defines the extension to load
  44494. * @returns true if the extension is supported
  44495. */
  44496. static IsPluginForExtensionAvailable(extension: string): boolean;
  44497. /**
  44498. * Adds a new plugin to the list of registered plugins
  44499. * @param plugin defines the plugin to add
  44500. */
  44501. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44502. /**
  44503. * Import meshes into a scene
  44504. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44505. * @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)
  44506. * @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)
  44507. * @param scene the instance of BABYLON.Scene to append to
  44508. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44509. * @param onProgress a callback with a progress event for each file being loaded
  44510. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44511. * @param pluginExtension the extension used to determine the plugin
  44512. * @returns The loaded plugin
  44513. */
  44514. 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>;
  44515. /**
  44516. * Import meshes into a scene
  44517. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44518. * @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)
  44519. * @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)
  44520. * @param scene the instance of BABYLON.Scene to append to
  44521. * @param onProgress a callback with a progress event for each file being loaded
  44522. * @param pluginExtension the extension used to determine the plugin
  44523. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44524. */
  44525. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44526. meshes: AbstractMesh[];
  44527. particleSystems: IParticleSystem[];
  44528. skeletons: Skeleton[];
  44529. animationGroups: AnimationGroup[];
  44530. }>;
  44531. /**
  44532. * Load a scene
  44533. * @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)
  44534. * @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)
  44535. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44536. * @param onSuccess a callback with the scene when import succeeds
  44537. * @param onProgress a callback with a progress event for each file being loaded
  44538. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44539. * @param pluginExtension the extension used to determine the plugin
  44540. * @returns The loaded plugin
  44541. */
  44542. 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>;
  44543. /**
  44544. * Load a scene
  44545. * @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)
  44546. * @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)
  44547. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44548. * @param onProgress a callback with a progress event for each file being loaded
  44549. * @param pluginExtension the extension used to determine the plugin
  44550. * @returns The loaded scene
  44551. */
  44552. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44553. /**
  44554. * Append a scene
  44555. * @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)
  44556. * @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)
  44557. * @param scene is the instance of BABYLON.Scene to append to
  44558. * @param onSuccess a callback with the scene when import succeeds
  44559. * @param onProgress a callback with a progress event for each file being loaded
  44560. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44561. * @param pluginExtension the extension used to determine the plugin
  44562. * @returns The loaded plugin
  44563. */
  44564. 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>;
  44565. /**
  44566. * Append a scene
  44567. * @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)
  44568. * @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)
  44569. * @param scene is the instance of BABYLON.Scene to append to
  44570. * @param onProgress a callback with a progress event for each file being loaded
  44571. * @param pluginExtension the extension used to determine the plugin
  44572. * @returns The given scene
  44573. */
  44574. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44575. /**
  44576. * Load a scene into an asset container
  44577. * @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)
  44578. * @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)
  44579. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44580. * @param onSuccess a callback with the scene when import succeeds
  44581. * @param onProgress a callback with a progress event for each file being loaded
  44582. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44583. * @param pluginExtension the extension used to determine the plugin
  44584. * @returns The loaded plugin
  44585. */
  44586. 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>;
  44587. /**
  44588. * Load a scene into an asset container
  44589. * @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)
  44590. * @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)
  44591. * @param scene is the instance of Scene to append to
  44592. * @param onProgress a callback with a progress event for each file being loaded
  44593. * @param pluginExtension the extension used to determine the plugin
  44594. * @returns The loaded asset container
  44595. */
  44596. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44597. /**
  44598. * Import animations from a file into a scene
  44599. * @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)
  44600. * @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)
  44601. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44602. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44603. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44604. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44605. * @param onSuccess a callback with the scene when import succeeds
  44606. * @param onProgress a callback with a progress event for each file being loaded
  44607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44608. */
  44609. 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;
  44610. /**
  44611. * Import animations from a file into a scene
  44612. * @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)
  44613. * @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)
  44614. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44615. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44616. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44617. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44618. * @param onSuccess a callback with the scene when import succeeds
  44619. * @param onProgress a callback with a progress event for each file being loaded
  44620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44621. * @returns the updated scene with imported animations
  44622. */
  44623. 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>;
  44624. }
  44625. }
  44626. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44627. import { Scene } from "babylonjs/scene";
  44628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44629. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44630. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44631. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44632. /**
  44633. * Generic Controller
  44634. */
  44635. export class GenericController extends WebVRController {
  44636. /**
  44637. * Base Url for the controller model.
  44638. */
  44639. static readonly MODEL_BASE_URL: string;
  44640. /**
  44641. * File name for the controller model.
  44642. */
  44643. static readonly MODEL_FILENAME: string;
  44644. /**
  44645. * Creates a new GenericController from a gamepad
  44646. * @param vrGamepad the gamepad that the controller should be created from
  44647. */
  44648. constructor(vrGamepad: any);
  44649. /**
  44650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44651. * @param scene scene in which to add meshes
  44652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44653. */
  44654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44655. /**
  44656. * Called once for each button that changed state since the last frame
  44657. * @param buttonIdx Which button index changed
  44658. * @param state New state of the button
  44659. * @param changes Which properties on the state changed since last frame
  44660. */
  44661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44662. }
  44663. }
  44664. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44665. import { Observable } from "babylonjs/Misc/observable";
  44666. import { Scene } from "babylonjs/scene";
  44667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44668. import { Ray } from "babylonjs/Culling/ray";
  44669. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44670. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44671. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44672. /**
  44673. * Defines the WindowsMotionController object that the state of the windows motion controller
  44674. */
  44675. export class WindowsMotionController extends WebVRController {
  44676. /**
  44677. * The base url used to load the left and right controller models
  44678. */
  44679. static MODEL_BASE_URL: string;
  44680. /**
  44681. * The name of the left controller model file
  44682. */
  44683. static MODEL_LEFT_FILENAME: string;
  44684. /**
  44685. * The name of the right controller model file
  44686. */
  44687. static MODEL_RIGHT_FILENAME: string;
  44688. /**
  44689. * The controller name prefix for this controller type
  44690. */
  44691. static readonly GAMEPAD_ID_PREFIX: string;
  44692. /**
  44693. * The controller id pattern for this controller type
  44694. */
  44695. private static readonly GAMEPAD_ID_PATTERN;
  44696. private _loadedMeshInfo;
  44697. protected readonly _mapping: {
  44698. buttons: string[];
  44699. buttonMeshNames: {
  44700. 'trigger': string;
  44701. 'menu': string;
  44702. 'grip': string;
  44703. 'thumbstick': string;
  44704. 'trackpad': string;
  44705. };
  44706. buttonObservableNames: {
  44707. 'trigger': string;
  44708. 'menu': string;
  44709. 'grip': string;
  44710. 'thumbstick': string;
  44711. 'trackpad': string;
  44712. };
  44713. axisMeshNames: string[];
  44714. pointingPoseMeshName: string;
  44715. };
  44716. /**
  44717. * Fired when the trackpad on this controller is clicked
  44718. */
  44719. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44720. /**
  44721. * Fired when the trackpad on this controller is modified
  44722. */
  44723. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44724. /**
  44725. * The current x and y values of this controller's trackpad
  44726. */
  44727. trackpad: StickValues;
  44728. /**
  44729. * Creates a new WindowsMotionController from a gamepad
  44730. * @param vrGamepad the gamepad that the controller should be created from
  44731. */
  44732. constructor(vrGamepad: any);
  44733. /**
  44734. * Fired when the trigger on this controller is modified
  44735. */
  44736. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44737. /**
  44738. * Fired when the menu button on this controller is modified
  44739. */
  44740. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44741. /**
  44742. * Fired when the grip button on this controller is modified
  44743. */
  44744. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44745. /**
  44746. * Fired when the thumbstick button on this controller is modified
  44747. */
  44748. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44749. /**
  44750. * Fired when the touchpad button on this controller is modified
  44751. */
  44752. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44753. /**
  44754. * Fired when the touchpad values on this controller are modified
  44755. */
  44756. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44757. protected _updateTrackpad(): void;
  44758. /**
  44759. * Called once per frame by the engine.
  44760. */
  44761. update(): void;
  44762. /**
  44763. * Called once for each button that changed state since the last frame
  44764. * @param buttonIdx Which button index changed
  44765. * @param state New state of the button
  44766. * @param changes Which properties on the state changed since last frame
  44767. */
  44768. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44769. /**
  44770. * Moves the buttons on the controller mesh based on their current state
  44771. * @param buttonName the name of the button to move
  44772. * @param buttonValue the value of the button which determines the buttons new position
  44773. */
  44774. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44775. /**
  44776. * Moves the axis on the controller mesh based on its current state
  44777. * @param axis the index of the axis
  44778. * @param axisValue the value of the axis which determines the meshes new position
  44779. * @hidden
  44780. */
  44781. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44782. /**
  44783. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44784. * @param scene scene in which to add meshes
  44785. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44786. */
  44787. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44788. /**
  44789. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44790. * can be transformed by button presses and axes values, based on this._mapping.
  44791. *
  44792. * @param scene scene in which the meshes exist
  44793. * @param meshes list of meshes that make up the controller model to process
  44794. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44795. */
  44796. private processModel;
  44797. private createMeshInfo;
  44798. /**
  44799. * Gets the ray of the controller in the direction the controller is pointing
  44800. * @param length the length the resulting ray should be
  44801. * @returns a ray in the direction the controller is pointing
  44802. */
  44803. getForwardRay(length?: number): Ray;
  44804. /**
  44805. * Disposes of the controller
  44806. */
  44807. dispose(): void;
  44808. }
  44809. /**
  44810. * This class represents a new windows motion controller in XR.
  44811. */
  44812. export class XRWindowsMotionController extends WindowsMotionController {
  44813. /**
  44814. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44815. */
  44816. protected readonly _mapping: {
  44817. buttons: string[];
  44818. buttonMeshNames: {
  44819. 'trigger': string;
  44820. 'menu': string;
  44821. 'grip': string;
  44822. 'thumbstick': string;
  44823. 'trackpad': string;
  44824. };
  44825. buttonObservableNames: {
  44826. 'trigger': string;
  44827. 'menu': string;
  44828. 'grip': string;
  44829. 'thumbstick': string;
  44830. 'trackpad': string;
  44831. };
  44832. axisMeshNames: string[];
  44833. pointingPoseMeshName: string;
  44834. };
  44835. /**
  44836. * Construct a new XR-Based windows motion controller
  44837. *
  44838. * @param gamepadInfo the gamepad object from the browser
  44839. */
  44840. constructor(gamepadInfo: any);
  44841. /**
  44842. * holds the thumbstick values (X,Y)
  44843. */
  44844. thumbstickValues: StickValues;
  44845. /**
  44846. * Fired when the thumbstick on this controller is clicked
  44847. */
  44848. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44849. /**
  44850. * Fired when the thumbstick on this controller is modified
  44851. */
  44852. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44853. /**
  44854. * Fired when the touchpad button on this controller is modified
  44855. */
  44856. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44857. /**
  44858. * Fired when the touchpad values on this controller are modified
  44859. */
  44860. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44861. /**
  44862. * Fired when the thumbstick button on this controller is modified
  44863. * here to prevent breaking changes
  44864. */
  44865. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44866. /**
  44867. * updating the thumbstick(!) and not the trackpad.
  44868. * This is named this way due to the difference between WebVR and XR and to avoid
  44869. * changing the parent class.
  44870. */
  44871. protected _updateTrackpad(): void;
  44872. /**
  44873. * Disposes the class with joy
  44874. */
  44875. dispose(): void;
  44876. }
  44877. }
  44878. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44879. import { Observable } from "babylonjs/Misc/observable";
  44880. import { Scene } from "babylonjs/scene";
  44881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44882. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44883. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44884. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44885. /**
  44886. * Oculus Touch Controller
  44887. */
  44888. export class OculusTouchController extends WebVRController {
  44889. /**
  44890. * Base Url for the controller model.
  44891. */
  44892. static MODEL_BASE_URL: string;
  44893. /**
  44894. * File name for the left controller model.
  44895. */
  44896. static MODEL_LEFT_FILENAME: string;
  44897. /**
  44898. * File name for the right controller model.
  44899. */
  44900. static MODEL_RIGHT_FILENAME: string;
  44901. /**
  44902. * Base Url for the Quest controller model.
  44903. */
  44904. static QUEST_MODEL_BASE_URL: string;
  44905. /**
  44906. * @hidden
  44907. * If the controllers are running on a device that needs the updated Quest controller models
  44908. */
  44909. static _IsQuest: boolean;
  44910. /**
  44911. * Fired when the secondary trigger on this controller is modified
  44912. */
  44913. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44914. /**
  44915. * Fired when the thumb rest on this controller is modified
  44916. */
  44917. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44918. /**
  44919. * Creates a new OculusTouchController from a gamepad
  44920. * @param vrGamepad the gamepad that the controller should be created from
  44921. */
  44922. constructor(vrGamepad: any);
  44923. /**
  44924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44925. * @param scene scene in which to add meshes
  44926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44927. */
  44928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44929. /**
  44930. * Fired when the A button on this controller is modified
  44931. */
  44932. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44933. /**
  44934. * Fired when the B button on this controller is modified
  44935. */
  44936. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44937. /**
  44938. * Fired when the X button on this controller is modified
  44939. */
  44940. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44941. /**
  44942. * Fired when the Y button on this controller is modified
  44943. */
  44944. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44945. /**
  44946. * Called once for each button that changed state since the last frame
  44947. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44948. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44949. * 2) secondary trigger (same)
  44950. * 3) A (right) X (left), touch, pressed = value
  44951. * 4) B / Y
  44952. * 5) thumb rest
  44953. * @param buttonIdx Which button index changed
  44954. * @param state New state of the button
  44955. * @param changes Which properties on the state changed since last frame
  44956. */
  44957. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44958. }
  44959. }
  44960. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44961. import { Scene } from "babylonjs/scene";
  44962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44963. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44964. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44965. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44966. import { Observable } from "babylonjs/Misc/observable";
  44967. /**
  44968. * Vive Controller
  44969. */
  44970. export class ViveController extends WebVRController {
  44971. /**
  44972. * Base Url for the controller model.
  44973. */
  44974. static MODEL_BASE_URL: string;
  44975. /**
  44976. * File name for the controller model.
  44977. */
  44978. static MODEL_FILENAME: string;
  44979. /**
  44980. * Creates a new ViveController from a gamepad
  44981. * @param vrGamepad the gamepad that the controller should be created from
  44982. */
  44983. constructor(vrGamepad: any);
  44984. /**
  44985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44986. * @param scene scene in which to add meshes
  44987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44988. */
  44989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44990. /**
  44991. * Fired when the left button on this controller is modified
  44992. */
  44993. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44994. /**
  44995. * Fired when the right button on this controller is modified
  44996. */
  44997. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44998. /**
  44999. * Fired when the menu button on this controller is modified
  45000. */
  45001. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45002. /**
  45003. * Called once for each button that changed state since the last frame
  45004. * Vive mapping:
  45005. * 0: touchpad
  45006. * 1: trigger
  45007. * 2: left AND right buttons
  45008. * 3: menu button
  45009. * @param buttonIdx Which button index changed
  45010. * @param state New state of the button
  45011. * @param changes Which properties on the state changed since last frame
  45012. */
  45013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45014. }
  45015. }
  45016. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45017. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45018. import { Observable } from "babylonjs/Misc/observable";
  45019. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45020. /**
  45021. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45022. */
  45023. export class WebXRControllerModelLoader {
  45024. /**
  45025. * an observable that triggers when a new model (the mesh itself) was initialized.
  45026. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45027. */
  45028. onControllerModelLoaded: Observable<WebXRController>;
  45029. /**
  45030. * Creates the WebXRControllerModelLoader
  45031. * @param input xr input that creates the controllers
  45032. */
  45033. constructor(input: WebXRInput);
  45034. }
  45035. }
  45036. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45037. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45038. /**
  45039. * Handles pointer input automatically for the pointer of XR controllers
  45040. */
  45041. export class WebXRControllerPointerSelection {
  45042. private static _idCounter;
  45043. private _tmpRay;
  45044. /**
  45045. * Creates a WebXRControllerPointerSelection
  45046. * @param input input manager to setup pointer selection
  45047. */
  45048. constructor(input: WebXRInput);
  45049. private _convertNormalToDirectionOfRay;
  45050. private _updatePointerDistance;
  45051. }
  45052. }
  45053. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45055. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45056. /**
  45057. * Enables teleportation
  45058. */
  45059. export class WebXRControllerTeleportation {
  45060. private _teleportationFillColor;
  45061. private _teleportationBorderColor;
  45062. private _tmpRay;
  45063. private _tmpVector;
  45064. /**
  45065. * when set to true (default) teleportation will wait for thumbstick changes.
  45066. * When set to false teleportation will be disabled.
  45067. *
  45068. * If set to false while teleporting results can be unexpected.
  45069. */
  45070. enabled: boolean;
  45071. /**
  45072. * Creates a WebXRControllerTeleportation
  45073. * @param input input manager to add teleportation to
  45074. * @param floorMeshes floormeshes which can be teleported to
  45075. */
  45076. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45077. }
  45078. }
  45079. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45080. import { Nullable } from "babylonjs/types";
  45081. import { Observable } from "babylonjs/Misc/observable";
  45082. import { IDisposable, Scene } from "babylonjs/scene";
  45083. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45084. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45085. /**
  45086. * Button which can be used to enter a different mode of XR
  45087. */
  45088. export class WebXREnterExitUIButton {
  45089. /** button element */
  45090. element: HTMLElement;
  45091. /** XR initialization options for the button */
  45092. sessionMode: XRSessionMode;
  45093. /** Reference space type */
  45094. referenceSpaceType: XRReferenceSpaceType;
  45095. /**
  45096. * Creates a WebXREnterExitUIButton
  45097. * @param element button element
  45098. * @param sessionMode XR initialization session mode
  45099. * @param referenceSpaceType the type of reference space to be used
  45100. */
  45101. constructor(
  45102. /** button element */
  45103. element: HTMLElement,
  45104. /** XR initialization options for the button */
  45105. sessionMode: XRSessionMode,
  45106. /** Reference space type */
  45107. referenceSpaceType: XRReferenceSpaceType);
  45108. /**
  45109. * Overwritable function which can be used to update the button's visuals when the state changes
  45110. * @param activeButton the current active button in the UI
  45111. */
  45112. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45113. }
  45114. /**
  45115. * Options to create the webXR UI
  45116. */
  45117. export class WebXREnterExitUIOptions {
  45118. /**
  45119. * Context to enter xr with
  45120. */
  45121. renderTarget?: Nullable<WebXRRenderTarget>;
  45122. /**
  45123. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45124. */
  45125. customButtons?: Array<WebXREnterExitUIButton>;
  45126. /**
  45127. * A session mode to use when creating the default button.
  45128. * Default is immersive-vr
  45129. */
  45130. sessionMode?: XRSessionMode;
  45131. /**
  45132. * A reference space type to use when creating the default button.
  45133. * Default is local-floor
  45134. */
  45135. referenceSpaceType?: XRReferenceSpaceType;
  45136. }
  45137. /**
  45138. * UI to allow the user to enter/exit XR mode
  45139. */
  45140. export class WebXREnterExitUI implements IDisposable {
  45141. private scene;
  45142. /** version of the options passed to this UI */
  45143. options: WebXREnterExitUIOptions;
  45144. private _overlay;
  45145. private _buttons;
  45146. private _activeButton;
  45147. /**
  45148. * Fired every time the active button is changed.
  45149. *
  45150. * When xr is entered via a button that launches xr that button will be the callback parameter
  45151. *
  45152. * When exiting xr the callback parameter will be null)
  45153. */
  45154. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45155. /**
  45156. * Creates UI to allow the user to enter/exit XR mode
  45157. * @param scene the scene to add the ui to
  45158. * @param helper the xr experience helper to enter/exit xr with
  45159. * @param options options to configure the UI
  45160. * @returns the created ui
  45161. */
  45162. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45163. /**
  45164. *
  45165. * @param scene babylon scene object to use
  45166. * @param options (read-only) version of the options passed to this UI
  45167. */
  45168. private constructor();
  45169. private _updateButtons;
  45170. /**
  45171. * Disposes of the object
  45172. */
  45173. dispose(): void;
  45174. }
  45175. }
  45176. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45177. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45178. import { Scene } from "babylonjs/scene";
  45179. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45180. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45181. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45182. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45183. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45184. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45186. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45187. /**
  45188. * Options for the default xr helper
  45189. */
  45190. export class WebXRDefaultExperienceOptions {
  45191. /**
  45192. * Floor meshes that should be used for teleporting
  45193. */
  45194. floorMeshes: Array<AbstractMesh>;
  45195. /**
  45196. * Enable or disable default UI to enter XR
  45197. */
  45198. disableDefaultUI?: boolean;
  45199. /**
  45200. * optional configuration for the output canvas
  45201. */
  45202. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45203. /**
  45204. * optional UI options. This can be used among other to change session mode and reference space type
  45205. */
  45206. uiOptions?: WebXREnterExitUIOptions;
  45207. }
  45208. /**
  45209. * Default experience which provides a similar setup to the previous webVRExperience
  45210. */
  45211. export class WebXRDefaultExperience {
  45212. /**
  45213. * Base experience
  45214. */
  45215. baseExperience: WebXRExperienceHelper;
  45216. /**
  45217. * Input experience extension
  45218. */
  45219. input: WebXRInput;
  45220. /**
  45221. * Loads the controller models
  45222. */
  45223. controllerModelLoader: WebXRControllerModelLoader;
  45224. /**
  45225. * Enables laser pointer and selection
  45226. */
  45227. pointerSelection: WebXRControllerPointerSelection;
  45228. /**
  45229. * Enables teleportation
  45230. */
  45231. teleportation: WebXRControllerTeleportation;
  45232. /**
  45233. * Enables ui for entering/exiting xr
  45234. */
  45235. enterExitUI: WebXREnterExitUI;
  45236. /**
  45237. * Default target xr should render to
  45238. */
  45239. renderTarget: WebXRRenderTarget;
  45240. /**
  45241. * Creates the default xr experience
  45242. * @param scene scene
  45243. * @param options options for basic configuration
  45244. * @returns resulting WebXRDefaultExperience
  45245. */
  45246. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45247. private constructor();
  45248. /**
  45249. * DIsposes of the experience helper
  45250. */
  45251. dispose(): void;
  45252. }
  45253. }
  45254. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45255. import { Observable } from "babylonjs/Misc/observable";
  45256. import { Nullable } from "babylonjs/types";
  45257. import { Camera } from "babylonjs/Cameras/camera";
  45258. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45259. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45260. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45261. import { Scene } from "babylonjs/scene";
  45262. import { Vector3 } from "babylonjs/Maths/math.vector";
  45263. import { Color3 } from "babylonjs/Maths/math.color";
  45264. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45266. import { Mesh } from "babylonjs/Meshes/mesh";
  45267. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45268. import { EasingFunction } from "babylonjs/Animations/easing";
  45269. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45270. import "babylonjs/Meshes/Builders/groundBuilder";
  45271. import "babylonjs/Meshes/Builders/torusBuilder";
  45272. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45273. import "babylonjs/Gamepads/gamepadSceneComponent";
  45274. import "babylonjs/Animations/animatable";
  45275. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45276. /**
  45277. * Options to modify the vr teleportation behavior.
  45278. */
  45279. export interface VRTeleportationOptions {
  45280. /**
  45281. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45282. */
  45283. floorMeshName?: string;
  45284. /**
  45285. * A list of meshes to be used as the teleportation floor. (default: empty)
  45286. */
  45287. floorMeshes?: Mesh[];
  45288. /**
  45289. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45290. */
  45291. teleportationMode?: number;
  45292. /**
  45293. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45294. */
  45295. teleportationTime?: number;
  45296. /**
  45297. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45298. */
  45299. teleportationSpeed?: number;
  45300. /**
  45301. * The easing function used in the animation or null for Linear. (default CircleEase)
  45302. */
  45303. easingFunction?: EasingFunction;
  45304. }
  45305. /**
  45306. * Options to modify the vr experience helper's behavior.
  45307. */
  45308. export interface VRExperienceHelperOptions extends WebVROptions {
  45309. /**
  45310. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45311. */
  45312. createDeviceOrientationCamera?: boolean;
  45313. /**
  45314. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45315. */
  45316. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45317. /**
  45318. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45319. */
  45320. laserToggle?: boolean;
  45321. /**
  45322. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45323. */
  45324. floorMeshes?: Mesh[];
  45325. /**
  45326. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45327. */
  45328. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45329. /**
  45330. * Defines if WebXR should be used instead of WebVR (if available)
  45331. */
  45332. useXR?: boolean;
  45333. }
  45334. /**
  45335. * Event containing information after VR has been entered
  45336. */
  45337. export class OnAfterEnteringVRObservableEvent {
  45338. /**
  45339. * If entering vr was successful
  45340. */
  45341. success: boolean;
  45342. }
  45343. /**
  45344. * Helps to quickly add VR support to an existing scene.
  45345. * See http://doc.babylonjs.com/how_to/webvr_helper
  45346. */
  45347. export class VRExperienceHelper {
  45348. /** Options to modify the vr experience helper's behavior. */
  45349. webVROptions: VRExperienceHelperOptions;
  45350. private _scene;
  45351. private _position;
  45352. private _btnVR;
  45353. private _btnVRDisplayed;
  45354. private _webVRsupported;
  45355. private _webVRready;
  45356. private _webVRrequesting;
  45357. private _webVRpresenting;
  45358. private _hasEnteredVR;
  45359. private _fullscreenVRpresenting;
  45360. private _inputElement;
  45361. private _webVRCamera;
  45362. private _vrDeviceOrientationCamera;
  45363. private _deviceOrientationCamera;
  45364. private _existingCamera;
  45365. private _onKeyDown;
  45366. private _onVrDisplayPresentChange;
  45367. private _onVRDisplayChanged;
  45368. private _onVRRequestPresentStart;
  45369. private _onVRRequestPresentComplete;
  45370. /**
  45371. * 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)
  45372. */
  45373. enableGazeEvenWhenNoPointerLock: boolean;
  45374. /**
  45375. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45376. */
  45377. exitVROnDoubleTap: boolean;
  45378. /**
  45379. * Observable raised right before entering VR.
  45380. */
  45381. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45382. /**
  45383. * Observable raised when entering VR has completed.
  45384. */
  45385. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45386. /**
  45387. * Observable raised when exiting VR.
  45388. */
  45389. onExitingVRObservable: Observable<VRExperienceHelper>;
  45390. /**
  45391. * Observable raised when controller mesh is loaded.
  45392. */
  45393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45394. /** Return this.onEnteringVRObservable
  45395. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45396. */
  45397. get onEnteringVR(): Observable<VRExperienceHelper>;
  45398. /** Return this.onExitingVRObservable
  45399. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45400. */
  45401. get onExitingVR(): Observable<VRExperienceHelper>;
  45402. /** Return this.onControllerMeshLoadedObservable
  45403. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45404. */
  45405. get onControllerMeshLoaded(): Observable<WebVRController>;
  45406. private _rayLength;
  45407. private _useCustomVRButton;
  45408. private _teleportationRequested;
  45409. private _teleportActive;
  45410. private _floorMeshName;
  45411. private _floorMeshesCollection;
  45412. private _teleportationMode;
  45413. private _teleportationTime;
  45414. private _teleportationSpeed;
  45415. private _teleportationEasing;
  45416. private _rotationAllowed;
  45417. private _teleportBackwardsVector;
  45418. private _teleportationTarget;
  45419. private _isDefaultTeleportationTarget;
  45420. private _postProcessMove;
  45421. private _teleportationFillColor;
  45422. private _teleportationBorderColor;
  45423. private _rotationAngle;
  45424. private _haloCenter;
  45425. private _cameraGazer;
  45426. private _padSensibilityUp;
  45427. private _padSensibilityDown;
  45428. private _leftController;
  45429. private _rightController;
  45430. /**
  45431. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45432. */
  45433. onNewMeshSelected: Observable<AbstractMesh>;
  45434. /**
  45435. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45436. * This observable will provide the mesh and the controller used to select the mesh
  45437. */
  45438. onMeshSelectedWithController: Observable<{
  45439. mesh: AbstractMesh;
  45440. controller: WebVRController;
  45441. }>;
  45442. /**
  45443. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45444. */
  45445. onNewMeshPicked: Observable<PickingInfo>;
  45446. private _circleEase;
  45447. /**
  45448. * Observable raised before camera teleportation
  45449. */
  45450. onBeforeCameraTeleport: Observable<Vector3>;
  45451. /**
  45452. * Observable raised after camera teleportation
  45453. */
  45454. onAfterCameraTeleport: Observable<Vector3>;
  45455. /**
  45456. * Observable raised when current selected mesh gets unselected
  45457. */
  45458. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45459. private _raySelectionPredicate;
  45460. /**
  45461. * To be optionaly changed by user to define custom ray selection
  45462. */
  45463. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45464. /**
  45465. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45466. */
  45467. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45468. /**
  45469. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45470. */
  45471. teleportationEnabled: boolean;
  45472. private _defaultHeight;
  45473. private _teleportationInitialized;
  45474. private _interactionsEnabled;
  45475. private _interactionsRequested;
  45476. private _displayGaze;
  45477. private _displayLaserPointer;
  45478. /**
  45479. * The mesh used to display where the user is going to teleport.
  45480. */
  45481. get teleportationTarget(): Mesh;
  45482. /**
  45483. * Sets the mesh to be used to display where the user is going to teleport.
  45484. */
  45485. set teleportationTarget(value: Mesh);
  45486. /**
  45487. * 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
  45488. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45489. * See http://doc.babylonjs.com/resources/baking_transformations
  45490. */
  45491. get gazeTrackerMesh(): Mesh;
  45492. set gazeTrackerMesh(value: Mesh);
  45493. /**
  45494. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45495. */
  45496. updateGazeTrackerScale: boolean;
  45497. /**
  45498. * If the gaze trackers color should be updated when selecting meshes
  45499. */
  45500. updateGazeTrackerColor: boolean;
  45501. /**
  45502. * If the controller laser color should be updated when selecting meshes
  45503. */
  45504. updateControllerLaserColor: boolean;
  45505. /**
  45506. * The gaze tracking mesh corresponding to the left controller
  45507. */
  45508. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45509. /**
  45510. * The gaze tracking mesh corresponding to the right controller
  45511. */
  45512. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45513. /**
  45514. * If the ray of the gaze should be displayed.
  45515. */
  45516. get displayGaze(): boolean;
  45517. /**
  45518. * Sets if the ray of the gaze should be displayed.
  45519. */
  45520. set displayGaze(value: boolean);
  45521. /**
  45522. * If the ray of the LaserPointer should be displayed.
  45523. */
  45524. get displayLaserPointer(): boolean;
  45525. /**
  45526. * Sets if the ray of the LaserPointer should be displayed.
  45527. */
  45528. set displayLaserPointer(value: boolean);
  45529. /**
  45530. * The deviceOrientationCamera used as the camera when not in VR.
  45531. */
  45532. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45533. /**
  45534. * Based on the current WebVR support, returns the current VR camera used.
  45535. */
  45536. get currentVRCamera(): Nullable<Camera>;
  45537. /**
  45538. * The webVRCamera which is used when in VR.
  45539. */
  45540. get webVRCamera(): WebVRFreeCamera;
  45541. /**
  45542. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45543. */
  45544. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45545. /**
  45546. * The html button that is used to trigger entering into VR.
  45547. */
  45548. get vrButton(): Nullable<HTMLButtonElement>;
  45549. private get _teleportationRequestInitiated();
  45550. /**
  45551. * Defines wether or not Pointer lock should be requested when switching to
  45552. * full screen.
  45553. */
  45554. requestPointerLockOnFullScreen: boolean;
  45555. /**
  45556. * If asking to force XR, this will be populated with the default xr experience
  45557. */
  45558. xr: WebXRDefaultExperience;
  45559. /**
  45560. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45561. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45562. */
  45563. xrTestDone: boolean;
  45564. /**
  45565. * Instantiates a VRExperienceHelper.
  45566. * Helps to quickly add VR support to an existing scene.
  45567. * @param scene The scene the VRExperienceHelper belongs to.
  45568. * @param webVROptions Options to modify the vr experience helper's behavior.
  45569. */
  45570. constructor(scene: Scene,
  45571. /** Options to modify the vr experience helper's behavior. */
  45572. webVROptions?: VRExperienceHelperOptions);
  45573. private completeVRInit;
  45574. private _onDefaultMeshLoaded;
  45575. private _onResize;
  45576. private _onFullscreenChange;
  45577. /**
  45578. * Gets a value indicating if we are currently in VR mode.
  45579. */
  45580. get isInVRMode(): boolean;
  45581. private onVrDisplayPresentChange;
  45582. private onVRDisplayChanged;
  45583. private moveButtonToBottomRight;
  45584. private displayVRButton;
  45585. private updateButtonVisibility;
  45586. private _cachedAngularSensibility;
  45587. /**
  45588. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45589. * Otherwise, will use the fullscreen API.
  45590. */
  45591. enterVR(): void;
  45592. /**
  45593. * Attempt to exit VR, or fullscreen.
  45594. */
  45595. exitVR(): void;
  45596. /**
  45597. * The position of the vr experience helper.
  45598. */
  45599. get position(): Vector3;
  45600. /**
  45601. * Sets the position of the vr experience helper.
  45602. */
  45603. set position(value: Vector3);
  45604. /**
  45605. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45606. */
  45607. enableInteractions(): void;
  45608. private get _noControllerIsActive();
  45609. private beforeRender;
  45610. private _isTeleportationFloor;
  45611. /**
  45612. * Adds a floor mesh to be used for teleportation.
  45613. * @param floorMesh the mesh to be used for teleportation.
  45614. */
  45615. addFloorMesh(floorMesh: Mesh): void;
  45616. /**
  45617. * Removes a floor mesh from being used for teleportation.
  45618. * @param floorMesh the mesh to be removed.
  45619. */
  45620. removeFloorMesh(floorMesh: Mesh): void;
  45621. /**
  45622. * Enables interactions and teleportation using the VR controllers and gaze.
  45623. * @param vrTeleportationOptions options to modify teleportation behavior.
  45624. */
  45625. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45626. private _onNewGamepadConnected;
  45627. private _tryEnableInteractionOnController;
  45628. private _onNewGamepadDisconnected;
  45629. private _enableInteractionOnController;
  45630. private _checkTeleportWithRay;
  45631. private _checkRotate;
  45632. private _checkTeleportBackwards;
  45633. private _enableTeleportationOnController;
  45634. private _createTeleportationCircles;
  45635. private _displayTeleportationTarget;
  45636. private _hideTeleportationTarget;
  45637. private _rotateCamera;
  45638. private _moveTeleportationSelectorTo;
  45639. private _workingVector;
  45640. private _workingQuaternion;
  45641. private _workingMatrix;
  45642. /**
  45643. * Time Constant Teleportation Mode
  45644. */
  45645. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45646. /**
  45647. * Speed Constant Teleportation Mode
  45648. */
  45649. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45650. /**
  45651. * Teleports the users feet to the desired location
  45652. * @param location The location where the user's feet should be placed
  45653. */
  45654. teleportCamera(location: Vector3): void;
  45655. private _convertNormalToDirectionOfRay;
  45656. private _castRayAndSelectObject;
  45657. private _notifySelectedMeshUnselected;
  45658. /**
  45659. * Sets the color of the laser ray from the vr controllers.
  45660. * @param color new color for the ray.
  45661. */
  45662. changeLaserColor(color: Color3): void;
  45663. /**
  45664. * Sets the color of the ray from the vr headsets gaze.
  45665. * @param color new color for the ray.
  45666. */
  45667. changeGazeColor(color: Color3): void;
  45668. /**
  45669. * Exits VR and disposes of the vr experience helper
  45670. */
  45671. dispose(): void;
  45672. /**
  45673. * Gets the name of the VRExperienceHelper class
  45674. * @returns "VRExperienceHelper"
  45675. */
  45676. getClassName(): string;
  45677. }
  45678. }
  45679. declare module "babylonjs/Cameras/VR/index" {
  45680. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45681. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45682. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45683. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45684. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45685. export * from "babylonjs/Cameras/VR/webVRCamera";
  45686. }
  45687. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45688. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45689. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45690. import { Observable } from "babylonjs/Misc/observable";
  45691. import { Matrix } from "babylonjs/Maths/math.vector";
  45692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45693. /**
  45694. * Options used for hit testing
  45695. */
  45696. export interface IWebXRHitTestOptions {
  45697. /**
  45698. * Only test when user interacted with the scene. Default - hit test every frame
  45699. */
  45700. testOnPointerDownOnly?: boolean;
  45701. /**
  45702. * The node to use to transform the local results to world coordinates
  45703. */
  45704. worldParentNode?: TransformNode;
  45705. }
  45706. /**
  45707. * Interface defining the babylon result of raycasting/hit-test
  45708. */
  45709. export interface IWebXRHitResult {
  45710. /**
  45711. * The native hit test result
  45712. */
  45713. xrHitResult: XRHitResult;
  45714. /**
  45715. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45716. */
  45717. transformationMatrix: Matrix;
  45718. }
  45719. /**
  45720. * The currently-working hit-test module.
  45721. * Hit test (or raycasting) is used to interact with the real world.
  45722. * For further information read here - https://github.com/immersive-web/hit-test
  45723. */
  45724. export class WebXRHitTestLegacy implements IWebXRFeature {
  45725. private _xrSessionManager;
  45726. /**
  45727. * options to use when constructing this feature
  45728. */
  45729. readonly options: IWebXRHitTestOptions;
  45730. /**
  45731. * The module's name
  45732. */
  45733. static readonly Name: string;
  45734. /**
  45735. * The (Babylon) version of this module.
  45736. * This is an integer representing the implementation version.
  45737. * This number does not correspond to the webxr specs version
  45738. */
  45739. static readonly Version: number;
  45740. /**
  45741. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45742. * @param event the (select) event to use to select with
  45743. * @param referenceSpace the reference space to use for this hit test
  45744. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45745. */
  45746. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45747. /**
  45748. * execute a hit test with an XR Ray
  45749. *
  45750. * @param xrSession a native xrSession that will execute this hit test
  45751. * @param xrRay the ray (position and direction) to use for raycasting
  45752. * @param referenceSpace native XR reference space to use for the hit-test
  45753. * @param filter filter function that will filter the results
  45754. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45755. */
  45756. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45757. /**
  45758. * Triggered when new babylon (transformed) hit test results are available
  45759. */
  45760. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45761. /**
  45762. * Creates a new instance of the (legacy version) hit test feature
  45763. * @param _xrSessionManager an instance of WebXRSessionManager
  45764. * @param options options to use when constructing this feature
  45765. */
  45766. constructor(_xrSessionManager: WebXRSessionManager,
  45767. /**
  45768. * options to use when constructing this feature
  45769. */
  45770. options?: IWebXRHitTestOptions);
  45771. private _onSelectEnabled;
  45772. private _xrFrameObserver;
  45773. private _attached;
  45774. /**
  45775. * Populated with the last native XR Hit Results
  45776. */
  45777. lastNativeXRHitResults: XRHitResult[];
  45778. /**
  45779. * attach this feature
  45780. * Will usually be called by the features manager
  45781. *
  45782. * @returns true if successful.
  45783. */
  45784. attach(): boolean;
  45785. /**
  45786. * detach this feature.
  45787. * Will usually be called by the features manager
  45788. *
  45789. * @returns true if successful.
  45790. */
  45791. detach(): boolean;
  45792. private _onHitTestResults;
  45793. private _onSelect;
  45794. /**
  45795. * Dispose this feature and all of the resources attached
  45796. */
  45797. dispose(): void;
  45798. }
  45799. }
  45800. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45801. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45802. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45803. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45804. import { Observable } from "babylonjs/Misc/observable";
  45805. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45806. /**
  45807. * Options used in the plane detector module
  45808. */
  45809. export interface IWebXRPlaneDetectorOptions {
  45810. /**
  45811. * The node to use to transform the local results to world coordinates
  45812. */
  45813. worldParentNode?: TransformNode;
  45814. }
  45815. /**
  45816. * A babylon interface for a webxr plane.
  45817. * A Plane is actually a polygon, built from N points in space
  45818. */
  45819. export interface IWebXRPlane {
  45820. /**
  45821. * a babylon-assigned ID for this polygon
  45822. */
  45823. id: number;
  45824. /**
  45825. * the native xr-plane object
  45826. */
  45827. xrPlane: XRPlane;
  45828. /**
  45829. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45830. */
  45831. polygonDefinition: Array<Vector3>;
  45832. /**
  45833. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45834. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45835. */
  45836. transformationMatrix: Matrix;
  45837. }
  45838. /**
  45839. * The plane detector is used to detect planes in the real world when in AR
  45840. * For more information see https://github.com/immersive-web/real-world-geometry/
  45841. */
  45842. export class WebXRPlaneDetector implements IWebXRFeature {
  45843. private _xrSessionManager;
  45844. private _options;
  45845. /**
  45846. * The module's name
  45847. */
  45848. static readonly Name: string;
  45849. /**
  45850. * The (Babylon) version of this module.
  45851. * This is an integer representing the implementation version.
  45852. * This number does not correspond to the webxr specs version
  45853. */
  45854. static readonly Version: number;
  45855. /**
  45856. * Observers registered here will be executed when a new plane was added to the session
  45857. */
  45858. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45859. /**
  45860. * Observers registered here will be executed when a plane is no longer detected in the session
  45861. */
  45862. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45863. /**
  45864. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45865. * This can execute N times every frame
  45866. */
  45867. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45868. private _enabled;
  45869. private _attached;
  45870. private _detectedPlanes;
  45871. private _lastFrameDetected;
  45872. private _observerTracked;
  45873. /**
  45874. * construct a new Plane Detector
  45875. * @param _xrSessionManager an instance of xr Session manager
  45876. * @param _options configuration to use when constructing this feature
  45877. */
  45878. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45879. /**
  45880. * attach this feature
  45881. * Will usually be called by the features manager
  45882. *
  45883. * @returns true if successful.
  45884. */
  45885. attach(): boolean;
  45886. /**
  45887. * detach this feature.
  45888. * Will usually be called by the features manager
  45889. *
  45890. * @returns true if successful.
  45891. */
  45892. detach(): boolean;
  45893. /**
  45894. * Dispose this feature and all of the resources attached
  45895. */
  45896. dispose(): void;
  45897. private _updatePlaneWithXRPlane;
  45898. /**
  45899. * avoiding using Array.find for global support.
  45900. * @param xrPlane the plane to find in the array
  45901. */
  45902. private findIndexInPlaneArray;
  45903. }
  45904. }
  45905. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45906. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45907. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45908. import { Observable } from "babylonjs/Misc/observable";
  45909. import { Matrix } from "babylonjs/Maths/math.vector";
  45910. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45911. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45912. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45913. /**
  45914. * Configuration options of the anchor system
  45915. */
  45916. export interface IWebXRAnchorSystemOptions {
  45917. /**
  45918. * a node that will be used to convert local to world coordinates
  45919. */
  45920. worldParentNode?: TransformNode;
  45921. /**
  45922. * should the anchor system use plane detection.
  45923. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45924. */
  45925. usePlaneDetection?: boolean;
  45926. /**
  45927. * Should a new anchor be added every time a select event is triggered
  45928. */
  45929. addAnchorOnSelect?: boolean;
  45930. }
  45931. /**
  45932. * A babylon container for an XR Anchor
  45933. */
  45934. export interface IWebXRAnchor {
  45935. /**
  45936. * A babylon-assigned ID for this anchor
  45937. */
  45938. id: number;
  45939. /**
  45940. * The native anchor object
  45941. */
  45942. xrAnchor: XRAnchor;
  45943. /**
  45944. * Transformation matrix to apply to an object attached to this anchor
  45945. */
  45946. transformationMatrix: Matrix;
  45947. }
  45948. /**
  45949. * An implementation of the anchor system of WebXR.
  45950. * Note that the current documented implementation is not available in any browser. Future implementations
  45951. * will use the frame to create an anchor and not the session or a detected plane
  45952. * For further information see https://github.com/immersive-web/anchors/
  45953. */
  45954. export class WebXRAnchorSystem implements IWebXRFeature {
  45955. private _xrSessionManager;
  45956. private _options;
  45957. /**
  45958. * The module's name
  45959. */
  45960. static readonly Name: string;
  45961. /**
  45962. * The (Babylon) version of this module.
  45963. * This is an integer representing the implementation version.
  45964. * This number does not correspond to the webxr specs version
  45965. */
  45966. static readonly Version: number;
  45967. /**
  45968. * Observers registered here will be executed when a new anchor was added to the session
  45969. */
  45970. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45971. /**
  45972. * Observers registered here will be executed when an existing anchor updates
  45973. * This can execute N times every frame
  45974. */
  45975. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45976. /**
  45977. * Observers registered here will be executed when an anchor was removed from the session
  45978. */
  45979. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45980. private _planeDetector;
  45981. private _hitTestModule;
  45982. private _enabled;
  45983. private _attached;
  45984. private _trackedAnchors;
  45985. private _lastFrameDetected;
  45986. private _observerTracked;
  45987. /**
  45988. * constructs a new anchor system
  45989. * @param _xrSessionManager an instance of WebXRSessionManager
  45990. * @param _options configuration object for this feature
  45991. */
  45992. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45993. /**
  45994. * set the plane detector to use in order to create anchors from frames
  45995. * @param planeDetector the plane-detector module to use
  45996. * @param enable enable plane-anchors. default is true
  45997. */
  45998. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45999. /**
  46000. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46001. * @param hitTestModule the hit-test module to use.
  46002. */
  46003. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46004. /**
  46005. * attach this feature
  46006. * Will usually be called by the features manager
  46007. *
  46008. * @returns true if successful.
  46009. */
  46010. attach(): boolean;
  46011. /**
  46012. * detach this feature.
  46013. * Will usually be called by the features manager
  46014. *
  46015. * @returns true if successful.
  46016. */
  46017. detach(): boolean;
  46018. /**
  46019. * Dispose this feature and all of the resources attached
  46020. */
  46021. dispose(): void;
  46022. private _onSelect;
  46023. /**
  46024. * Add anchor at a specific XR point.
  46025. *
  46026. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46027. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46028. * @returns a promise the fulfills when the anchor was created
  46029. */
  46030. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46031. private _updateAnchorWithXRFrame;
  46032. /**
  46033. * avoiding using Array.find for global support.
  46034. * @param xrAnchor the plane to find in the array
  46035. */
  46036. private _findIndexInAnchorArray;
  46037. }
  46038. }
  46039. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46040. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46041. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46043. import { Observable } from "babylonjs/Misc/observable";
  46044. /**
  46045. * Options interface for the background remover plugin
  46046. */
  46047. export interface IWebXRBackgroundRemoverOptions {
  46048. /**
  46049. * don't disable the environment helper
  46050. */
  46051. ignoreEnvironmentHelper?: boolean;
  46052. /**
  46053. * flags to configure the removal of the environment helper.
  46054. * If not set, the entire background will be removed. If set, flags should be set as well.
  46055. */
  46056. environmentHelperRemovalFlags?: {
  46057. /**
  46058. * Should the skybox be removed (default false)
  46059. */
  46060. skyBox?: boolean;
  46061. /**
  46062. * Should the ground be removed (default false)
  46063. */
  46064. ground?: boolean;
  46065. };
  46066. /**
  46067. * Further background meshes to disable when entering AR
  46068. */
  46069. backgroundMeshes?: AbstractMesh[];
  46070. }
  46071. /**
  46072. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46073. */
  46074. export class WebXRBackgroundRemover implements IWebXRFeature {
  46075. private _xrSessionManager;
  46076. /**
  46077. * read-only options to be used in this module
  46078. */
  46079. readonly options: IWebXRBackgroundRemoverOptions;
  46080. /**
  46081. * The module's name
  46082. */
  46083. static readonly Name: string;
  46084. /**
  46085. * The (Babylon) version of this module.
  46086. * This is an integer representing the implementation version.
  46087. * This number does not correspond to the webxr specs version
  46088. */
  46089. static readonly Version: number;
  46090. /**
  46091. * registered observers will be triggered when the background state changes
  46092. */
  46093. onBackgroundStateChangedObservable: Observable<boolean>;
  46094. /**
  46095. * constructs a new background remover module
  46096. * @param _xrSessionManager the session manager for this module
  46097. * @param options read-only options to be used in this module
  46098. */
  46099. constructor(_xrSessionManager: WebXRSessionManager,
  46100. /**
  46101. * read-only options to be used in this module
  46102. */
  46103. options?: IWebXRBackgroundRemoverOptions);
  46104. /**
  46105. * attach this feature
  46106. * Will usually be called by the features manager
  46107. *
  46108. * @returns true if successful.
  46109. */
  46110. attach(): boolean;
  46111. /**
  46112. * detach this feature.
  46113. * Will usually be called by the features manager
  46114. *
  46115. * @returns true if successful.
  46116. */
  46117. detach(): boolean;
  46118. private _setBackgroundState;
  46119. /**
  46120. * Dispose this feature and all of the resources attached
  46121. */
  46122. dispose(): void;
  46123. }
  46124. }
  46125. declare module "babylonjs/Cameras/XR/features/index" {
  46126. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46127. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46128. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46129. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46130. }
  46131. declare module "babylonjs/Cameras/XR/index" {
  46132. export * from "babylonjs/Cameras/XR/webXRCamera";
  46133. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46134. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46135. export * from "babylonjs/Cameras/XR/webXRInput";
  46136. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46137. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46138. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46139. export * from "babylonjs/Cameras/XR/webXRController";
  46140. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46141. export * from "babylonjs/Cameras/XR/webXRTypes";
  46142. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46143. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46144. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46145. export * from "babylonjs/Cameras/XR/features/index";
  46146. }
  46147. declare module "babylonjs/Cameras/RigModes/index" {
  46148. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46149. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46150. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46151. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46152. }
  46153. declare module "babylonjs/Cameras/index" {
  46154. export * from "babylonjs/Cameras/Inputs/index";
  46155. export * from "babylonjs/Cameras/cameraInputsManager";
  46156. export * from "babylonjs/Cameras/camera";
  46157. export * from "babylonjs/Cameras/targetCamera";
  46158. export * from "babylonjs/Cameras/freeCamera";
  46159. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46160. export * from "babylonjs/Cameras/touchCamera";
  46161. export * from "babylonjs/Cameras/arcRotateCamera";
  46162. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46163. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46164. export * from "babylonjs/Cameras/flyCamera";
  46165. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46166. export * from "babylonjs/Cameras/followCamera";
  46167. export * from "babylonjs/Cameras/followCameraInputsManager";
  46168. export * from "babylonjs/Cameras/gamepadCamera";
  46169. export * from "babylonjs/Cameras/Stereoscopic/index";
  46170. export * from "babylonjs/Cameras/universalCamera";
  46171. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46172. export * from "babylonjs/Cameras/VR/index";
  46173. export * from "babylonjs/Cameras/XR/index";
  46174. export * from "babylonjs/Cameras/RigModes/index";
  46175. }
  46176. declare module "babylonjs/Collisions/index" {
  46177. export * from "babylonjs/Collisions/collider";
  46178. export * from "babylonjs/Collisions/collisionCoordinator";
  46179. export * from "babylonjs/Collisions/pickingInfo";
  46180. export * from "babylonjs/Collisions/intersectionInfo";
  46181. export * from "babylonjs/Collisions/meshCollisionData";
  46182. }
  46183. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46184. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46185. import { Vector3 } from "babylonjs/Maths/math.vector";
  46186. import { Ray } from "babylonjs/Culling/ray";
  46187. import { Plane } from "babylonjs/Maths/math.plane";
  46188. /**
  46189. * Contains an array of blocks representing the octree
  46190. */
  46191. export interface IOctreeContainer<T> {
  46192. /**
  46193. * Blocks within the octree
  46194. */
  46195. blocks: Array<OctreeBlock<T>>;
  46196. }
  46197. /**
  46198. * Class used to store a cell in an octree
  46199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46200. */
  46201. export class OctreeBlock<T> {
  46202. /**
  46203. * Gets the content of the current block
  46204. */
  46205. entries: T[];
  46206. /**
  46207. * Gets the list of block children
  46208. */
  46209. blocks: Array<OctreeBlock<T>>;
  46210. private _depth;
  46211. private _maxDepth;
  46212. private _capacity;
  46213. private _minPoint;
  46214. private _maxPoint;
  46215. private _boundingVectors;
  46216. private _creationFunc;
  46217. /**
  46218. * Creates a new block
  46219. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46220. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46221. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46222. * @param depth defines the current depth of this block in the octree
  46223. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46224. * @param creationFunc defines a callback to call when an element is added to the block
  46225. */
  46226. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46227. /**
  46228. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46229. */
  46230. get capacity(): number;
  46231. /**
  46232. * Gets the minimum vector (in world space) of the block's bounding box
  46233. */
  46234. get minPoint(): Vector3;
  46235. /**
  46236. * Gets the maximum vector (in world space) of the block's bounding box
  46237. */
  46238. get maxPoint(): Vector3;
  46239. /**
  46240. * Add a new element to this block
  46241. * @param entry defines the element to add
  46242. */
  46243. addEntry(entry: T): void;
  46244. /**
  46245. * Remove an element from this block
  46246. * @param entry defines the element to remove
  46247. */
  46248. removeEntry(entry: T): void;
  46249. /**
  46250. * Add an array of elements to this block
  46251. * @param entries defines the array of elements to add
  46252. */
  46253. addEntries(entries: T[]): void;
  46254. /**
  46255. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46256. * @param frustumPlanes defines the frustum planes to test
  46257. * @param selection defines the array to store current content if selection is positive
  46258. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46259. */
  46260. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46261. /**
  46262. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46263. * @param sphereCenter defines the bounding sphere center
  46264. * @param sphereRadius defines the bounding sphere radius
  46265. * @param selection defines the array to store current content if selection is positive
  46266. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46267. */
  46268. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46269. /**
  46270. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46271. * @param ray defines the ray to test with
  46272. * @param selection defines the array to store current content if selection is positive
  46273. */
  46274. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46275. /**
  46276. * Subdivide the content into child blocks (this block will then be empty)
  46277. */
  46278. createInnerBlocks(): void;
  46279. /**
  46280. * @hidden
  46281. */
  46282. 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;
  46283. }
  46284. }
  46285. declare module "babylonjs/Culling/Octrees/octree" {
  46286. import { SmartArray } from "babylonjs/Misc/smartArray";
  46287. import { Vector3 } from "babylonjs/Maths/math.vector";
  46288. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46290. import { Ray } from "babylonjs/Culling/ray";
  46291. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46292. import { Plane } from "babylonjs/Maths/math.plane";
  46293. /**
  46294. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46295. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46296. */
  46297. export class Octree<T> {
  46298. /** 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.) */
  46299. maxDepth: number;
  46300. /**
  46301. * Blocks within the octree containing objects
  46302. */
  46303. blocks: Array<OctreeBlock<T>>;
  46304. /**
  46305. * Content stored in the octree
  46306. */
  46307. dynamicContent: T[];
  46308. private _maxBlockCapacity;
  46309. private _selectionContent;
  46310. private _creationFunc;
  46311. /**
  46312. * Creates a octree
  46313. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46314. * @param creationFunc function to be used to instatiate the octree
  46315. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46316. * @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.)
  46317. */
  46318. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46319. /** 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.) */
  46320. maxDepth?: number);
  46321. /**
  46322. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46323. * @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);
  46324. * @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);
  46325. * @param entries meshes to be added to the octree blocks
  46326. */
  46327. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46328. /**
  46329. * Adds a mesh to the octree
  46330. * @param entry Mesh to add to the octree
  46331. */
  46332. addMesh(entry: T): void;
  46333. /**
  46334. * Remove an element from the octree
  46335. * @param entry defines the element to remove
  46336. */
  46337. removeMesh(entry: T): void;
  46338. /**
  46339. * Selects an array of meshes within the frustum
  46340. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46341. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46342. * @returns array of meshes within the frustum
  46343. */
  46344. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46345. /**
  46346. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46347. * @param sphereCenter defines the bounding sphere center
  46348. * @param sphereRadius defines the bounding sphere radius
  46349. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46350. * @returns an array of objects that intersect the sphere
  46351. */
  46352. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46353. /**
  46354. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46355. * @param ray defines the ray to test with
  46356. * @returns array of intersected objects
  46357. */
  46358. intersectsRay(ray: Ray): SmartArray<T>;
  46359. /**
  46360. * Adds a mesh into the octree block if it intersects the block
  46361. */
  46362. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46363. /**
  46364. * Adds a submesh into the octree block if it intersects the block
  46365. */
  46366. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46367. }
  46368. }
  46369. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46370. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46371. import { Scene } from "babylonjs/scene";
  46372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46374. import { Ray } from "babylonjs/Culling/ray";
  46375. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46376. import { Collider } from "babylonjs/Collisions/collider";
  46377. module "babylonjs/scene" {
  46378. interface Scene {
  46379. /**
  46380. * @hidden
  46381. * Backing Filed
  46382. */
  46383. _selectionOctree: Octree<AbstractMesh>;
  46384. /**
  46385. * Gets the octree used to boost mesh selection (picking)
  46386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46387. */
  46388. selectionOctree: Octree<AbstractMesh>;
  46389. /**
  46390. * Creates or updates the octree used to boost selection (picking)
  46391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46392. * @param maxCapacity defines the maximum capacity per leaf
  46393. * @param maxDepth defines the maximum depth of the octree
  46394. * @returns an octree of AbstractMesh
  46395. */
  46396. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46397. }
  46398. }
  46399. module "babylonjs/Meshes/abstractMesh" {
  46400. interface AbstractMesh {
  46401. /**
  46402. * @hidden
  46403. * Backing Field
  46404. */
  46405. _submeshesOctree: Octree<SubMesh>;
  46406. /**
  46407. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46408. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46409. * @param maxCapacity defines the maximum size of each block (64 by default)
  46410. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46411. * @returns the new octree
  46412. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46414. */
  46415. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46416. }
  46417. }
  46418. /**
  46419. * Defines the octree scene component responsible to manage any octrees
  46420. * in a given scene.
  46421. */
  46422. export class OctreeSceneComponent {
  46423. /**
  46424. * The component name help to identify the component in the list of scene components.
  46425. */
  46426. readonly name: string;
  46427. /**
  46428. * The scene the component belongs to.
  46429. */
  46430. scene: Scene;
  46431. /**
  46432. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46433. */
  46434. readonly checksIsEnabled: boolean;
  46435. /**
  46436. * Creates a new instance of the component for the given scene
  46437. * @param scene Defines the scene to register the component in
  46438. */
  46439. constructor(scene: Scene);
  46440. /**
  46441. * Registers the component in a given scene
  46442. */
  46443. register(): void;
  46444. /**
  46445. * Return the list of active meshes
  46446. * @returns the list of active meshes
  46447. */
  46448. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46449. /**
  46450. * Return the list of active sub meshes
  46451. * @param mesh The mesh to get the candidates sub meshes from
  46452. * @returns the list of active sub meshes
  46453. */
  46454. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46455. private _tempRay;
  46456. /**
  46457. * Return the list of sub meshes intersecting with a given local ray
  46458. * @param mesh defines the mesh to find the submesh for
  46459. * @param localRay defines the ray in local space
  46460. * @returns the list of intersecting sub meshes
  46461. */
  46462. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46463. /**
  46464. * Return the list of sub meshes colliding with a collider
  46465. * @param mesh defines the mesh to find the submesh for
  46466. * @param collider defines the collider to evaluate the collision against
  46467. * @returns the list of colliding sub meshes
  46468. */
  46469. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46470. /**
  46471. * Rebuilds the elements related to this component in case of
  46472. * context lost for instance.
  46473. */
  46474. rebuild(): void;
  46475. /**
  46476. * Disposes the component and the associated ressources.
  46477. */
  46478. dispose(): void;
  46479. }
  46480. }
  46481. declare module "babylonjs/Culling/Octrees/index" {
  46482. export * from "babylonjs/Culling/Octrees/octree";
  46483. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46484. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46485. }
  46486. declare module "babylonjs/Culling/index" {
  46487. export * from "babylonjs/Culling/boundingBox";
  46488. export * from "babylonjs/Culling/boundingInfo";
  46489. export * from "babylonjs/Culling/boundingSphere";
  46490. export * from "babylonjs/Culling/Octrees/index";
  46491. export * from "babylonjs/Culling/ray";
  46492. }
  46493. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46494. import { IDisposable, Scene } from "babylonjs/scene";
  46495. import { Nullable } from "babylonjs/types";
  46496. import { Observable } from "babylonjs/Misc/observable";
  46497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46498. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46499. import { Camera } from "babylonjs/Cameras/camera";
  46500. /**
  46501. * Renders a layer on top of an existing scene
  46502. */
  46503. export class UtilityLayerRenderer implements IDisposable {
  46504. /** the original scene that will be rendered on top of */
  46505. originalScene: Scene;
  46506. private _pointerCaptures;
  46507. private _lastPointerEvents;
  46508. private static _DefaultUtilityLayer;
  46509. private static _DefaultKeepDepthUtilityLayer;
  46510. private _sharedGizmoLight;
  46511. private _renderCamera;
  46512. /**
  46513. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46514. * @returns the camera that is used when rendering the utility layer
  46515. */
  46516. getRenderCamera(): Nullable<Camera>;
  46517. /**
  46518. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46519. * @param cam the camera that should be used when rendering the utility layer
  46520. */
  46521. setRenderCamera(cam: Nullable<Camera>): void;
  46522. /**
  46523. * @hidden
  46524. * Light which used by gizmos to get light shading
  46525. */
  46526. _getSharedGizmoLight(): HemisphericLight;
  46527. /**
  46528. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46529. */
  46530. pickUtilitySceneFirst: boolean;
  46531. /**
  46532. * 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)
  46533. */
  46534. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46535. /**
  46536. * 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)
  46537. */
  46538. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46539. /**
  46540. * The scene that is rendered on top of the original scene
  46541. */
  46542. utilityLayerScene: Scene;
  46543. /**
  46544. * If the utility layer should automatically be rendered on top of existing scene
  46545. */
  46546. shouldRender: boolean;
  46547. /**
  46548. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46549. */
  46550. onlyCheckPointerDownEvents: boolean;
  46551. /**
  46552. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46553. */
  46554. processAllEvents: boolean;
  46555. /**
  46556. * Observable raised when the pointer move from the utility layer scene to the main scene
  46557. */
  46558. onPointerOutObservable: Observable<number>;
  46559. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46560. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46561. private _afterRenderObserver;
  46562. private _sceneDisposeObserver;
  46563. private _originalPointerObserver;
  46564. /**
  46565. * Instantiates a UtilityLayerRenderer
  46566. * @param originalScene the original scene that will be rendered on top of
  46567. * @param handleEvents boolean indicating if the utility layer should handle events
  46568. */
  46569. constructor(
  46570. /** the original scene that will be rendered on top of */
  46571. originalScene: Scene, handleEvents?: boolean);
  46572. private _notifyObservers;
  46573. /**
  46574. * Renders the utility layers scene on top of the original scene
  46575. */
  46576. render(): void;
  46577. /**
  46578. * Disposes of the renderer
  46579. */
  46580. dispose(): void;
  46581. private _updateCamera;
  46582. }
  46583. }
  46584. declare module "babylonjs/Gizmos/gizmo" {
  46585. import { Nullable } from "babylonjs/types";
  46586. import { IDisposable } from "babylonjs/scene";
  46587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46588. import { Mesh } from "babylonjs/Meshes/mesh";
  46589. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46590. /**
  46591. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46592. */
  46593. export class Gizmo implements IDisposable {
  46594. /** The utility layer the gizmo will be added to */
  46595. gizmoLayer: UtilityLayerRenderer;
  46596. /**
  46597. * The root mesh of the gizmo
  46598. */
  46599. _rootMesh: Mesh;
  46600. private _attachedMesh;
  46601. /**
  46602. * Ratio for the scale of the gizmo (Default: 1)
  46603. */
  46604. scaleRatio: number;
  46605. /**
  46606. * If a custom mesh has been set (Default: false)
  46607. */
  46608. protected _customMeshSet: boolean;
  46609. /**
  46610. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46611. * * When set, interactions will be enabled
  46612. */
  46613. get attachedMesh(): Nullable<AbstractMesh>;
  46614. set attachedMesh(value: Nullable<AbstractMesh>);
  46615. /**
  46616. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46617. * @param mesh The mesh to replace the default mesh of the gizmo
  46618. */
  46619. setCustomMesh(mesh: Mesh): void;
  46620. /**
  46621. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46622. */
  46623. updateGizmoRotationToMatchAttachedMesh: boolean;
  46624. /**
  46625. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46626. */
  46627. updateGizmoPositionToMatchAttachedMesh: boolean;
  46628. /**
  46629. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46630. */
  46631. updateScale: boolean;
  46632. protected _interactionsEnabled: boolean;
  46633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46634. private _beforeRenderObserver;
  46635. private _tempVector;
  46636. /**
  46637. * Creates a gizmo
  46638. * @param gizmoLayer The utility layer the gizmo will be added to
  46639. */
  46640. constructor(
  46641. /** The utility layer the gizmo will be added to */
  46642. gizmoLayer?: UtilityLayerRenderer);
  46643. /**
  46644. * Updates the gizmo to match the attached mesh's position/rotation
  46645. */
  46646. protected _update(): void;
  46647. /**
  46648. * Disposes of the gizmo
  46649. */
  46650. dispose(): void;
  46651. }
  46652. }
  46653. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46654. import { Observable } from "babylonjs/Misc/observable";
  46655. import { Nullable } from "babylonjs/types";
  46656. import { Vector3 } from "babylonjs/Maths/math.vector";
  46657. import { Color3 } from "babylonjs/Maths/math.color";
  46658. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46660. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46663. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46664. import { Scene } from "babylonjs/scene";
  46665. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46666. /**
  46667. * Single plane drag gizmo
  46668. */
  46669. export class PlaneDragGizmo extends Gizmo {
  46670. /**
  46671. * Drag behavior responsible for the gizmos dragging interactions
  46672. */
  46673. dragBehavior: PointerDragBehavior;
  46674. private _pointerObserver;
  46675. /**
  46676. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46677. */
  46678. snapDistance: number;
  46679. /**
  46680. * Event that fires each time the gizmo snaps to a new location.
  46681. * * snapDistance is the the change in distance
  46682. */
  46683. onSnapObservable: Observable<{
  46684. snapDistance: number;
  46685. }>;
  46686. private _plane;
  46687. private _coloredMaterial;
  46688. private _hoverMaterial;
  46689. private _isEnabled;
  46690. private _parent;
  46691. /** @hidden */
  46692. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46693. /** @hidden */
  46694. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46695. /**
  46696. * Creates a PlaneDragGizmo
  46697. * @param gizmoLayer The utility layer the gizmo will be added to
  46698. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46699. * @param color The color of the gizmo
  46700. */
  46701. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46703. /**
  46704. * If the gizmo is enabled
  46705. */
  46706. set isEnabled(value: boolean);
  46707. get isEnabled(): boolean;
  46708. /**
  46709. * Disposes of the gizmo
  46710. */
  46711. dispose(): void;
  46712. }
  46713. }
  46714. declare module "babylonjs/Gizmos/positionGizmo" {
  46715. import { Observable } from "babylonjs/Misc/observable";
  46716. import { Nullable } from "babylonjs/types";
  46717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46718. import { Mesh } from "babylonjs/Meshes/mesh";
  46719. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46720. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46721. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46722. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46723. /**
  46724. * Gizmo that enables dragging a mesh along 3 axis
  46725. */
  46726. export class PositionGizmo extends Gizmo {
  46727. /**
  46728. * Internal gizmo used for interactions on the x axis
  46729. */
  46730. xGizmo: AxisDragGizmo;
  46731. /**
  46732. * Internal gizmo used for interactions on the y axis
  46733. */
  46734. yGizmo: AxisDragGizmo;
  46735. /**
  46736. * Internal gizmo used for interactions on the z axis
  46737. */
  46738. zGizmo: AxisDragGizmo;
  46739. /**
  46740. * Internal gizmo used for interactions on the yz plane
  46741. */
  46742. xPlaneGizmo: PlaneDragGizmo;
  46743. /**
  46744. * Internal gizmo used for interactions on the xz plane
  46745. */
  46746. yPlaneGizmo: PlaneDragGizmo;
  46747. /**
  46748. * Internal gizmo used for interactions on the xy plane
  46749. */
  46750. zPlaneGizmo: PlaneDragGizmo;
  46751. /**
  46752. * private variables
  46753. */
  46754. private _meshAttached;
  46755. private _updateGizmoRotationToMatchAttachedMesh;
  46756. private _snapDistance;
  46757. private _scaleRatio;
  46758. /** Fires an event when any of it's sub gizmos are dragged */
  46759. onDragStartObservable: Observable<unknown>;
  46760. /** Fires an event when any of it's sub gizmos are released from dragging */
  46761. onDragEndObservable: Observable<unknown>;
  46762. /**
  46763. * If set to true, planar drag is enabled
  46764. */
  46765. private _planarGizmoEnabled;
  46766. get attachedMesh(): Nullable<AbstractMesh>;
  46767. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46768. /**
  46769. * Creates a PositionGizmo
  46770. * @param gizmoLayer The utility layer the gizmo will be added to
  46771. */
  46772. constructor(gizmoLayer?: UtilityLayerRenderer);
  46773. /**
  46774. * If the planar drag gizmo is enabled
  46775. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46776. */
  46777. set planarGizmoEnabled(value: boolean);
  46778. get planarGizmoEnabled(): boolean;
  46779. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46780. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46781. /**
  46782. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46783. */
  46784. set snapDistance(value: number);
  46785. get snapDistance(): number;
  46786. /**
  46787. * Ratio for the scale of the gizmo (Default: 1)
  46788. */
  46789. set scaleRatio(value: number);
  46790. get scaleRatio(): number;
  46791. /**
  46792. * Disposes of the gizmo
  46793. */
  46794. dispose(): void;
  46795. /**
  46796. * CustomMeshes are not supported by this gizmo
  46797. * @param mesh The mesh to replace the default mesh of the gizmo
  46798. */
  46799. setCustomMesh(mesh: Mesh): void;
  46800. }
  46801. }
  46802. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46803. import { Observable } from "babylonjs/Misc/observable";
  46804. import { Nullable } from "babylonjs/types";
  46805. import { Vector3 } from "babylonjs/Maths/math.vector";
  46806. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46808. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46809. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46810. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46811. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46812. import { Scene } from "babylonjs/scene";
  46813. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46814. import { Color3 } from "babylonjs/Maths/math.color";
  46815. /**
  46816. * Single axis drag gizmo
  46817. */
  46818. export class AxisDragGizmo extends Gizmo {
  46819. /**
  46820. * Drag behavior responsible for the gizmos dragging interactions
  46821. */
  46822. dragBehavior: PointerDragBehavior;
  46823. private _pointerObserver;
  46824. /**
  46825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46826. */
  46827. snapDistance: number;
  46828. /**
  46829. * Event that fires each time the gizmo snaps to a new location.
  46830. * * snapDistance is the the change in distance
  46831. */
  46832. onSnapObservable: Observable<{
  46833. snapDistance: number;
  46834. }>;
  46835. private _isEnabled;
  46836. private _parent;
  46837. private _arrow;
  46838. private _coloredMaterial;
  46839. private _hoverMaterial;
  46840. /** @hidden */
  46841. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46842. /** @hidden */
  46843. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46844. /**
  46845. * Creates an AxisDragGizmo
  46846. * @param gizmoLayer The utility layer the gizmo will be added to
  46847. * @param dragAxis The axis which the gizmo will be able to drag on
  46848. * @param color The color of the gizmo
  46849. */
  46850. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46851. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46852. /**
  46853. * If the gizmo is enabled
  46854. */
  46855. set isEnabled(value: boolean);
  46856. get isEnabled(): boolean;
  46857. /**
  46858. * Disposes of the gizmo
  46859. */
  46860. dispose(): void;
  46861. }
  46862. }
  46863. declare module "babylonjs/Debug/axesViewer" {
  46864. import { Vector3 } from "babylonjs/Maths/math.vector";
  46865. import { Nullable } from "babylonjs/types";
  46866. import { Scene } from "babylonjs/scene";
  46867. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46868. /**
  46869. * The Axes viewer will show 3 axes in a specific point in space
  46870. */
  46871. export class AxesViewer {
  46872. private _xAxis;
  46873. private _yAxis;
  46874. private _zAxis;
  46875. private _scaleLinesFactor;
  46876. private _instanced;
  46877. /**
  46878. * Gets the hosting scene
  46879. */
  46880. scene: Scene;
  46881. /**
  46882. * Gets or sets a number used to scale line length
  46883. */
  46884. scaleLines: number;
  46885. /** Gets the node hierarchy used to render x-axis */
  46886. get xAxis(): TransformNode;
  46887. /** Gets the node hierarchy used to render y-axis */
  46888. get yAxis(): TransformNode;
  46889. /** Gets the node hierarchy used to render z-axis */
  46890. get zAxis(): TransformNode;
  46891. /**
  46892. * Creates a new AxesViewer
  46893. * @param scene defines the hosting scene
  46894. * @param scaleLines defines a number used to scale line length (1 by default)
  46895. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46896. * @param xAxis defines the node hierarchy used to render the x-axis
  46897. * @param yAxis defines the node hierarchy used to render the y-axis
  46898. * @param zAxis defines the node hierarchy used to render the z-axis
  46899. */
  46900. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46901. /**
  46902. * Force the viewer to update
  46903. * @param position defines the position of the viewer
  46904. * @param xaxis defines the x axis of the viewer
  46905. * @param yaxis defines the y axis of the viewer
  46906. * @param zaxis defines the z axis of the viewer
  46907. */
  46908. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46909. /**
  46910. * Creates an instance of this axes viewer.
  46911. * @returns a new axes viewer with instanced meshes
  46912. */
  46913. createInstance(): AxesViewer;
  46914. /** Releases resources */
  46915. dispose(): void;
  46916. private static _SetRenderingGroupId;
  46917. }
  46918. }
  46919. declare module "babylonjs/Debug/boneAxesViewer" {
  46920. import { Nullable } from "babylonjs/types";
  46921. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46922. import { Vector3 } from "babylonjs/Maths/math.vector";
  46923. import { Mesh } from "babylonjs/Meshes/mesh";
  46924. import { Bone } from "babylonjs/Bones/bone";
  46925. import { Scene } from "babylonjs/scene";
  46926. /**
  46927. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46928. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46929. */
  46930. export class BoneAxesViewer extends AxesViewer {
  46931. /**
  46932. * Gets or sets the target mesh where to display the axes viewer
  46933. */
  46934. mesh: Nullable<Mesh>;
  46935. /**
  46936. * Gets or sets the target bone where to display the axes viewer
  46937. */
  46938. bone: Nullable<Bone>;
  46939. /** Gets current position */
  46940. pos: Vector3;
  46941. /** Gets direction of X axis */
  46942. xaxis: Vector3;
  46943. /** Gets direction of Y axis */
  46944. yaxis: Vector3;
  46945. /** Gets direction of Z axis */
  46946. zaxis: Vector3;
  46947. /**
  46948. * Creates a new BoneAxesViewer
  46949. * @param scene defines the hosting scene
  46950. * @param bone defines the target bone
  46951. * @param mesh defines the target mesh
  46952. * @param scaleLines defines a scaling factor for line length (1 by default)
  46953. */
  46954. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46955. /**
  46956. * Force the viewer to update
  46957. */
  46958. update(): void;
  46959. /** Releases resources */
  46960. dispose(): void;
  46961. }
  46962. }
  46963. declare module "babylonjs/Debug/debugLayer" {
  46964. import { Scene } from "babylonjs/scene";
  46965. /**
  46966. * Interface used to define scene explorer extensibility option
  46967. */
  46968. export interface IExplorerExtensibilityOption {
  46969. /**
  46970. * Define the option label
  46971. */
  46972. label: string;
  46973. /**
  46974. * Defines the action to execute on click
  46975. */
  46976. action: (entity: any) => void;
  46977. }
  46978. /**
  46979. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46980. */
  46981. export interface IExplorerExtensibilityGroup {
  46982. /**
  46983. * Defines a predicate to test if a given type mut be extended
  46984. */
  46985. predicate: (entity: any) => boolean;
  46986. /**
  46987. * Gets the list of options added to a type
  46988. */
  46989. entries: IExplorerExtensibilityOption[];
  46990. }
  46991. /**
  46992. * Interface used to define the options to use to create the Inspector
  46993. */
  46994. export interface IInspectorOptions {
  46995. /**
  46996. * Display in overlay mode (default: false)
  46997. */
  46998. overlay?: boolean;
  46999. /**
  47000. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47001. */
  47002. globalRoot?: HTMLElement;
  47003. /**
  47004. * Display the Scene explorer
  47005. */
  47006. showExplorer?: boolean;
  47007. /**
  47008. * Display the property inspector
  47009. */
  47010. showInspector?: boolean;
  47011. /**
  47012. * Display in embed mode (both panes on the right)
  47013. */
  47014. embedMode?: boolean;
  47015. /**
  47016. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47017. */
  47018. handleResize?: boolean;
  47019. /**
  47020. * Allow the panes to popup (default: true)
  47021. */
  47022. enablePopup?: boolean;
  47023. /**
  47024. * Allow the panes to be closed by users (default: true)
  47025. */
  47026. enableClose?: boolean;
  47027. /**
  47028. * Optional list of extensibility entries
  47029. */
  47030. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47031. /**
  47032. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47033. */
  47034. inspectorURL?: string;
  47035. /**
  47036. * Optional initial tab (default to DebugLayerTab.Properties)
  47037. */
  47038. initialTab?: DebugLayerTab;
  47039. }
  47040. module "babylonjs/scene" {
  47041. interface Scene {
  47042. /**
  47043. * @hidden
  47044. * Backing field
  47045. */
  47046. _debugLayer: DebugLayer;
  47047. /**
  47048. * Gets the debug layer (aka Inspector) associated with the scene
  47049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47050. */
  47051. debugLayer: DebugLayer;
  47052. }
  47053. }
  47054. /**
  47055. * Enum of inspector action tab
  47056. */
  47057. export enum DebugLayerTab {
  47058. /**
  47059. * Properties tag (default)
  47060. */
  47061. Properties = 0,
  47062. /**
  47063. * Debug tab
  47064. */
  47065. Debug = 1,
  47066. /**
  47067. * Statistics tab
  47068. */
  47069. Statistics = 2,
  47070. /**
  47071. * Tools tab
  47072. */
  47073. Tools = 3,
  47074. /**
  47075. * Settings tab
  47076. */
  47077. Settings = 4
  47078. }
  47079. /**
  47080. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47081. * what is happening in your scene
  47082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47083. */
  47084. export class DebugLayer {
  47085. /**
  47086. * Define the url to get the inspector script from.
  47087. * By default it uses the babylonjs CDN.
  47088. * @ignoreNaming
  47089. */
  47090. static InspectorURL: string;
  47091. private _scene;
  47092. private BJSINSPECTOR;
  47093. private _onPropertyChangedObservable?;
  47094. /**
  47095. * Observable triggered when a property is changed through the inspector.
  47096. */
  47097. get onPropertyChangedObservable(): any;
  47098. /**
  47099. * Instantiates a new debug layer.
  47100. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47101. * what is happening in your scene
  47102. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47103. * @param scene Defines the scene to inspect
  47104. */
  47105. constructor(scene: Scene);
  47106. /** Creates the inspector window. */
  47107. private _createInspector;
  47108. /**
  47109. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47110. * @param entity defines the entity to select
  47111. * @param lineContainerTitle defines the specific block to highlight
  47112. */
  47113. select(entity: any, lineContainerTitle?: string): void;
  47114. /** Get the inspector from bundle or global */
  47115. private _getGlobalInspector;
  47116. /**
  47117. * Get if the inspector is visible or not.
  47118. * @returns true if visible otherwise, false
  47119. */
  47120. isVisible(): boolean;
  47121. /**
  47122. * Hide the inspector and close its window.
  47123. */
  47124. hide(): void;
  47125. /**
  47126. * Launch the debugLayer.
  47127. * @param config Define the configuration of the inspector
  47128. * @return a promise fulfilled when the debug layer is visible
  47129. */
  47130. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47131. }
  47132. }
  47133. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47134. import { Nullable } from "babylonjs/types";
  47135. import { Scene } from "babylonjs/scene";
  47136. import { Vector4 } from "babylonjs/Maths/math.vector";
  47137. import { Color4 } from "babylonjs/Maths/math.color";
  47138. import { Mesh } from "babylonjs/Meshes/mesh";
  47139. /**
  47140. * Class containing static functions to help procedurally build meshes
  47141. */
  47142. export class BoxBuilder {
  47143. /**
  47144. * Creates a box mesh
  47145. * * The parameter `size` sets the size (float) of each box side (default 1)
  47146. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47147. * * 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)
  47148. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47152. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47153. * @param name defines the name of the mesh
  47154. * @param options defines the options used to create the mesh
  47155. * @param scene defines the hosting scene
  47156. * @returns the box mesh
  47157. */
  47158. static CreateBox(name: string, options: {
  47159. size?: number;
  47160. width?: number;
  47161. height?: number;
  47162. depth?: number;
  47163. faceUV?: Vector4[];
  47164. faceColors?: Color4[];
  47165. sideOrientation?: number;
  47166. frontUVs?: Vector4;
  47167. backUVs?: Vector4;
  47168. wrap?: boolean;
  47169. topBaseAt?: number;
  47170. bottomBaseAt?: number;
  47171. updatable?: boolean;
  47172. }, scene?: Nullable<Scene>): Mesh;
  47173. }
  47174. }
  47175. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47176. import { Vector4 } from "babylonjs/Maths/math.vector";
  47177. import { Mesh } from "babylonjs/Meshes/mesh";
  47178. import { Scene } from "babylonjs/scene";
  47179. import { Nullable } from "babylonjs/types";
  47180. /**
  47181. * Class containing static functions to help procedurally build meshes
  47182. */
  47183. export class SphereBuilder {
  47184. /**
  47185. * Creates a sphere mesh
  47186. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47187. * * 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`)
  47188. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47189. * * 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
  47190. * * 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)
  47191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47194. * @param name defines the name of the mesh
  47195. * @param options defines the options used to create the mesh
  47196. * @param scene defines the hosting scene
  47197. * @returns the sphere mesh
  47198. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47199. */
  47200. static CreateSphere(name: string, options: {
  47201. segments?: number;
  47202. diameter?: number;
  47203. diameterX?: number;
  47204. diameterY?: number;
  47205. diameterZ?: number;
  47206. arc?: number;
  47207. slice?: number;
  47208. sideOrientation?: number;
  47209. frontUVs?: Vector4;
  47210. backUVs?: Vector4;
  47211. updatable?: boolean;
  47212. }, scene?: Nullable<Scene>): Mesh;
  47213. }
  47214. }
  47215. declare module "babylonjs/Debug/physicsViewer" {
  47216. import { Nullable } from "babylonjs/types";
  47217. import { Scene } from "babylonjs/scene";
  47218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47219. import { Mesh } from "babylonjs/Meshes/mesh";
  47220. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47221. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47222. /**
  47223. * Used to show the physics impostor around the specific mesh
  47224. */
  47225. export class PhysicsViewer {
  47226. /** @hidden */
  47227. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47228. /** @hidden */
  47229. protected _meshes: Array<Nullable<AbstractMesh>>;
  47230. /** @hidden */
  47231. protected _scene: Nullable<Scene>;
  47232. /** @hidden */
  47233. protected _numMeshes: number;
  47234. /** @hidden */
  47235. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47236. private _renderFunction;
  47237. private _utilityLayer;
  47238. private _debugBoxMesh;
  47239. private _debugSphereMesh;
  47240. private _debugCylinderMesh;
  47241. private _debugMaterial;
  47242. private _debugMeshMeshes;
  47243. /**
  47244. * Creates a new PhysicsViewer
  47245. * @param scene defines the hosting scene
  47246. */
  47247. constructor(scene: Scene);
  47248. /** @hidden */
  47249. protected _updateDebugMeshes(): void;
  47250. /**
  47251. * Renders a specified physic impostor
  47252. * @param impostor defines the impostor to render
  47253. * @param targetMesh defines the mesh represented by the impostor
  47254. * @returns the new debug mesh used to render the impostor
  47255. */
  47256. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47257. /**
  47258. * Hides a specified physic impostor
  47259. * @param impostor defines the impostor to hide
  47260. */
  47261. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47262. private _getDebugMaterial;
  47263. private _getDebugBoxMesh;
  47264. private _getDebugSphereMesh;
  47265. private _getDebugCylinderMesh;
  47266. private _getDebugMeshMesh;
  47267. private _getDebugMesh;
  47268. /** Releases all resources */
  47269. dispose(): void;
  47270. }
  47271. }
  47272. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47273. import { Vector3 } from "babylonjs/Maths/math.vector";
  47274. import { Color4 } from "babylonjs/Maths/math.color";
  47275. import { Nullable } from "babylonjs/types";
  47276. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47277. import { Scene } from "babylonjs/scene";
  47278. /**
  47279. * Class containing static functions to help procedurally build meshes
  47280. */
  47281. export class LinesBuilder {
  47282. /**
  47283. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47284. * * 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
  47285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47286. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47287. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47288. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47290. * * 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
  47291. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47294. * @param name defines the name of the new line system
  47295. * @param options defines the options used to create the line system
  47296. * @param scene defines the hosting scene
  47297. * @returns a new line system mesh
  47298. */
  47299. static CreateLineSystem(name: string, options: {
  47300. lines: Vector3[][];
  47301. updatable?: boolean;
  47302. instance?: Nullable<LinesMesh>;
  47303. colors?: Nullable<Color4[][]>;
  47304. useVertexAlpha?: boolean;
  47305. }, scene: Nullable<Scene>): LinesMesh;
  47306. /**
  47307. * Creates a line mesh
  47308. * 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
  47309. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47310. * * The parameter `points` is an array successive Vector3
  47311. * * 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
  47312. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47313. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47314. * * When updating an instance, remember that only point positions can change, not the number of points
  47315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47317. * @param name defines the name of the new line system
  47318. * @param options defines the options used to create the line system
  47319. * @param scene defines the hosting scene
  47320. * @returns a new line mesh
  47321. */
  47322. static CreateLines(name: string, options: {
  47323. points: Vector3[];
  47324. updatable?: boolean;
  47325. instance?: Nullable<LinesMesh>;
  47326. colors?: Color4[];
  47327. useVertexAlpha?: boolean;
  47328. }, scene?: Nullable<Scene>): LinesMesh;
  47329. /**
  47330. * Creates a dashed line mesh
  47331. * * 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
  47332. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47333. * * The parameter `points` is an array successive Vector3
  47334. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47335. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47336. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47337. * * 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
  47338. * * When updating an instance, remember that only point positions can change, not the number of points
  47339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47340. * @param name defines the name of the mesh
  47341. * @param options defines the options used to create the mesh
  47342. * @param scene defines the hosting scene
  47343. * @returns the dashed line mesh
  47344. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47345. */
  47346. static CreateDashedLines(name: string, options: {
  47347. points: Vector3[];
  47348. dashSize?: number;
  47349. gapSize?: number;
  47350. dashNb?: number;
  47351. updatable?: boolean;
  47352. instance?: LinesMesh;
  47353. }, scene?: Nullable<Scene>): LinesMesh;
  47354. }
  47355. }
  47356. declare module "babylonjs/Debug/rayHelper" {
  47357. import { Nullable } from "babylonjs/types";
  47358. import { Ray } from "babylonjs/Culling/ray";
  47359. import { Vector3 } from "babylonjs/Maths/math.vector";
  47360. import { Color3 } from "babylonjs/Maths/math.color";
  47361. import { Scene } from "babylonjs/scene";
  47362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47363. import "babylonjs/Meshes/Builders/linesBuilder";
  47364. /**
  47365. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47366. * in order to better appreciate the issue one might have.
  47367. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47368. */
  47369. export class RayHelper {
  47370. /**
  47371. * Defines the ray we are currently tryin to visualize.
  47372. */
  47373. ray: Nullable<Ray>;
  47374. private _renderPoints;
  47375. private _renderLine;
  47376. private _renderFunction;
  47377. private _scene;
  47378. private _updateToMeshFunction;
  47379. private _attachedToMesh;
  47380. private _meshSpaceDirection;
  47381. private _meshSpaceOrigin;
  47382. /**
  47383. * Helper function to create a colored helper in a scene in one line.
  47384. * @param ray Defines the ray we are currently tryin to visualize
  47385. * @param scene Defines the scene the ray is used in
  47386. * @param color Defines the color we want to see the ray in
  47387. * @returns The newly created ray helper.
  47388. */
  47389. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47390. /**
  47391. * Instantiate a new ray helper.
  47392. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47393. * in order to better appreciate the issue one might have.
  47394. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47395. * @param ray Defines the ray we are currently tryin to visualize
  47396. */
  47397. constructor(ray: Ray);
  47398. /**
  47399. * Shows the ray we are willing to debug.
  47400. * @param scene Defines the scene the ray needs to be rendered in
  47401. * @param color Defines the color the ray needs to be rendered in
  47402. */
  47403. show(scene: Scene, color?: Color3): void;
  47404. /**
  47405. * Hides the ray we are debugging.
  47406. */
  47407. hide(): void;
  47408. private _render;
  47409. /**
  47410. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47411. * @param mesh Defines the mesh we want the helper attached to
  47412. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47413. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47414. * @param length Defines the length of the ray
  47415. */
  47416. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47417. /**
  47418. * Detach the ray helper from the mesh it has previously been attached to.
  47419. */
  47420. detachFromMesh(): void;
  47421. private _updateToMesh;
  47422. /**
  47423. * Dispose the helper and release its associated resources.
  47424. */
  47425. dispose(): void;
  47426. }
  47427. }
  47428. declare module "babylonjs/Debug/skeletonViewer" {
  47429. import { Color3 } from "babylonjs/Maths/math.color";
  47430. import { Scene } from "babylonjs/scene";
  47431. import { Nullable } from "babylonjs/types";
  47432. import { Skeleton } from "babylonjs/Bones/skeleton";
  47433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47434. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47435. /**
  47436. * Class used to render a debug view of a given skeleton
  47437. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47438. */
  47439. export class SkeletonViewer {
  47440. /** defines the skeleton to render */
  47441. skeleton: Skeleton;
  47442. /** defines the mesh attached to the skeleton */
  47443. mesh: AbstractMesh;
  47444. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47445. autoUpdateBonesMatrices: boolean;
  47446. /** defines the rendering group id to use with the viewer */
  47447. renderingGroupId: number;
  47448. /** Gets or sets the color used to render the skeleton */
  47449. color: Color3;
  47450. private _scene;
  47451. private _debugLines;
  47452. private _debugMesh;
  47453. private _isEnabled;
  47454. private _renderFunction;
  47455. private _utilityLayer;
  47456. /**
  47457. * Returns the mesh used to render the bones
  47458. */
  47459. get debugMesh(): Nullable<LinesMesh>;
  47460. /**
  47461. * Creates a new SkeletonViewer
  47462. * @param skeleton defines the skeleton to render
  47463. * @param mesh defines the mesh attached to the skeleton
  47464. * @param scene defines the hosting scene
  47465. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47466. * @param renderingGroupId defines the rendering group id to use with the viewer
  47467. */
  47468. constructor(
  47469. /** defines the skeleton to render */
  47470. skeleton: Skeleton,
  47471. /** defines the mesh attached to the skeleton */
  47472. mesh: AbstractMesh, scene: Scene,
  47473. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47474. autoUpdateBonesMatrices?: boolean,
  47475. /** defines the rendering group id to use with the viewer */
  47476. renderingGroupId?: number);
  47477. /** Gets or sets a boolean indicating if the viewer is enabled */
  47478. set isEnabled(value: boolean);
  47479. get isEnabled(): boolean;
  47480. private _getBonePosition;
  47481. private _getLinesForBonesWithLength;
  47482. private _getLinesForBonesNoLength;
  47483. /** Update the viewer to sync with current skeleton state */
  47484. update(): void;
  47485. /** Release associated resources */
  47486. dispose(): void;
  47487. }
  47488. }
  47489. declare module "babylonjs/Debug/index" {
  47490. export * from "babylonjs/Debug/axesViewer";
  47491. export * from "babylonjs/Debug/boneAxesViewer";
  47492. export * from "babylonjs/Debug/debugLayer";
  47493. export * from "babylonjs/Debug/physicsViewer";
  47494. export * from "babylonjs/Debug/rayHelper";
  47495. export * from "babylonjs/Debug/skeletonViewer";
  47496. }
  47497. declare module "babylonjs/Engines/nullEngine" {
  47498. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47499. import { Scene } from "babylonjs/scene";
  47500. import { Engine } from "babylonjs/Engines/engine";
  47501. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47502. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47504. import { Effect } from "babylonjs/Materials/effect";
  47505. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47506. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47507. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47508. /**
  47509. * Options to create the null engine
  47510. */
  47511. export class NullEngineOptions {
  47512. /**
  47513. * Render width (Default: 512)
  47514. */
  47515. renderWidth: number;
  47516. /**
  47517. * Render height (Default: 256)
  47518. */
  47519. renderHeight: number;
  47520. /**
  47521. * Texture size (Default: 512)
  47522. */
  47523. textureSize: number;
  47524. /**
  47525. * If delta time between frames should be constant
  47526. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47527. */
  47528. deterministicLockstep: boolean;
  47529. /**
  47530. * Maximum about of steps between frames (Default: 4)
  47531. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47532. */
  47533. lockstepMaxSteps: number;
  47534. }
  47535. /**
  47536. * The null engine class provides support for headless version of babylon.js.
  47537. * This can be used in server side scenario or for testing purposes
  47538. */
  47539. export class NullEngine extends Engine {
  47540. private _options;
  47541. /**
  47542. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47544. * @returns true if engine is in deterministic lock step mode
  47545. */
  47546. isDeterministicLockStep(): boolean;
  47547. /**
  47548. * Gets the max steps when engine is running in deterministic lock step
  47549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47550. * @returns the max steps
  47551. */
  47552. getLockstepMaxSteps(): number;
  47553. /**
  47554. * Gets the current hardware scaling level.
  47555. * By default the hardware scaling level is computed from the window device ratio.
  47556. * 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.
  47557. * @returns a number indicating the current hardware scaling level
  47558. */
  47559. getHardwareScalingLevel(): number;
  47560. constructor(options?: NullEngineOptions);
  47561. /**
  47562. * Creates a vertex buffer
  47563. * @param vertices the data for the vertex buffer
  47564. * @returns the new WebGL static buffer
  47565. */
  47566. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47567. /**
  47568. * Creates a new index buffer
  47569. * @param indices defines the content of the index buffer
  47570. * @param updatable defines if the index buffer must be updatable
  47571. * @returns a new webGL buffer
  47572. */
  47573. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47574. /**
  47575. * Clear the current render buffer or the current render target (if any is set up)
  47576. * @param color defines the color to use
  47577. * @param backBuffer defines if the back buffer must be cleared
  47578. * @param depth defines if the depth buffer must be cleared
  47579. * @param stencil defines if the stencil buffer must be cleared
  47580. */
  47581. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47582. /**
  47583. * Gets the current render width
  47584. * @param useScreen defines if screen size must be used (or the current render target if any)
  47585. * @returns a number defining the current render width
  47586. */
  47587. getRenderWidth(useScreen?: boolean): number;
  47588. /**
  47589. * Gets the current render height
  47590. * @param useScreen defines if screen size must be used (or the current render target if any)
  47591. * @returns a number defining the current render height
  47592. */
  47593. getRenderHeight(useScreen?: boolean): number;
  47594. /**
  47595. * Set the WebGL's viewport
  47596. * @param viewport defines the viewport element to be used
  47597. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47598. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47599. */
  47600. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47601. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47602. /**
  47603. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47604. * @param pipelineContext defines the pipeline context to use
  47605. * @param uniformsNames defines the list of uniform names
  47606. * @returns an array of webGL uniform locations
  47607. */
  47608. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47609. /**
  47610. * Gets the lsit of active attributes for a given webGL program
  47611. * @param pipelineContext defines the pipeline context to use
  47612. * @param attributesNames defines the list of attribute names to get
  47613. * @returns an array of indices indicating the offset of each attribute
  47614. */
  47615. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47616. /**
  47617. * Binds an effect to the webGL context
  47618. * @param effect defines the effect to bind
  47619. */
  47620. bindSamplers(effect: Effect): void;
  47621. /**
  47622. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47623. * @param effect defines the effect to activate
  47624. */
  47625. enableEffect(effect: Effect): void;
  47626. /**
  47627. * Set various states to the webGL context
  47628. * @param culling defines backface culling state
  47629. * @param zOffset defines the value to apply to zOffset (0 by default)
  47630. * @param force defines if states must be applied even if cache is up to date
  47631. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47632. */
  47633. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47634. /**
  47635. * Set the value of an uniform to an array of int32
  47636. * @param uniform defines the webGL uniform location where to store the value
  47637. * @param array defines the array of int32 to store
  47638. */
  47639. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47640. /**
  47641. * Set the value of an uniform to an array of int32 (stored as vec2)
  47642. * @param uniform defines the webGL uniform location where to store the value
  47643. * @param array defines the array of int32 to store
  47644. */
  47645. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47646. /**
  47647. * Set the value of an uniform to an array of int32 (stored as vec3)
  47648. * @param uniform defines the webGL uniform location where to store the value
  47649. * @param array defines the array of int32 to store
  47650. */
  47651. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47652. /**
  47653. * Set the value of an uniform to an array of int32 (stored as vec4)
  47654. * @param uniform defines the webGL uniform location where to store the value
  47655. * @param array defines the array of int32 to store
  47656. */
  47657. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47658. /**
  47659. * Set the value of an uniform to an array of float32
  47660. * @param uniform defines the webGL uniform location where to store the value
  47661. * @param array defines the array of float32 to store
  47662. */
  47663. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47664. /**
  47665. * Set the value of an uniform to an array of float32 (stored as vec2)
  47666. * @param uniform defines the webGL uniform location where to store the value
  47667. * @param array defines the array of float32 to store
  47668. */
  47669. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47670. /**
  47671. * Set the value of an uniform to an array of float32 (stored as vec3)
  47672. * @param uniform defines the webGL uniform location where to store the value
  47673. * @param array defines the array of float32 to store
  47674. */
  47675. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47676. /**
  47677. * Set the value of an uniform to an array of float32 (stored as vec4)
  47678. * @param uniform defines the webGL uniform location where to store the value
  47679. * @param array defines the array of float32 to store
  47680. */
  47681. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47682. /**
  47683. * Set the value of an uniform to an array of number
  47684. * @param uniform defines the webGL uniform location where to store the value
  47685. * @param array defines the array of number to store
  47686. */
  47687. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47688. /**
  47689. * Set the value of an uniform to an array of number (stored as vec2)
  47690. * @param uniform defines the webGL uniform location where to store the value
  47691. * @param array defines the array of number to store
  47692. */
  47693. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47694. /**
  47695. * Set the value of an uniform to an array of number (stored as vec3)
  47696. * @param uniform defines the webGL uniform location where to store the value
  47697. * @param array defines the array of number to store
  47698. */
  47699. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47700. /**
  47701. * Set the value of an uniform to an array of number (stored as vec4)
  47702. * @param uniform defines the webGL uniform location where to store the value
  47703. * @param array defines the array of number to store
  47704. */
  47705. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47706. /**
  47707. * Set the value of an uniform to an array of float32 (stored as matrices)
  47708. * @param uniform defines the webGL uniform location where to store the value
  47709. * @param matrices defines the array of float32 to store
  47710. */
  47711. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47712. /**
  47713. * Set the value of an uniform to a matrix (3x3)
  47714. * @param uniform defines the webGL uniform location where to store the value
  47715. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47716. */
  47717. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47718. /**
  47719. * Set the value of an uniform to a matrix (2x2)
  47720. * @param uniform defines the webGL uniform location where to store the value
  47721. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47722. */
  47723. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47724. /**
  47725. * Set the value of an uniform to a number (float)
  47726. * @param uniform defines the webGL uniform location where to store the value
  47727. * @param value defines the float number to store
  47728. */
  47729. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47730. /**
  47731. * Set the value of an uniform to a vec2
  47732. * @param uniform defines the webGL uniform location where to store the value
  47733. * @param x defines the 1st component of the value
  47734. * @param y defines the 2nd component of the value
  47735. */
  47736. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47737. /**
  47738. * Set the value of an uniform to a vec3
  47739. * @param uniform defines the webGL uniform location where to store the value
  47740. * @param x defines the 1st component of the value
  47741. * @param y defines the 2nd component of the value
  47742. * @param z defines the 3rd component of the value
  47743. */
  47744. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47745. /**
  47746. * Set the value of an uniform to a boolean
  47747. * @param uniform defines the webGL uniform location where to store the value
  47748. * @param bool defines the boolean to store
  47749. */
  47750. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47751. /**
  47752. * Set the value of an uniform to a vec4
  47753. * @param uniform defines the webGL uniform location where to store the value
  47754. * @param x defines the 1st component of the value
  47755. * @param y defines the 2nd component of the value
  47756. * @param z defines the 3rd component of the value
  47757. * @param w defines the 4th component of the value
  47758. */
  47759. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47760. /**
  47761. * Sets the current alpha mode
  47762. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47763. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47764. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47765. */
  47766. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47767. /**
  47768. * Bind webGl buffers directly to the webGL context
  47769. * @param vertexBuffers defines the vertex buffer to bind
  47770. * @param indexBuffer defines the index buffer to bind
  47771. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47772. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47773. * @param effect defines the effect associated with the vertex buffer
  47774. */
  47775. bindBuffers(vertexBuffers: {
  47776. [key: string]: VertexBuffer;
  47777. }, indexBuffer: DataBuffer, effect: Effect): void;
  47778. /**
  47779. * Force the entire cache to be cleared
  47780. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47781. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47782. */
  47783. wipeCaches(bruteForce?: boolean): void;
  47784. /**
  47785. * Send a draw order
  47786. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47787. * @param indexStart defines the starting index
  47788. * @param indexCount defines the number of index to draw
  47789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47790. */
  47791. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47792. /**
  47793. * Draw a list of indexed primitives
  47794. * @param fillMode defines the primitive to use
  47795. * @param indexStart defines the starting index
  47796. * @param indexCount defines the number of index to draw
  47797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47798. */
  47799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47800. /**
  47801. * Draw a list of unindexed primitives
  47802. * @param fillMode defines the primitive to use
  47803. * @param verticesStart defines the index of first vertex to draw
  47804. * @param verticesCount defines the count of vertices to draw
  47805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47806. */
  47807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47808. /** @hidden */
  47809. _createTexture(): WebGLTexture;
  47810. /** @hidden */
  47811. _releaseTexture(texture: InternalTexture): void;
  47812. /**
  47813. * Usually called from Texture.ts.
  47814. * Passed information to create a WebGLTexture
  47815. * @param urlArg defines a value which contains one of the following:
  47816. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47817. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47818. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47820. * @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)
  47821. * @param scene needed for loading to the correct scene
  47822. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47823. * @param onLoad optional callback to be called upon successful completion
  47824. * @param onError optional callback to be called upon failure
  47825. * @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
  47826. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47827. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47828. * @param forcedExtension defines the extension to use to pick the right loader
  47829. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47830. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47831. */
  47832. 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;
  47833. /**
  47834. * Creates a new render target texture
  47835. * @param size defines the size of the texture
  47836. * @param options defines the options used to create the texture
  47837. * @returns a new render target texture stored in an InternalTexture
  47838. */
  47839. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47840. /**
  47841. * Update the sampling mode of a given texture
  47842. * @param samplingMode defines the required sampling mode
  47843. * @param texture defines the texture to update
  47844. */
  47845. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47846. /**
  47847. * Binds the frame buffer to the specified texture.
  47848. * @param texture The texture to render to or null for the default canvas
  47849. * @param faceIndex The face of the texture to render to in case of cube texture
  47850. * @param requiredWidth The width of the target to render to
  47851. * @param requiredHeight The height of the target to render to
  47852. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47853. * @param depthStencilTexture The depth stencil texture to use to render
  47854. * @param lodLevel defines le lod level to bind to the frame buffer
  47855. */
  47856. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47857. /**
  47858. * Unbind the current render target texture from the webGL context
  47859. * @param texture defines the render target texture to unbind
  47860. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47861. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47862. */
  47863. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47864. /**
  47865. * Creates a dynamic vertex buffer
  47866. * @param vertices the data for the dynamic vertex buffer
  47867. * @returns the new WebGL dynamic buffer
  47868. */
  47869. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47870. /**
  47871. * Update the content of a dynamic texture
  47872. * @param texture defines the texture to update
  47873. * @param canvas defines the canvas containing the source
  47874. * @param invertY defines if data must be stored with Y axis inverted
  47875. * @param premulAlpha defines if alpha is stored as premultiplied
  47876. * @param format defines the format of the data
  47877. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47878. */
  47879. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47880. /**
  47881. * Gets a boolean indicating if all created effects are ready
  47882. * @returns true if all effects are ready
  47883. */
  47884. areAllEffectsReady(): boolean;
  47885. /**
  47886. * @hidden
  47887. * Get the current error code of the webGL context
  47888. * @returns the error code
  47889. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47890. */
  47891. getError(): number;
  47892. /** @hidden */
  47893. _getUnpackAlignement(): number;
  47894. /** @hidden */
  47895. _unpackFlipY(value: boolean): void;
  47896. /**
  47897. * Update a dynamic index buffer
  47898. * @param indexBuffer defines the target index buffer
  47899. * @param indices defines the data to update
  47900. * @param offset defines the offset in the target index buffer where update should start
  47901. */
  47902. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47903. /**
  47904. * Updates a dynamic vertex buffer.
  47905. * @param vertexBuffer the vertex buffer to update
  47906. * @param vertices the data used to update the vertex buffer
  47907. * @param byteOffset the byte offset of the data (optional)
  47908. * @param byteLength the byte length of the data (optional)
  47909. */
  47910. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47911. /** @hidden */
  47912. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47913. /** @hidden */
  47914. _bindTexture(channel: number, texture: InternalTexture): void;
  47915. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47916. /**
  47917. * 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
  47918. */
  47919. releaseEffects(): void;
  47920. displayLoadingUI(): void;
  47921. hideLoadingUI(): void;
  47922. /** @hidden */
  47923. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47924. /** @hidden */
  47925. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47926. /** @hidden */
  47927. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47928. /** @hidden */
  47929. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47930. }
  47931. }
  47932. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  47933. import { Nullable, int } from "babylonjs/types";
  47934. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  47935. /** @hidden */
  47936. export class _OcclusionDataStorage {
  47937. /** @hidden */
  47938. occlusionInternalRetryCounter: number;
  47939. /** @hidden */
  47940. isOcclusionQueryInProgress: boolean;
  47941. /** @hidden */
  47942. isOccluded: boolean;
  47943. /** @hidden */
  47944. occlusionRetryCount: number;
  47945. /** @hidden */
  47946. occlusionType: number;
  47947. /** @hidden */
  47948. occlusionQueryAlgorithmType: number;
  47949. }
  47950. module "babylonjs/Engines/engine" {
  47951. interface Engine {
  47952. /**
  47953. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47954. * @return the new query
  47955. */
  47956. createQuery(): WebGLQuery;
  47957. /**
  47958. * Delete and release a webGL query
  47959. * @param query defines the query to delete
  47960. * @return the current engine
  47961. */
  47962. deleteQuery(query: WebGLQuery): Engine;
  47963. /**
  47964. * Check if a given query has resolved and got its value
  47965. * @param query defines the query to check
  47966. * @returns true if the query got its value
  47967. */
  47968. isQueryResultAvailable(query: WebGLQuery): boolean;
  47969. /**
  47970. * Gets the value of a given query
  47971. * @param query defines the query to check
  47972. * @returns the value of the query
  47973. */
  47974. getQueryResult(query: WebGLQuery): number;
  47975. /**
  47976. * Initiates an occlusion query
  47977. * @param algorithmType defines the algorithm to use
  47978. * @param query defines the query to use
  47979. * @returns the current engine
  47980. * @see http://doc.babylonjs.com/features/occlusionquery
  47981. */
  47982. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47983. /**
  47984. * Ends an occlusion query
  47985. * @see http://doc.babylonjs.com/features/occlusionquery
  47986. * @param algorithmType defines the algorithm to use
  47987. * @returns the current engine
  47988. */
  47989. endOcclusionQuery(algorithmType: number): Engine;
  47990. /**
  47991. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47992. * Please note that only one query can be issued at a time
  47993. * @returns a time token used to track the time span
  47994. */
  47995. startTimeQuery(): Nullable<_TimeToken>;
  47996. /**
  47997. * Ends a time query
  47998. * @param token defines the token used to measure the time span
  47999. * @returns the time spent (in ns)
  48000. */
  48001. endTimeQuery(token: _TimeToken): int;
  48002. /** @hidden */
  48003. _currentNonTimestampToken: Nullable<_TimeToken>;
  48004. /** @hidden */
  48005. _createTimeQuery(): WebGLQuery;
  48006. /** @hidden */
  48007. _deleteTimeQuery(query: WebGLQuery): void;
  48008. /** @hidden */
  48009. _getGlAlgorithmType(algorithmType: number): number;
  48010. /** @hidden */
  48011. _getTimeQueryResult(query: WebGLQuery): any;
  48012. /** @hidden */
  48013. _getTimeQueryAvailability(query: WebGLQuery): any;
  48014. }
  48015. }
  48016. module "babylonjs/Meshes/abstractMesh" {
  48017. interface AbstractMesh {
  48018. /**
  48019. * Backing filed
  48020. * @hidden
  48021. */
  48022. __occlusionDataStorage: _OcclusionDataStorage;
  48023. /**
  48024. * Access property
  48025. * @hidden
  48026. */
  48027. _occlusionDataStorage: _OcclusionDataStorage;
  48028. /**
  48029. * 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.
  48030. * The default value is -1 which means don't break the query and wait till the result
  48031. * @see http://doc.babylonjs.com/features/occlusionquery
  48032. */
  48033. occlusionRetryCount: number;
  48034. /**
  48035. * 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:
  48036. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48037. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48038. * * 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.
  48039. * @see http://doc.babylonjs.com/features/occlusionquery
  48040. */
  48041. occlusionType: number;
  48042. /**
  48043. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48044. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48045. * * 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.
  48046. * @see http://doc.babylonjs.com/features/occlusionquery
  48047. */
  48048. occlusionQueryAlgorithmType: number;
  48049. /**
  48050. * 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
  48051. * @see http://doc.babylonjs.com/features/occlusionquery
  48052. */
  48053. isOccluded: boolean;
  48054. /**
  48055. * Flag to check the progress status of the query
  48056. * @see http://doc.babylonjs.com/features/occlusionquery
  48057. */
  48058. isOcclusionQueryInProgress: boolean;
  48059. }
  48060. }
  48061. }
  48062. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48063. import { Nullable } from "babylonjs/types";
  48064. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48065. /** @hidden */
  48066. export var _forceTransformFeedbackToBundle: boolean;
  48067. module "babylonjs/Engines/engine" {
  48068. interface Engine {
  48069. /**
  48070. * Creates a webGL transform feedback object
  48071. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48072. * @returns the webGL transform feedback object
  48073. */
  48074. createTransformFeedback(): WebGLTransformFeedback;
  48075. /**
  48076. * Delete a webGL transform feedback object
  48077. * @param value defines the webGL transform feedback object to delete
  48078. */
  48079. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48080. /**
  48081. * Bind a webGL transform feedback object to the webgl context
  48082. * @param value defines the webGL transform feedback object to bind
  48083. */
  48084. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48085. /**
  48086. * Begins a transform feedback operation
  48087. * @param usePoints defines if points or triangles must be used
  48088. */
  48089. beginTransformFeedback(usePoints: boolean): void;
  48090. /**
  48091. * Ends a transform feedback operation
  48092. */
  48093. endTransformFeedback(): void;
  48094. /**
  48095. * Specify the varyings to use with transform feedback
  48096. * @param program defines the associated webGL program
  48097. * @param value defines the list of strings representing the varying names
  48098. */
  48099. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48100. /**
  48101. * Bind a webGL buffer for a transform feedback operation
  48102. * @param value defines the webGL buffer to bind
  48103. */
  48104. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48105. }
  48106. }
  48107. }
  48108. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48109. import { Scene } from "babylonjs/scene";
  48110. import { Engine } from "babylonjs/Engines/engine";
  48111. import { Texture } from "babylonjs/Materials/Textures/texture";
  48112. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48113. import "babylonjs/Engines/Extensions/engine.multiRender";
  48114. /**
  48115. * Creation options of the multi render target texture.
  48116. */
  48117. export interface IMultiRenderTargetOptions {
  48118. /**
  48119. * Define if the texture needs to create mip maps after render.
  48120. */
  48121. generateMipMaps?: boolean;
  48122. /**
  48123. * Define the types of all the draw buffers we want to create
  48124. */
  48125. types?: number[];
  48126. /**
  48127. * Define the sampling modes of all the draw buffers we want to create
  48128. */
  48129. samplingModes?: number[];
  48130. /**
  48131. * Define if a depth buffer is required
  48132. */
  48133. generateDepthBuffer?: boolean;
  48134. /**
  48135. * Define if a stencil buffer is required
  48136. */
  48137. generateStencilBuffer?: boolean;
  48138. /**
  48139. * Define if a depth texture is required instead of a depth buffer
  48140. */
  48141. generateDepthTexture?: boolean;
  48142. /**
  48143. * Define the number of desired draw buffers
  48144. */
  48145. textureCount?: number;
  48146. /**
  48147. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48148. */
  48149. doNotChangeAspectRatio?: boolean;
  48150. /**
  48151. * Define the default type of the buffers we are creating
  48152. */
  48153. defaultType?: number;
  48154. }
  48155. /**
  48156. * A multi render target, like a render target provides the ability to render to a texture.
  48157. * Unlike the render target, it can render to several draw buffers in one draw.
  48158. * This is specially interesting in deferred rendering or for any effects requiring more than
  48159. * just one color from a single pass.
  48160. */
  48161. export class MultiRenderTarget extends RenderTargetTexture {
  48162. private _internalTextures;
  48163. private _textures;
  48164. private _multiRenderTargetOptions;
  48165. /**
  48166. * Get if draw buffers are currently supported by the used hardware and browser.
  48167. */
  48168. get isSupported(): boolean;
  48169. /**
  48170. * Get the list of textures generated by the multi render target.
  48171. */
  48172. get textures(): Texture[];
  48173. /**
  48174. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48175. */
  48176. get depthTexture(): Texture;
  48177. /**
  48178. * Set the wrapping mode on U of all the textures we are rendering to.
  48179. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48180. */
  48181. set wrapU(wrap: number);
  48182. /**
  48183. * Set the wrapping mode on V of all the textures we are rendering to.
  48184. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48185. */
  48186. set wrapV(wrap: number);
  48187. /**
  48188. * Instantiate a new multi render target texture.
  48189. * A multi render target, like a render target provides the ability to render to a texture.
  48190. * Unlike the render target, it can render to several draw buffers in one draw.
  48191. * This is specially interesting in deferred rendering or for any effects requiring more than
  48192. * just one color from a single pass.
  48193. * @param name Define the name of the texture
  48194. * @param size Define the size of the buffers to render to
  48195. * @param count Define the number of target we are rendering into
  48196. * @param scene Define the scene the texture belongs to
  48197. * @param options Define the options used to create the multi render target
  48198. */
  48199. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48200. /** @hidden */
  48201. _rebuild(): void;
  48202. private _createInternalTextures;
  48203. private _createTextures;
  48204. /**
  48205. * Define the number of samples used if MSAA is enabled.
  48206. */
  48207. get samples(): number;
  48208. set samples(value: number);
  48209. /**
  48210. * Resize all the textures in the multi render target.
  48211. * Be carrefull as it will recreate all the data in the new texture.
  48212. * @param size Define the new size
  48213. */
  48214. resize(size: any): void;
  48215. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48216. /**
  48217. * Dispose the render targets and their associated resources
  48218. */
  48219. dispose(): void;
  48220. /**
  48221. * Release all the underlying texture used as draw buffers.
  48222. */
  48223. releaseInternalTextures(): void;
  48224. }
  48225. }
  48226. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48228. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48229. import { Nullable } from "babylonjs/types";
  48230. module "babylonjs/Engines/thinEngine" {
  48231. interface ThinEngine {
  48232. /**
  48233. * Unbind a list of render target textures from the webGL context
  48234. * This is used only when drawBuffer extension or webGL2 are active
  48235. * @param textures defines the render target textures to unbind
  48236. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48237. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48238. */
  48239. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48240. /**
  48241. * Create a multi render target texture
  48242. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48243. * @param size defines the size of the texture
  48244. * @param options defines the creation options
  48245. * @returns the cube texture as an InternalTexture
  48246. */
  48247. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48248. /**
  48249. * Update the sample count for a given multiple render target texture
  48250. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48251. * @param textures defines the textures to update
  48252. * @param samples defines the sample count to set
  48253. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48254. */
  48255. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48256. }
  48257. }
  48258. }
  48259. declare module "babylonjs/Engines/Extensions/engine.views" {
  48260. import { Camera } from "babylonjs/Cameras/camera";
  48261. import { Nullable } from "babylonjs/types";
  48262. /**
  48263. * Class used to define an additional view for the engine
  48264. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48265. */
  48266. export class EngineView {
  48267. /** Defines the canvas where to render the view */
  48268. target: HTMLCanvasElement;
  48269. /** Defines an optional camera used to render the view (will use active camera else) */
  48270. camera?: Camera;
  48271. }
  48272. module "babylonjs/Engines/engine" {
  48273. interface Engine {
  48274. /**
  48275. * Gets or sets the HTML element to use for attaching events
  48276. */
  48277. inputElement: Nullable<HTMLElement>;
  48278. /**
  48279. * Gets the current engine view
  48280. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48281. */
  48282. activeView: Nullable<EngineView>;
  48283. /** Gets or sets the list of views */
  48284. views: EngineView[];
  48285. /**
  48286. * Register a new child canvas
  48287. * @param canvas defines the canvas to register
  48288. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48289. * @returns the associated view
  48290. */
  48291. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48292. /**
  48293. * Remove a registered child canvas
  48294. * @param canvas defines the canvas to remove
  48295. * @returns the current engine
  48296. */
  48297. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48298. }
  48299. }
  48300. }
  48301. declare module "babylonjs/Engines/Extensions/index" {
  48302. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48303. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48304. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48305. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48306. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48307. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48308. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48309. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48310. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48311. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48312. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48313. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48314. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48315. export * from "babylonjs/Engines/Extensions/engine.views";
  48316. }
  48317. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48318. import { Nullable } from "babylonjs/types";
  48319. /**
  48320. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48321. */
  48322. export interface CubeMapInfo {
  48323. /**
  48324. * The pixel array for the front face.
  48325. * This is stored in format, left to right, up to down format.
  48326. */
  48327. front: Nullable<ArrayBufferView>;
  48328. /**
  48329. * The pixel array for the back face.
  48330. * This is stored in format, left to right, up to down format.
  48331. */
  48332. back: Nullable<ArrayBufferView>;
  48333. /**
  48334. * The pixel array for the left face.
  48335. * This is stored in format, left to right, up to down format.
  48336. */
  48337. left: Nullable<ArrayBufferView>;
  48338. /**
  48339. * The pixel array for the right face.
  48340. * This is stored in format, left to right, up to down format.
  48341. */
  48342. right: Nullable<ArrayBufferView>;
  48343. /**
  48344. * The pixel array for the up face.
  48345. * This is stored in format, left to right, up to down format.
  48346. */
  48347. up: Nullable<ArrayBufferView>;
  48348. /**
  48349. * The pixel array for the down face.
  48350. * This is stored in format, left to right, up to down format.
  48351. */
  48352. down: Nullable<ArrayBufferView>;
  48353. /**
  48354. * The size of the cubemap stored.
  48355. *
  48356. * Each faces will be size * size pixels.
  48357. */
  48358. size: number;
  48359. /**
  48360. * The format of the texture.
  48361. *
  48362. * RGBA, RGB.
  48363. */
  48364. format: number;
  48365. /**
  48366. * The type of the texture data.
  48367. *
  48368. * UNSIGNED_INT, FLOAT.
  48369. */
  48370. type: number;
  48371. /**
  48372. * Specifies whether the texture is in gamma space.
  48373. */
  48374. gammaSpace: boolean;
  48375. }
  48376. /**
  48377. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48378. */
  48379. export class PanoramaToCubeMapTools {
  48380. private static FACE_FRONT;
  48381. private static FACE_BACK;
  48382. private static FACE_RIGHT;
  48383. private static FACE_LEFT;
  48384. private static FACE_DOWN;
  48385. private static FACE_UP;
  48386. /**
  48387. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48388. *
  48389. * @param float32Array The source data.
  48390. * @param inputWidth The width of the input panorama.
  48391. * @param inputHeight The height of the input panorama.
  48392. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48393. * @return The cubemap data
  48394. */
  48395. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48396. private static CreateCubemapTexture;
  48397. private static CalcProjectionSpherical;
  48398. }
  48399. }
  48400. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48401. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48403. import { Nullable } from "babylonjs/types";
  48404. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48405. /**
  48406. * Helper class dealing with the extraction of spherical polynomial dataArray
  48407. * from a cube map.
  48408. */
  48409. export class CubeMapToSphericalPolynomialTools {
  48410. private static FileFaces;
  48411. /**
  48412. * Converts a texture to the according Spherical Polynomial data.
  48413. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48414. *
  48415. * @param texture The texture to extract the information from.
  48416. * @return The Spherical Polynomial data.
  48417. */
  48418. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48419. /**
  48420. * Converts a cubemap to the according Spherical Polynomial data.
  48421. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48422. *
  48423. * @param cubeInfo The Cube map to extract the information from.
  48424. * @return The Spherical Polynomial data.
  48425. */
  48426. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48427. }
  48428. }
  48429. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48430. import { Nullable } from "babylonjs/types";
  48431. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48432. module "babylonjs/Materials/Textures/baseTexture" {
  48433. interface BaseTexture {
  48434. /**
  48435. * Get the polynomial representation of the texture data.
  48436. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48437. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48438. */
  48439. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48440. }
  48441. }
  48442. }
  48443. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48444. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48445. /** @hidden */
  48446. export var rgbdEncodePixelShader: {
  48447. name: string;
  48448. shader: string;
  48449. };
  48450. }
  48451. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48453. /** @hidden */
  48454. export var rgbdDecodePixelShader: {
  48455. name: string;
  48456. shader: string;
  48457. };
  48458. }
  48459. declare module "babylonjs/Misc/environmentTextureTools" {
  48460. import { Nullable } from "babylonjs/types";
  48461. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48463. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48464. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48465. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48466. import "babylonjs/Shaders/rgbdEncode.fragment";
  48467. import "babylonjs/Shaders/rgbdDecode.fragment";
  48468. /**
  48469. * Raw texture data and descriptor sufficient for WebGL texture upload
  48470. */
  48471. export interface EnvironmentTextureInfo {
  48472. /**
  48473. * Version of the environment map
  48474. */
  48475. version: number;
  48476. /**
  48477. * Width of image
  48478. */
  48479. width: number;
  48480. /**
  48481. * Irradiance information stored in the file.
  48482. */
  48483. irradiance: any;
  48484. /**
  48485. * Specular information stored in the file.
  48486. */
  48487. specular: any;
  48488. }
  48489. /**
  48490. * Defines One Image in the file. It requires only the position in the file
  48491. * as well as the length.
  48492. */
  48493. interface BufferImageData {
  48494. /**
  48495. * Length of the image data.
  48496. */
  48497. length: number;
  48498. /**
  48499. * Position of the data from the null terminator delimiting the end of the JSON.
  48500. */
  48501. position: number;
  48502. }
  48503. /**
  48504. * Defines the specular data enclosed in the file.
  48505. * This corresponds to the version 1 of the data.
  48506. */
  48507. export interface EnvironmentTextureSpecularInfoV1 {
  48508. /**
  48509. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48510. */
  48511. specularDataPosition?: number;
  48512. /**
  48513. * This contains all the images data needed to reconstruct the cubemap.
  48514. */
  48515. mipmaps: Array<BufferImageData>;
  48516. /**
  48517. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48518. */
  48519. lodGenerationScale: number;
  48520. }
  48521. /**
  48522. * Sets of helpers addressing the serialization and deserialization of environment texture
  48523. * stored in a BabylonJS env file.
  48524. * Those files are usually stored as .env files.
  48525. */
  48526. export class EnvironmentTextureTools {
  48527. /**
  48528. * Magic number identifying the env file.
  48529. */
  48530. private static _MagicBytes;
  48531. /**
  48532. * Gets the environment info from an env file.
  48533. * @param data The array buffer containing the .env bytes.
  48534. * @returns the environment file info (the json header) if successfully parsed.
  48535. */
  48536. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48537. /**
  48538. * Creates an environment texture from a loaded cube texture.
  48539. * @param texture defines the cube texture to convert in env file
  48540. * @return a promise containing the environment data if succesfull.
  48541. */
  48542. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48543. /**
  48544. * Creates a JSON representation of the spherical data.
  48545. * @param texture defines the texture containing the polynomials
  48546. * @return the JSON representation of the spherical info
  48547. */
  48548. private static _CreateEnvTextureIrradiance;
  48549. /**
  48550. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48551. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48552. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48553. * @return the views described by info providing access to the underlying buffer
  48554. */
  48555. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48556. /**
  48557. * Uploads the texture info contained in the env file to the GPU.
  48558. * @param texture defines the internal texture to upload to
  48559. * @param arrayBuffer defines the buffer cotaining the data to load
  48560. * @param info defines the texture info retrieved through the GetEnvInfo method
  48561. * @returns a promise
  48562. */
  48563. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48564. private static _OnImageReadyAsync;
  48565. /**
  48566. * Uploads the levels of image data to the GPU.
  48567. * @param texture defines the internal texture to upload to
  48568. * @param imageData defines the array buffer views of image data [mipmap][face]
  48569. * @returns a promise
  48570. */
  48571. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48572. /**
  48573. * Uploads spherical polynomials information to the texture.
  48574. * @param texture defines the texture we are trying to upload the information to
  48575. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48576. */
  48577. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48578. /** @hidden */
  48579. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48580. }
  48581. }
  48582. declare module "babylonjs/Maths/math.vertexFormat" {
  48583. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48584. /**
  48585. * Contains position and normal vectors for a vertex
  48586. */
  48587. export class PositionNormalVertex {
  48588. /** the position of the vertex (defaut: 0,0,0) */
  48589. position: Vector3;
  48590. /** the normal of the vertex (defaut: 0,1,0) */
  48591. normal: Vector3;
  48592. /**
  48593. * Creates a PositionNormalVertex
  48594. * @param position the position of the vertex (defaut: 0,0,0)
  48595. * @param normal the normal of the vertex (defaut: 0,1,0)
  48596. */
  48597. constructor(
  48598. /** the position of the vertex (defaut: 0,0,0) */
  48599. position?: Vector3,
  48600. /** the normal of the vertex (defaut: 0,1,0) */
  48601. normal?: Vector3);
  48602. /**
  48603. * Clones the PositionNormalVertex
  48604. * @returns the cloned PositionNormalVertex
  48605. */
  48606. clone(): PositionNormalVertex;
  48607. }
  48608. /**
  48609. * Contains position, normal and uv vectors for a vertex
  48610. */
  48611. export class PositionNormalTextureVertex {
  48612. /** the position of the vertex (defaut: 0,0,0) */
  48613. position: Vector3;
  48614. /** the normal of the vertex (defaut: 0,1,0) */
  48615. normal: Vector3;
  48616. /** the uv of the vertex (default: 0,0) */
  48617. uv: Vector2;
  48618. /**
  48619. * Creates a PositionNormalTextureVertex
  48620. * @param position the position of the vertex (defaut: 0,0,0)
  48621. * @param normal the normal of the vertex (defaut: 0,1,0)
  48622. * @param uv the uv of the vertex (default: 0,0)
  48623. */
  48624. constructor(
  48625. /** the position of the vertex (defaut: 0,0,0) */
  48626. position?: Vector3,
  48627. /** the normal of the vertex (defaut: 0,1,0) */
  48628. normal?: Vector3,
  48629. /** the uv of the vertex (default: 0,0) */
  48630. uv?: Vector2);
  48631. /**
  48632. * Clones the PositionNormalTextureVertex
  48633. * @returns the cloned PositionNormalTextureVertex
  48634. */
  48635. clone(): PositionNormalTextureVertex;
  48636. }
  48637. }
  48638. declare module "babylonjs/Maths/math" {
  48639. export * from "babylonjs/Maths/math.axis";
  48640. export * from "babylonjs/Maths/math.color";
  48641. export * from "babylonjs/Maths/math.constants";
  48642. export * from "babylonjs/Maths/math.frustum";
  48643. export * from "babylonjs/Maths/math.path";
  48644. export * from "babylonjs/Maths/math.plane";
  48645. export * from "babylonjs/Maths/math.size";
  48646. export * from "babylonjs/Maths/math.vector";
  48647. export * from "babylonjs/Maths/math.vertexFormat";
  48648. export * from "babylonjs/Maths/math.viewport";
  48649. }
  48650. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48651. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48652. /** @hidden */
  48653. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48654. private _genericAttributeLocation;
  48655. private _varyingLocationCount;
  48656. private _varyingLocationMap;
  48657. private _replacements;
  48658. private _textureCount;
  48659. private _uniforms;
  48660. lineProcessor(line: string): string;
  48661. attributeProcessor(attribute: string): string;
  48662. varyingProcessor(varying: string, isFragment: boolean): string;
  48663. uniformProcessor(uniform: string): string;
  48664. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48665. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48666. }
  48667. }
  48668. declare module "babylonjs/Engines/nativeEngine" {
  48669. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48670. import { Engine } from "babylonjs/Engines/engine";
  48671. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48674. import { Effect } from "babylonjs/Materials/effect";
  48675. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48676. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48677. import { IColor4Like } from "babylonjs/Maths/math.like";
  48678. import { Scene } from "babylonjs/scene";
  48679. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48680. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48681. /**
  48682. * Container for accessors for natively-stored mesh data buffers.
  48683. */
  48684. class NativeDataBuffer extends DataBuffer {
  48685. /**
  48686. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48687. */
  48688. nativeIndexBuffer?: any;
  48689. /**
  48690. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48691. */
  48692. nativeVertexBuffer?: any;
  48693. }
  48694. /** @hidden */
  48695. class NativeTexture extends InternalTexture {
  48696. getInternalTexture(): InternalTexture;
  48697. getViewCount(): number;
  48698. }
  48699. /** @hidden */
  48700. export class NativeEngine extends Engine {
  48701. private readonly _native;
  48702. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48703. private readonly INVALID_HANDLE;
  48704. getHardwareScalingLevel(): number;
  48705. constructor();
  48706. /**
  48707. * Can be used to override the current requestAnimationFrame requester.
  48708. * @hidden
  48709. */
  48710. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48711. /**
  48712. * Override default engine behavior.
  48713. * @param color
  48714. * @param backBuffer
  48715. * @param depth
  48716. * @param stencil
  48717. */
  48718. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48719. /**
  48720. * Gets host document
  48721. * @returns the host document object
  48722. */
  48723. getHostDocument(): Nullable<Document>;
  48724. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48725. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48726. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48727. recordVertexArrayObject(vertexBuffers: {
  48728. [key: string]: VertexBuffer;
  48729. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48730. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48731. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48732. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48733. /**
  48734. * Draw a list of indexed primitives
  48735. * @param fillMode defines the primitive to use
  48736. * @param indexStart defines the starting index
  48737. * @param indexCount defines the number of index to draw
  48738. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48739. */
  48740. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48741. /**
  48742. * Draw a list of unindexed primitives
  48743. * @param fillMode defines the primitive to use
  48744. * @param verticesStart defines the index of first vertex to draw
  48745. * @param verticesCount defines the count of vertices to draw
  48746. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48747. */
  48748. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48749. createPipelineContext(): IPipelineContext;
  48750. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48751. /** @hidden */
  48752. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48753. /** @hidden */
  48754. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48755. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48756. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48757. protected _setProgram(program: WebGLProgram): void;
  48758. _releaseEffect(effect: Effect): void;
  48759. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48760. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48761. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48762. bindSamplers(effect: Effect): void;
  48763. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48764. getRenderWidth(useScreen?: boolean): number;
  48765. getRenderHeight(useScreen?: boolean): number;
  48766. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48767. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48768. /**
  48769. * Set the z offset to apply to current rendering
  48770. * @param value defines the offset to apply
  48771. */
  48772. setZOffset(value: number): void;
  48773. /**
  48774. * Gets the current value of the zOffset
  48775. * @returns the current zOffset state
  48776. */
  48777. getZOffset(): number;
  48778. /**
  48779. * Enable or disable depth buffering
  48780. * @param enable defines the state to set
  48781. */
  48782. setDepthBuffer(enable: boolean): void;
  48783. /**
  48784. * Gets a boolean indicating if depth writing is enabled
  48785. * @returns the current depth writing state
  48786. */
  48787. getDepthWrite(): boolean;
  48788. /**
  48789. * Enable or disable depth writing
  48790. * @param enable defines the state to set
  48791. */
  48792. setDepthWrite(enable: boolean): void;
  48793. /**
  48794. * Enable or disable color writing
  48795. * @param enable defines the state to set
  48796. */
  48797. setColorWrite(enable: boolean): void;
  48798. /**
  48799. * Gets a boolean indicating if color writing is enabled
  48800. * @returns the current color writing state
  48801. */
  48802. getColorWrite(): boolean;
  48803. /**
  48804. * Sets alpha constants used by some alpha blending modes
  48805. * @param r defines the red component
  48806. * @param g defines the green component
  48807. * @param b defines the blue component
  48808. * @param a defines the alpha component
  48809. */
  48810. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48811. /**
  48812. * Sets the current alpha mode
  48813. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48814. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48815. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48816. */
  48817. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48818. /**
  48819. * Gets the current alpha mode
  48820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48821. * @returns the current alpha mode
  48822. */
  48823. getAlphaMode(): number;
  48824. setInt(uniform: WebGLUniformLocation, int: number): void;
  48825. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48826. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48827. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48828. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48829. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48830. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48831. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48832. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48833. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48834. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48835. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48836. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48837. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48838. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48839. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48840. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48841. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48842. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48843. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48844. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48845. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48846. wipeCaches(bruteForce?: boolean): void;
  48847. _createTexture(): WebGLTexture;
  48848. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48849. /**
  48850. * Usually called from BABYLON.Texture.ts.
  48851. * Passed information to create a WebGLTexture
  48852. * @param urlArg defines a value which contains one of the following:
  48853. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48854. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48855. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48857. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48858. * @param scene needed for loading to the correct scene
  48859. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48860. * @param onLoad optional callback to be called upon successful completion
  48861. * @param onError optional callback to be called upon failure
  48862. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48863. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48864. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48865. * @param forcedExtension defines the extension to use to pick the right loader
  48866. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48867. */
  48868. 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;
  48869. /**
  48870. * Creates a cube texture
  48871. * @param rootUrl defines the url where the files to load is located
  48872. * @param scene defines the current scene
  48873. * @param files defines the list of files to load (1 per face)
  48874. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48875. * @param onLoad defines an optional callback raised when the texture is loaded
  48876. * @param onError defines an optional callback raised if there is an issue to load the texture
  48877. * @param format defines the format of the data
  48878. * @param forcedExtension defines the extension to use to pick the right loader
  48879. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48880. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48881. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48882. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48883. * @returns the cube texture as an InternalTexture
  48884. */
  48885. 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;
  48886. private _getSamplingFilter;
  48887. private static _GetNativeTextureFormat;
  48888. createRenderTargetTexture(size: number | {
  48889. width: number;
  48890. height: number;
  48891. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48892. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48893. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48894. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48895. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48896. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48897. /**
  48898. * Updates a dynamic vertex buffer.
  48899. * @param vertexBuffer the vertex buffer to update
  48900. * @param data the data used to update the vertex buffer
  48901. * @param byteOffset the byte offset of the data (optional)
  48902. * @param byteLength the byte length of the data (optional)
  48903. */
  48904. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48905. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48906. private _updateAnisotropicLevel;
  48907. private _getAddressMode;
  48908. /** @hidden */
  48909. _bindTexture(channel: number, texture: InternalTexture): void;
  48910. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48911. releaseEffects(): void;
  48912. /** @hidden */
  48913. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48914. /** @hidden */
  48915. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48916. /** @hidden */
  48917. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48918. /** @hidden */
  48919. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48920. }
  48921. }
  48922. declare module "babylonjs/Engines/index" {
  48923. export * from "babylonjs/Engines/constants";
  48924. export * from "babylonjs/Engines/engineCapabilities";
  48925. export * from "babylonjs/Engines/instancingAttributeInfo";
  48926. export * from "babylonjs/Engines/thinEngine";
  48927. export * from "babylonjs/Engines/engine";
  48928. export * from "babylonjs/Engines/engineStore";
  48929. export * from "babylonjs/Engines/nullEngine";
  48930. export * from "babylonjs/Engines/Extensions/index";
  48931. export * from "babylonjs/Engines/IPipelineContext";
  48932. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  48933. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48934. export * from "babylonjs/Engines/nativeEngine";
  48935. }
  48936. declare module "babylonjs/Events/clipboardEvents" {
  48937. /**
  48938. * Gather the list of clipboard event types as constants.
  48939. */
  48940. export class ClipboardEventTypes {
  48941. /**
  48942. * The clipboard event is fired when a copy command is active (pressed).
  48943. */
  48944. static readonly COPY: number;
  48945. /**
  48946. * The clipboard event is fired when a cut command is active (pressed).
  48947. */
  48948. static readonly CUT: number;
  48949. /**
  48950. * The clipboard event is fired when a paste command is active (pressed).
  48951. */
  48952. static readonly PASTE: number;
  48953. }
  48954. /**
  48955. * This class is used to store clipboard related info for the onClipboardObservable event.
  48956. */
  48957. export class ClipboardInfo {
  48958. /**
  48959. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48960. */
  48961. type: number;
  48962. /**
  48963. * Defines the related dom event
  48964. */
  48965. event: ClipboardEvent;
  48966. /**
  48967. *Creates an instance of ClipboardInfo.
  48968. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48969. * @param event Defines the related dom event
  48970. */
  48971. constructor(
  48972. /**
  48973. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48974. */
  48975. type: number,
  48976. /**
  48977. * Defines the related dom event
  48978. */
  48979. event: ClipboardEvent);
  48980. /**
  48981. * Get the clipboard event's type from the keycode.
  48982. * @param keyCode Defines the keyCode for the current keyboard event.
  48983. * @return {number}
  48984. */
  48985. static GetTypeFromCharacter(keyCode: number): number;
  48986. }
  48987. }
  48988. declare module "babylonjs/Events/index" {
  48989. export * from "babylonjs/Events/keyboardEvents";
  48990. export * from "babylonjs/Events/pointerEvents";
  48991. export * from "babylonjs/Events/clipboardEvents";
  48992. }
  48993. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  48994. import { Scene } from "babylonjs/scene";
  48995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48996. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48997. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48998. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48999. /**
  49000. * Google Daydream controller
  49001. */
  49002. export class DaydreamController extends WebVRController {
  49003. /**
  49004. * Base Url for the controller model.
  49005. */
  49006. static MODEL_BASE_URL: string;
  49007. /**
  49008. * File name for the controller model.
  49009. */
  49010. static MODEL_FILENAME: string;
  49011. /**
  49012. * Gamepad Id prefix used to identify Daydream Controller.
  49013. */
  49014. static readonly GAMEPAD_ID_PREFIX: string;
  49015. /**
  49016. * Creates a new DaydreamController from a gamepad
  49017. * @param vrGamepad the gamepad that the controller should be created from
  49018. */
  49019. constructor(vrGamepad: any);
  49020. /**
  49021. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49022. * @param scene scene in which to add meshes
  49023. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49024. */
  49025. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49026. /**
  49027. * Called once for each button that changed state since the last frame
  49028. * @param buttonIdx Which button index changed
  49029. * @param state New state of the button
  49030. * @param changes Which properties on the state changed since last frame
  49031. */
  49032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49033. }
  49034. }
  49035. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49036. import { Scene } from "babylonjs/scene";
  49037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49038. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49039. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49040. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49041. /**
  49042. * Gear VR Controller
  49043. */
  49044. export class GearVRController extends WebVRController {
  49045. /**
  49046. * Base Url for the controller model.
  49047. */
  49048. static MODEL_BASE_URL: string;
  49049. /**
  49050. * File name for the controller model.
  49051. */
  49052. static MODEL_FILENAME: string;
  49053. /**
  49054. * Gamepad Id prefix used to identify this controller.
  49055. */
  49056. static readonly GAMEPAD_ID_PREFIX: string;
  49057. private readonly _buttonIndexToObservableNameMap;
  49058. /**
  49059. * Creates a new GearVRController from a gamepad
  49060. * @param vrGamepad the gamepad that the controller should be created from
  49061. */
  49062. constructor(vrGamepad: any);
  49063. /**
  49064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49065. * @param scene scene in which to add meshes
  49066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49067. */
  49068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49069. /**
  49070. * Called once for each button that changed state since the last frame
  49071. * @param buttonIdx Which button index changed
  49072. * @param state New state of the button
  49073. * @param changes Which properties on the state changed since last frame
  49074. */
  49075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49076. }
  49077. }
  49078. declare module "babylonjs/Gamepads/Controllers/index" {
  49079. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49080. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49081. export * from "babylonjs/Gamepads/Controllers/genericController";
  49082. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49083. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49084. export * from "babylonjs/Gamepads/Controllers/viveController";
  49085. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49086. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49087. }
  49088. declare module "babylonjs/Gamepads/index" {
  49089. export * from "babylonjs/Gamepads/Controllers/index";
  49090. export * from "babylonjs/Gamepads/gamepad";
  49091. export * from "babylonjs/Gamepads/gamepadManager";
  49092. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49093. export * from "babylonjs/Gamepads/xboxGamepad";
  49094. export * from "babylonjs/Gamepads/dualShockGamepad";
  49095. }
  49096. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49097. import { Scene } from "babylonjs/scene";
  49098. import { Vector4 } from "babylonjs/Maths/math.vector";
  49099. import { Color4 } from "babylonjs/Maths/math.color";
  49100. import { Mesh } from "babylonjs/Meshes/mesh";
  49101. import { Nullable } from "babylonjs/types";
  49102. /**
  49103. * Class containing static functions to help procedurally build meshes
  49104. */
  49105. export class PolyhedronBuilder {
  49106. /**
  49107. * Creates a polyhedron mesh
  49108. * * 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
  49109. * * The parameter `size` (positive float, default 1) sets the polygon size
  49110. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49111. * * 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`
  49112. * * 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
  49113. * * 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)`)
  49114. * * 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
  49115. * * 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
  49116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49119. * @param name defines the name of the mesh
  49120. * @param options defines the options used to create the mesh
  49121. * @param scene defines the hosting scene
  49122. * @returns the polyhedron mesh
  49123. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49124. */
  49125. static CreatePolyhedron(name: string, options: {
  49126. type?: number;
  49127. size?: number;
  49128. sizeX?: number;
  49129. sizeY?: number;
  49130. sizeZ?: number;
  49131. custom?: any;
  49132. faceUV?: Vector4[];
  49133. faceColors?: Color4[];
  49134. flat?: boolean;
  49135. updatable?: boolean;
  49136. sideOrientation?: number;
  49137. frontUVs?: Vector4;
  49138. backUVs?: Vector4;
  49139. }, scene?: Nullable<Scene>): Mesh;
  49140. }
  49141. }
  49142. declare module "babylonjs/Gizmos/scaleGizmo" {
  49143. import { Observable } from "babylonjs/Misc/observable";
  49144. import { Nullable } from "babylonjs/types";
  49145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49146. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49147. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49148. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49149. /**
  49150. * Gizmo that enables scaling a mesh along 3 axis
  49151. */
  49152. export class ScaleGizmo extends Gizmo {
  49153. /**
  49154. * Internal gizmo used for interactions on the x axis
  49155. */
  49156. xGizmo: AxisScaleGizmo;
  49157. /**
  49158. * Internal gizmo used for interactions on the y axis
  49159. */
  49160. yGizmo: AxisScaleGizmo;
  49161. /**
  49162. * Internal gizmo used for interactions on the z axis
  49163. */
  49164. zGizmo: AxisScaleGizmo;
  49165. /**
  49166. * Internal gizmo used to scale all axis equally
  49167. */
  49168. uniformScaleGizmo: AxisScaleGizmo;
  49169. private _meshAttached;
  49170. private _updateGizmoRotationToMatchAttachedMesh;
  49171. private _snapDistance;
  49172. private _scaleRatio;
  49173. private _uniformScalingMesh;
  49174. private _octahedron;
  49175. private _sensitivity;
  49176. /** Fires an event when any of it's sub gizmos are dragged */
  49177. onDragStartObservable: Observable<unknown>;
  49178. /** Fires an event when any of it's sub gizmos are released from dragging */
  49179. onDragEndObservable: Observable<unknown>;
  49180. get attachedMesh(): Nullable<AbstractMesh>;
  49181. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49182. /**
  49183. * Creates a ScaleGizmo
  49184. * @param gizmoLayer The utility layer the gizmo will be added to
  49185. */
  49186. constructor(gizmoLayer?: UtilityLayerRenderer);
  49187. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49188. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49189. /**
  49190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49191. */
  49192. set snapDistance(value: number);
  49193. get snapDistance(): number;
  49194. /**
  49195. * Ratio for the scale of the gizmo (Default: 1)
  49196. */
  49197. set scaleRatio(value: number);
  49198. get scaleRatio(): number;
  49199. /**
  49200. * Sensitivity factor for dragging (Default: 1)
  49201. */
  49202. set sensitivity(value: number);
  49203. get sensitivity(): number;
  49204. /**
  49205. * Disposes of the gizmo
  49206. */
  49207. dispose(): void;
  49208. }
  49209. }
  49210. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49211. import { Observable } from "babylonjs/Misc/observable";
  49212. import { Nullable } from "babylonjs/types";
  49213. import { Vector3 } from "babylonjs/Maths/math.vector";
  49214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49215. import { Mesh } from "babylonjs/Meshes/mesh";
  49216. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49217. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49218. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49219. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49220. import { Color3 } from "babylonjs/Maths/math.color";
  49221. /**
  49222. * Single axis scale gizmo
  49223. */
  49224. export class AxisScaleGizmo extends Gizmo {
  49225. /**
  49226. * Drag behavior responsible for the gizmos dragging interactions
  49227. */
  49228. dragBehavior: PointerDragBehavior;
  49229. private _pointerObserver;
  49230. /**
  49231. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49232. */
  49233. snapDistance: number;
  49234. /**
  49235. * Event that fires each time the gizmo snaps to a new location.
  49236. * * snapDistance is the the change in distance
  49237. */
  49238. onSnapObservable: Observable<{
  49239. snapDistance: number;
  49240. }>;
  49241. /**
  49242. * If the scaling operation should be done on all axis (default: false)
  49243. */
  49244. uniformScaling: boolean;
  49245. /**
  49246. * Custom sensitivity value for the drag strength
  49247. */
  49248. sensitivity: number;
  49249. private _isEnabled;
  49250. private _parent;
  49251. private _arrow;
  49252. private _coloredMaterial;
  49253. private _hoverMaterial;
  49254. /**
  49255. * Creates an AxisScaleGizmo
  49256. * @param gizmoLayer The utility layer the gizmo will be added to
  49257. * @param dragAxis The axis which the gizmo will be able to scale on
  49258. * @param color The color of the gizmo
  49259. */
  49260. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49261. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49262. /**
  49263. * If the gizmo is enabled
  49264. */
  49265. set isEnabled(value: boolean);
  49266. get isEnabled(): boolean;
  49267. /**
  49268. * Disposes of the gizmo
  49269. */
  49270. dispose(): void;
  49271. /**
  49272. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49273. * @param mesh The mesh to replace the default mesh of the gizmo
  49274. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49275. */
  49276. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49277. }
  49278. }
  49279. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49280. import { Observable } from "babylonjs/Misc/observable";
  49281. import { Nullable } from "babylonjs/types";
  49282. import { Vector3 } from "babylonjs/Maths/math.vector";
  49283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49284. import { Mesh } from "babylonjs/Meshes/mesh";
  49285. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49286. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49287. import { Color3 } from "babylonjs/Maths/math.color";
  49288. import "babylonjs/Meshes/Builders/boxBuilder";
  49289. /**
  49290. * Bounding box gizmo
  49291. */
  49292. export class BoundingBoxGizmo extends Gizmo {
  49293. private _lineBoundingBox;
  49294. private _rotateSpheresParent;
  49295. private _scaleBoxesParent;
  49296. private _boundingDimensions;
  49297. private _renderObserver;
  49298. private _pointerObserver;
  49299. private _scaleDragSpeed;
  49300. private _tmpQuaternion;
  49301. private _tmpVector;
  49302. private _tmpRotationMatrix;
  49303. /**
  49304. * 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)
  49305. */
  49306. ignoreChildren: boolean;
  49307. /**
  49308. * 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)
  49309. */
  49310. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49311. /**
  49312. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49313. */
  49314. rotationSphereSize: number;
  49315. /**
  49316. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49317. */
  49318. scaleBoxSize: number;
  49319. /**
  49320. * 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)
  49321. */
  49322. fixedDragMeshScreenSize: boolean;
  49323. /**
  49324. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49325. */
  49326. fixedDragMeshScreenSizeDistanceFactor: number;
  49327. /**
  49328. * Fired when a rotation sphere or scale box is dragged
  49329. */
  49330. onDragStartObservable: Observable<{}>;
  49331. /**
  49332. * Fired when a scale box is dragged
  49333. */
  49334. onScaleBoxDragObservable: Observable<{}>;
  49335. /**
  49336. * Fired when a scale box drag is ended
  49337. */
  49338. onScaleBoxDragEndObservable: Observable<{}>;
  49339. /**
  49340. * Fired when a rotation sphere is dragged
  49341. */
  49342. onRotationSphereDragObservable: Observable<{}>;
  49343. /**
  49344. * Fired when a rotation sphere drag is ended
  49345. */
  49346. onRotationSphereDragEndObservable: Observable<{}>;
  49347. /**
  49348. * 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)
  49349. */
  49350. scalePivot: Nullable<Vector3>;
  49351. /**
  49352. * Mesh used as a pivot to rotate the attached mesh
  49353. */
  49354. private _anchorMesh;
  49355. private _existingMeshScale;
  49356. private _dragMesh;
  49357. private pointerDragBehavior;
  49358. private coloredMaterial;
  49359. private hoverColoredMaterial;
  49360. /**
  49361. * Sets the color of the bounding box gizmo
  49362. * @param color the color to set
  49363. */
  49364. setColor(color: Color3): void;
  49365. /**
  49366. * Creates an BoundingBoxGizmo
  49367. * @param gizmoLayer The utility layer the gizmo will be added to
  49368. * @param color The color of the gizmo
  49369. */
  49370. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49371. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49372. private _selectNode;
  49373. /**
  49374. * Updates the bounding box information for the Gizmo
  49375. */
  49376. updateBoundingBox(): void;
  49377. private _updateRotationSpheres;
  49378. private _updateScaleBoxes;
  49379. /**
  49380. * Enables rotation on the specified axis and disables rotation on the others
  49381. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49382. */
  49383. setEnabledRotationAxis(axis: string): void;
  49384. /**
  49385. * Enables/disables scaling
  49386. * @param enable if scaling should be enabled
  49387. */
  49388. setEnabledScaling(enable: boolean): void;
  49389. private _updateDummy;
  49390. /**
  49391. * Enables a pointer drag behavior on the bounding box of the gizmo
  49392. */
  49393. enableDragBehavior(): void;
  49394. /**
  49395. * Disposes of the gizmo
  49396. */
  49397. dispose(): void;
  49398. /**
  49399. * 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)
  49400. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49401. * @returns the bounding box mesh with the passed in mesh as a child
  49402. */
  49403. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49404. /**
  49405. * CustomMeshes are not supported by this gizmo
  49406. * @param mesh The mesh to replace the default mesh of the gizmo
  49407. */
  49408. setCustomMesh(mesh: Mesh): void;
  49409. }
  49410. }
  49411. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49412. import { Observable } from "babylonjs/Misc/observable";
  49413. import { Nullable } from "babylonjs/types";
  49414. import { Vector3 } from "babylonjs/Maths/math.vector";
  49415. import { Color3 } from "babylonjs/Maths/math.color";
  49416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49417. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49418. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49419. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49420. import "babylonjs/Meshes/Builders/linesBuilder";
  49421. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49422. /**
  49423. * Single plane rotation gizmo
  49424. */
  49425. export class PlaneRotationGizmo extends Gizmo {
  49426. /**
  49427. * Drag behavior responsible for the gizmos dragging interactions
  49428. */
  49429. dragBehavior: PointerDragBehavior;
  49430. private _pointerObserver;
  49431. /**
  49432. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49433. */
  49434. snapDistance: number;
  49435. /**
  49436. * Event that fires each time the gizmo snaps to a new location.
  49437. * * snapDistance is the the change in distance
  49438. */
  49439. onSnapObservable: Observable<{
  49440. snapDistance: number;
  49441. }>;
  49442. private _isEnabled;
  49443. private _parent;
  49444. /**
  49445. * Creates a PlaneRotationGizmo
  49446. * @param gizmoLayer The utility layer the gizmo will be added to
  49447. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49448. * @param color The color of the gizmo
  49449. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49450. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49451. */
  49452. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49453. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49454. /**
  49455. * If the gizmo is enabled
  49456. */
  49457. set isEnabled(value: boolean);
  49458. get isEnabled(): boolean;
  49459. /**
  49460. * Disposes of the gizmo
  49461. */
  49462. dispose(): void;
  49463. }
  49464. }
  49465. declare module "babylonjs/Gizmos/rotationGizmo" {
  49466. import { Observable } from "babylonjs/Misc/observable";
  49467. import { Nullable } from "babylonjs/types";
  49468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49469. import { Mesh } from "babylonjs/Meshes/mesh";
  49470. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49471. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49472. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49473. /**
  49474. * Gizmo that enables rotating a mesh along 3 axis
  49475. */
  49476. export class RotationGizmo extends Gizmo {
  49477. /**
  49478. * Internal gizmo used for interactions on the x axis
  49479. */
  49480. xGizmo: PlaneRotationGizmo;
  49481. /**
  49482. * Internal gizmo used for interactions on the y axis
  49483. */
  49484. yGizmo: PlaneRotationGizmo;
  49485. /**
  49486. * Internal gizmo used for interactions on the z axis
  49487. */
  49488. zGizmo: PlaneRotationGizmo;
  49489. /** Fires an event when any of it's sub gizmos are dragged */
  49490. onDragStartObservable: Observable<unknown>;
  49491. /** Fires an event when any of it's sub gizmos are released from dragging */
  49492. onDragEndObservable: Observable<unknown>;
  49493. private _meshAttached;
  49494. get attachedMesh(): Nullable<AbstractMesh>;
  49495. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49496. /**
  49497. * Creates a RotationGizmo
  49498. * @param gizmoLayer The utility layer the gizmo will be added to
  49499. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49500. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49501. */
  49502. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49503. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49504. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49505. /**
  49506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49507. */
  49508. set snapDistance(value: number);
  49509. get snapDistance(): number;
  49510. /**
  49511. * Ratio for the scale of the gizmo (Default: 1)
  49512. */
  49513. set scaleRatio(value: number);
  49514. get scaleRatio(): number;
  49515. /**
  49516. * Disposes of the gizmo
  49517. */
  49518. dispose(): void;
  49519. /**
  49520. * CustomMeshes are not supported by this gizmo
  49521. * @param mesh The mesh to replace the default mesh of the gizmo
  49522. */
  49523. setCustomMesh(mesh: Mesh): void;
  49524. }
  49525. }
  49526. declare module "babylonjs/Gizmos/gizmoManager" {
  49527. import { Observable } from "babylonjs/Misc/observable";
  49528. import { Nullable } from "babylonjs/types";
  49529. import { Scene, IDisposable } from "babylonjs/scene";
  49530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49531. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49532. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49533. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49534. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49535. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49536. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49537. /**
  49538. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49539. */
  49540. export class GizmoManager implements IDisposable {
  49541. private scene;
  49542. /**
  49543. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49544. */
  49545. gizmos: {
  49546. positionGizmo: Nullable<PositionGizmo>;
  49547. rotationGizmo: Nullable<RotationGizmo>;
  49548. scaleGizmo: Nullable<ScaleGizmo>;
  49549. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49550. };
  49551. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49552. clearGizmoOnEmptyPointerEvent: boolean;
  49553. /** Fires an event when the manager is attached to a mesh */
  49554. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49555. private _gizmosEnabled;
  49556. private _pointerObserver;
  49557. private _attachedMesh;
  49558. private _boundingBoxColor;
  49559. private _defaultUtilityLayer;
  49560. private _defaultKeepDepthUtilityLayer;
  49561. /**
  49562. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49563. */
  49564. boundingBoxDragBehavior: SixDofDragBehavior;
  49565. /**
  49566. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49567. */
  49568. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49569. /**
  49570. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49571. */
  49572. usePointerToAttachGizmos: boolean;
  49573. /**
  49574. * Utility layer that the bounding box gizmo belongs to
  49575. */
  49576. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49577. /**
  49578. * Utility layer that all gizmos besides bounding box belong to
  49579. */
  49580. get utilityLayer(): UtilityLayerRenderer;
  49581. /**
  49582. * Instatiates a gizmo manager
  49583. * @param scene the scene to overlay the gizmos on top of
  49584. */
  49585. constructor(scene: Scene);
  49586. /**
  49587. * Attaches a set of gizmos to the specified mesh
  49588. * @param mesh The mesh the gizmo's should be attached to
  49589. */
  49590. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49591. /**
  49592. * If the position gizmo is enabled
  49593. */
  49594. set positionGizmoEnabled(value: boolean);
  49595. get positionGizmoEnabled(): boolean;
  49596. /**
  49597. * If the rotation gizmo is enabled
  49598. */
  49599. set rotationGizmoEnabled(value: boolean);
  49600. get rotationGizmoEnabled(): boolean;
  49601. /**
  49602. * If the scale gizmo is enabled
  49603. */
  49604. set scaleGizmoEnabled(value: boolean);
  49605. get scaleGizmoEnabled(): boolean;
  49606. /**
  49607. * If the boundingBox gizmo is enabled
  49608. */
  49609. set boundingBoxGizmoEnabled(value: boolean);
  49610. get boundingBoxGizmoEnabled(): boolean;
  49611. /**
  49612. * Disposes of the gizmo manager
  49613. */
  49614. dispose(): void;
  49615. }
  49616. }
  49617. declare module "babylonjs/Lights/directionalLight" {
  49618. import { Camera } from "babylonjs/Cameras/camera";
  49619. import { Scene } from "babylonjs/scene";
  49620. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49622. import { Light } from "babylonjs/Lights/light";
  49623. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49624. import { Effect } from "babylonjs/Materials/effect";
  49625. /**
  49626. * A directional light is defined by a direction (what a surprise!).
  49627. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49628. * 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.
  49629. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49630. */
  49631. export class DirectionalLight extends ShadowLight {
  49632. private _shadowFrustumSize;
  49633. /**
  49634. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49635. */
  49636. get shadowFrustumSize(): number;
  49637. /**
  49638. * Specifies a fix frustum size for the shadow generation.
  49639. */
  49640. set shadowFrustumSize(value: number);
  49641. private _shadowOrthoScale;
  49642. /**
  49643. * Gets the shadow projection scale against the optimal computed one.
  49644. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49645. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49646. */
  49647. get shadowOrthoScale(): number;
  49648. /**
  49649. * Sets the shadow projection scale against the optimal computed one.
  49650. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49651. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49652. */
  49653. set shadowOrthoScale(value: number);
  49654. /**
  49655. * Automatically compute the projection matrix to best fit (including all the casters)
  49656. * on each frame.
  49657. */
  49658. autoUpdateExtends: boolean;
  49659. private _orthoLeft;
  49660. private _orthoRight;
  49661. private _orthoTop;
  49662. private _orthoBottom;
  49663. /**
  49664. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49665. * The directional light is emitted from everywhere in the given direction.
  49666. * It can cast shadows.
  49667. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49668. * @param name The friendly name of the light
  49669. * @param direction The direction of the light
  49670. * @param scene The scene the light belongs to
  49671. */
  49672. constructor(name: string, direction: Vector3, scene: Scene);
  49673. /**
  49674. * Returns the string "DirectionalLight".
  49675. * @return The class name
  49676. */
  49677. getClassName(): string;
  49678. /**
  49679. * Returns the integer 1.
  49680. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49681. */
  49682. getTypeID(): number;
  49683. /**
  49684. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49685. * Returns the DirectionalLight Shadow projection matrix.
  49686. */
  49687. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49688. /**
  49689. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49690. * Returns the DirectionalLight Shadow projection matrix.
  49691. */
  49692. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49693. /**
  49694. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49695. * Returns the DirectionalLight Shadow projection matrix.
  49696. */
  49697. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49698. protected _buildUniformLayout(): void;
  49699. /**
  49700. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49701. * @param effect The effect to update
  49702. * @param lightIndex The index of the light in the effect to update
  49703. * @returns The directional light
  49704. */
  49705. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49706. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49707. /**
  49708. * Gets the minZ used for shadow according to both the scene and the light.
  49709. *
  49710. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49711. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49712. * @param activeCamera The camera we are returning the min for
  49713. * @returns the depth min z
  49714. */
  49715. getDepthMinZ(activeCamera: Camera): number;
  49716. /**
  49717. * Gets the maxZ used for shadow according to both the scene and the light.
  49718. *
  49719. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49720. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49721. * @param activeCamera The camera we are returning the max for
  49722. * @returns the depth max z
  49723. */
  49724. getDepthMaxZ(activeCamera: Camera): number;
  49725. /**
  49726. * Prepares the list of defines specific to the light type.
  49727. * @param defines the list of defines
  49728. * @param lightIndex defines the index of the light for the effect
  49729. */
  49730. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49731. }
  49732. }
  49733. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49734. import { Mesh } from "babylonjs/Meshes/mesh";
  49735. /**
  49736. * Class containing static functions to help procedurally build meshes
  49737. */
  49738. export class HemisphereBuilder {
  49739. /**
  49740. * Creates a hemisphere mesh
  49741. * @param name defines the name of the mesh
  49742. * @param options defines the options used to create the mesh
  49743. * @param scene defines the hosting scene
  49744. * @returns the hemisphere mesh
  49745. */
  49746. static CreateHemisphere(name: string, options: {
  49747. segments?: number;
  49748. diameter?: number;
  49749. sideOrientation?: number;
  49750. }, scene: any): Mesh;
  49751. }
  49752. }
  49753. declare module "babylonjs/Lights/spotLight" {
  49754. import { Nullable } from "babylonjs/types";
  49755. import { Scene } from "babylonjs/scene";
  49756. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49758. import { Effect } from "babylonjs/Materials/effect";
  49759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49760. import { Light } from "babylonjs/Lights/light";
  49761. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49762. /**
  49763. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49764. * These values define a cone of light starting from the position, emitting toward the direction.
  49765. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49766. * and the exponent defines the speed of the decay of the light with distance (reach).
  49767. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49768. */
  49769. export class SpotLight extends ShadowLight {
  49770. private _angle;
  49771. private _innerAngle;
  49772. private _cosHalfAngle;
  49773. private _lightAngleScale;
  49774. private _lightAngleOffset;
  49775. /**
  49776. * Gets the cone angle of the spot light in Radians.
  49777. */
  49778. get angle(): number;
  49779. /**
  49780. * Sets the cone angle of the spot light in Radians.
  49781. */
  49782. set angle(value: number);
  49783. /**
  49784. * Only used in gltf falloff mode, this defines the angle where
  49785. * the directional falloff will start before cutting at angle which could be seen
  49786. * as outer angle.
  49787. */
  49788. get innerAngle(): number;
  49789. /**
  49790. * Only used in gltf falloff mode, this defines the angle where
  49791. * the directional falloff will start before cutting at angle which could be seen
  49792. * as outer angle.
  49793. */
  49794. set innerAngle(value: number);
  49795. private _shadowAngleScale;
  49796. /**
  49797. * Allows scaling the angle of the light for shadow generation only.
  49798. */
  49799. get shadowAngleScale(): number;
  49800. /**
  49801. * Allows scaling the angle of the light for shadow generation only.
  49802. */
  49803. set shadowAngleScale(value: number);
  49804. /**
  49805. * The light decay speed with the distance from the emission spot.
  49806. */
  49807. exponent: number;
  49808. private _projectionTextureMatrix;
  49809. /**
  49810. * Allows reading the projecton texture
  49811. */
  49812. get projectionTextureMatrix(): Matrix;
  49813. protected _projectionTextureLightNear: number;
  49814. /**
  49815. * Gets the near clip of the Spotlight for texture projection.
  49816. */
  49817. get projectionTextureLightNear(): number;
  49818. /**
  49819. * Sets the near clip of the Spotlight for texture projection.
  49820. */
  49821. set projectionTextureLightNear(value: number);
  49822. protected _projectionTextureLightFar: number;
  49823. /**
  49824. * Gets the far clip of the Spotlight for texture projection.
  49825. */
  49826. get projectionTextureLightFar(): number;
  49827. /**
  49828. * Sets the far clip of the Spotlight for texture projection.
  49829. */
  49830. set projectionTextureLightFar(value: number);
  49831. protected _projectionTextureUpDirection: Vector3;
  49832. /**
  49833. * Gets the Up vector of the Spotlight for texture projection.
  49834. */
  49835. get projectionTextureUpDirection(): Vector3;
  49836. /**
  49837. * Sets the Up vector of the Spotlight for texture projection.
  49838. */
  49839. set projectionTextureUpDirection(value: Vector3);
  49840. private _projectionTexture;
  49841. /**
  49842. * Gets the projection texture of the light.
  49843. */
  49844. get projectionTexture(): Nullable<BaseTexture>;
  49845. /**
  49846. * Sets the projection texture of the light.
  49847. */
  49848. set projectionTexture(value: Nullable<BaseTexture>);
  49849. private _projectionTextureViewLightDirty;
  49850. private _projectionTextureProjectionLightDirty;
  49851. private _projectionTextureDirty;
  49852. private _projectionTextureViewTargetVector;
  49853. private _projectionTextureViewLightMatrix;
  49854. private _projectionTextureProjectionLightMatrix;
  49855. private _projectionTextureScalingMatrix;
  49856. /**
  49857. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49858. * It can cast shadows.
  49859. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49860. * @param name The light friendly name
  49861. * @param position The position of the spot light in the scene
  49862. * @param direction The direction of the light in the scene
  49863. * @param angle The cone angle of the light in Radians
  49864. * @param exponent The light decay speed with the distance from the emission spot
  49865. * @param scene The scene the lights belongs to
  49866. */
  49867. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49868. /**
  49869. * Returns the string "SpotLight".
  49870. * @returns the class name
  49871. */
  49872. getClassName(): string;
  49873. /**
  49874. * Returns the integer 2.
  49875. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49876. */
  49877. getTypeID(): number;
  49878. /**
  49879. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49880. */
  49881. protected _setDirection(value: Vector3): void;
  49882. /**
  49883. * Overrides the position setter to recompute the projection texture view light Matrix.
  49884. */
  49885. protected _setPosition(value: Vector3): void;
  49886. /**
  49887. * 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.
  49888. * Returns the SpotLight.
  49889. */
  49890. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49891. protected _computeProjectionTextureViewLightMatrix(): void;
  49892. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49893. /**
  49894. * Main function for light texture projection matrix computing.
  49895. */
  49896. protected _computeProjectionTextureMatrix(): void;
  49897. protected _buildUniformLayout(): void;
  49898. private _computeAngleValues;
  49899. /**
  49900. * Sets the passed Effect "effect" with the Light textures.
  49901. * @param effect The effect to update
  49902. * @param lightIndex The index of the light in the effect to update
  49903. * @returns The light
  49904. */
  49905. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49906. /**
  49907. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49908. * @param effect The effect to update
  49909. * @param lightIndex The index of the light in the effect to update
  49910. * @returns The spot light
  49911. */
  49912. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49913. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49914. /**
  49915. * Disposes the light and the associated resources.
  49916. */
  49917. dispose(): void;
  49918. /**
  49919. * Prepares the list of defines specific to the light type.
  49920. * @param defines the list of defines
  49921. * @param lightIndex defines the index of the light for the effect
  49922. */
  49923. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49924. }
  49925. }
  49926. declare module "babylonjs/Gizmos/lightGizmo" {
  49927. import { Nullable } from "babylonjs/types";
  49928. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49929. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49930. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  49931. import { Light } from "babylonjs/Lights/light";
  49932. /**
  49933. * Gizmo that enables viewing a light
  49934. */
  49935. export class LightGizmo extends Gizmo {
  49936. private _lightMesh;
  49937. private _material;
  49938. private _cachedPosition;
  49939. private _cachedForward;
  49940. private _attachedMeshParent;
  49941. /**
  49942. * Creates a LightGizmo
  49943. * @param gizmoLayer The utility layer the gizmo will be added to
  49944. */
  49945. constructor(gizmoLayer?: UtilityLayerRenderer);
  49946. private _light;
  49947. /**
  49948. * The light that the gizmo is attached to
  49949. */
  49950. set light(light: Nullable<Light>);
  49951. get light(): Nullable<Light>;
  49952. /**
  49953. * Gets the material used to render the light gizmo
  49954. */
  49955. get material(): StandardMaterial;
  49956. /**
  49957. * @hidden
  49958. * Updates the gizmo to match the attached mesh's position/rotation
  49959. */
  49960. protected _update(): void;
  49961. private static _Scale;
  49962. /**
  49963. * Creates the lines for a light mesh
  49964. */
  49965. private static _CreateLightLines;
  49966. /**
  49967. * Disposes of the light gizmo
  49968. */
  49969. dispose(): void;
  49970. private static _CreateHemisphericLightMesh;
  49971. private static _CreatePointLightMesh;
  49972. private static _CreateSpotLightMesh;
  49973. private static _CreateDirectionalLightMesh;
  49974. }
  49975. }
  49976. declare module "babylonjs/Gizmos/index" {
  49977. export * from "babylonjs/Gizmos/axisDragGizmo";
  49978. export * from "babylonjs/Gizmos/axisScaleGizmo";
  49979. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  49980. export * from "babylonjs/Gizmos/gizmo";
  49981. export * from "babylonjs/Gizmos/gizmoManager";
  49982. export * from "babylonjs/Gizmos/planeRotationGizmo";
  49983. export * from "babylonjs/Gizmos/positionGizmo";
  49984. export * from "babylonjs/Gizmos/rotationGizmo";
  49985. export * from "babylonjs/Gizmos/scaleGizmo";
  49986. export * from "babylonjs/Gizmos/lightGizmo";
  49987. export * from "babylonjs/Gizmos/planeDragGizmo";
  49988. }
  49989. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  49990. /** @hidden */
  49991. export var backgroundFragmentDeclaration: {
  49992. name: string;
  49993. shader: string;
  49994. };
  49995. }
  49996. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  49997. /** @hidden */
  49998. export var backgroundUboDeclaration: {
  49999. name: string;
  50000. shader: string;
  50001. };
  50002. }
  50003. declare module "babylonjs/Shaders/background.fragment" {
  50004. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50005. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50006. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50007. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50008. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50009. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50010. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50011. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50012. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50013. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50014. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50015. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50016. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50017. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50018. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50019. /** @hidden */
  50020. export var backgroundPixelShader: {
  50021. name: string;
  50022. shader: string;
  50023. };
  50024. }
  50025. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50026. /** @hidden */
  50027. export var backgroundVertexDeclaration: {
  50028. name: string;
  50029. shader: string;
  50030. };
  50031. }
  50032. declare module "babylonjs/Shaders/background.vertex" {
  50033. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50034. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50036. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50037. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50038. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50039. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50040. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50041. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50042. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50043. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50044. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50045. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50046. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50047. /** @hidden */
  50048. export var backgroundVertexShader: {
  50049. name: string;
  50050. shader: string;
  50051. };
  50052. }
  50053. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50054. import { Nullable, int, float } from "babylonjs/types";
  50055. import { Scene } from "babylonjs/scene";
  50056. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50057. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50059. import { Mesh } from "babylonjs/Meshes/mesh";
  50060. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50061. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50064. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50065. import { Color3 } from "babylonjs/Maths/math.color";
  50066. import "babylonjs/Shaders/background.fragment";
  50067. import "babylonjs/Shaders/background.vertex";
  50068. /**
  50069. * Background material used to create an efficient environement around your scene.
  50070. */
  50071. export class BackgroundMaterial extends PushMaterial {
  50072. /**
  50073. * Standard reflectance value at parallel view angle.
  50074. */
  50075. static StandardReflectance0: number;
  50076. /**
  50077. * Standard reflectance value at grazing angle.
  50078. */
  50079. static StandardReflectance90: number;
  50080. protected _primaryColor: Color3;
  50081. /**
  50082. * Key light Color (multiply against the environement texture)
  50083. */
  50084. primaryColor: Color3;
  50085. protected __perceptualColor: Nullable<Color3>;
  50086. /**
  50087. * Experimental Internal Use Only.
  50088. *
  50089. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50090. * This acts as a helper to set the primary color to a more "human friendly" value.
  50091. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50092. * output color as close as possible from the chosen value.
  50093. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50094. * part of lighting setup.)
  50095. */
  50096. get _perceptualColor(): Nullable<Color3>;
  50097. set _perceptualColor(value: Nullable<Color3>);
  50098. protected _primaryColorShadowLevel: float;
  50099. /**
  50100. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50101. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50102. */
  50103. get primaryColorShadowLevel(): float;
  50104. set primaryColorShadowLevel(value: float);
  50105. protected _primaryColorHighlightLevel: float;
  50106. /**
  50107. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50108. * The primary color is used at the level chosen to define what the white area would look.
  50109. */
  50110. get primaryColorHighlightLevel(): float;
  50111. set primaryColorHighlightLevel(value: float);
  50112. protected _reflectionTexture: Nullable<BaseTexture>;
  50113. /**
  50114. * Reflection Texture used in the material.
  50115. * Should be author in a specific way for the best result (refer to the documentation).
  50116. */
  50117. reflectionTexture: Nullable<BaseTexture>;
  50118. protected _reflectionBlur: float;
  50119. /**
  50120. * Reflection Texture level of blur.
  50121. *
  50122. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50123. * texture twice.
  50124. */
  50125. reflectionBlur: float;
  50126. protected _diffuseTexture: Nullable<BaseTexture>;
  50127. /**
  50128. * Diffuse Texture used in the material.
  50129. * Should be author in a specific way for the best result (refer to the documentation).
  50130. */
  50131. diffuseTexture: Nullable<BaseTexture>;
  50132. protected _shadowLights: Nullable<IShadowLight[]>;
  50133. /**
  50134. * Specify the list of lights casting shadow on the material.
  50135. * All scene shadow lights will be included if null.
  50136. */
  50137. shadowLights: Nullable<IShadowLight[]>;
  50138. protected _shadowLevel: float;
  50139. /**
  50140. * Helps adjusting the shadow to a softer level if required.
  50141. * 0 means black shadows and 1 means no shadows.
  50142. */
  50143. shadowLevel: float;
  50144. protected _sceneCenter: Vector3;
  50145. /**
  50146. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50147. * It is usually zero but might be interesting to modify according to your setup.
  50148. */
  50149. sceneCenter: Vector3;
  50150. protected _opacityFresnel: boolean;
  50151. /**
  50152. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50153. * This helps ensuring a nice transition when the camera goes under the ground.
  50154. */
  50155. opacityFresnel: boolean;
  50156. protected _reflectionFresnel: boolean;
  50157. /**
  50158. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50159. * This helps adding a mirror texture on the ground.
  50160. */
  50161. reflectionFresnel: boolean;
  50162. protected _reflectionFalloffDistance: number;
  50163. /**
  50164. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50165. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50166. */
  50167. reflectionFalloffDistance: number;
  50168. protected _reflectionAmount: number;
  50169. /**
  50170. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50171. */
  50172. reflectionAmount: number;
  50173. protected _reflectionReflectance0: number;
  50174. /**
  50175. * This specifies the weight of the reflection at grazing angle.
  50176. */
  50177. reflectionReflectance0: number;
  50178. protected _reflectionReflectance90: number;
  50179. /**
  50180. * This specifies the weight of the reflection at a perpendicular point of view.
  50181. */
  50182. reflectionReflectance90: number;
  50183. /**
  50184. * Sets the reflection reflectance fresnel values according to the default standard
  50185. * empirically know to work well :-)
  50186. */
  50187. set reflectionStandardFresnelWeight(value: number);
  50188. protected _useRGBColor: boolean;
  50189. /**
  50190. * Helps to directly use the maps channels instead of their level.
  50191. */
  50192. useRGBColor: boolean;
  50193. protected _enableNoise: boolean;
  50194. /**
  50195. * This helps reducing the banding effect that could occur on the background.
  50196. */
  50197. enableNoise: boolean;
  50198. /**
  50199. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50200. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50201. * Recommended to be keep at 1.0 except for special cases.
  50202. */
  50203. get fovMultiplier(): number;
  50204. set fovMultiplier(value: number);
  50205. private _fovMultiplier;
  50206. /**
  50207. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50208. */
  50209. useEquirectangularFOV: boolean;
  50210. private _maxSimultaneousLights;
  50211. /**
  50212. * Number of Simultaneous lights allowed on the material.
  50213. */
  50214. maxSimultaneousLights: int;
  50215. /**
  50216. * Default configuration related to image processing available in the Background Material.
  50217. */
  50218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50219. /**
  50220. * Keep track of the image processing observer to allow dispose and replace.
  50221. */
  50222. private _imageProcessingObserver;
  50223. /**
  50224. * Attaches a new image processing configuration to the PBR Material.
  50225. * @param configuration (if null the scene configuration will be use)
  50226. */
  50227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50228. /**
  50229. * Gets the image processing configuration used either in this material.
  50230. */
  50231. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50232. /**
  50233. * Sets the Default image processing configuration used either in the this material.
  50234. *
  50235. * If sets to null, the scene one is in use.
  50236. */
  50237. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50238. /**
  50239. * Gets wether the color curves effect is enabled.
  50240. */
  50241. get cameraColorCurvesEnabled(): boolean;
  50242. /**
  50243. * Sets wether the color curves effect is enabled.
  50244. */
  50245. set cameraColorCurvesEnabled(value: boolean);
  50246. /**
  50247. * Gets wether the color grading effect is enabled.
  50248. */
  50249. get cameraColorGradingEnabled(): boolean;
  50250. /**
  50251. * Gets wether the color grading effect is enabled.
  50252. */
  50253. set cameraColorGradingEnabled(value: boolean);
  50254. /**
  50255. * Gets wether tonemapping is enabled or not.
  50256. */
  50257. get cameraToneMappingEnabled(): boolean;
  50258. /**
  50259. * Sets wether tonemapping is enabled or not
  50260. */
  50261. set cameraToneMappingEnabled(value: boolean);
  50262. /**
  50263. * The camera exposure used on this material.
  50264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50265. * This corresponds to a photographic exposure.
  50266. */
  50267. get cameraExposure(): float;
  50268. /**
  50269. * The camera exposure used on this material.
  50270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50271. * This corresponds to a photographic exposure.
  50272. */
  50273. set cameraExposure(value: float);
  50274. /**
  50275. * Gets The camera contrast used on this material.
  50276. */
  50277. get cameraContrast(): float;
  50278. /**
  50279. * Sets The camera contrast used on this material.
  50280. */
  50281. set cameraContrast(value: float);
  50282. /**
  50283. * Gets the Color Grading 2D Lookup Texture.
  50284. */
  50285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50286. /**
  50287. * Sets the Color Grading 2D Lookup Texture.
  50288. */
  50289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50290. /**
  50291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50293. * 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;
  50294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50295. */
  50296. get cameraColorCurves(): Nullable<ColorCurves>;
  50297. /**
  50298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50300. * 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;
  50301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50302. */
  50303. set cameraColorCurves(value: Nullable<ColorCurves>);
  50304. /**
  50305. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50306. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50307. */
  50308. switchToBGR: boolean;
  50309. private _renderTargets;
  50310. private _reflectionControls;
  50311. private _white;
  50312. private _primaryShadowColor;
  50313. private _primaryHighlightColor;
  50314. /**
  50315. * Instantiates a Background Material in the given scene
  50316. * @param name The friendly name of the material
  50317. * @param scene The scene to add the material to
  50318. */
  50319. constructor(name: string, scene: Scene);
  50320. /**
  50321. * Gets a boolean indicating that current material needs to register RTT
  50322. */
  50323. get hasRenderTargetTextures(): boolean;
  50324. /**
  50325. * The entire material has been created in order to prevent overdraw.
  50326. * @returns false
  50327. */
  50328. needAlphaTesting(): boolean;
  50329. /**
  50330. * The entire material has been created in order to prevent overdraw.
  50331. * @returns true if blending is enable
  50332. */
  50333. needAlphaBlending(): boolean;
  50334. /**
  50335. * Checks wether the material is ready to be rendered for a given mesh.
  50336. * @param mesh The mesh to render
  50337. * @param subMesh The submesh to check against
  50338. * @param useInstances Specify wether or not the material is used with instances
  50339. * @returns true if all the dependencies are ready (Textures, Effects...)
  50340. */
  50341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50342. /**
  50343. * Compute the primary color according to the chosen perceptual color.
  50344. */
  50345. private _computePrimaryColorFromPerceptualColor;
  50346. /**
  50347. * Compute the highlights and shadow colors according to their chosen levels.
  50348. */
  50349. private _computePrimaryColors;
  50350. /**
  50351. * Build the uniform buffer used in the material.
  50352. */
  50353. buildUniformLayout(): void;
  50354. /**
  50355. * Unbind the material.
  50356. */
  50357. unbind(): void;
  50358. /**
  50359. * Bind only the world matrix to the material.
  50360. * @param world The world matrix to bind.
  50361. */
  50362. bindOnlyWorldMatrix(world: Matrix): void;
  50363. /**
  50364. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50365. * @param world The world matrix to bind.
  50366. * @param subMesh The submesh to bind for.
  50367. */
  50368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50369. /**
  50370. * Checks to see if a texture is used in the material.
  50371. * @param texture - Base texture to use.
  50372. * @returns - Boolean specifying if a texture is used in the material.
  50373. */
  50374. hasTexture(texture: BaseTexture): boolean;
  50375. /**
  50376. * Dispose the material.
  50377. * @param forceDisposeEffect Force disposal of the associated effect.
  50378. * @param forceDisposeTextures Force disposal of the associated textures.
  50379. */
  50380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50381. /**
  50382. * Clones the material.
  50383. * @param name The cloned name.
  50384. * @returns The cloned material.
  50385. */
  50386. clone(name: string): BackgroundMaterial;
  50387. /**
  50388. * Serializes the current material to its JSON representation.
  50389. * @returns The JSON representation.
  50390. */
  50391. serialize(): any;
  50392. /**
  50393. * Gets the class name of the material
  50394. * @returns "BackgroundMaterial"
  50395. */
  50396. getClassName(): string;
  50397. /**
  50398. * Parse a JSON input to create back a background material.
  50399. * @param source The JSON data to parse
  50400. * @param scene The scene to create the parsed material in
  50401. * @param rootUrl The root url of the assets the material depends upon
  50402. * @returns the instantiated BackgroundMaterial.
  50403. */
  50404. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50405. }
  50406. }
  50407. declare module "babylonjs/Helpers/environmentHelper" {
  50408. import { Observable } from "babylonjs/Misc/observable";
  50409. import { Nullable } from "babylonjs/types";
  50410. import { Scene } from "babylonjs/scene";
  50411. import { Vector3 } from "babylonjs/Maths/math.vector";
  50412. import { Color3 } from "babylonjs/Maths/math.color";
  50413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50414. import { Mesh } from "babylonjs/Meshes/mesh";
  50415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50416. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50417. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50418. import "babylonjs/Meshes/Builders/planeBuilder";
  50419. import "babylonjs/Meshes/Builders/boxBuilder";
  50420. /**
  50421. * Represents the different options available during the creation of
  50422. * a Environment helper.
  50423. *
  50424. * This can control the default ground, skybox and image processing setup of your scene.
  50425. */
  50426. export interface IEnvironmentHelperOptions {
  50427. /**
  50428. * Specifies wether or not to create a ground.
  50429. * True by default.
  50430. */
  50431. createGround: boolean;
  50432. /**
  50433. * Specifies the ground size.
  50434. * 15 by default.
  50435. */
  50436. groundSize: number;
  50437. /**
  50438. * The texture used on the ground for the main color.
  50439. * Comes from the BabylonJS CDN by default.
  50440. *
  50441. * Remarks: Can be either a texture or a url.
  50442. */
  50443. groundTexture: string | BaseTexture;
  50444. /**
  50445. * The color mixed in the ground texture by default.
  50446. * BabylonJS clearColor by default.
  50447. */
  50448. groundColor: Color3;
  50449. /**
  50450. * Specifies the ground opacity.
  50451. * 1 by default.
  50452. */
  50453. groundOpacity: number;
  50454. /**
  50455. * Enables the ground to receive shadows.
  50456. * True by default.
  50457. */
  50458. enableGroundShadow: boolean;
  50459. /**
  50460. * Helps preventing the shadow to be fully black on the ground.
  50461. * 0.5 by default.
  50462. */
  50463. groundShadowLevel: number;
  50464. /**
  50465. * Creates a mirror texture attach to the ground.
  50466. * false by default.
  50467. */
  50468. enableGroundMirror: boolean;
  50469. /**
  50470. * Specifies the ground mirror size ratio.
  50471. * 0.3 by default as the default kernel is 64.
  50472. */
  50473. groundMirrorSizeRatio: number;
  50474. /**
  50475. * Specifies the ground mirror blur kernel size.
  50476. * 64 by default.
  50477. */
  50478. groundMirrorBlurKernel: number;
  50479. /**
  50480. * Specifies the ground mirror visibility amount.
  50481. * 1 by default
  50482. */
  50483. groundMirrorAmount: number;
  50484. /**
  50485. * Specifies the ground mirror reflectance weight.
  50486. * This uses the standard weight of the background material to setup the fresnel effect
  50487. * of the mirror.
  50488. * 1 by default.
  50489. */
  50490. groundMirrorFresnelWeight: number;
  50491. /**
  50492. * Specifies the ground mirror Falloff distance.
  50493. * This can helps reducing the size of the reflection.
  50494. * 0 by Default.
  50495. */
  50496. groundMirrorFallOffDistance: number;
  50497. /**
  50498. * Specifies the ground mirror texture type.
  50499. * Unsigned Int by Default.
  50500. */
  50501. groundMirrorTextureType: number;
  50502. /**
  50503. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50504. * the shown objects.
  50505. */
  50506. groundYBias: number;
  50507. /**
  50508. * Specifies wether or not to create a skybox.
  50509. * True by default.
  50510. */
  50511. createSkybox: boolean;
  50512. /**
  50513. * Specifies the skybox size.
  50514. * 20 by default.
  50515. */
  50516. skyboxSize: number;
  50517. /**
  50518. * The texture used on the skybox for the main color.
  50519. * Comes from the BabylonJS CDN by default.
  50520. *
  50521. * Remarks: Can be either a texture or a url.
  50522. */
  50523. skyboxTexture: string | BaseTexture;
  50524. /**
  50525. * The color mixed in the skybox texture by default.
  50526. * BabylonJS clearColor by default.
  50527. */
  50528. skyboxColor: Color3;
  50529. /**
  50530. * The background rotation around the Y axis of the scene.
  50531. * This helps aligning the key lights of your scene with the background.
  50532. * 0 by default.
  50533. */
  50534. backgroundYRotation: number;
  50535. /**
  50536. * Compute automatically the size of the elements to best fit with the scene.
  50537. */
  50538. sizeAuto: boolean;
  50539. /**
  50540. * Default position of the rootMesh if autoSize is not true.
  50541. */
  50542. rootPosition: Vector3;
  50543. /**
  50544. * Sets up the image processing in the scene.
  50545. * true by default.
  50546. */
  50547. setupImageProcessing: boolean;
  50548. /**
  50549. * The texture used as your environment texture in the scene.
  50550. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50551. *
  50552. * Remarks: Can be either a texture or a url.
  50553. */
  50554. environmentTexture: string | BaseTexture;
  50555. /**
  50556. * The value of the exposure to apply to the scene.
  50557. * 0.6 by default if setupImageProcessing is true.
  50558. */
  50559. cameraExposure: number;
  50560. /**
  50561. * The value of the contrast to apply to the scene.
  50562. * 1.6 by default if setupImageProcessing is true.
  50563. */
  50564. cameraContrast: number;
  50565. /**
  50566. * Specifies wether or not tonemapping should be enabled in the scene.
  50567. * true by default if setupImageProcessing is true.
  50568. */
  50569. toneMappingEnabled: boolean;
  50570. }
  50571. /**
  50572. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50573. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50574. * It also helps with the default setup of your imageProcessing configuration.
  50575. */
  50576. export class EnvironmentHelper {
  50577. /**
  50578. * Default ground texture URL.
  50579. */
  50580. private static _groundTextureCDNUrl;
  50581. /**
  50582. * Default skybox texture URL.
  50583. */
  50584. private static _skyboxTextureCDNUrl;
  50585. /**
  50586. * Default environment texture URL.
  50587. */
  50588. private static _environmentTextureCDNUrl;
  50589. /**
  50590. * Creates the default options for the helper.
  50591. */
  50592. private static _getDefaultOptions;
  50593. private _rootMesh;
  50594. /**
  50595. * Gets the root mesh created by the helper.
  50596. */
  50597. get rootMesh(): Mesh;
  50598. private _skybox;
  50599. /**
  50600. * Gets the skybox created by the helper.
  50601. */
  50602. get skybox(): Nullable<Mesh>;
  50603. private _skyboxTexture;
  50604. /**
  50605. * Gets the skybox texture created by the helper.
  50606. */
  50607. get skyboxTexture(): Nullable<BaseTexture>;
  50608. private _skyboxMaterial;
  50609. /**
  50610. * Gets the skybox material created by the helper.
  50611. */
  50612. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50613. private _ground;
  50614. /**
  50615. * Gets the ground mesh created by the helper.
  50616. */
  50617. get ground(): Nullable<Mesh>;
  50618. private _groundTexture;
  50619. /**
  50620. * Gets the ground texture created by the helper.
  50621. */
  50622. get groundTexture(): Nullable<BaseTexture>;
  50623. private _groundMirror;
  50624. /**
  50625. * Gets the ground mirror created by the helper.
  50626. */
  50627. get groundMirror(): Nullable<MirrorTexture>;
  50628. /**
  50629. * Gets the ground mirror render list to helps pushing the meshes
  50630. * you wish in the ground reflection.
  50631. */
  50632. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50633. private _groundMaterial;
  50634. /**
  50635. * Gets the ground material created by the helper.
  50636. */
  50637. get groundMaterial(): Nullable<BackgroundMaterial>;
  50638. /**
  50639. * Stores the creation options.
  50640. */
  50641. private readonly _scene;
  50642. private _options;
  50643. /**
  50644. * This observable will be notified with any error during the creation of the environment,
  50645. * mainly texture creation errors.
  50646. */
  50647. onErrorObservable: Observable<{
  50648. message?: string;
  50649. exception?: any;
  50650. }>;
  50651. /**
  50652. * constructor
  50653. * @param options Defines the options we want to customize the helper
  50654. * @param scene The scene to add the material to
  50655. */
  50656. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50657. /**
  50658. * Updates the background according to the new options
  50659. * @param options
  50660. */
  50661. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50662. /**
  50663. * Sets the primary color of all the available elements.
  50664. * @param color the main color to affect to the ground and the background
  50665. */
  50666. setMainColor(color: Color3): void;
  50667. /**
  50668. * Setup the image processing according to the specified options.
  50669. */
  50670. private _setupImageProcessing;
  50671. /**
  50672. * Setup the environment texture according to the specified options.
  50673. */
  50674. private _setupEnvironmentTexture;
  50675. /**
  50676. * Setup the background according to the specified options.
  50677. */
  50678. private _setupBackground;
  50679. /**
  50680. * Get the scene sizes according to the setup.
  50681. */
  50682. private _getSceneSize;
  50683. /**
  50684. * Setup the ground according to the specified options.
  50685. */
  50686. private _setupGround;
  50687. /**
  50688. * Setup the ground material according to the specified options.
  50689. */
  50690. private _setupGroundMaterial;
  50691. /**
  50692. * Setup the ground diffuse texture according to the specified options.
  50693. */
  50694. private _setupGroundDiffuseTexture;
  50695. /**
  50696. * Setup the ground mirror texture according to the specified options.
  50697. */
  50698. private _setupGroundMirrorTexture;
  50699. /**
  50700. * Setup the ground to receive the mirror texture.
  50701. */
  50702. private _setupMirrorInGroundMaterial;
  50703. /**
  50704. * Setup the skybox according to the specified options.
  50705. */
  50706. private _setupSkybox;
  50707. /**
  50708. * Setup the skybox material according to the specified options.
  50709. */
  50710. private _setupSkyboxMaterial;
  50711. /**
  50712. * Setup the skybox reflection texture according to the specified options.
  50713. */
  50714. private _setupSkyboxReflectionTexture;
  50715. private _errorHandler;
  50716. /**
  50717. * Dispose all the elements created by the Helper.
  50718. */
  50719. dispose(): void;
  50720. }
  50721. }
  50722. declare module "babylonjs/Helpers/photoDome" {
  50723. import { Observable } from "babylonjs/Misc/observable";
  50724. import { Nullable } from "babylonjs/types";
  50725. import { Scene } from "babylonjs/scene";
  50726. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50727. import { Mesh } from "babylonjs/Meshes/mesh";
  50728. import { Texture } from "babylonjs/Materials/Textures/texture";
  50729. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50730. import "babylonjs/Meshes/Builders/sphereBuilder";
  50731. /**
  50732. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50733. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50734. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50735. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50736. */
  50737. export class PhotoDome extends TransformNode {
  50738. /**
  50739. * Define the image as a Monoscopic panoramic 360 image.
  50740. */
  50741. static readonly MODE_MONOSCOPIC: number;
  50742. /**
  50743. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50744. */
  50745. static readonly MODE_TOPBOTTOM: number;
  50746. /**
  50747. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50748. */
  50749. static readonly MODE_SIDEBYSIDE: number;
  50750. private _useDirectMapping;
  50751. /**
  50752. * The texture being displayed on the sphere
  50753. */
  50754. protected _photoTexture: Texture;
  50755. /**
  50756. * Gets or sets the texture being displayed on the sphere
  50757. */
  50758. get photoTexture(): Texture;
  50759. set photoTexture(value: Texture);
  50760. /**
  50761. * Observable raised when an error occured while loading the 360 image
  50762. */
  50763. onLoadErrorObservable: Observable<string>;
  50764. /**
  50765. * The skybox material
  50766. */
  50767. protected _material: BackgroundMaterial;
  50768. /**
  50769. * The surface used for the skybox
  50770. */
  50771. protected _mesh: Mesh;
  50772. /**
  50773. * Gets the mesh used for the skybox.
  50774. */
  50775. get mesh(): Mesh;
  50776. /**
  50777. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50778. * Also see the options.resolution property.
  50779. */
  50780. get fovMultiplier(): number;
  50781. set fovMultiplier(value: number);
  50782. private _imageMode;
  50783. /**
  50784. * Gets or set the current video mode for the video. It can be:
  50785. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50786. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50787. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50788. */
  50789. get imageMode(): number;
  50790. set imageMode(value: number);
  50791. /**
  50792. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50793. * @param name Element's name, child elements will append suffixes for their own names.
  50794. * @param urlsOfPhoto defines the url of the photo to display
  50795. * @param options defines an object containing optional or exposed sub element properties
  50796. * @param onError defines a callback called when an error occured while loading the texture
  50797. */
  50798. constructor(name: string, urlOfPhoto: string, options: {
  50799. resolution?: number;
  50800. size?: number;
  50801. useDirectMapping?: boolean;
  50802. faceForward?: boolean;
  50803. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50804. private _onBeforeCameraRenderObserver;
  50805. private _changeImageMode;
  50806. /**
  50807. * Releases resources associated with this node.
  50808. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50809. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50810. */
  50811. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50812. }
  50813. }
  50814. declare module "babylonjs/Misc/rgbdTextureTools" {
  50815. import "babylonjs/Shaders/rgbdDecode.fragment";
  50816. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50817. import { Texture } from "babylonjs/Materials/Textures/texture";
  50818. /**
  50819. * Class used to host RGBD texture specific utilities
  50820. */
  50821. export class RGBDTextureTools {
  50822. /**
  50823. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50824. * @param texture the texture to expand.
  50825. */
  50826. static ExpandRGBDTexture(texture: Texture): void;
  50827. }
  50828. }
  50829. declare module "babylonjs/Misc/brdfTextureTools" {
  50830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50831. import { Scene } from "babylonjs/scene";
  50832. /**
  50833. * Class used to host texture specific utilities
  50834. */
  50835. export class BRDFTextureTools {
  50836. /**
  50837. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50838. * @param scene defines the hosting scene
  50839. * @returns the environment BRDF texture
  50840. */
  50841. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50842. private static _environmentBRDFBase64Texture;
  50843. }
  50844. }
  50845. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50846. import { Nullable } from "babylonjs/types";
  50847. import { Color3 } from "babylonjs/Maths/math.color";
  50848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50849. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50850. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50851. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50852. import { Engine } from "babylonjs/Engines/engine";
  50853. import { Scene } from "babylonjs/scene";
  50854. /**
  50855. * @hidden
  50856. */
  50857. export interface IMaterialClearCoatDefines {
  50858. CLEARCOAT: boolean;
  50859. CLEARCOAT_DEFAULTIOR: boolean;
  50860. CLEARCOAT_TEXTURE: boolean;
  50861. CLEARCOAT_TEXTUREDIRECTUV: number;
  50862. CLEARCOAT_BUMP: boolean;
  50863. CLEARCOAT_BUMPDIRECTUV: number;
  50864. CLEARCOAT_TINT: boolean;
  50865. CLEARCOAT_TINT_TEXTURE: boolean;
  50866. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50867. /** @hidden */
  50868. _areTexturesDirty: boolean;
  50869. }
  50870. /**
  50871. * Define the code related to the clear coat parameters of the pbr material.
  50872. */
  50873. export class PBRClearCoatConfiguration {
  50874. /**
  50875. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50876. * The default fits with a polyurethane material.
  50877. */
  50878. private static readonly _DefaultIndexOfRefraction;
  50879. private _isEnabled;
  50880. /**
  50881. * Defines if the clear coat is enabled in the material.
  50882. */
  50883. isEnabled: boolean;
  50884. /**
  50885. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50886. */
  50887. intensity: number;
  50888. /**
  50889. * Defines the clear coat layer roughness.
  50890. */
  50891. roughness: number;
  50892. private _indexOfRefraction;
  50893. /**
  50894. * Defines the index of refraction of the clear coat.
  50895. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50896. * The default fits with a polyurethane material.
  50897. * Changing the default value is more performance intensive.
  50898. */
  50899. indexOfRefraction: number;
  50900. private _texture;
  50901. /**
  50902. * Stores the clear coat values in a texture.
  50903. */
  50904. texture: Nullable<BaseTexture>;
  50905. private _bumpTexture;
  50906. /**
  50907. * Define the clear coat specific bump texture.
  50908. */
  50909. bumpTexture: Nullable<BaseTexture>;
  50910. private _isTintEnabled;
  50911. /**
  50912. * Defines if the clear coat tint is enabled in the material.
  50913. */
  50914. isTintEnabled: boolean;
  50915. /**
  50916. * Defines the clear coat tint of the material.
  50917. * This is only use if tint is enabled
  50918. */
  50919. tintColor: Color3;
  50920. /**
  50921. * Defines the distance at which the tint color should be found in the
  50922. * clear coat media.
  50923. * This is only use if tint is enabled
  50924. */
  50925. tintColorAtDistance: number;
  50926. /**
  50927. * Defines the clear coat layer thickness.
  50928. * This is only use if tint is enabled
  50929. */
  50930. tintThickness: number;
  50931. private _tintTexture;
  50932. /**
  50933. * Stores the clear tint values in a texture.
  50934. * rgb is tint
  50935. * a is a thickness factor
  50936. */
  50937. tintTexture: Nullable<BaseTexture>;
  50938. /** @hidden */
  50939. private _internalMarkAllSubMeshesAsTexturesDirty;
  50940. /** @hidden */
  50941. _markAllSubMeshesAsTexturesDirty(): void;
  50942. /**
  50943. * Instantiate a new istance of clear coat configuration.
  50944. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50945. */
  50946. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50947. /**
  50948. * Gets wehter the submesh is ready to be used or not.
  50949. * @param defines the list of "defines" to update.
  50950. * @param scene defines the scene the material belongs to.
  50951. * @param engine defines the engine the material belongs to.
  50952. * @param disableBumpMap defines wether the material disables bump or not.
  50953. * @returns - boolean indicating that the submesh is ready or not.
  50954. */
  50955. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50956. /**
  50957. * Checks to see if a texture is used in the material.
  50958. * @param defines the list of "defines" to update.
  50959. * @param scene defines the scene to the material belongs to.
  50960. */
  50961. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50962. /**
  50963. * Binds the material data.
  50964. * @param uniformBuffer defines the Uniform buffer to fill in.
  50965. * @param scene defines the scene the material belongs to.
  50966. * @param engine defines the engine the material belongs to.
  50967. * @param disableBumpMap defines wether the material disables bump or not.
  50968. * @param isFrozen defines wether the material is frozen or not.
  50969. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50970. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50971. */
  50972. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50973. /**
  50974. * Checks to see if a texture is used in the material.
  50975. * @param texture - Base texture to use.
  50976. * @returns - Boolean specifying if a texture is used in the material.
  50977. */
  50978. hasTexture(texture: BaseTexture): boolean;
  50979. /**
  50980. * Returns an array of the actively used textures.
  50981. * @param activeTextures Array of BaseTextures
  50982. */
  50983. getActiveTextures(activeTextures: BaseTexture[]): void;
  50984. /**
  50985. * Returns the animatable textures.
  50986. * @param animatables Array of animatable textures.
  50987. */
  50988. getAnimatables(animatables: IAnimatable[]): void;
  50989. /**
  50990. * Disposes the resources of the material.
  50991. * @param forceDisposeTextures - Forces the disposal of all textures.
  50992. */
  50993. dispose(forceDisposeTextures?: boolean): void;
  50994. /**
  50995. * Get the current class name of the texture useful for serialization or dynamic coding.
  50996. * @returns "PBRClearCoatConfiguration"
  50997. */
  50998. getClassName(): string;
  50999. /**
  51000. * Add fallbacks to the effect fallbacks list.
  51001. * @param defines defines the Base texture to use.
  51002. * @param fallbacks defines the current fallback list.
  51003. * @param currentRank defines the current fallback rank.
  51004. * @returns the new fallback rank.
  51005. */
  51006. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51007. /**
  51008. * Add the required uniforms to the current list.
  51009. * @param uniforms defines the current uniform list.
  51010. */
  51011. static AddUniforms(uniforms: string[]): void;
  51012. /**
  51013. * Add the required samplers to the current list.
  51014. * @param samplers defines the current sampler list.
  51015. */
  51016. static AddSamplers(samplers: string[]): void;
  51017. /**
  51018. * Add the required uniforms to the current buffer.
  51019. * @param uniformBuffer defines the current uniform buffer.
  51020. */
  51021. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51022. /**
  51023. * Makes a duplicate of the current configuration into another one.
  51024. * @param clearCoatConfiguration define the config where to copy the info
  51025. */
  51026. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51027. /**
  51028. * Serializes this clear coat configuration.
  51029. * @returns - An object with the serialized config.
  51030. */
  51031. serialize(): any;
  51032. /**
  51033. * Parses a anisotropy Configuration from a serialized object.
  51034. * @param source - Serialized object.
  51035. * @param scene Defines the scene we are parsing for
  51036. * @param rootUrl Defines the rootUrl to load from
  51037. */
  51038. parse(source: any, scene: Scene, rootUrl: string): void;
  51039. }
  51040. }
  51041. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51044. import { Vector2 } from "babylonjs/Maths/math.vector";
  51045. import { Scene } from "babylonjs/scene";
  51046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51047. import { Nullable } from "babylonjs/types";
  51048. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51049. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51050. /**
  51051. * @hidden
  51052. */
  51053. export interface IMaterialAnisotropicDefines {
  51054. ANISOTROPIC: boolean;
  51055. ANISOTROPIC_TEXTURE: boolean;
  51056. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51057. MAINUV1: boolean;
  51058. _areTexturesDirty: boolean;
  51059. _needUVs: boolean;
  51060. }
  51061. /**
  51062. * Define the code related to the anisotropic parameters of the pbr material.
  51063. */
  51064. export class PBRAnisotropicConfiguration {
  51065. private _isEnabled;
  51066. /**
  51067. * Defines if the anisotropy is enabled in the material.
  51068. */
  51069. isEnabled: boolean;
  51070. /**
  51071. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51072. */
  51073. intensity: number;
  51074. /**
  51075. * Defines if the effect is along the tangents, bitangents or in between.
  51076. * By default, the effect is "strectching" the highlights along the tangents.
  51077. */
  51078. direction: Vector2;
  51079. private _texture;
  51080. /**
  51081. * Stores the anisotropy values in a texture.
  51082. * rg is direction (like normal from -1 to 1)
  51083. * b is a intensity
  51084. */
  51085. texture: Nullable<BaseTexture>;
  51086. /** @hidden */
  51087. private _internalMarkAllSubMeshesAsTexturesDirty;
  51088. /** @hidden */
  51089. _markAllSubMeshesAsTexturesDirty(): void;
  51090. /**
  51091. * Instantiate a new istance of anisotropy configuration.
  51092. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51093. */
  51094. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51095. /**
  51096. * Specifies that the submesh is ready to be used.
  51097. * @param defines the list of "defines" to update.
  51098. * @param scene defines the scene the material belongs to.
  51099. * @returns - boolean indicating that the submesh is ready or not.
  51100. */
  51101. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51102. /**
  51103. * Checks to see if a texture is used in the material.
  51104. * @param defines the list of "defines" to update.
  51105. * @param mesh the mesh we are preparing the defines for.
  51106. * @param scene defines the scene the material belongs to.
  51107. */
  51108. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51109. /**
  51110. * Binds the material data.
  51111. * @param uniformBuffer defines the Uniform buffer to fill in.
  51112. * @param scene defines the scene the material belongs to.
  51113. * @param isFrozen defines wether the material is frozen or not.
  51114. */
  51115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51116. /**
  51117. * Checks to see if a texture is used in the material.
  51118. * @param texture - Base texture to use.
  51119. * @returns - Boolean specifying if a texture is used in the material.
  51120. */
  51121. hasTexture(texture: BaseTexture): boolean;
  51122. /**
  51123. * Returns an array of the actively used textures.
  51124. * @param activeTextures Array of BaseTextures
  51125. */
  51126. getActiveTextures(activeTextures: BaseTexture[]): void;
  51127. /**
  51128. * Returns the animatable textures.
  51129. * @param animatables Array of animatable textures.
  51130. */
  51131. getAnimatables(animatables: IAnimatable[]): void;
  51132. /**
  51133. * Disposes the resources of the material.
  51134. * @param forceDisposeTextures - Forces the disposal of all textures.
  51135. */
  51136. dispose(forceDisposeTextures?: boolean): void;
  51137. /**
  51138. * Get the current class name of the texture useful for serialization or dynamic coding.
  51139. * @returns "PBRAnisotropicConfiguration"
  51140. */
  51141. getClassName(): string;
  51142. /**
  51143. * Add fallbacks to the effect fallbacks list.
  51144. * @param defines defines the Base texture to use.
  51145. * @param fallbacks defines the current fallback list.
  51146. * @param currentRank defines the current fallback rank.
  51147. * @returns the new fallback rank.
  51148. */
  51149. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51150. /**
  51151. * Add the required uniforms to the current list.
  51152. * @param uniforms defines the current uniform list.
  51153. */
  51154. static AddUniforms(uniforms: string[]): void;
  51155. /**
  51156. * Add the required uniforms to the current buffer.
  51157. * @param uniformBuffer defines the current uniform buffer.
  51158. */
  51159. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51160. /**
  51161. * Add the required samplers to the current list.
  51162. * @param samplers defines the current sampler list.
  51163. */
  51164. static AddSamplers(samplers: string[]): void;
  51165. /**
  51166. * Makes a duplicate of the current configuration into another one.
  51167. * @param anisotropicConfiguration define the config where to copy the info
  51168. */
  51169. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51170. /**
  51171. * Serializes this anisotropy configuration.
  51172. * @returns - An object with the serialized config.
  51173. */
  51174. serialize(): any;
  51175. /**
  51176. * Parses a anisotropy Configuration from a serialized object.
  51177. * @param source - Serialized object.
  51178. * @param scene Defines the scene we are parsing for
  51179. * @param rootUrl Defines the rootUrl to load from
  51180. */
  51181. parse(source: any, scene: Scene, rootUrl: string): void;
  51182. }
  51183. }
  51184. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51185. import { Scene } from "babylonjs/scene";
  51186. /**
  51187. * @hidden
  51188. */
  51189. export interface IMaterialBRDFDefines {
  51190. BRDF_V_HEIGHT_CORRELATED: boolean;
  51191. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51192. SPHERICAL_HARMONICS: boolean;
  51193. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51194. /** @hidden */
  51195. _areMiscDirty: boolean;
  51196. }
  51197. /**
  51198. * Define the code related to the BRDF parameters of the pbr material.
  51199. */
  51200. export class PBRBRDFConfiguration {
  51201. /**
  51202. * Default value used for the energy conservation.
  51203. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51204. */
  51205. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51206. /**
  51207. * Default value used for the Smith Visibility Height Correlated mode.
  51208. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51209. */
  51210. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51211. /**
  51212. * Default value used for the IBL diffuse part.
  51213. * This can help switching back to the polynomials mode globally which is a tiny bit
  51214. * less GPU intensive at the drawback of a lower quality.
  51215. */
  51216. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51217. /**
  51218. * Default value used for activating energy conservation for the specular workflow.
  51219. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51220. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51221. */
  51222. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51223. private _useEnergyConservation;
  51224. /**
  51225. * Defines if the material uses energy conservation.
  51226. */
  51227. useEnergyConservation: boolean;
  51228. private _useSmithVisibilityHeightCorrelated;
  51229. /**
  51230. * LEGACY Mode set to false
  51231. * Defines if the material uses height smith correlated visibility term.
  51232. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51233. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51234. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51235. * Not relying on height correlated will also disable energy conservation.
  51236. */
  51237. useSmithVisibilityHeightCorrelated: boolean;
  51238. private _useSphericalHarmonics;
  51239. /**
  51240. * LEGACY Mode set to false
  51241. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51242. * diffuse part of the IBL.
  51243. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51244. * to the ground truth.
  51245. */
  51246. useSphericalHarmonics: boolean;
  51247. private _useSpecularGlossinessInputEnergyConservation;
  51248. /**
  51249. * Defines if the material uses energy conservation, when the specular workflow is active.
  51250. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51251. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51252. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51253. */
  51254. useSpecularGlossinessInputEnergyConservation: boolean;
  51255. /** @hidden */
  51256. private _internalMarkAllSubMeshesAsMiscDirty;
  51257. /** @hidden */
  51258. _markAllSubMeshesAsMiscDirty(): void;
  51259. /**
  51260. * Instantiate a new istance of clear coat configuration.
  51261. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51262. */
  51263. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51264. /**
  51265. * Checks to see if a texture is used in the material.
  51266. * @param defines the list of "defines" to update.
  51267. */
  51268. prepareDefines(defines: IMaterialBRDFDefines): void;
  51269. /**
  51270. * Get the current class name of the texture useful for serialization or dynamic coding.
  51271. * @returns "PBRClearCoatConfiguration"
  51272. */
  51273. getClassName(): string;
  51274. /**
  51275. * Makes a duplicate of the current configuration into another one.
  51276. * @param brdfConfiguration define the config where to copy the info
  51277. */
  51278. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51279. /**
  51280. * Serializes this BRDF configuration.
  51281. * @returns - An object with the serialized config.
  51282. */
  51283. serialize(): any;
  51284. /**
  51285. * Parses a anisotropy Configuration from a serialized object.
  51286. * @param source - Serialized object.
  51287. * @param scene Defines the scene we are parsing for
  51288. * @param rootUrl Defines the rootUrl to load from
  51289. */
  51290. parse(source: any, scene: Scene, rootUrl: string): void;
  51291. }
  51292. }
  51293. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51294. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51295. import { Color3 } from "babylonjs/Maths/math.color";
  51296. import { Scene } from "babylonjs/scene";
  51297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51298. import { Nullable } from "babylonjs/types";
  51299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51300. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51301. /**
  51302. * @hidden
  51303. */
  51304. export interface IMaterialSheenDefines {
  51305. SHEEN: boolean;
  51306. SHEEN_TEXTURE: boolean;
  51307. SHEEN_TEXTUREDIRECTUV: number;
  51308. SHEEN_LINKWITHALBEDO: boolean;
  51309. /** @hidden */
  51310. _areTexturesDirty: boolean;
  51311. }
  51312. /**
  51313. * Define the code related to the Sheen parameters of the pbr material.
  51314. */
  51315. export class PBRSheenConfiguration {
  51316. private _isEnabled;
  51317. /**
  51318. * Defines if the material uses sheen.
  51319. */
  51320. isEnabled: boolean;
  51321. private _linkSheenWithAlbedo;
  51322. /**
  51323. * Defines if the sheen is linked to the sheen color.
  51324. */
  51325. linkSheenWithAlbedo: boolean;
  51326. /**
  51327. * Defines the sheen intensity.
  51328. */
  51329. intensity: number;
  51330. /**
  51331. * Defines the sheen color.
  51332. */
  51333. color: Color3;
  51334. private _texture;
  51335. /**
  51336. * Stores the sheen tint values in a texture.
  51337. * rgb is tint
  51338. * a is a intensity
  51339. */
  51340. texture: Nullable<BaseTexture>;
  51341. /** @hidden */
  51342. private _internalMarkAllSubMeshesAsTexturesDirty;
  51343. /** @hidden */
  51344. _markAllSubMeshesAsTexturesDirty(): void;
  51345. /**
  51346. * Instantiate a new istance of clear coat configuration.
  51347. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51348. */
  51349. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51350. /**
  51351. * Specifies that the submesh is ready to be used.
  51352. * @param defines the list of "defines" to update.
  51353. * @param scene defines the scene the material belongs to.
  51354. * @returns - boolean indicating that the submesh is ready or not.
  51355. */
  51356. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51357. /**
  51358. * Checks to see if a texture is used in the material.
  51359. * @param defines the list of "defines" to update.
  51360. * @param scene defines the scene the material belongs to.
  51361. */
  51362. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51363. /**
  51364. * Binds the material data.
  51365. * @param uniformBuffer defines the Uniform buffer to fill in.
  51366. * @param scene defines the scene the material belongs to.
  51367. * @param isFrozen defines wether the material is frozen or not.
  51368. */
  51369. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51370. /**
  51371. * Checks to see if a texture is used in the material.
  51372. * @param texture - Base texture to use.
  51373. * @returns - Boolean specifying if a texture is used in the material.
  51374. */
  51375. hasTexture(texture: BaseTexture): boolean;
  51376. /**
  51377. * Returns an array of the actively used textures.
  51378. * @param activeTextures Array of BaseTextures
  51379. */
  51380. getActiveTextures(activeTextures: BaseTexture[]): void;
  51381. /**
  51382. * Returns the animatable textures.
  51383. * @param animatables Array of animatable textures.
  51384. */
  51385. getAnimatables(animatables: IAnimatable[]): void;
  51386. /**
  51387. * Disposes the resources of the material.
  51388. * @param forceDisposeTextures - Forces the disposal of all textures.
  51389. */
  51390. dispose(forceDisposeTextures?: boolean): void;
  51391. /**
  51392. * Get the current class name of the texture useful for serialization or dynamic coding.
  51393. * @returns "PBRSheenConfiguration"
  51394. */
  51395. getClassName(): string;
  51396. /**
  51397. * Add fallbacks to the effect fallbacks list.
  51398. * @param defines defines the Base texture to use.
  51399. * @param fallbacks defines the current fallback list.
  51400. * @param currentRank defines the current fallback rank.
  51401. * @returns the new fallback rank.
  51402. */
  51403. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51404. /**
  51405. * Add the required uniforms to the current list.
  51406. * @param uniforms defines the current uniform list.
  51407. */
  51408. static AddUniforms(uniforms: string[]): void;
  51409. /**
  51410. * Add the required uniforms to the current buffer.
  51411. * @param uniformBuffer defines the current uniform buffer.
  51412. */
  51413. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51414. /**
  51415. * Add the required samplers to the current list.
  51416. * @param samplers defines the current sampler list.
  51417. */
  51418. static AddSamplers(samplers: string[]): void;
  51419. /**
  51420. * Makes a duplicate of the current configuration into another one.
  51421. * @param sheenConfiguration define the config where to copy the info
  51422. */
  51423. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51424. /**
  51425. * Serializes this BRDF configuration.
  51426. * @returns - An object with the serialized config.
  51427. */
  51428. serialize(): any;
  51429. /**
  51430. * Parses a anisotropy Configuration from a serialized object.
  51431. * @param source - Serialized object.
  51432. * @param scene Defines the scene we are parsing for
  51433. * @param rootUrl Defines the rootUrl to load from
  51434. */
  51435. parse(source: any, scene: Scene, rootUrl: string): void;
  51436. }
  51437. }
  51438. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51439. import { Nullable } from "babylonjs/types";
  51440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51441. import { Color3 } from "babylonjs/Maths/math.color";
  51442. import { SmartArray } from "babylonjs/Misc/smartArray";
  51443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51444. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51445. import { Effect } from "babylonjs/Materials/effect";
  51446. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51447. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51448. import { Engine } from "babylonjs/Engines/engine";
  51449. import { Scene } from "babylonjs/scene";
  51450. /**
  51451. * @hidden
  51452. */
  51453. export interface IMaterialSubSurfaceDefines {
  51454. SUBSURFACE: boolean;
  51455. SS_REFRACTION: boolean;
  51456. SS_TRANSLUCENCY: boolean;
  51457. SS_SCATERRING: boolean;
  51458. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51459. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51460. SS_REFRACTIONMAP_3D: boolean;
  51461. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51462. SS_LODINREFRACTIONALPHA: boolean;
  51463. SS_GAMMAREFRACTION: boolean;
  51464. SS_RGBDREFRACTION: boolean;
  51465. SS_LINEARSPECULARREFRACTION: boolean;
  51466. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51467. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51468. /** @hidden */
  51469. _areTexturesDirty: boolean;
  51470. }
  51471. /**
  51472. * Define the code related to the sub surface parameters of the pbr material.
  51473. */
  51474. export class PBRSubSurfaceConfiguration {
  51475. private _isRefractionEnabled;
  51476. /**
  51477. * Defines if the refraction is enabled in the material.
  51478. */
  51479. isRefractionEnabled: boolean;
  51480. private _isTranslucencyEnabled;
  51481. /**
  51482. * Defines if the translucency is enabled in the material.
  51483. */
  51484. isTranslucencyEnabled: boolean;
  51485. private _isScatteringEnabled;
  51486. /**
  51487. * Defines the refraction intensity of the material.
  51488. * The refraction when enabled replaces the Diffuse part of the material.
  51489. * The intensity helps transitionning between diffuse and refraction.
  51490. */
  51491. refractionIntensity: number;
  51492. /**
  51493. * Defines the translucency intensity of the material.
  51494. * When translucency has been enabled, this defines how much of the "translucency"
  51495. * is addded to the diffuse part of the material.
  51496. */
  51497. translucencyIntensity: number;
  51498. /**
  51499. * Defines the scattering intensity of the material.
  51500. * When scattering has been enabled, this defines how much of the "scattered light"
  51501. * is addded to the diffuse part of the material.
  51502. */
  51503. scatteringIntensity: number;
  51504. private _thicknessTexture;
  51505. /**
  51506. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51507. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51508. * 0 would mean minimumThickness
  51509. * 1 would mean maximumThickness
  51510. * The other channels might be use as a mask to vary the different effects intensity.
  51511. */
  51512. thicknessTexture: Nullable<BaseTexture>;
  51513. private _refractionTexture;
  51514. /**
  51515. * Defines the texture to use for refraction.
  51516. */
  51517. refractionTexture: Nullable<BaseTexture>;
  51518. private _indexOfRefraction;
  51519. /**
  51520. * Defines the index of refraction used in the material.
  51521. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51522. */
  51523. indexOfRefraction: number;
  51524. private _invertRefractionY;
  51525. /**
  51526. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51527. */
  51528. invertRefractionY: boolean;
  51529. private _linkRefractionWithTransparency;
  51530. /**
  51531. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51532. * Materials half opaque for instance using refraction could benefit from this control.
  51533. */
  51534. linkRefractionWithTransparency: boolean;
  51535. /**
  51536. * Defines the minimum thickness stored in the thickness map.
  51537. * If no thickness map is defined, this value will be used to simulate thickness.
  51538. */
  51539. minimumThickness: number;
  51540. /**
  51541. * Defines the maximum thickness stored in the thickness map.
  51542. */
  51543. maximumThickness: number;
  51544. /**
  51545. * Defines the volume tint of the material.
  51546. * This is used for both translucency and scattering.
  51547. */
  51548. tintColor: Color3;
  51549. /**
  51550. * Defines the distance at which the tint color should be found in the media.
  51551. * This is used for refraction only.
  51552. */
  51553. tintColorAtDistance: number;
  51554. /**
  51555. * Defines how far each channel transmit through the media.
  51556. * It is defined as a color to simplify it selection.
  51557. */
  51558. diffusionDistance: Color3;
  51559. private _useMaskFromThicknessTexture;
  51560. /**
  51561. * Stores the intensity of the different subsurface effects in the thickness texture.
  51562. * * the green channel is the translucency intensity.
  51563. * * the blue channel is the scattering intensity.
  51564. * * the alpha channel is the refraction intensity.
  51565. */
  51566. useMaskFromThicknessTexture: boolean;
  51567. /** @hidden */
  51568. private _internalMarkAllSubMeshesAsTexturesDirty;
  51569. /** @hidden */
  51570. _markAllSubMeshesAsTexturesDirty(): void;
  51571. /**
  51572. * Instantiate a new istance of sub surface configuration.
  51573. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51574. */
  51575. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51576. /**
  51577. * Gets wehter the submesh is ready to be used or not.
  51578. * @param defines the list of "defines" to update.
  51579. * @param scene defines the scene the material belongs to.
  51580. * @returns - boolean indicating that the submesh is ready or not.
  51581. */
  51582. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51583. /**
  51584. * Checks to see if a texture is used in the material.
  51585. * @param defines the list of "defines" to update.
  51586. * @param scene defines the scene to the material belongs to.
  51587. */
  51588. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51589. /**
  51590. * Binds the material data.
  51591. * @param uniformBuffer defines the Uniform buffer to fill in.
  51592. * @param scene defines the scene the material belongs to.
  51593. * @param engine defines the engine the material belongs to.
  51594. * @param isFrozen defines wether the material is frozen or not.
  51595. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51596. */
  51597. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51598. /**
  51599. * Unbinds the material from the mesh.
  51600. * @param activeEffect defines the effect that should be unbound from.
  51601. * @returns true if unbound, otherwise false
  51602. */
  51603. unbind(activeEffect: Effect): boolean;
  51604. /**
  51605. * Returns the texture used for refraction or null if none is used.
  51606. * @param scene defines the scene the material belongs to.
  51607. * @returns - Refraction texture if present. If no refraction texture and refraction
  51608. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51609. */
  51610. private _getRefractionTexture;
  51611. /**
  51612. * Returns true if alpha blending should be disabled.
  51613. */
  51614. get disableAlphaBlending(): boolean;
  51615. /**
  51616. * Fills the list of render target textures.
  51617. * @param renderTargets the list of render targets to update
  51618. */
  51619. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51620. /**
  51621. * Checks to see if a texture is used in the material.
  51622. * @param texture - Base texture to use.
  51623. * @returns - Boolean specifying if a texture is used in the material.
  51624. */
  51625. hasTexture(texture: BaseTexture): boolean;
  51626. /**
  51627. * Gets a boolean indicating that current material needs to register RTT
  51628. * @returns true if this uses a render target otherwise false.
  51629. */
  51630. hasRenderTargetTextures(): boolean;
  51631. /**
  51632. * Returns an array of the actively used textures.
  51633. * @param activeTextures Array of BaseTextures
  51634. */
  51635. getActiveTextures(activeTextures: BaseTexture[]): void;
  51636. /**
  51637. * Returns the animatable textures.
  51638. * @param animatables Array of animatable textures.
  51639. */
  51640. getAnimatables(animatables: IAnimatable[]): void;
  51641. /**
  51642. * Disposes the resources of the material.
  51643. * @param forceDisposeTextures - Forces the disposal of all textures.
  51644. */
  51645. dispose(forceDisposeTextures?: boolean): void;
  51646. /**
  51647. * Get the current class name of the texture useful for serialization or dynamic coding.
  51648. * @returns "PBRSubSurfaceConfiguration"
  51649. */
  51650. getClassName(): string;
  51651. /**
  51652. * Add fallbacks to the effect fallbacks list.
  51653. * @param defines defines the Base texture to use.
  51654. * @param fallbacks defines the current fallback list.
  51655. * @param currentRank defines the current fallback rank.
  51656. * @returns the new fallback rank.
  51657. */
  51658. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51659. /**
  51660. * Add the required uniforms to the current list.
  51661. * @param uniforms defines the current uniform list.
  51662. */
  51663. static AddUniforms(uniforms: string[]): void;
  51664. /**
  51665. * Add the required samplers to the current list.
  51666. * @param samplers defines the current sampler list.
  51667. */
  51668. static AddSamplers(samplers: string[]): void;
  51669. /**
  51670. * Add the required uniforms to the current buffer.
  51671. * @param uniformBuffer defines the current uniform buffer.
  51672. */
  51673. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51674. /**
  51675. * Makes a duplicate of the current configuration into another one.
  51676. * @param configuration define the config where to copy the info
  51677. */
  51678. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51679. /**
  51680. * Serializes this Sub Surface configuration.
  51681. * @returns - An object with the serialized config.
  51682. */
  51683. serialize(): any;
  51684. /**
  51685. * Parses a anisotropy Configuration from a serialized object.
  51686. * @param source - Serialized object.
  51687. * @param scene Defines the scene we are parsing for
  51688. * @param rootUrl Defines the rootUrl to load from
  51689. */
  51690. parse(source: any, scene: Scene, rootUrl: string): void;
  51691. }
  51692. }
  51693. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51694. /** @hidden */
  51695. export var pbrFragmentDeclaration: {
  51696. name: string;
  51697. shader: string;
  51698. };
  51699. }
  51700. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51701. /** @hidden */
  51702. export var pbrUboDeclaration: {
  51703. name: string;
  51704. shader: string;
  51705. };
  51706. }
  51707. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51708. /** @hidden */
  51709. export var pbrFragmentExtraDeclaration: {
  51710. name: string;
  51711. shader: string;
  51712. };
  51713. }
  51714. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51715. /** @hidden */
  51716. export var pbrFragmentSamplersDeclaration: {
  51717. name: string;
  51718. shader: string;
  51719. };
  51720. }
  51721. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51722. /** @hidden */
  51723. export var pbrHelperFunctions: {
  51724. name: string;
  51725. shader: string;
  51726. };
  51727. }
  51728. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51729. /** @hidden */
  51730. export var harmonicsFunctions: {
  51731. name: string;
  51732. shader: string;
  51733. };
  51734. }
  51735. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51736. /** @hidden */
  51737. export var pbrDirectLightingSetupFunctions: {
  51738. name: string;
  51739. shader: string;
  51740. };
  51741. }
  51742. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51743. /** @hidden */
  51744. export var pbrDirectLightingFalloffFunctions: {
  51745. name: string;
  51746. shader: string;
  51747. };
  51748. }
  51749. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51750. /** @hidden */
  51751. export var pbrBRDFFunctions: {
  51752. name: string;
  51753. shader: string;
  51754. };
  51755. }
  51756. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51757. /** @hidden */
  51758. export var pbrDirectLightingFunctions: {
  51759. name: string;
  51760. shader: string;
  51761. };
  51762. }
  51763. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51764. /** @hidden */
  51765. export var pbrIBLFunctions: {
  51766. name: string;
  51767. shader: string;
  51768. };
  51769. }
  51770. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51771. /** @hidden */
  51772. export var pbrDebug: {
  51773. name: string;
  51774. shader: string;
  51775. };
  51776. }
  51777. declare module "babylonjs/Shaders/pbr.fragment" {
  51778. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51779. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51780. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51781. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51782. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51783. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51784. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51785. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51786. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51787. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51788. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51789. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51790. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51791. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51792. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51793. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51794. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51795. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51796. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51797. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51798. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51799. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51800. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51801. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51802. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51803. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51804. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51805. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51806. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51807. /** @hidden */
  51808. export var pbrPixelShader: {
  51809. name: string;
  51810. shader: string;
  51811. };
  51812. }
  51813. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51814. /** @hidden */
  51815. export var pbrVertexDeclaration: {
  51816. name: string;
  51817. shader: string;
  51818. };
  51819. }
  51820. declare module "babylonjs/Shaders/pbr.vertex" {
  51821. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51822. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51824. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51825. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51826. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51827. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51829. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51830. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51831. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51832. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51834. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51836. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51837. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51838. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51839. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51840. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51841. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51842. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51843. /** @hidden */
  51844. export var pbrVertexShader: {
  51845. name: string;
  51846. shader: string;
  51847. };
  51848. }
  51849. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51850. import { Nullable } from "babylonjs/types";
  51851. import { Scene } from "babylonjs/scene";
  51852. import { Matrix } from "babylonjs/Maths/math.vector";
  51853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51855. import { Mesh } from "babylonjs/Meshes/mesh";
  51856. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51857. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51858. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51859. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51860. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51861. import { Color3 } from "babylonjs/Maths/math.color";
  51862. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51863. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51864. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51865. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51867. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51868. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51869. import "babylonjs/Shaders/pbr.fragment";
  51870. import "babylonjs/Shaders/pbr.vertex";
  51871. /**
  51872. * Manages the defines for the PBR Material.
  51873. * @hidden
  51874. */
  51875. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51876. PBR: boolean;
  51877. MAINUV1: boolean;
  51878. MAINUV2: boolean;
  51879. UV1: boolean;
  51880. UV2: boolean;
  51881. ALBEDO: boolean;
  51882. ALBEDODIRECTUV: number;
  51883. VERTEXCOLOR: boolean;
  51884. AMBIENT: boolean;
  51885. AMBIENTDIRECTUV: number;
  51886. AMBIENTINGRAYSCALE: boolean;
  51887. OPACITY: boolean;
  51888. VERTEXALPHA: boolean;
  51889. OPACITYDIRECTUV: number;
  51890. OPACITYRGB: boolean;
  51891. ALPHATEST: boolean;
  51892. DEPTHPREPASS: boolean;
  51893. ALPHABLEND: boolean;
  51894. ALPHAFROMALBEDO: boolean;
  51895. ALPHATESTVALUE: string;
  51896. SPECULAROVERALPHA: boolean;
  51897. RADIANCEOVERALPHA: boolean;
  51898. ALPHAFRESNEL: boolean;
  51899. LINEARALPHAFRESNEL: boolean;
  51900. PREMULTIPLYALPHA: boolean;
  51901. EMISSIVE: boolean;
  51902. EMISSIVEDIRECTUV: number;
  51903. REFLECTIVITY: boolean;
  51904. REFLECTIVITYDIRECTUV: number;
  51905. SPECULARTERM: boolean;
  51906. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51907. MICROSURFACEAUTOMATIC: boolean;
  51908. LODBASEDMICROSFURACE: boolean;
  51909. MICROSURFACEMAP: boolean;
  51910. MICROSURFACEMAPDIRECTUV: number;
  51911. METALLICWORKFLOW: boolean;
  51912. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51913. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51914. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51915. AOSTOREINMETALMAPRED: boolean;
  51916. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51917. ENVIRONMENTBRDF: boolean;
  51918. ENVIRONMENTBRDF_RGBD: boolean;
  51919. NORMAL: boolean;
  51920. TANGENT: boolean;
  51921. BUMP: boolean;
  51922. BUMPDIRECTUV: number;
  51923. OBJECTSPACE_NORMALMAP: boolean;
  51924. PARALLAX: boolean;
  51925. PARALLAXOCCLUSION: boolean;
  51926. NORMALXYSCALE: boolean;
  51927. LIGHTMAP: boolean;
  51928. LIGHTMAPDIRECTUV: number;
  51929. USELIGHTMAPASSHADOWMAP: boolean;
  51930. GAMMALIGHTMAP: boolean;
  51931. RGBDLIGHTMAP: boolean;
  51932. REFLECTION: boolean;
  51933. REFLECTIONMAP_3D: boolean;
  51934. REFLECTIONMAP_SPHERICAL: boolean;
  51935. REFLECTIONMAP_PLANAR: boolean;
  51936. REFLECTIONMAP_CUBIC: boolean;
  51937. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51938. REFLECTIONMAP_PROJECTION: boolean;
  51939. REFLECTIONMAP_SKYBOX: boolean;
  51940. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51941. REFLECTIONMAP_EXPLICIT: boolean;
  51942. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51943. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51944. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51945. INVERTCUBICMAP: boolean;
  51946. USESPHERICALFROMREFLECTIONMAP: boolean;
  51947. USEIRRADIANCEMAP: boolean;
  51948. SPHERICAL_HARMONICS: boolean;
  51949. USESPHERICALINVERTEX: boolean;
  51950. REFLECTIONMAP_OPPOSITEZ: boolean;
  51951. LODINREFLECTIONALPHA: boolean;
  51952. GAMMAREFLECTION: boolean;
  51953. RGBDREFLECTION: boolean;
  51954. LINEARSPECULARREFLECTION: boolean;
  51955. RADIANCEOCCLUSION: boolean;
  51956. HORIZONOCCLUSION: boolean;
  51957. INSTANCES: boolean;
  51958. NUM_BONE_INFLUENCERS: number;
  51959. BonesPerMesh: number;
  51960. BONETEXTURE: boolean;
  51961. NONUNIFORMSCALING: boolean;
  51962. MORPHTARGETS: boolean;
  51963. MORPHTARGETS_NORMAL: boolean;
  51964. MORPHTARGETS_TANGENT: boolean;
  51965. MORPHTARGETS_UV: boolean;
  51966. NUM_MORPH_INFLUENCERS: number;
  51967. IMAGEPROCESSING: boolean;
  51968. VIGNETTE: boolean;
  51969. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51970. VIGNETTEBLENDMODEOPAQUE: boolean;
  51971. TONEMAPPING: boolean;
  51972. TONEMAPPING_ACES: boolean;
  51973. CONTRAST: boolean;
  51974. COLORCURVES: boolean;
  51975. COLORGRADING: boolean;
  51976. COLORGRADING3D: boolean;
  51977. SAMPLER3DGREENDEPTH: boolean;
  51978. SAMPLER3DBGRMAP: boolean;
  51979. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51980. EXPOSURE: boolean;
  51981. MULTIVIEW: boolean;
  51982. USEPHYSICALLIGHTFALLOFF: boolean;
  51983. USEGLTFLIGHTFALLOFF: boolean;
  51984. TWOSIDEDLIGHTING: boolean;
  51985. SHADOWFLOAT: boolean;
  51986. CLIPPLANE: boolean;
  51987. CLIPPLANE2: boolean;
  51988. CLIPPLANE3: boolean;
  51989. CLIPPLANE4: boolean;
  51990. POINTSIZE: boolean;
  51991. FOG: boolean;
  51992. LOGARITHMICDEPTH: boolean;
  51993. FORCENORMALFORWARD: boolean;
  51994. SPECULARAA: boolean;
  51995. CLEARCOAT: boolean;
  51996. CLEARCOAT_DEFAULTIOR: boolean;
  51997. CLEARCOAT_TEXTURE: boolean;
  51998. CLEARCOAT_TEXTUREDIRECTUV: number;
  51999. CLEARCOAT_BUMP: boolean;
  52000. CLEARCOAT_BUMPDIRECTUV: number;
  52001. CLEARCOAT_TINT: boolean;
  52002. CLEARCOAT_TINT_TEXTURE: boolean;
  52003. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52004. ANISOTROPIC: boolean;
  52005. ANISOTROPIC_TEXTURE: boolean;
  52006. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52007. BRDF_V_HEIGHT_CORRELATED: boolean;
  52008. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52009. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52010. SHEEN: boolean;
  52011. SHEEN_TEXTURE: boolean;
  52012. SHEEN_TEXTUREDIRECTUV: number;
  52013. SHEEN_LINKWITHALBEDO: boolean;
  52014. SUBSURFACE: boolean;
  52015. SS_REFRACTION: boolean;
  52016. SS_TRANSLUCENCY: boolean;
  52017. SS_SCATERRING: boolean;
  52018. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52019. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52020. SS_REFRACTIONMAP_3D: boolean;
  52021. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52022. SS_LODINREFRACTIONALPHA: boolean;
  52023. SS_GAMMAREFRACTION: boolean;
  52024. SS_RGBDREFRACTION: boolean;
  52025. SS_LINEARSPECULARREFRACTION: boolean;
  52026. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52027. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52028. UNLIT: boolean;
  52029. DEBUGMODE: number;
  52030. /**
  52031. * Initializes the PBR Material defines.
  52032. */
  52033. constructor();
  52034. /**
  52035. * Resets the PBR Material defines.
  52036. */
  52037. reset(): void;
  52038. }
  52039. /**
  52040. * The Physically based material base class of BJS.
  52041. *
  52042. * This offers the main features of a standard PBR material.
  52043. * For more information, please refer to the documentation :
  52044. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52045. */
  52046. export abstract class PBRBaseMaterial extends PushMaterial {
  52047. /**
  52048. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52049. */
  52050. static readonly PBRMATERIAL_OPAQUE: number;
  52051. /**
  52052. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52053. */
  52054. static readonly PBRMATERIAL_ALPHATEST: number;
  52055. /**
  52056. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52057. */
  52058. static readonly PBRMATERIAL_ALPHABLEND: number;
  52059. /**
  52060. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52061. * They are also discarded below the alpha cutoff threshold to improve performances.
  52062. */
  52063. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52064. /**
  52065. * Defines the default value of how much AO map is occluding the analytical lights
  52066. * (point spot...).
  52067. */
  52068. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52069. /**
  52070. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52071. */
  52072. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52073. /**
  52074. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52075. * to enhance interoperability with other engines.
  52076. */
  52077. static readonly LIGHTFALLOFF_GLTF: number;
  52078. /**
  52079. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52080. * to enhance interoperability with other materials.
  52081. */
  52082. static readonly LIGHTFALLOFF_STANDARD: number;
  52083. /**
  52084. * Intensity of the direct lights e.g. the four lights available in your scene.
  52085. * This impacts both the direct diffuse and specular highlights.
  52086. */
  52087. protected _directIntensity: number;
  52088. /**
  52089. * Intensity of the emissive part of the material.
  52090. * This helps controlling the emissive effect without modifying the emissive color.
  52091. */
  52092. protected _emissiveIntensity: number;
  52093. /**
  52094. * Intensity of the environment e.g. how much the environment will light the object
  52095. * either through harmonics for rough material or through the refelction for shiny ones.
  52096. */
  52097. protected _environmentIntensity: number;
  52098. /**
  52099. * This is a special control allowing the reduction of the specular highlights coming from the
  52100. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52101. */
  52102. protected _specularIntensity: number;
  52103. /**
  52104. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52105. */
  52106. private _lightingInfos;
  52107. /**
  52108. * Debug Control allowing disabling the bump map on this material.
  52109. */
  52110. protected _disableBumpMap: boolean;
  52111. /**
  52112. * AKA Diffuse Texture in standard nomenclature.
  52113. */
  52114. protected _albedoTexture: Nullable<BaseTexture>;
  52115. /**
  52116. * AKA Occlusion Texture in other nomenclature.
  52117. */
  52118. protected _ambientTexture: Nullable<BaseTexture>;
  52119. /**
  52120. * AKA Occlusion Texture Intensity in other nomenclature.
  52121. */
  52122. protected _ambientTextureStrength: number;
  52123. /**
  52124. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52125. * 1 means it completely occludes it
  52126. * 0 mean it has no impact
  52127. */
  52128. protected _ambientTextureImpactOnAnalyticalLights: number;
  52129. /**
  52130. * Stores the alpha values in a texture.
  52131. */
  52132. protected _opacityTexture: Nullable<BaseTexture>;
  52133. /**
  52134. * Stores the reflection values in a texture.
  52135. */
  52136. protected _reflectionTexture: Nullable<BaseTexture>;
  52137. /**
  52138. * Stores the emissive values in a texture.
  52139. */
  52140. protected _emissiveTexture: Nullable<BaseTexture>;
  52141. /**
  52142. * AKA Specular texture in other nomenclature.
  52143. */
  52144. protected _reflectivityTexture: Nullable<BaseTexture>;
  52145. /**
  52146. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52147. */
  52148. protected _metallicTexture: Nullable<BaseTexture>;
  52149. /**
  52150. * Specifies the metallic scalar of the metallic/roughness workflow.
  52151. * Can also be used to scale the metalness values of the metallic texture.
  52152. */
  52153. protected _metallic: Nullable<number>;
  52154. /**
  52155. * Specifies the roughness scalar of the metallic/roughness workflow.
  52156. * Can also be used to scale the roughness values of the metallic texture.
  52157. */
  52158. protected _roughness: Nullable<number>;
  52159. /**
  52160. * Specifies the an F0 factor to help configuring the material F0.
  52161. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52162. * to 0.5 the previously hard coded value stays the same.
  52163. * Can also be used to scale the F0 values of the metallic texture.
  52164. */
  52165. protected _metallicF0Factor: number;
  52166. /**
  52167. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52168. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52169. * your expectation as it multiplies with the texture data.
  52170. */
  52171. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52172. /**
  52173. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52174. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52175. */
  52176. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52177. /**
  52178. * Stores surface normal data used to displace a mesh in a texture.
  52179. */
  52180. protected _bumpTexture: Nullable<BaseTexture>;
  52181. /**
  52182. * Stores the pre-calculated light information of a mesh in a texture.
  52183. */
  52184. protected _lightmapTexture: Nullable<BaseTexture>;
  52185. /**
  52186. * The color of a material in ambient lighting.
  52187. */
  52188. protected _ambientColor: Color3;
  52189. /**
  52190. * AKA Diffuse Color in other nomenclature.
  52191. */
  52192. protected _albedoColor: Color3;
  52193. /**
  52194. * AKA Specular Color in other nomenclature.
  52195. */
  52196. protected _reflectivityColor: Color3;
  52197. /**
  52198. * The color applied when light is reflected from a material.
  52199. */
  52200. protected _reflectionColor: Color3;
  52201. /**
  52202. * The color applied when light is emitted from a material.
  52203. */
  52204. protected _emissiveColor: Color3;
  52205. /**
  52206. * AKA Glossiness in other nomenclature.
  52207. */
  52208. protected _microSurface: number;
  52209. /**
  52210. * Specifies that the material will use the light map as a show map.
  52211. */
  52212. protected _useLightmapAsShadowmap: boolean;
  52213. /**
  52214. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52215. * makes the reflect vector face the model (under horizon).
  52216. */
  52217. protected _useHorizonOcclusion: boolean;
  52218. /**
  52219. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52220. * too much the area relying on ambient texture to define their ambient occlusion.
  52221. */
  52222. protected _useRadianceOcclusion: boolean;
  52223. /**
  52224. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52225. */
  52226. protected _useAlphaFromAlbedoTexture: boolean;
  52227. /**
  52228. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52229. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52230. */
  52231. protected _useSpecularOverAlpha: boolean;
  52232. /**
  52233. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52234. */
  52235. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52236. /**
  52237. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52238. */
  52239. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52240. /**
  52241. * Specifies if the metallic texture contains the roughness information in its green channel.
  52242. */
  52243. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52244. /**
  52245. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52246. */
  52247. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52248. /**
  52249. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52250. */
  52251. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52252. /**
  52253. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52254. */
  52255. protected _useAmbientInGrayScale: boolean;
  52256. /**
  52257. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52258. * The material will try to infer what glossiness each pixel should be.
  52259. */
  52260. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52261. /**
  52262. * Defines the falloff type used in this material.
  52263. * It by default is Physical.
  52264. */
  52265. protected _lightFalloff: number;
  52266. /**
  52267. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52268. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52269. */
  52270. protected _useRadianceOverAlpha: boolean;
  52271. /**
  52272. * Allows using an object space normal map (instead of tangent space).
  52273. */
  52274. protected _useObjectSpaceNormalMap: boolean;
  52275. /**
  52276. * Allows using the bump map in parallax mode.
  52277. */
  52278. protected _useParallax: boolean;
  52279. /**
  52280. * Allows using the bump map in parallax occlusion mode.
  52281. */
  52282. protected _useParallaxOcclusion: boolean;
  52283. /**
  52284. * Controls the scale bias of the parallax mode.
  52285. */
  52286. protected _parallaxScaleBias: number;
  52287. /**
  52288. * If sets to true, disables all the lights affecting the material.
  52289. */
  52290. protected _disableLighting: boolean;
  52291. /**
  52292. * Number of Simultaneous lights allowed on the material.
  52293. */
  52294. protected _maxSimultaneousLights: number;
  52295. /**
  52296. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52297. */
  52298. protected _invertNormalMapX: boolean;
  52299. /**
  52300. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52301. */
  52302. protected _invertNormalMapY: boolean;
  52303. /**
  52304. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52305. */
  52306. protected _twoSidedLighting: boolean;
  52307. /**
  52308. * Defines the alpha limits in alpha test mode.
  52309. */
  52310. protected _alphaCutOff: number;
  52311. /**
  52312. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52313. */
  52314. protected _forceAlphaTest: boolean;
  52315. /**
  52316. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52317. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52318. */
  52319. protected _useAlphaFresnel: boolean;
  52320. /**
  52321. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52322. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52323. */
  52324. protected _useLinearAlphaFresnel: boolean;
  52325. /**
  52326. * The transparency mode of the material.
  52327. */
  52328. protected _transparencyMode: Nullable<number>;
  52329. /**
  52330. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52331. * from cos thetav and roughness:
  52332. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52333. */
  52334. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52335. /**
  52336. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52337. */
  52338. protected _forceIrradianceInFragment: boolean;
  52339. /**
  52340. * Force normal to face away from face.
  52341. */
  52342. protected _forceNormalForward: boolean;
  52343. /**
  52344. * Enables specular anti aliasing in the PBR shader.
  52345. * It will both interacts on the Geometry for analytical and IBL lighting.
  52346. * It also prefilter the roughness map based on the bump values.
  52347. */
  52348. protected _enableSpecularAntiAliasing: boolean;
  52349. /**
  52350. * Default configuration related to image processing available in the PBR Material.
  52351. */
  52352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52353. /**
  52354. * Keep track of the image processing observer to allow dispose and replace.
  52355. */
  52356. private _imageProcessingObserver;
  52357. /**
  52358. * Attaches a new image processing configuration to the PBR Material.
  52359. * @param configuration
  52360. */
  52361. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52362. /**
  52363. * Stores the available render targets.
  52364. */
  52365. private _renderTargets;
  52366. /**
  52367. * Sets the global ambient color for the material used in lighting calculations.
  52368. */
  52369. private _globalAmbientColor;
  52370. /**
  52371. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52372. */
  52373. private _useLogarithmicDepth;
  52374. /**
  52375. * If set to true, no lighting calculations will be applied.
  52376. */
  52377. private _unlit;
  52378. private _debugMode;
  52379. /**
  52380. * @hidden
  52381. * This is reserved for the inspector.
  52382. * Defines the material debug mode.
  52383. * It helps seeing only some components of the material while troubleshooting.
  52384. */
  52385. debugMode: number;
  52386. /**
  52387. * @hidden
  52388. * This is reserved for the inspector.
  52389. * Specify from where on screen the debug mode should start.
  52390. * The value goes from -1 (full screen) to 1 (not visible)
  52391. * It helps with side by side comparison against the final render
  52392. * This defaults to -1
  52393. */
  52394. private debugLimit;
  52395. /**
  52396. * @hidden
  52397. * This is reserved for the inspector.
  52398. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52399. * You can use the factor to better multiply the final value.
  52400. */
  52401. private debugFactor;
  52402. /**
  52403. * Defines the clear coat layer parameters for the material.
  52404. */
  52405. readonly clearCoat: PBRClearCoatConfiguration;
  52406. /**
  52407. * Defines the anisotropic parameters for the material.
  52408. */
  52409. readonly anisotropy: PBRAnisotropicConfiguration;
  52410. /**
  52411. * Defines the BRDF parameters for the material.
  52412. */
  52413. readonly brdf: PBRBRDFConfiguration;
  52414. /**
  52415. * Defines the Sheen parameters for the material.
  52416. */
  52417. readonly sheen: PBRSheenConfiguration;
  52418. /**
  52419. * Defines the SubSurface parameters for the material.
  52420. */
  52421. readonly subSurface: PBRSubSurfaceConfiguration;
  52422. /**
  52423. * Custom callback helping to override the default shader used in the material.
  52424. */
  52425. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52426. protected _rebuildInParallel: boolean;
  52427. /**
  52428. * Instantiates a new PBRMaterial instance.
  52429. *
  52430. * @param name The material name
  52431. * @param scene The scene the material will be use in.
  52432. */
  52433. constructor(name: string, scene: Scene);
  52434. /**
  52435. * Gets a boolean indicating that current material needs to register RTT
  52436. */
  52437. get hasRenderTargetTextures(): boolean;
  52438. /**
  52439. * Gets the name of the material class.
  52440. */
  52441. getClassName(): string;
  52442. /**
  52443. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52444. */
  52445. get useLogarithmicDepth(): boolean;
  52446. /**
  52447. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52448. */
  52449. set useLogarithmicDepth(value: boolean);
  52450. /**
  52451. * Gets the current transparency mode.
  52452. */
  52453. get transparencyMode(): Nullable<number>;
  52454. /**
  52455. * Sets the transparency mode of the material.
  52456. *
  52457. * | Value | Type | Description |
  52458. * | ----- | ----------------------------------- | ----------- |
  52459. * | 0 | OPAQUE | |
  52460. * | 1 | ALPHATEST | |
  52461. * | 2 | ALPHABLEND | |
  52462. * | 3 | ALPHATESTANDBLEND | |
  52463. *
  52464. */
  52465. set transparencyMode(value: Nullable<number>);
  52466. /**
  52467. * Returns true if alpha blending should be disabled.
  52468. */
  52469. private get _disableAlphaBlending();
  52470. /**
  52471. * Specifies whether or not this material should be rendered in alpha blend mode.
  52472. */
  52473. needAlphaBlending(): boolean;
  52474. /**
  52475. * Specifies if the mesh will require alpha blending.
  52476. * @param mesh - BJS mesh.
  52477. */
  52478. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52479. /**
  52480. * Specifies whether or not this material should be rendered in alpha test mode.
  52481. */
  52482. needAlphaTesting(): boolean;
  52483. /**
  52484. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52485. */
  52486. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52487. /**
  52488. * Gets the texture used for the alpha test.
  52489. */
  52490. getAlphaTestTexture(): Nullable<BaseTexture>;
  52491. /**
  52492. * Specifies that the submesh is ready to be used.
  52493. * @param mesh - BJS mesh.
  52494. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52495. * @param useInstances - Specifies that instances should be used.
  52496. * @returns - boolean indicating that the submesh is ready or not.
  52497. */
  52498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52499. /**
  52500. * Specifies if the material uses metallic roughness workflow.
  52501. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52502. */
  52503. isMetallicWorkflow(): boolean;
  52504. private _prepareEffect;
  52505. private _prepareDefines;
  52506. /**
  52507. * Force shader compilation
  52508. */
  52509. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52510. /**
  52511. * Initializes the uniform buffer layout for the shader.
  52512. */
  52513. buildUniformLayout(): void;
  52514. /**
  52515. * Unbinds the material from the mesh
  52516. */
  52517. unbind(): void;
  52518. /**
  52519. * Binds the submesh data.
  52520. * @param world - The world matrix.
  52521. * @param mesh - The BJS mesh.
  52522. * @param subMesh - A submesh of the BJS mesh.
  52523. */
  52524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52525. /**
  52526. * Returns the animatable textures.
  52527. * @returns - Array of animatable textures.
  52528. */
  52529. getAnimatables(): IAnimatable[];
  52530. /**
  52531. * Returns the texture used for reflections.
  52532. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52533. */
  52534. private _getReflectionTexture;
  52535. /**
  52536. * Returns an array of the actively used textures.
  52537. * @returns - Array of BaseTextures
  52538. */
  52539. getActiveTextures(): BaseTexture[];
  52540. /**
  52541. * Checks to see if a texture is used in the material.
  52542. * @param texture - Base texture to use.
  52543. * @returns - Boolean specifying if a texture is used in the material.
  52544. */
  52545. hasTexture(texture: BaseTexture): boolean;
  52546. /**
  52547. * Disposes the resources of the material.
  52548. * @param forceDisposeEffect - Forces the disposal of effects.
  52549. * @param forceDisposeTextures - Forces the disposal of all textures.
  52550. */
  52551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52552. }
  52553. }
  52554. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52555. import { Nullable } from "babylonjs/types";
  52556. import { Scene } from "babylonjs/scene";
  52557. import { Color3 } from "babylonjs/Maths/math.color";
  52558. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52559. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52561. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52562. /**
  52563. * The Physically based material of BJS.
  52564. *
  52565. * This offers the main features of a standard PBR material.
  52566. * For more information, please refer to the documentation :
  52567. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52568. */
  52569. export class PBRMaterial extends PBRBaseMaterial {
  52570. /**
  52571. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52572. */
  52573. static readonly PBRMATERIAL_OPAQUE: number;
  52574. /**
  52575. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52576. */
  52577. static readonly PBRMATERIAL_ALPHATEST: number;
  52578. /**
  52579. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52580. */
  52581. static readonly PBRMATERIAL_ALPHABLEND: number;
  52582. /**
  52583. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52584. * They are also discarded below the alpha cutoff threshold to improve performances.
  52585. */
  52586. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52587. /**
  52588. * Defines the default value of how much AO map is occluding the analytical lights
  52589. * (point spot...).
  52590. */
  52591. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52592. /**
  52593. * Intensity of the direct lights e.g. the four lights available in your scene.
  52594. * This impacts both the direct diffuse and specular highlights.
  52595. */
  52596. directIntensity: number;
  52597. /**
  52598. * Intensity of the emissive part of the material.
  52599. * This helps controlling the emissive effect without modifying the emissive color.
  52600. */
  52601. emissiveIntensity: number;
  52602. /**
  52603. * Intensity of the environment e.g. how much the environment will light the object
  52604. * either through harmonics for rough material or through the refelction for shiny ones.
  52605. */
  52606. environmentIntensity: number;
  52607. /**
  52608. * This is a special control allowing the reduction of the specular highlights coming from the
  52609. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52610. */
  52611. specularIntensity: number;
  52612. /**
  52613. * Debug Control allowing disabling the bump map on this material.
  52614. */
  52615. disableBumpMap: boolean;
  52616. /**
  52617. * AKA Diffuse Texture in standard nomenclature.
  52618. */
  52619. albedoTexture: BaseTexture;
  52620. /**
  52621. * AKA Occlusion Texture in other nomenclature.
  52622. */
  52623. ambientTexture: BaseTexture;
  52624. /**
  52625. * AKA Occlusion Texture Intensity in other nomenclature.
  52626. */
  52627. ambientTextureStrength: number;
  52628. /**
  52629. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52630. * 1 means it completely occludes it
  52631. * 0 mean it has no impact
  52632. */
  52633. ambientTextureImpactOnAnalyticalLights: number;
  52634. /**
  52635. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52636. */
  52637. opacityTexture: BaseTexture;
  52638. /**
  52639. * Stores the reflection values in a texture.
  52640. */
  52641. reflectionTexture: Nullable<BaseTexture>;
  52642. /**
  52643. * Stores the emissive values in a texture.
  52644. */
  52645. emissiveTexture: BaseTexture;
  52646. /**
  52647. * AKA Specular texture in other nomenclature.
  52648. */
  52649. reflectivityTexture: BaseTexture;
  52650. /**
  52651. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52652. */
  52653. metallicTexture: BaseTexture;
  52654. /**
  52655. * Specifies the metallic scalar of the metallic/roughness workflow.
  52656. * Can also be used to scale the metalness values of the metallic texture.
  52657. */
  52658. metallic: Nullable<number>;
  52659. /**
  52660. * Specifies the roughness scalar of the metallic/roughness workflow.
  52661. * Can also be used to scale the roughness values of the metallic texture.
  52662. */
  52663. roughness: Nullable<number>;
  52664. /**
  52665. * Specifies the an F0 factor to help configuring the material F0.
  52666. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52667. * to 0.5 the previously hard coded value stays the same.
  52668. * Can also be used to scale the F0 values of the metallic texture.
  52669. */
  52670. metallicF0Factor: number;
  52671. /**
  52672. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52673. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52674. * your expectation as it multiplies with the texture data.
  52675. */
  52676. useMetallicF0FactorFromMetallicTexture: boolean;
  52677. /**
  52678. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52679. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52680. */
  52681. microSurfaceTexture: BaseTexture;
  52682. /**
  52683. * Stores surface normal data used to displace a mesh in a texture.
  52684. */
  52685. bumpTexture: BaseTexture;
  52686. /**
  52687. * Stores the pre-calculated light information of a mesh in a texture.
  52688. */
  52689. lightmapTexture: BaseTexture;
  52690. /**
  52691. * Stores the refracted light information in a texture.
  52692. */
  52693. get refractionTexture(): Nullable<BaseTexture>;
  52694. set refractionTexture(value: Nullable<BaseTexture>);
  52695. /**
  52696. * The color of a material in ambient lighting.
  52697. */
  52698. ambientColor: Color3;
  52699. /**
  52700. * AKA Diffuse Color in other nomenclature.
  52701. */
  52702. albedoColor: Color3;
  52703. /**
  52704. * AKA Specular Color in other nomenclature.
  52705. */
  52706. reflectivityColor: Color3;
  52707. /**
  52708. * The color reflected from the material.
  52709. */
  52710. reflectionColor: Color3;
  52711. /**
  52712. * The color emitted from the material.
  52713. */
  52714. emissiveColor: Color3;
  52715. /**
  52716. * AKA Glossiness in other nomenclature.
  52717. */
  52718. microSurface: number;
  52719. /**
  52720. * source material index of refraction (IOR)' / 'destination material IOR.
  52721. */
  52722. get indexOfRefraction(): number;
  52723. set indexOfRefraction(value: number);
  52724. /**
  52725. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52726. */
  52727. get invertRefractionY(): boolean;
  52728. set invertRefractionY(value: boolean);
  52729. /**
  52730. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52731. * Materials half opaque for instance using refraction could benefit from this control.
  52732. */
  52733. get linkRefractionWithTransparency(): boolean;
  52734. set linkRefractionWithTransparency(value: boolean);
  52735. /**
  52736. * If true, the light map contains occlusion information instead of lighting info.
  52737. */
  52738. useLightmapAsShadowmap: boolean;
  52739. /**
  52740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52741. */
  52742. useAlphaFromAlbedoTexture: boolean;
  52743. /**
  52744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52745. */
  52746. forceAlphaTest: boolean;
  52747. /**
  52748. * Defines the alpha limits in alpha test mode.
  52749. */
  52750. alphaCutOff: number;
  52751. /**
  52752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52754. */
  52755. useSpecularOverAlpha: boolean;
  52756. /**
  52757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52758. */
  52759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52760. /**
  52761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52762. */
  52763. useRoughnessFromMetallicTextureAlpha: boolean;
  52764. /**
  52765. * Specifies if the metallic texture contains the roughness information in its green channel.
  52766. */
  52767. useRoughnessFromMetallicTextureGreen: boolean;
  52768. /**
  52769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52770. */
  52771. useMetallnessFromMetallicTextureBlue: boolean;
  52772. /**
  52773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52774. */
  52775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52776. /**
  52777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52778. */
  52779. useAmbientInGrayScale: boolean;
  52780. /**
  52781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52782. * The material will try to infer what glossiness each pixel should be.
  52783. */
  52784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52785. /**
  52786. * BJS is using an harcoded light falloff based on a manually sets up range.
  52787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52789. */
  52790. get usePhysicalLightFalloff(): boolean;
  52791. /**
  52792. * BJS is using an harcoded light falloff based on a manually sets up range.
  52793. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52794. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52795. */
  52796. set usePhysicalLightFalloff(value: boolean);
  52797. /**
  52798. * In order to support the falloff compatibility with gltf, a special mode has been added
  52799. * to reproduce the gltf light falloff.
  52800. */
  52801. get useGLTFLightFalloff(): boolean;
  52802. /**
  52803. * In order to support the falloff compatibility with gltf, a special mode has been added
  52804. * to reproduce the gltf light falloff.
  52805. */
  52806. set useGLTFLightFalloff(value: boolean);
  52807. /**
  52808. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52809. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52810. */
  52811. useRadianceOverAlpha: boolean;
  52812. /**
  52813. * Allows using an object space normal map (instead of tangent space).
  52814. */
  52815. useObjectSpaceNormalMap: boolean;
  52816. /**
  52817. * Allows using the bump map in parallax mode.
  52818. */
  52819. useParallax: boolean;
  52820. /**
  52821. * Allows using the bump map in parallax occlusion mode.
  52822. */
  52823. useParallaxOcclusion: boolean;
  52824. /**
  52825. * Controls the scale bias of the parallax mode.
  52826. */
  52827. parallaxScaleBias: number;
  52828. /**
  52829. * If sets to true, disables all the lights affecting the material.
  52830. */
  52831. disableLighting: boolean;
  52832. /**
  52833. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52834. */
  52835. forceIrradianceInFragment: boolean;
  52836. /**
  52837. * Number of Simultaneous lights allowed on the material.
  52838. */
  52839. maxSimultaneousLights: number;
  52840. /**
  52841. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52842. */
  52843. invertNormalMapX: boolean;
  52844. /**
  52845. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52846. */
  52847. invertNormalMapY: boolean;
  52848. /**
  52849. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52850. */
  52851. twoSidedLighting: boolean;
  52852. /**
  52853. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52854. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52855. */
  52856. useAlphaFresnel: boolean;
  52857. /**
  52858. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52859. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52860. */
  52861. useLinearAlphaFresnel: boolean;
  52862. /**
  52863. * Let user defines the brdf lookup texture used for IBL.
  52864. * A default 8bit version is embedded but you could point at :
  52865. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52866. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52867. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52868. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52869. */
  52870. environmentBRDFTexture: Nullable<BaseTexture>;
  52871. /**
  52872. * Force normal to face away from face.
  52873. */
  52874. forceNormalForward: boolean;
  52875. /**
  52876. * Enables specular anti aliasing in the PBR shader.
  52877. * It will both interacts on the Geometry for analytical and IBL lighting.
  52878. * It also prefilter the roughness map based on the bump values.
  52879. */
  52880. enableSpecularAntiAliasing: boolean;
  52881. /**
  52882. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52883. * makes the reflect vector face the model (under horizon).
  52884. */
  52885. useHorizonOcclusion: boolean;
  52886. /**
  52887. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52888. * too much the area relying on ambient texture to define their ambient occlusion.
  52889. */
  52890. useRadianceOcclusion: boolean;
  52891. /**
  52892. * If set to true, no lighting calculations will be applied.
  52893. */
  52894. unlit: boolean;
  52895. /**
  52896. * Gets the image processing configuration used either in this material.
  52897. */
  52898. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52899. /**
  52900. * Sets the Default image processing configuration used either in the this material.
  52901. *
  52902. * If sets to null, the scene one is in use.
  52903. */
  52904. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52905. /**
  52906. * Gets wether the color curves effect is enabled.
  52907. */
  52908. get cameraColorCurvesEnabled(): boolean;
  52909. /**
  52910. * Sets wether the color curves effect is enabled.
  52911. */
  52912. set cameraColorCurvesEnabled(value: boolean);
  52913. /**
  52914. * Gets wether the color grading effect is enabled.
  52915. */
  52916. get cameraColorGradingEnabled(): boolean;
  52917. /**
  52918. * Gets wether the color grading effect is enabled.
  52919. */
  52920. set cameraColorGradingEnabled(value: boolean);
  52921. /**
  52922. * Gets wether tonemapping is enabled or not.
  52923. */
  52924. get cameraToneMappingEnabled(): boolean;
  52925. /**
  52926. * Sets wether tonemapping is enabled or not
  52927. */
  52928. set cameraToneMappingEnabled(value: boolean);
  52929. /**
  52930. * The camera exposure used on this material.
  52931. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52932. * This corresponds to a photographic exposure.
  52933. */
  52934. get cameraExposure(): number;
  52935. /**
  52936. * The camera exposure used on this material.
  52937. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52938. * This corresponds to a photographic exposure.
  52939. */
  52940. set cameraExposure(value: number);
  52941. /**
  52942. * Gets The camera contrast used on this material.
  52943. */
  52944. get cameraContrast(): number;
  52945. /**
  52946. * Sets The camera contrast used on this material.
  52947. */
  52948. set cameraContrast(value: number);
  52949. /**
  52950. * Gets the Color Grading 2D Lookup Texture.
  52951. */
  52952. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52953. /**
  52954. * Sets the Color Grading 2D Lookup Texture.
  52955. */
  52956. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52957. /**
  52958. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52959. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52960. * 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;
  52961. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52962. */
  52963. get cameraColorCurves(): Nullable<ColorCurves>;
  52964. /**
  52965. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52966. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52967. * 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;
  52968. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52969. */
  52970. set cameraColorCurves(value: Nullable<ColorCurves>);
  52971. /**
  52972. * Instantiates a new PBRMaterial instance.
  52973. *
  52974. * @param name The material name
  52975. * @param scene The scene the material will be use in.
  52976. */
  52977. constructor(name: string, scene: Scene);
  52978. /**
  52979. * Returns the name of this material class.
  52980. */
  52981. getClassName(): string;
  52982. /**
  52983. * Makes a duplicate of the current material.
  52984. * @param name - name to use for the new material.
  52985. */
  52986. clone(name: string): PBRMaterial;
  52987. /**
  52988. * Serializes this PBR Material.
  52989. * @returns - An object with the serialized material.
  52990. */
  52991. serialize(): any;
  52992. /**
  52993. * Parses a PBR Material from a serialized object.
  52994. * @param source - Serialized object.
  52995. * @param scene - BJS scene instance.
  52996. * @param rootUrl - url for the scene object
  52997. * @returns - PBRMaterial
  52998. */
  52999. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53000. }
  53001. }
  53002. declare module "babylonjs/Misc/dds" {
  53003. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53005. import { Nullable } from "babylonjs/types";
  53006. import { Scene } from "babylonjs/scene";
  53007. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53008. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53009. /**
  53010. * Direct draw surface info
  53011. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53012. */
  53013. export interface DDSInfo {
  53014. /**
  53015. * Width of the texture
  53016. */
  53017. width: number;
  53018. /**
  53019. * Width of the texture
  53020. */
  53021. height: number;
  53022. /**
  53023. * Number of Mipmaps for the texture
  53024. * @see https://en.wikipedia.org/wiki/Mipmap
  53025. */
  53026. mipmapCount: number;
  53027. /**
  53028. * If the textures format is a known fourCC format
  53029. * @see https://www.fourcc.org/
  53030. */
  53031. isFourCC: boolean;
  53032. /**
  53033. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53034. */
  53035. isRGB: boolean;
  53036. /**
  53037. * If the texture is a lumincance format
  53038. */
  53039. isLuminance: boolean;
  53040. /**
  53041. * If this is a cube texture
  53042. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53043. */
  53044. isCube: boolean;
  53045. /**
  53046. * If the texture is a compressed format eg. FOURCC_DXT1
  53047. */
  53048. isCompressed: boolean;
  53049. /**
  53050. * The dxgiFormat of the texture
  53051. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53052. */
  53053. dxgiFormat: number;
  53054. /**
  53055. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53056. */
  53057. textureType: number;
  53058. /**
  53059. * Sphericle polynomial created for the dds texture
  53060. */
  53061. sphericalPolynomial?: SphericalPolynomial;
  53062. }
  53063. /**
  53064. * Class used to provide DDS decompression tools
  53065. */
  53066. export class DDSTools {
  53067. /**
  53068. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53069. */
  53070. static StoreLODInAlphaChannel: boolean;
  53071. /**
  53072. * Gets DDS information from an array buffer
  53073. * @param arrayBuffer defines the array buffer to read data from
  53074. * @returns the DDS information
  53075. */
  53076. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53077. private static _FloatView;
  53078. private static _Int32View;
  53079. private static _ToHalfFloat;
  53080. private static _FromHalfFloat;
  53081. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53082. private static _GetHalfFloatRGBAArrayBuffer;
  53083. private static _GetFloatRGBAArrayBuffer;
  53084. private static _GetFloatAsUIntRGBAArrayBuffer;
  53085. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53086. private static _GetRGBAArrayBuffer;
  53087. private static _ExtractLongWordOrder;
  53088. private static _GetRGBArrayBuffer;
  53089. private static _GetLuminanceArrayBuffer;
  53090. /**
  53091. * Uploads DDS Levels to a Babylon Texture
  53092. * @hidden
  53093. */
  53094. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53095. }
  53096. module "babylonjs/Engines/thinEngine" {
  53097. interface ThinEngine {
  53098. /**
  53099. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53100. * @param rootUrl defines the url where the file to load is located
  53101. * @param scene defines the current scene
  53102. * @param lodScale defines scale to apply to the mip map selection
  53103. * @param lodOffset defines offset to apply to the mip map selection
  53104. * @param onLoad defines an optional callback raised when the texture is loaded
  53105. * @param onError defines an optional callback raised if there is an issue to load the texture
  53106. * @param format defines the format of the data
  53107. * @param forcedExtension defines the extension to use to pick the right loader
  53108. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53109. * @returns the cube texture as an InternalTexture
  53110. */
  53111. 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;
  53112. }
  53113. }
  53114. }
  53115. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53116. import { Nullable } from "babylonjs/types";
  53117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53118. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53119. /**
  53120. * Implementation of the DDS Texture Loader.
  53121. * @hidden
  53122. */
  53123. export class _DDSTextureLoader implements IInternalTextureLoader {
  53124. /**
  53125. * Defines wether the loader supports cascade loading the different faces.
  53126. */
  53127. readonly supportCascades: boolean;
  53128. /**
  53129. * This returns if the loader support the current file information.
  53130. * @param extension defines the file extension of the file being loaded
  53131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53132. * @param fallback defines the fallback internal texture if any
  53133. * @param isBase64 defines whether the texture is encoded as a base64
  53134. * @param isBuffer defines whether the texture data are stored as a buffer
  53135. * @returns true if the loader can load the specified file
  53136. */
  53137. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53138. /**
  53139. * Transform the url before loading if required.
  53140. * @param rootUrl the url of the texture
  53141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53142. * @returns the transformed texture
  53143. */
  53144. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53145. /**
  53146. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53147. * @param rootUrl the url of the texture
  53148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53149. * @returns the fallback texture
  53150. */
  53151. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53152. /**
  53153. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53154. * @param data contains the texture data
  53155. * @param texture defines the BabylonJS internal texture
  53156. * @param createPolynomials will be true if polynomials have been requested
  53157. * @param onLoad defines the callback to trigger once the texture is ready
  53158. * @param onError defines the callback to trigger in case of error
  53159. */
  53160. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53161. /**
  53162. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53163. * @param data contains the texture data
  53164. * @param texture defines the BabylonJS internal texture
  53165. * @param callback defines the method to call once ready to upload
  53166. */
  53167. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53168. }
  53169. }
  53170. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53171. import { Nullable } from "babylonjs/types";
  53172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53173. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53174. /**
  53175. * Implementation of the ENV Texture Loader.
  53176. * @hidden
  53177. */
  53178. export class _ENVTextureLoader implements IInternalTextureLoader {
  53179. /**
  53180. * Defines wether the loader supports cascade loading the different faces.
  53181. */
  53182. readonly supportCascades: boolean;
  53183. /**
  53184. * This returns if the loader support the current file information.
  53185. * @param extension defines the file extension of the file being loaded
  53186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53187. * @param fallback defines the fallback internal texture if any
  53188. * @param isBase64 defines whether the texture is encoded as a base64
  53189. * @param isBuffer defines whether the texture data are stored as a buffer
  53190. * @returns true if the loader can load the specified file
  53191. */
  53192. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53193. /**
  53194. * Transform the url before loading if required.
  53195. * @param rootUrl the url of the texture
  53196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53197. * @returns the transformed texture
  53198. */
  53199. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53200. /**
  53201. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53202. * @param rootUrl the url of the texture
  53203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53204. * @returns the fallback texture
  53205. */
  53206. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53207. /**
  53208. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53209. * @param data contains the texture data
  53210. * @param texture defines the BabylonJS internal texture
  53211. * @param createPolynomials will be true if polynomials have been requested
  53212. * @param onLoad defines the callback to trigger once the texture is ready
  53213. * @param onError defines the callback to trigger in case of error
  53214. */
  53215. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53216. /**
  53217. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53218. * @param data contains the texture data
  53219. * @param texture defines the BabylonJS internal texture
  53220. * @param callback defines the method to call once ready to upload
  53221. */
  53222. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53223. }
  53224. }
  53225. declare module "babylonjs/Misc/khronosTextureContainer" {
  53226. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53227. /**
  53228. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53229. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53230. */
  53231. export class KhronosTextureContainer {
  53232. /** contents of the KTX container file */
  53233. arrayBuffer: any;
  53234. private static HEADER_LEN;
  53235. private static COMPRESSED_2D;
  53236. private static COMPRESSED_3D;
  53237. private static TEX_2D;
  53238. private static TEX_3D;
  53239. /**
  53240. * Gets the openGL type
  53241. */
  53242. glType: number;
  53243. /**
  53244. * Gets the openGL type size
  53245. */
  53246. glTypeSize: number;
  53247. /**
  53248. * Gets the openGL format
  53249. */
  53250. glFormat: number;
  53251. /**
  53252. * Gets the openGL internal format
  53253. */
  53254. glInternalFormat: number;
  53255. /**
  53256. * Gets the base internal format
  53257. */
  53258. glBaseInternalFormat: number;
  53259. /**
  53260. * Gets image width in pixel
  53261. */
  53262. pixelWidth: number;
  53263. /**
  53264. * Gets image height in pixel
  53265. */
  53266. pixelHeight: number;
  53267. /**
  53268. * Gets image depth in pixels
  53269. */
  53270. pixelDepth: number;
  53271. /**
  53272. * Gets the number of array elements
  53273. */
  53274. numberOfArrayElements: number;
  53275. /**
  53276. * Gets the number of faces
  53277. */
  53278. numberOfFaces: number;
  53279. /**
  53280. * Gets the number of mipmap levels
  53281. */
  53282. numberOfMipmapLevels: number;
  53283. /**
  53284. * Gets the bytes of key value data
  53285. */
  53286. bytesOfKeyValueData: number;
  53287. /**
  53288. * Gets the load type
  53289. */
  53290. loadType: number;
  53291. /**
  53292. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53293. */
  53294. isInvalid: boolean;
  53295. /**
  53296. * Creates a new KhronosTextureContainer
  53297. * @param arrayBuffer contents of the KTX container file
  53298. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53299. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53300. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53301. */
  53302. constructor(
  53303. /** contents of the KTX container file */
  53304. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53305. /**
  53306. * Uploads KTX content to a Babylon Texture.
  53307. * It is assumed that the texture has already been created & is currently bound
  53308. * @hidden
  53309. */
  53310. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53311. private _upload2DCompressedLevels;
  53312. }
  53313. }
  53314. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53315. import { Nullable } from "babylonjs/types";
  53316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53317. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53318. /**
  53319. * Implementation of the KTX Texture Loader.
  53320. * @hidden
  53321. */
  53322. export class _KTXTextureLoader implements IInternalTextureLoader {
  53323. /**
  53324. * Defines wether the loader supports cascade loading the different faces.
  53325. */
  53326. readonly supportCascades: boolean;
  53327. /**
  53328. * This returns if the loader support the current file information.
  53329. * @param extension defines the file extension of the file being loaded
  53330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53331. * @param fallback defines the fallback internal texture if any
  53332. * @param isBase64 defines whether the texture is encoded as a base64
  53333. * @param isBuffer defines whether the texture data are stored as a buffer
  53334. * @returns true if the loader can load the specified file
  53335. */
  53336. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53337. /**
  53338. * Transform the url before loading if required.
  53339. * @param rootUrl the url of the texture
  53340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53341. * @returns the transformed texture
  53342. */
  53343. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53344. /**
  53345. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53346. * @param rootUrl the url of the texture
  53347. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53348. * @returns the fallback texture
  53349. */
  53350. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53351. /**
  53352. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53353. * @param data contains the texture data
  53354. * @param texture defines the BabylonJS internal texture
  53355. * @param createPolynomials will be true if polynomials have been requested
  53356. * @param onLoad defines the callback to trigger once the texture is ready
  53357. * @param onError defines the callback to trigger in case of error
  53358. */
  53359. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53360. /**
  53361. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53362. * @param data contains the texture data
  53363. * @param texture defines the BabylonJS internal texture
  53364. * @param callback defines the method to call once ready to upload
  53365. */
  53366. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53367. }
  53368. }
  53369. declare module "babylonjs/Helpers/sceneHelpers" {
  53370. import { Nullable } from "babylonjs/types";
  53371. import { Mesh } from "babylonjs/Meshes/mesh";
  53372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53373. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53374. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53375. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53376. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53377. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53378. import "babylonjs/Meshes/Builders/boxBuilder";
  53379. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53380. /** @hidden */
  53381. export var _forceSceneHelpersToBundle: boolean;
  53382. module "babylonjs/scene" {
  53383. interface Scene {
  53384. /**
  53385. * Creates a default light for the scene.
  53386. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53387. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53388. */
  53389. createDefaultLight(replace?: boolean): void;
  53390. /**
  53391. * Creates a default camera for the scene.
  53392. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53393. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53394. * @param replace has default false, when true replaces the active camera in the scene
  53395. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53396. */
  53397. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53398. /**
  53399. * Creates a default camera and a default light.
  53400. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53401. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53402. * @param replace has the default false, when true replaces the active camera/light in the scene
  53403. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53404. */
  53405. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53406. /**
  53407. * Creates a new sky box
  53408. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53409. * @param environmentTexture defines the texture to use as environment texture
  53410. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53411. * @param scale defines the overall scale of the skybox
  53412. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53413. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53414. * @returns a new mesh holding the sky box
  53415. */
  53416. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53417. /**
  53418. * Creates a new environment
  53419. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53420. * @param options defines the options you can use to configure the environment
  53421. * @returns the new EnvironmentHelper
  53422. */
  53423. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53424. /**
  53425. * Creates a new VREXperienceHelper
  53426. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53427. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53428. * @returns a new VREXperienceHelper
  53429. */
  53430. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53431. /**
  53432. * Creates a new WebXRDefaultExperience
  53433. * @see http://doc.babylonjs.com/how_to/webxr
  53434. * @param options experience options
  53435. * @returns a promise for a new WebXRDefaultExperience
  53436. */
  53437. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53438. }
  53439. }
  53440. }
  53441. declare module "babylonjs/Helpers/videoDome" {
  53442. import { Scene } from "babylonjs/scene";
  53443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53444. import { Mesh } from "babylonjs/Meshes/mesh";
  53445. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53446. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53447. import "babylonjs/Meshes/Builders/sphereBuilder";
  53448. /**
  53449. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53450. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53451. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53452. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53453. */
  53454. export class VideoDome extends TransformNode {
  53455. /**
  53456. * Define the video source as a Monoscopic panoramic 360 video.
  53457. */
  53458. static readonly MODE_MONOSCOPIC: number;
  53459. /**
  53460. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53461. */
  53462. static readonly MODE_TOPBOTTOM: number;
  53463. /**
  53464. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53465. */
  53466. static readonly MODE_SIDEBYSIDE: number;
  53467. private _halfDome;
  53468. private _useDirectMapping;
  53469. /**
  53470. * The video texture being displayed on the sphere
  53471. */
  53472. protected _videoTexture: VideoTexture;
  53473. /**
  53474. * Gets the video texture being displayed on the sphere
  53475. */
  53476. get videoTexture(): VideoTexture;
  53477. /**
  53478. * The skybox material
  53479. */
  53480. protected _material: BackgroundMaterial;
  53481. /**
  53482. * The surface used for the skybox
  53483. */
  53484. protected _mesh: Mesh;
  53485. /**
  53486. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53487. */
  53488. private _halfDomeMask;
  53489. /**
  53490. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53491. * Also see the options.resolution property.
  53492. */
  53493. get fovMultiplier(): number;
  53494. set fovMultiplier(value: number);
  53495. private _videoMode;
  53496. /**
  53497. * Gets or set the current video mode for the video. It can be:
  53498. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53499. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53500. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53501. */
  53502. get videoMode(): number;
  53503. set videoMode(value: number);
  53504. /**
  53505. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53506. *
  53507. */
  53508. get halfDome(): boolean;
  53509. /**
  53510. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53511. */
  53512. set halfDome(enabled: boolean);
  53513. /**
  53514. * Oberserver used in Stereoscopic VR Mode.
  53515. */
  53516. private _onBeforeCameraRenderObserver;
  53517. /**
  53518. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53519. * @param name Element's name, child elements will append suffixes for their own names.
  53520. * @param urlsOrVideo defines the url(s) or the video element to use
  53521. * @param options An object containing optional or exposed sub element properties
  53522. */
  53523. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53524. resolution?: number;
  53525. clickToPlay?: boolean;
  53526. autoPlay?: boolean;
  53527. loop?: boolean;
  53528. size?: number;
  53529. poster?: string;
  53530. faceForward?: boolean;
  53531. useDirectMapping?: boolean;
  53532. halfDomeMode?: boolean;
  53533. }, scene: Scene);
  53534. private _changeVideoMode;
  53535. /**
  53536. * Releases resources associated with this node.
  53537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53539. */
  53540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53541. }
  53542. }
  53543. declare module "babylonjs/Helpers/index" {
  53544. export * from "babylonjs/Helpers/environmentHelper";
  53545. export * from "babylonjs/Helpers/photoDome";
  53546. export * from "babylonjs/Helpers/sceneHelpers";
  53547. export * from "babylonjs/Helpers/videoDome";
  53548. }
  53549. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53550. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53551. import { IDisposable } from "babylonjs/scene";
  53552. import { Engine } from "babylonjs/Engines/engine";
  53553. /**
  53554. * This class can be used to get instrumentation data from a Babylon engine
  53555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53556. */
  53557. export class EngineInstrumentation implements IDisposable {
  53558. /**
  53559. * Define the instrumented engine.
  53560. */
  53561. engine: Engine;
  53562. private _captureGPUFrameTime;
  53563. private _gpuFrameTimeToken;
  53564. private _gpuFrameTime;
  53565. private _captureShaderCompilationTime;
  53566. private _shaderCompilationTime;
  53567. private _onBeginFrameObserver;
  53568. private _onEndFrameObserver;
  53569. private _onBeforeShaderCompilationObserver;
  53570. private _onAfterShaderCompilationObserver;
  53571. /**
  53572. * Gets the perf counter used for GPU frame time
  53573. */
  53574. get gpuFrameTimeCounter(): PerfCounter;
  53575. /**
  53576. * Gets the GPU frame time capture status
  53577. */
  53578. get captureGPUFrameTime(): boolean;
  53579. /**
  53580. * Enable or disable the GPU frame time capture
  53581. */
  53582. set captureGPUFrameTime(value: boolean);
  53583. /**
  53584. * Gets the perf counter used for shader compilation time
  53585. */
  53586. get shaderCompilationTimeCounter(): PerfCounter;
  53587. /**
  53588. * Gets the shader compilation time capture status
  53589. */
  53590. get captureShaderCompilationTime(): boolean;
  53591. /**
  53592. * Enable or disable the shader compilation time capture
  53593. */
  53594. set captureShaderCompilationTime(value: boolean);
  53595. /**
  53596. * Instantiates a new engine instrumentation.
  53597. * This class can be used to get instrumentation data from a Babylon engine
  53598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53599. * @param engine Defines the engine to instrument
  53600. */
  53601. constructor(
  53602. /**
  53603. * Define the instrumented engine.
  53604. */
  53605. engine: Engine);
  53606. /**
  53607. * Dispose and release associated resources.
  53608. */
  53609. dispose(): void;
  53610. }
  53611. }
  53612. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53613. import { Scene, IDisposable } from "babylonjs/scene";
  53614. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53615. /**
  53616. * This class can be used to get instrumentation data from a Babylon engine
  53617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53618. */
  53619. export class SceneInstrumentation implements IDisposable {
  53620. /**
  53621. * Defines the scene to instrument
  53622. */
  53623. scene: Scene;
  53624. private _captureActiveMeshesEvaluationTime;
  53625. private _activeMeshesEvaluationTime;
  53626. private _captureRenderTargetsRenderTime;
  53627. private _renderTargetsRenderTime;
  53628. private _captureFrameTime;
  53629. private _frameTime;
  53630. private _captureRenderTime;
  53631. private _renderTime;
  53632. private _captureInterFrameTime;
  53633. private _interFrameTime;
  53634. private _captureParticlesRenderTime;
  53635. private _particlesRenderTime;
  53636. private _captureSpritesRenderTime;
  53637. private _spritesRenderTime;
  53638. private _capturePhysicsTime;
  53639. private _physicsTime;
  53640. private _captureAnimationsTime;
  53641. private _animationsTime;
  53642. private _captureCameraRenderTime;
  53643. private _cameraRenderTime;
  53644. private _onBeforeActiveMeshesEvaluationObserver;
  53645. private _onAfterActiveMeshesEvaluationObserver;
  53646. private _onBeforeRenderTargetsRenderObserver;
  53647. private _onAfterRenderTargetsRenderObserver;
  53648. private _onAfterRenderObserver;
  53649. private _onBeforeDrawPhaseObserver;
  53650. private _onAfterDrawPhaseObserver;
  53651. private _onBeforeAnimationsObserver;
  53652. private _onBeforeParticlesRenderingObserver;
  53653. private _onAfterParticlesRenderingObserver;
  53654. private _onBeforeSpritesRenderingObserver;
  53655. private _onAfterSpritesRenderingObserver;
  53656. private _onBeforePhysicsObserver;
  53657. private _onAfterPhysicsObserver;
  53658. private _onAfterAnimationsObserver;
  53659. private _onBeforeCameraRenderObserver;
  53660. private _onAfterCameraRenderObserver;
  53661. /**
  53662. * Gets the perf counter used for active meshes evaluation time
  53663. */
  53664. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53665. /**
  53666. * Gets the active meshes evaluation time capture status
  53667. */
  53668. get captureActiveMeshesEvaluationTime(): boolean;
  53669. /**
  53670. * Enable or disable the active meshes evaluation time capture
  53671. */
  53672. set captureActiveMeshesEvaluationTime(value: boolean);
  53673. /**
  53674. * Gets the perf counter used for render targets render time
  53675. */
  53676. get renderTargetsRenderTimeCounter(): PerfCounter;
  53677. /**
  53678. * Gets the render targets render time capture status
  53679. */
  53680. get captureRenderTargetsRenderTime(): boolean;
  53681. /**
  53682. * Enable or disable the render targets render time capture
  53683. */
  53684. set captureRenderTargetsRenderTime(value: boolean);
  53685. /**
  53686. * Gets the perf counter used for particles render time
  53687. */
  53688. get particlesRenderTimeCounter(): PerfCounter;
  53689. /**
  53690. * Gets the particles render time capture status
  53691. */
  53692. get captureParticlesRenderTime(): boolean;
  53693. /**
  53694. * Enable or disable the particles render time capture
  53695. */
  53696. set captureParticlesRenderTime(value: boolean);
  53697. /**
  53698. * Gets the perf counter used for sprites render time
  53699. */
  53700. get spritesRenderTimeCounter(): PerfCounter;
  53701. /**
  53702. * Gets the sprites render time capture status
  53703. */
  53704. get captureSpritesRenderTime(): boolean;
  53705. /**
  53706. * Enable or disable the sprites render time capture
  53707. */
  53708. set captureSpritesRenderTime(value: boolean);
  53709. /**
  53710. * Gets the perf counter used for physics time
  53711. */
  53712. get physicsTimeCounter(): PerfCounter;
  53713. /**
  53714. * Gets the physics time capture status
  53715. */
  53716. get capturePhysicsTime(): boolean;
  53717. /**
  53718. * Enable or disable the physics time capture
  53719. */
  53720. set capturePhysicsTime(value: boolean);
  53721. /**
  53722. * Gets the perf counter used for animations time
  53723. */
  53724. get animationsTimeCounter(): PerfCounter;
  53725. /**
  53726. * Gets the animations time capture status
  53727. */
  53728. get captureAnimationsTime(): boolean;
  53729. /**
  53730. * Enable or disable the animations time capture
  53731. */
  53732. set captureAnimationsTime(value: boolean);
  53733. /**
  53734. * Gets the perf counter used for frame time capture
  53735. */
  53736. get frameTimeCounter(): PerfCounter;
  53737. /**
  53738. * Gets the frame time capture status
  53739. */
  53740. get captureFrameTime(): boolean;
  53741. /**
  53742. * Enable or disable the frame time capture
  53743. */
  53744. set captureFrameTime(value: boolean);
  53745. /**
  53746. * Gets the perf counter used for inter-frames time capture
  53747. */
  53748. get interFrameTimeCounter(): PerfCounter;
  53749. /**
  53750. * Gets the inter-frames time capture status
  53751. */
  53752. get captureInterFrameTime(): boolean;
  53753. /**
  53754. * Enable or disable the inter-frames time capture
  53755. */
  53756. set captureInterFrameTime(value: boolean);
  53757. /**
  53758. * Gets the perf counter used for render time capture
  53759. */
  53760. get renderTimeCounter(): PerfCounter;
  53761. /**
  53762. * Gets the render time capture status
  53763. */
  53764. get captureRenderTime(): boolean;
  53765. /**
  53766. * Enable or disable the render time capture
  53767. */
  53768. set captureRenderTime(value: boolean);
  53769. /**
  53770. * Gets the perf counter used for camera render time capture
  53771. */
  53772. get cameraRenderTimeCounter(): PerfCounter;
  53773. /**
  53774. * Gets the camera render time capture status
  53775. */
  53776. get captureCameraRenderTime(): boolean;
  53777. /**
  53778. * Enable or disable the camera render time capture
  53779. */
  53780. set captureCameraRenderTime(value: boolean);
  53781. /**
  53782. * Gets the perf counter used for draw calls
  53783. */
  53784. get drawCallsCounter(): PerfCounter;
  53785. /**
  53786. * Instantiates a new scene instrumentation.
  53787. * This class can be used to get instrumentation data from a Babylon engine
  53788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53789. * @param scene Defines the scene to instrument
  53790. */
  53791. constructor(
  53792. /**
  53793. * Defines the scene to instrument
  53794. */
  53795. scene: Scene);
  53796. /**
  53797. * Dispose and release associated resources.
  53798. */
  53799. dispose(): void;
  53800. }
  53801. }
  53802. declare module "babylonjs/Instrumentation/index" {
  53803. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53804. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53805. export * from "babylonjs/Instrumentation/timeToken";
  53806. }
  53807. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53808. /** @hidden */
  53809. export var glowMapGenerationPixelShader: {
  53810. name: string;
  53811. shader: string;
  53812. };
  53813. }
  53814. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53815. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53818. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53820. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53821. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53822. /** @hidden */
  53823. export var glowMapGenerationVertexShader: {
  53824. name: string;
  53825. shader: string;
  53826. };
  53827. }
  53828. declare module "babylonjs/Layers/effectLayer" {
  53829. import { Observable } from "babylonjs/Misc/observable";
  53830. import { Nullable } from "babylonjs/types";
  53831. import { Camera } from "babylonjs/Cameras/camera";
  53832. import { Scene } from "babylonjs/scene";
  53833. import { ISize } from "babylonjs/Maths/math.size";
  53834. import { Color4 } from "babylonjs/Maths/math.color";
  53835. import { Engine } from "babylonjs/Engines/engine";
  53836. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53838. import { Mesh } from "babylonjs/Meshes/mesh";
  53839. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53841. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53842. import { Effect } from "babylonjs/Materials/effect";
  53843. import { Material } from "babylonjs/Materials/material";
  53844. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53845. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53846. /**
  53847. * Effect layer options. This helps customizing the behaviour
  53848. * of the effect layer.
  53849. */
  53850. export interface IEffectLayerOptions {
  53851. /**
  53852. * Multiplication factor apply to the canvas size to compute the render target size
  53853. * used to generated the objects (the smaller the faster).
  53854. */
  53855. mainTextureRatio: number;
  53856. /**
  53857. * Enforces a fixed size texture to ensure effect stability across devices.
  53858. */
  53859. mainTextureFixedSize?: number;
  53860. /**
  53861. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53862. */
  53863. alphaBlendingMode: number;
  53864. /**
  53865. * The camera attached to the layer.
  53866. */
  53867. camera: Nullable<Camera>;
  53868. /**
  53869. * The rendering group to draw the layer in.
  53870. */
  53871. renderingGroupId: number;
  53872. }
  53873. /**
  53874. * The effect layer Helps adding post process effect blended with the main pass.
  53875. *
  53876. * This can be for instance use to generate glow or higlight effects on the scene.
  53877. *
  53878. * The effect layer class can not be used directly and is intented to inherited from to be
  53879. * customized per effects.
  53880. */
  53881. export abstract class EffectLayer {
  53882. private _vertexBuffers;
  53883. private _indexBuffer;
  53884. private _cachedDefines;
  53885. private _effectLayerMapGenerationEffect;
  53886. private _effectLayerOptions;
  53887. private _mergeEffect;
  53888. protected _scene: Scene;
  53889. protected _engine: Engine;
  53890. protected _maxSize: number;
  53891. protected _mainTextureDesiredSize: ISize;
  53892. protected _mainTexture: RenderTargetTexture;
  53893. protected _shouldRender: boolean;
  53894. protected _postProcesses: PostProcess[];
  53895. protected _textures: BaseTexture[];
  53896. protected _emissiveTextureAndColor: {
  53897. texture: Nullable<BaseTexture>;
  53898. color: Color4;
  53899. };
  53900. /**
  53901. * The name of the layer
  53902. */
  53903. name: string;
  53904. /**
  53905. * The clear color of the texture used to generate the glow map.
  53906. */
  53907. neutralColor: Color4;
  53908. /**
  53909. * Specifies wether the highlight layer is enabled or not.
  53910. */
  53911. isEnabled: boolean;
  53912. /**
  53913. * Gets the camera attached to the layer.
  53914. */
  53915. get camera(): Nullable<Camera>;
  53916. /**
  53917. * Gets the rendering group id the layer should render in.
  53918. */
  53919. get renderingGroupId(): number;
  53920. set renderingGroupId(renderingGroupId: number);
  53921. /**
  53922. * An event triggered when the effect layer has been disposed.
  53923. */
  53924. onDisposeObservable: Observable<EffectLayer>;
  53925. /**
  53926. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53927. */
  53928. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53929. /**
  53930. * An event triggered when the generated texture is being merged in the scene.
  53931. */
  53932. onBeforeComposeObservable: Observable<EffectLayer>;
  53933. /**
  53934. * An event triggered when the mesh is rendered into the effect render target.
  53935. */
  53936. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53937. /**
  53938. * An event triggered after the mesh has been rendered into the effect render target.
  53939. */
  53940. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53941. /**
  53942. * An event triggered when the generated texture has been merged in the scene.
  53943. */
  53944. onAfterComposeObservable: Observable<EffectLayer>;
  53945. /**
  53946. * An event triggered when the efffect layer changes its size.
  53947. */
  53948. onSizeChangedObservable: Observable<EffectLayer>;
  53949. /** @hidden */
  53950. static _SceneComponentInitialization: (scene: Scene) => void;
  53951. /**
  53952. * Instantiates a new effect Layer and references it in the scene.
  53953. * @param name The name of the layer
  53954. * @param scene The scene to use the layer in
  53955. */
  53956. constructor(
  53957. /** The Friendly of the effect in the scene */
  53958. name: string, scene: Scene);
  53959. /**
  53960. * Get the effect name of the layer.
  53961. * @return The effect name
  53962. */
  53963. abstract getEffectName(): string;
  53964. /**
  53965. * Checks for the readiness of the element composing the layer.
  53966. * @param subMesh the mesh to check for
  53967. * @param useInstances specify wether or not to use instances to render the mesh
  53968. * @return true if ready otherwise, false
  53969. */
  53970. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53971. /**
  53972. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53973. * @returns true if the effect requires stencil during the main canvas render pass.
  53974. */
  53975. abstract needStencil(): boolean;
  53976. /**
  53977. * Create the merge effect. This is the shader use to blit the information back
  53978. * to the main canvas at the end of the scene rendering.
  53979. * @returns The effect containing the shader used to merge the effect on the main canvas
  53980. */
  53981. protected abstract _createMergeEffect(): Effect;
  53982. /**
  53983. * Creates the render target textures and post processes used in the effect layer.
  53984. */
  53985. protected abstract _createTextureAndPostProcesses(): void;
  53986. /**
  53987. * Implementation specific of rendering the generating effect on the main canvas.
  53988. * @param effect The effect used to render through
  53989. */
  53990. protected abstract _internalRender(effect: Effect): void;
  53991. /**
  53992. * Sets the required values for both the emissive texture and and the main color.
  53993. */
  53994. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53995. /**
  53996. * Free any resources and references associated to a mesh.
  53997. * Internal use
  53998. * @param mesh The mesh to free.
  53999. */
  54000. abstract _disposeMesh(mesh: Mesh): void;
  54001. /**
  54002. * Serializes this layer (Glow or Highlight for example)
  54003. * @returns a serialized layer object
  54004. */
  54005. abstract serialize?(): any;
  54006. /**
  54007. * Initializes the effect layer with the required options.
  54008. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54009. */
  54010. protected _init(options: Partial<IEffectLayerOptions>): void;
  54011. /**
  54012. * Generates the index buffer of the full screen quad blending to the main canvas.
  54013. */
  54014. private _generateIndexBuffer;
  54015. /**
  54016. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54017. */
  54018. private _generateVertexBuffer;
  54019. /**
  54020. * Sets the main texture desired size which is the closest power of two
  54021. * of the engine canvas size.
  54022. */
  54023. private _setMainTextureSize;
  54024. /**
  54025. * Creates the main texture for the effect layer.
  54026. */
  54027. protected _createMainTexture(): void;
  54028. /**
  54029. * Adds specific effects defines.
  54030. * @param defines The defines to add specifics to.
  54031. */
  54032. protected _addCustomEffectDefines(defines: string[]): void;
  54033. /**
  54034. * Checks for the readiness of the element composing the layer.
  54035. * @param subMesh the mesh to check for
  54036. * @param useInstances specify wether or not to use instances to render the mesh
  54037. * @param emissiveTexture the associated emissive texture used to generate the glow
  54038. * @return true if ready otherwise, false
  54039. */
  54040. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54041. /**
  54042. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54043. */
  54044. render(): void;
  54045. /**
  54046. * Determine if a given mesh will be used in the current effect.
  54047. * @param mesh mesh to test
  54048. * @returns true if the mesh will be used
  54049. */
  54050. hasMesh(mesh: AbstractMesh): boolean;
  54051. /**
  54052. * Returns true if the layer contains information to display, otherwise false.
  54053. * @returns true if the glow layer should be rendered
  54054. */
  54055. shouldRender(): boolean;
  54056. /**
  54057. * Returns true if the mesh should render, otherwise false.
  54058. * @param mesh The mesh to render
  54059. * @returns true if it should render otherwise false
  54060. */
  54061. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54062. /**
  54063. * Returns true if the mesh can be rendered, otherwise false.
  54064. * @param mesh The mesh to render
  54065. * @param material The material used on the mesh
  54066. * @returns true if it can be rendered otherwise false
  54067. */
  54068. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54069. /**
  54070. * Returns true if the mesh should render, otherwise false.
  54071. * @param mesh The mesh to render
  54072. * @returns true if it should render otherwise false
  54073. */
  54074. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54075. /**
  54076. * Renders the submesh passed in parameter to the generation map.
  54077. */
  54078. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54079. /**
  54080. * Defines wether the current material of the mesh should be use to render the effect.
  54081. * @param mesh defines the current mesh to render
  54082. */
  54083. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54084. /**
  54085. * Rebuild the required buffers.
  54086. * @hidden Internal use only.
  54087. */
  54088. _rebuild(): void;
  54089. /**
  54090. * Dispose only the render target textures and post process.
  54091. */
  54092. private _disposeTextureAndPostProcesses;
  54093. /**
  54094. * Dispose the highlight layer and free resources.
  54095. */
  54096. dispose(): void;
  54097. /**
  54098. * Gets the class name of the effect layer
  54099. * @returns the string with the class name of the effect layer
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Creates an effect layer from parsed effect layer data
  54104. * @param parsedEffectLayer defines effect layer data
  54105. * @param scene defines the current scene
  54106. * @param rootUrl defines the root URL containing the effect layer information
  54107. * @returns a parsed effect Layer
  54108. */
  54109. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54110. }
  54111. }
  54112. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54113. import { Scene } from "babylonjs/scene";
  54114. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54115. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54116. import { AbstractScene } from "babylonjs/abstractScene";
  54117. module "babylonjs/abstractScene" {
  54118. interface AbstractScene {
  54119. /**
  54120. * The list of effect layers (highlights/glow) added to the scene
  54121. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54122. * @see http://doc.babylonjs.com/how_to/glow_layer
  54123. */
  54124. effectLayers: Array<EffectLayer>;
  54125. /**
  54126. * Removes the given effect layer from this scene.
  54127. * @param toRemove defines the effect layer to remove
  54128. * @returns the index of the removed effect layer
  54129. */
  54130. removeEffectLayer(toRemove: EffectLayer): number;
  54131. /**
  54132. * Adds the given effect layer to this scene
  54133. * @param newEffectLayer defines the effect layer to add
  54134. */
  54135. addEffectLayer(newEffectLayer: EffectLayer): void;
  54136. }
  54137. }
  54138. /**
  54139. * Defines the layer scene component responsible to manage any effect layers
  54140. * in a given scene.
  54141. */
  54142. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54143. /**
  54144. * The component name helpfull to identify the component in the list of scene components.
  54145. */
  54146. readonly name: string;
  54147. /**
  54148. * The scene the component belongs to.
  54149. */
  54150. scene: Scene;
  54151. private _engine;
  54152. private _renderEffects;
  54153. private _needStencil;
  54154. private _previousStencilState;
  54155. /**
  54156. * Creates a new instance of the component for the given scene
  54157. * @param scene Defines the scene to register the component in
  54158. */
  54159. constructor(scene: Scene);
  54160. /**
  54161. * Registers the component in a given scene
  54162. */
  54163. register(): void;
  54164. /**
  54165. * Rebuilds the elements related to this component in case of
  54166. * context lost for instance.
  54167. */
  54168. rebuild(): void;
  54169. /**
  54170. * Serializes the component data to the specified json object
  54171. * @param serializationObject The object to serialize to
  54172. */
  54173. serialize(serializationObject: any): void;
  54174. /**
  54175. * Adds all the elements from the container to the scene
  54176. * @param container the container holding the elements
  54177. */
  54178. addFromContainer(container: AbstractScene): void;
  54179. /**
  54180. * Removes all the elements in the container from the scene
  54181. * @param container contains the elements to remove
  54182. * @param dispose if the removed element should be disposed (default: false)
  54183. */
  54184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54185. /**
  54186. * Disposes the component and the associated ressources.
  54187. */
  54188. dispose(): void;
  54189. private _isReadyForMesh;
  54190. private _renderMainTexture;
  54191. private _setStencil;
  54192. private _setStencilBack;
  54193. private _draw;
  54194. private _drawCamera;
  54195. private _drawRenderingGroup;
  54196. }
  54197. }
  54198. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54199. /** @hidden */
  54200. export var glowMapMergePixelShader: {
  54201. name: string;
  54202. shader: string;
  54203. };
  54204. }
  54205. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54206. /** @hidden */
  54207. export var glowMapMergeVertexShader: {
  54208. name: string;
  54209. shader: string;
  54210. };
  54211. }
  54212. declare module "babylonjs/Layers/glowLayer" {
  54213. import { Nullable } from "babylonjs/types";
  54214. import { Camera } from "babylonjs/Cameras/camera";
  54215. import { Scene } from "babylonjs/scene";
  54216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54218. import { Mesh } from "babylonjs/Meshes/mesh";
  54219. import { Texture } from "babylonjs/Materials/Textures/texture";
  54220. import { Effect } from "babylonjs/Materials/effect";
  54221. import { Material } from "babylonjs/Materials/material";
  54222. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54223. import { Color4 } from "babylonjs/Maths/math.color";
  54224. import "babylonjs/Shaders/glowMapMerge.fragment";
  54225. import "babylonjs/Shaders/glowMapMerge.vertex";
  54226. import "babylonjs/Layers/effectLayerSceneComponent";
  54227. module "babylonjs/abstractScene" {
  54228. interface AbstractScene {
  54229. /**
  54230. * Return a the first highlight layer of the scene with a given name.
  54231. * @param name The name of the highlight layer to look for.
  54232. * @return The highlight layer if found otherwise null.
  54233. */
  54234. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54235. }
  54236. }
  54237. /**
  54238. * Glow layer options. This helps customizing the behaviour
  54239. * of the glow layer.
  54240. */
  54241. export interface IGlowLayerOptions {
  54242. /**
  54243. * Multiplication factor apply to the canvas size to compute the render target size
  54244. * used to generated the glowing objects (the smaller the faster).
  54245. */
  54246. mainTextureRatio: number;
  54247. /**
  54248. * Enforces a fixed size texture to ensure resize independant blur.
  54249. */
  54250. mainTextureFixedSize?: number;
  54251. /**
  54252. * How big is the kernel of the blur texture.
  54253. */
  54254. blurKernelSize: number;
  54255. /**
  54256. * The camera attached to the layer.
  54257. */
  54258. camera: Nullable<Camera>;
  54259. /**
  54260. * Enable MSAA by chosing the number of samples.
  54261. */
  54262. mainTextureSamples?: number;
  54263. /**
  54264. * The rendering group to draw the layer in.
  54265. */
  54266. renderingGroupId: number;
  54267. }
  54268. /**
  54269. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54270. *
  54271. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54272. *
  54273. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54274. */
  54275. export class GlowLayer extends EffectLayer {
  54276. /**
  54277. * Effect Name of the layer.
  54278. */
  54279. static readonly EffectName: string;
  54280. /**
  54281. * The default blur kernel size used for the glow.
  54282. */
  54283. static DefaultBlurKernelSize: number;
  54284. /**
  54285. * The default texture size ratio used for the glow.
  54286. */
  54287. static DefaultTextureRatio: number;
  54288. /**
  54289. * Sets the kernel size of the blur.
  54290. */
  54291. set blurKernelSize(value: number);
  54292. /**
  54293. * Gets the kernel size of the blur.
  54294. */
  54295. get blurKernelSize(): number;
  54296. /**
  54297. * Sets the glow intensity.
  54298. */
  54299. set intensity(value: number);
  54300. /**
  54301. * Gets the glow intensity.
  54302. */
  54303. get intensity(): number;
  54304. private _options;
  54305. private _intensity;
  54306. private _horizontalBlurPostprocess1;
  54307. private _verticalBlurPostprocess1;
  54308. private _horizontalBlurPostprocess2;
  54309. private _verticalBlurPostprocess2;
  54310. private _blurTexture1;
  54311. private _blurTexture2;
  54312. private _postProcesses1;
  54313. private _postProcesses2;
  54314. private _includedOnlyMeshes;
  54315. private _excludedMeshes;
  54316. private _meshesUsingTheirOwnMaterials;
  54317. /**
  54318. * Callback used to let the user override the color selection on a per mesh basis
  54319. */
  54320. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54321. /**
  54322. * Callback used to let the user override the texture selection on a per mesh basis
  54323. */
  54324. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54325. /**
  54326. * Instantiates a new glow Layer and references it to the scene.
  54327. * @param name The name of the layer
  54328. * @param scene The scene to use the layer in
  54329. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54330. */
  54331. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54332. /**
  54333. * Get the effect name of the layer.
  54334. * @return The effect name
  54335. */
  54336. getEffectName(): string;
  54337. /**
  54338. * Create the merge effect. This is the shader use to blit the information back
  54339. * to the main canvas at the end of the scene rendering.
  54340. */
  54341. protected _createMergeEffect(): Effect;
  54342. /**
  54343. * Creates the render target textures and post processes used in the glow layer.
  54344. */
  54345. protected _createTextureAndPostProcesses(): void;
  54346. /**
  54347. * Checks for the readiness of the element composing the layer.
  54348. * @param subMesh the mesh to check for
  54349. * @param useInstances specify wether or not to use instances to render the mesh
  54350. * @param emissiveTexture the associated emissive texture used to generate the glow
  54351. * @return true if ready otherwise, false
  54352. */
  54353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54354. /**
  54355. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54356. */
  54357. needStencil(): boolean;
  54358. /**
  54359. * Returns true if the mesh can be rendered, otherwise false.
  54360. * @param mesh The mesh to render
  54361. * @param material The material used on the mesh
  54362. * @returns true if it can be rendered otherwise false
  54363. */
  54364. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54365. /**
  54366. * Implementation specific of rendering the generating effect on the main canvas.
  54367. * @param effect The effect used to render through
  54368. */
  54369. protected _internalRender(effect: Effect): void;
  54370. /**
  54371. * Sets the required values for both the emissive texture and and the main color.
  54372. */
  54373. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54374. /**
  54375. * Returns true if the mesh should render, otherwise false.
  54376. * @param mesh The mesh to render
  54377. * @returns true if it should render otherwise false
  54378. */
  54379. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54380. /**
  54381. * Adds specific effects defines.
  54382. * @param defines The defines to add specifics to.
  54383. */
  54384. protected _addCustomEffectDefines(defines: string[]): void;
  54385. /**
  54386. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54387. * @param mesh The mesh to exclude from the glow layer
  54388. */
  54389. addExcludedMesh(mesh: Mesh): void;
  54390. /**
  54391. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54392. * @param mesh The mesh to remove
  54393. */
  54394. removeExcludedMesh(mesh: Mesh): void;
  54395. /**
  54396. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54397. * @param mesh The mesh to include in the glow layer
  54398. */
  54399. addIncludedOnlyMesh(mesh: Mesh): void;
  54400. /**
  54401. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54402. * @param mesh The mesh to remove
  54403. */
  54404. removeIncludedOnlyMesh(mesh: Mesh): void;
  54405. /**
  54406. * Determine if a given mesh will be used in the glow layer
  54407. * @param mesh The mesh to test
  54408. * @returns true if the mesh will be highlighted by the current glow layer
  54409. */
  54410. hasMesh(mesh: AbstractMesh): boolean;
  54411. /**
  54412. * Defines wether the current material of the mesh should be use to render the effect.
  54413. * @param mesh defines the current mesh to render
  54414. */
  54415. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54416. /**
  54417. * Add a mesh to be rendered through its own material and not with emissive only.
  54418. * @param mesh The mesh for which we need to use its material
  54419. */
  54420. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54421. /**
  54422. * Remove a mesh from being rendered through its own material and not with emissive only.
  54423. * @param mesh The mesh for which we need to not use its material
  54424. */
  54425. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54426. /**
  54427. * Free any resources and references associated to a mesh.
  54428. * Internal use
  54429. * @param mesh The mesh to free.
  54430. * @hidden
  54431. */
  54432. _disposeMesh(mesh: Mesh): void;
  54433. /**
  54434. * Gets the class name of the effect layer
  54435. * @returns the string with the class name of the effect layer
  54436. */
  54437. getClassName(): string;
  54438. /**
  54439. * Serializes this glow layer
  54440. * @returns a serialized glow layer object
  54441. */
  54442. serialize(): any;
  54443. /**
  54444. * Creates a Glow Layer from parsed glow layer data
  54445. * @param parsedGlowLayer defines glow layer data
  54446. * @param scene defines the current scene
  54447. * @param rootUrl defines the root URL containing the glow layer information
  54448. * @returns a parsed Glow Layer
  54449. */
  54450. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54451. }
  54452. }
  54453. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54454. /** @hidden */
  54455. export var glowBlurPostProcessPixelShader: {
  54456. name: string;
  54457. shader: string;
  54458. };
  54459. }
  54460. declare module "babylonjs/Layers/highlightLayer" {
  54461. import { Observable } from "babylonjs/Misc/observable";
  54462. import { Nullable } from "babylonjs/types";
  54463. import { Camera } from "babylonjs/Cameras/camera";
  54464. import { Scene } from "babylonjs/scene";
  54465. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54467. import { Mesh } from "babylonjs/Meshes/mesh";
  54468. import { Effect } from "babylonjs/Materials/effect";
  54469. import { Material } from "babylonjs/Materials/material";
  54470. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54471. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54472. import "babylonjs/Shaders/glowMapMerge.fragment";
  54473. import "babylonjs/Shaders/glowMapMerge.vertex";
  54474. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54475. module "babylonjs/abstractScene" {
  54476. interface AbstractScene {
  54477. /**
  54478. * Return a the first highlight layer of the scene with a given name.
  54479. * @param name The name of the highlight layer to look for.
  54480. * @return The highlight layer if found otherwise null.
  54481. */
  54482. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54483. }
  54484. }
  54485. /**
  54486. * Highlight layer options. This helps customizing the behaviour
  54487. * of the highlight layer.
  54488. */
  54489. export interface IHighlightLayerOptions {
  54490. /**
  54491. * Multiplication factor apply to the canvas size to compute the render target size
  54492. * used to generated the glowing objects (the smaller the faster).
  54493. */
  54494. mainTextureRatio: number;
  54495. /**
  54496. * Enforces a fixed size texture to ensure resize independant blur.
  54497. */
  54498. mainTextureFixedSize?: number;
  54499. /**
  54500. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54501. * of the picture to blur (the smaller the faster).
  54502. */
  54503. blurTextureSizeRatio: number;
  54504. /**
  54505. * How big in texel of the blur texture is the vertical blur.
  54506. */
  54507. blurVerticalSize: number;
  54508. /**
  54509. * How big in texel of the blur texture is the horizontal blur.
  54510. */
  54511. blurHorizontalSize: number;
  54512. /**
  54513. * Alpha blending mode used to apply the blur. Default is combine.
  54514. */
  54515. alphaBlendingMode: number;
  54516. /**
  54517. * The camera attached to the layer.
  54518. */
  54519. camera: Nullable<Camera>;
  54520. /**
  54521. * Should we display highlight as a solid stroke?
  54522. */
  54523. isStroke?: boolean;
  54524. /**
  54525. * The rendering group to draw the layer in.
  54526. */
  54527. renderingGroupId: number;
  54528. }
  54529. /**
  54530. * The highlight layer Helps adding a glow effect around a mesh.
  54531. *
  54532. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54533. * glowy meshes to your scene.
  54534. *
  54535. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54536. */
  54537. export class HighlightLayer extends EffectLayer {
  54538. name: string;
  54539. /**
  54540. * Effect Name of the highlight layer.
  54541. */
  54542. static readonly EffectName: string;
  54543. /**
  54544. * The neutral color used during the preparation of the glow effect.
  54545. * This is black by default as the blend operation is a blend operation.
  54546. */
  54547. static NeutralColor: Color4;
  54548. /**
  54549. * Stencil value used for glowing meshes.
  54550. */
  54551. static GlowingMeshStencilReference: number;
  54552. /**
  54553. * Stencil value used for the other meshes in the scene.
  54554. */
  54555. static NormalMeshStencilReference: number;
  54556. /**
  54557. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54558. */
  54559. innerGlow: boolean;
  54560. /**
  54561. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54562. */
  54563. outerGlow: boolean;
  54564. /**
  54565. * Specifies the horizontal size of the blur.
  54566. */
  54567. set blurHorizontalSize(value: number);
  54568. /**
  54569. * Specifies the vertical size of the blur.
  54570. */
  54571. set blurVerticalSize(value: number);
  54572. /**
  54573. * Gets the horizontal size of the blur.
  54574. */
  54575. get blurHorizontalSize(): number;
  54576. /**
  54577. * Gets the vertical size of the blur.
  54578. */
  54579. get blurVerticalSize(): number;
  54580. /**
  54581. * An event triggered when the highlight layer is being blurred.
  54582. */
  54583. onBeforeBlurObservable: Observable<HighlightLayer>;
  54584. /**
  54585. * An event triggered when the highlight layer has been blurred.
  54586. */
  54587. onAfterBlurObservable: Observable<HighlightLayer>;
  54588. private _instanceGlowingMeshStencilReference;
  54589. private _options;
  54590. private _downSamplePostprocess;
  54591. private _horizontalBlurPostprocess;
  54592. private _verticalBlurPostprocess;
  54593. private _blurTexture;
  54594. private _meshes;
  54595. private _excludedMeshes;
  54596. /**
  54597. * Instantiates a new highlight Layer and references it to the scene..
  54598. * @param name The name of the layer
  54599. * @param scene The scene to use the layer in
  54600. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54601. */
  54602. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54603. /**
  54604. * Get the effect name of the layer.
  54605. * @return The effect name
  54606. */
  54607. getEffectName(): string;
  54608. /**
  54609. * Create the merge effect. This is the shader use to blit the information back
  54610. * to the main canvas at the end of the scene rendering.
  54611. */
  54612. protected _createMergeEffect(): Effect;
  54613. /**
  54614. * Creates the render target textures and post processes used in the highlight layer.
  54615. */
  54616. protected _createTextureAndPostProcesses(): void;
  54617. /**
  54618. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54619. */
  54620. needStencil(): boolean;
  54621. /**
  54622. * Checks for the readiness of the element composing the layer.
  54623. * @param subMesh the mesh to check for
  54624. * @param useInstances specify wether or not to use instances to render the mesh
  54625. * @param emissiveTexture the associated emissive texture used to generate the glow
  54626. * @return true if ready otherwise, false
  54627. */
  54628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54629. /**
  54630. * Implementation specific of rendering the generating effect on the main canvas.
  54631. * @param effect The effect used to render through
  54632. */
  54633. protected _internalRender(effect: Effect): void;
  54634. /**
  54635. * Returns true if the layer contains information to display, otherwise false.
  54636. */
  54637. shouldRender(): boolean;
  54638. /**
  54639. * Returns true if the mesh should render, otherwise false.
  54640. * @param mesh The mesh to render
  54641. * @returns true if it should render otherwise false
  54642. */
  54643. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54644. /**
  54645. * Sets the required values for both the emissive texture and and the main color.
  54646. */
  54647. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54648. /**
  54649. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54650. * @param mesh The mesh to exclude from the highlight layer
  54651. */
  54652. addExcludedMesh(mesh: Mesh): void;
  54653. /**
  54654. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54655. * @param mesh The mesh to highlight
  54656. */
  54657. removeExcludedMesh(mesh: Mesh): void;
  54658. /**
  54659. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54660. * @param mesh mesh to test
  54661. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54662. */
  54663. hasMesh(mesh: AbstractMesh): boolean;
  54664. /**
  54665. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54666. * @param mesh The mesh to highlight
  54667. * @param color The color of the highlight
  54668. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54669. */
  54670. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54671. /**
  54672. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54673. * @param mesh The mesh to highlight
  54674. */
  54675. removeMesh(mesh: Mesh): void;
  54676. /**
  54677. * Force the stencil to the normal expected value for none glowing parts
  54678. */
  54679. private _defaultStencilReference;
  54680. /**
  54681. * Free any resources and references associated to a mesh.
  54682. * Internal use
  54683. * @param mesh The mesh to free.
  54684. * @hidden
  54685. */
  54686. _disposeMesh(mesh: Mesh): void;
  54687. /**
  54688. * Dispose the highlight layer and free resources.
  54689. */
  54690. dispose(): void;
  54691. /**
  54692. * Gets the class name of the effect layer
  54693. * @returns the string with the class name of the effect layer
  54694. */
  54695. getClassName(): string;
  54696. /**
  54697. * Serializes this Highlight layer
  54698. * @returns a serialized Highlight layer object
  54699. */
  54700. serialize(): any;
  54701. /**
  54702. * Creates a Highlight layer from parsed Highlight layer data
  54703. * @param parsedHightlightLayer defines the Highlight layer data
  54704. * @param scene defines the current scene
  54705. * @param rootUrl defines the root URL containing the Highlight layer information
  54706. * @returns a parsed Highlight layer
  54707. */
  54708. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54709. }
  54710. }
  54711. declare module "babylonjs/Layers/layerSceneComponent" {
  54712. import { Scene } from "babylonjs/scene";
  54713. import { ISceneComponent } from "babylonjs/sceneComponent";
  54714. import { Layer } from "babylonjs/Layers/layer";
  54715. import { AbstractScene } from "babylonjs/abstractScene";
  54716. module "babylonjs/abstractScene" {
  54717. interface AbstractScene {
  54718. /**
  54719. * The list of layers (background and foreground) of the scene
  54720. */
  54721. layers: Array<Layer>;
  54722. }
  54723. }
  54724. /**
  54725. * Defines the layer scene component responsible to manage any layers
  54726. * in a given scene.
  54727. */
  54728. export class LayerSceneComponent implements ISceneComponent {
  54729. /**
  54730. * The component name helpfull to identify the component in the list of scene components.
  54731. */
  54732. readonly name: string;
  54733. /**
  54734. * The scene the component belongs to.
  54735. */
  54736. scene: Scene;
  54737. private _engine;
  54738. /**
  54739. * Creates a new instance of the component for the given scene
  54740. * @param scene Defines the scene to register the component in
  54741. */
  54742. constructor(scene: Scene);
  54743. /**
  54744. * Registers the component in a given scene
  54745. */
  54746. register(): void;
  54747. /**
  54748. * Rebuilds the elements related to this component in case of
  54749. * context lost for instance.
  54750. */
  54751. rebuild(): void;
  54752. /**
  54753. * Disposes the component and the associated ressources.
  54754. */
  54755. dispose(): void;
  54756. private _draw;
  54757. private _drawCameraPredicate;
  54758. private _drawCameraBackground;
  54759. private _drawCameraForeground;
  54760. private _drawRenderTargetPredicate;
  54761. private _drawRenderTargetBackground;
  54762. private _drawRenderTargetForeground;
  54763. /**
  54764. * Adds all the elements from the container to the scene
  54765. * @param container the container holding the elements
  54766. */
  54767. addFromContainer(container: AbstractScene): void;
  54768. /**
  54769. * Removes all the elements in the container from the scene
  54770. * @param container contains the elements to remove
  54771. * @param dispose if the removed element should be disposed (default: false)
  54772. */
  54773. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54774. }
  54775. }
  54776. declare module "babylonjs/Shaders/layer.fragment" {
  54777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54778. /** @hidden */
  54779. export var layerPixelShader: {
  54780. name: string;
  54781. shader: string;
  54782. };
  54783. }
  54784. declare module "babylonjs/Shaders/layer.vertex" {
  54785. /** @hidden */
  54786. export var layerVertexShader: {
  54787. name: string;
  54788. shader: string;
  54789. };
  54790. }
  54791. declare module "babylonjs/Layers/layer" {
  54792. import { Observable } from "babylonjs/Misc/observable";
  54793. import { Nullable } from "babylonjs/types";
  54794. import { Scene } from "babylonjs/scene";
  54795. import { Vector2 } from "babylonjs/Maths/math.vector";
  54796. import { Color4 } from "babylonjs/Maths/math.color";
  54797. import { Texture } from "babylonjs/Materials/Textures/texture";
  54798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54799. import "babylonjs/Shaders/layer.fragment";
  54800. import "babylonjs/Shaders/layer.vertex";
  54801. /**
  54802. * This represents a full screen 2d layer.
  54803. * This can be useful to display a picture in the background of your scene for instance.
  54804. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54805. */
  54806. export class Layer {
  54807. /**
  54808. * Define the name of the layer.
  54809. */
  54810. name: string;
  54811. /**
  54812. * Define the texture the layer should display.
  54813. */
  54814. texture: Nullable<Texture>;
  54815. /**
  54816. * Is the layer in background or foreground.
  54817. */
  54818. isBackground: boolean;
  54819. /**
  54820. * Define the color of the layer (instead of texture).
  54821. */
  54822. color: Color4;
  54823. /**
  54824. * Define the scale of the layer in order to zoom in out of the texture.
  54825. */
  54826. scale: Vector2;
  54827. /**
  54828. * Define an offset for the layer in order to shift the texture.
  54829. */
  54830. offset: Vector2;
  54831. /**
  54832. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54833. */
  54834. alphaBlendingMode: number;
  54835. /**
  54836. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54837. * Alpha test will not mix with the background color in case of transparency.
  54838. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54839. */
  54840. alphaTest: boolean;
  54841. /**
  54842. * Define a mask to restrict the layer to only some of the scene cameras.
  54843. */
  54844. layerMask: number;
  54845. /**
  54846. * Define the list of render target the layer is visible into.
  54847. */
  54848. renderTargetTextures: RenderTargetTexture[];
  54849. /**
  54850. * Define if the layer is only used in renderTarget or if it also
  54851. * renders in the main frame buffer of the canvas.
  54852. */
  54853. renderOnlyInRenderTargetTextures: boolean;
  54854. private _scene;
  54855. private _vertexBuffers;
  54856. private _indexBuffer;
  54857. private _effect;
  54858. private _previousDefines;
  54859. /**
  54860. * An event triggered when the layer is disposed.
  54861. */
  54862. onDisposeObservable: Observable<Layer>;
  54863. private _onDisposeObserver;
  54864. /**
  54865. * Back compatibility with callback before the onDisposeObservable existed.
  54866. * The set callback will be triggered when the layer has been disposed.
  54867. */
  54868. set onDispose(callback: () => void);
  54869. /**
  54870. * An event triggered before rendering the scene
  54871. */
  54872. onBeforeRenderObservable: Observable<Layer>;
  54873. private _onBeforeRenderObserver;
  54874. /**
  54875. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54876. * The set callback will be triggered just before rendering the layer.
  54877. */
  54878. set onBeforeRender(callback: () => void);
  54879. /**
  54880. * An event triggered after rendering the scene
  54881. */
  54882. onAfterRenderObservable: Observable<Layer>;
  54883. private _onAfterRenderObserver;
  54884. /**
  54885. * Back compatibility with callback before the onAfterRenderObservable existed.
  54886. * The set callback will be triggered just after rendering the layer.
  54887. */
  54888. set onAfterRender(callback: () => void);
  54889. /**
  54890. * Instantiates a new layer.
  54891. * This represents a full screen 2d layer.
  54892. * This can be useful to display a picture in the background of your scene for instance.
  54893. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54894. * @param name Define the name of the layer in the scene
  54895. * @param imgUrl Define the url of the texture to display in the layer
  54896. * @param scene Define the scene the layer belongs to
  54897. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54898. * @param color Defines a color for the layer
  54899. */
  54900. constructor(
  54901. /**
  54902. * Define the name of the layer.
  54903. */
  54904. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54905. private _createIndexBuffer;
  54906. /** @hidden */
  54907. _rebuild(): void;
  54908. /**
  54909. * Renders the layer in the scene.
  54910. */
  54911. render(): void;
  54912. /**
  54913. * Disposes and releases the associated ressources.
  54914. */
  54915. dispose(): void;
  54916. }
  54917. }
  54918. declare module "babylonjs/Layers/index" {
  54919. export * from "babylonjs/Layers/effectLayer";
  54920. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54921. export * from "babylonjs/Layers/glowLayer";
  54922. export * from "babylonjs/Layers/highlightLayer";
  54923. export * from "babylonjs/Layers/layer";
  54924. export * from "babylonjs/Layers/layerSceneComponent";
  54925. }
  54926. declare module "babylonjs/Shaders/lensFlare.fragment" {
  54927. /** @hidden */
  54928. export var lensFlarePixelShader: {
  54929. name: string;
  54930. shader: string;
  54931. };
  54932. }
  54933. declare module "babylonjs/Shaders/lensFlare.vertex" {
  54934. /** @hidden */
  54935. export var lensFlareVertexShader: {
  54936. name: string;
  54937. shader: string;
  54938. };
  54939. }
  54940. declare module "babylonjs/LensFlares/lensFlareSystem" {
  54941. import { Scene } from "babylonjs/scene";
  54942. import { Vector3 } from "babylonjs/Maths/math.vector";
  54943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54944. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  54945. import "babylonjs/Shaders/lensFlare.fragment";
  54946. import "babylonjs/Shaders/lensFlare.vertex";
  54947. import { Viewport } from "babylonjs/Maths/math.viewport";
  54948. /**
  54949. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54950. * It is usually composed of several `lensFlare`.
  54951. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54952. */
  54953. export class LensFlareSystem {
  54954. /**
  54955. * Define the name of the lens flare system
  54956. */
  54957. name: string;
  54958. /**
  54959. * List of lens flares used in this system.
  54960. */
  54961. lensFlares: LensFlare[];
  54962. /**
  54963. * Define a limit from the border the lens flare can be visible.
  54964. */
  54965. borderLimit: number;
  54966. /**
  54967. * Define a viewport border we do not want to see the lens flare in.
  54968. */
  54969. viewportBorder: number;
  54970. /**
  54971. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54972. */
  54973. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54974. /**
  54975. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54976. */
  54977. layerMask: number;
  54978. /**
  54979. * Define the id of the lens flare system in the scene.
  54980. * (equal to name by default)
  54981. */
  54982. id: string;
  54983. private _scene;
  54984. private _emitter;
  54985. private _vertexBuffers;
  54986. private _indexBuffer;
  54987. private _effect;
  54988. private _positionX;
  54989. private _positionY;
  54990. private _isEnabled;
  54991. /** @hidden */
  54992. static _SceneComponentInitialization: (scene: Scene) => void;
  54993. /**
  54994. * Instantiates a lens flare system.
  54995. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54996. * It is usually composed of several `lensFlare`.
  54997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54998. * @param name Define the name of the lens flare system in the scene
  54999. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55000. * @param scene Define the scene the lens flare system belongs to
  55001. */
  55002. constructor(
  55003. /**
  55004. * Define the name of the lens flare system
  55005. */
  55006. name: string, emitter: any, scene: Scene);
  55007. /**
  55008. * Define if the lens flare system is enabled.
  55009. */
  55010. get isEnabled(): boolean;
  55011. set isEnabled(value: boolean);
  55012. /**
  55013. * Get the scene the effects belongs to.
  55014. * @returns the scene holding the lens flare system
  55015. */
  55016. getScene(): Scene;
  55017. /**
  55018. * Get the emitter of the lens flare system.
  55019. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55020. * @returns the emitter of the lens flare system
  55021. */
  55022. getEmitter(): any;
  55023. /**
  55024. * Set the emitter of the lens flare system.
  55025. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55026. * @param newEmitter Define the new emitter of the system
  55027. */
  55028. setEmitter(newEmitter: any): void;
  55029. /**
  55030. * Get the lens flare system emitter position.
  55031. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55032. * @returns the position
  55033. */
  55034. getEmitterPosition(): Vector3;
  55035. /**
  55036. * @hidden
  55037. */
  55038. computeEffectivePosition(globalViewport: Viewport): boolean;
  55039. /** @hidden */
  55040. _isVisible(): boolean;
  55041. /**
  55042. * @hidden
  55043. */
  55044. render(): boolean;
  55045. /**
  55046. * Dispose and release the lens flare with its associated resources.
  55047. */
  55048. dispose(): void;
  55049. /**
  55050. * Parse a lens flare system from a JSON repressentation
  55051. * @param parsedLensFlareSystem Define the JSON to parse
  55052. * @param scene Define the scene the parsed system should be instantiated in
  55053. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55054. * @returns the parsed system
  55055. */
  55056. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55057. /**
  55058. * Serialize the current Lens Flare System into a JSON representation.
  55059. * @returns the serialized JSON
  55060. */
  55061. serialize(): any;
  55062. }
  55063. }
  55064. declare module "babylonjs/LensFlares/lensFlare" {
  55065. import { Nullable } from "babylonjs/types";
  55066. import { Color3 } from "babylonjs/Maths/math.color";
  55067. import { Texture } from "babylonjs/Materials/Textures/texture";
  55068. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55069. /**
  55070. * This represents one of the lens effect in a `lensFlareSystem`.
  55071. * It controls one of the indiviual texture used in the effect.
  55072. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55073. */
  55074. export class LensFlare {
  55075. /**
  55076. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55077. */
  55078. size: number;
  55079. /**
  55080. * 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.
  55081. */
  55082. position: number;
  55083. /**
  55084. * Define the lens color.
  55085. */
  55086. color: Color3;
  55087. /**
  55088. * Define the lens texture.
  55089. */
  55090. texture: Nullable<Texture>;
  55091. /**
  55092. * Define the alpha mode to render this particular lens.
  55093. */
  55094. alphaMode: number;
  55095. private _system;
  55096. /**
  55097. * Creates a new Lens Flare.
  55098. * This represents one of the lens effect in a `lensFlareSystem`.
  55099. * It controls one of the indiviual texture used in the effect.
  55100. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55101. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55102. * @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.
  55103. * @param color Define the lens color
  55104. * @param imgUrl Define the lens texture url
  55105. * @param system Define the `lensFlareSystem` this flare is part of
  55106. * @returns The newly created Lens Flare
  55107. */
  55108. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55109. /**
  55110. * Instantiates a new Lens Flare.
  55111. * This represents one of the lens effect in a `lensFlareSystem`.
  55112. * It controls one of the indiviual texture used in the effect.
  55113. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55114. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55115. * @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.
  55116. * @param color Define the lens color
  55117. * @param imgUrl Define the lens texture url
  55118. * @param system Define the `lensFlareSystem` this flare is part of
  55119. */
  55120. constructor(
  55121. /**
  55122. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55123. */
  55124. size: number,
  55125. /**
  55126. * 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.
  55127. */
  55128. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55129. /**
  55130. * Dispose and release the lens flare with its associated resources.
  55131. */
  55132. dispose(): void;
  55133. }
  55134. }
  55135. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55136. import { Nullable } from "babylonjs/types";
  55137. import { Scene } from "babylonjs/scene";
  55138. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55139. import { AbstractScene } from "babylonjs/abstractScene";
  55140. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55141. module "babylonjs/abstractScene" {
  55142. interface AbstractScene {
  55143. /**
  55144. * The list of lens flare system added to the scene
  55145. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55146. */
  55147. lensFlareSystems: Array<LensFlareSystem>;
  55148. /**
  55149. * Removes the given lens flare system from this scene.
  55150. * @param toRemove The lens flare system to remove
  55151. * @returns The index of the removed lens flare system
  55152. */
  55153. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55154. /**
  55155. * Adds the given lens flare system to this scene
  55156. * @param newLensFlareSystem The lens flare system to add
  55157. */
  55158. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55159. /**
  55160. * Gets a lens flare system using its name
  55161. * @param name defines the name to look for
  55162. * @returns the lens flare system or null if not found
  55163. */
  55164. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55165. /**
  55166. * Gets a lens flare system using its id
  55167. * @param id defines the id to look for
  55168. * @returns the lens flare system or null if not found
  55169. */
  55170. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55171. }
  55172. }
  55173. /**
  55174. * Defines the lens flare scene component responsible to manage any lens flares
  55175. * in a given scene.
  55176. */
  55177. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55178. /**
  55179. * The component name helpfull to identify the component in the list of scene components.
  55180. */
  55181. readonly name: string;
  55182. /**
  55183. * The scene the component belongs to.
  55184. */
  55185. scene: Scene;
  55186. /**
  55187. * Creates a new instance of the component for the given scene
  55188. * @param scene Defines the scene to register the component in
  55189. */
  55190. constructor(scene: Scene);
  55191. /**
  55192. * Registers the component in a given scene
  55193. */
  55194. register(): void;
  55195. /**
  55196. * Rebuilds the elements related to this component in case of
  55197. * context lost for instance.
  55198. */
  55199. rebuild(): void;
  55200. /**
  55201. * Adds all the elements from the container to the scene
  55202. * @param container the container holding the elements
  55203. */
  55204. addFromContainer(container: AbstractScene): void;
  55205. /**
  55206. * Removes all the elements in the container from the scene
  55207. * @param container contains the elements to remove
  55208. * @param dispose if the removed element should be disposed (default: false)
  55209. */
  55210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55211. /**
  55212. * Serializes the component data to the specified json object
  55213. * @param serializationObject The object to serialize to
  55214. */
  55215. serialize(serializationObject: any): void;
  55216. /**
  55217. * Disposes the component and the associated ressources.
  55218. */
  55219. dispose(): void;
  55220. private _draw;
  55221. }
  55222. }
  55223. declare module "babylonjs/LensFlares/index" {
  55224. export * from "babylonjs/LensFlares/lensFlare";
  55225. export * from "babylonjs/LensFlares/lensFlareSystem";
  55226. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55227. }
  55228. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55229. import { Scene } from "babylonjs/scene";
  55230. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55231. import { AbstractScene } from "babylonjs/abstractScene";
  55232. /**
  55233. * Defines the shadow generator component responsible to manage any shadow generators
  55234. * in a given scene.
  55235. */
  55236. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55237. /**
  55238. * The component name helpfull to identify the component in the list of scene components.
  55239. */
  55240. readonly name: string;
  55241. /**
  55242. * The scene the component belongs to.
  55243. */
  55244. scene: Scene;
  55245. /**
  55246. * Creates a new instance of the component for the given scene
  55247. * @param scene Defines the scene to register the component in
  55248. */
  55249. constructor(scene: Scene);
  55250. /**
  55251. * Registers the component in a given scene
  55252. */
  55253. register(): void;
  55254. /**
  55255. * Rebuilds the elements related to this component in case of
  55256. * context lost for instance.
  55257. */
  55258. rebuild(): void;
  55259. /**
  55260. * Serializes the component data to the specified json object
  55261. * @param serializationObject The object to serialize to
  55262. */
  55263. serialize(serializationObject: any): void;
  55264. /**
  55265. * Adds all the elements from the container to the scene
  55266. * @param container the container holding the elements
  55267. */
  55268. addFromContainer(container: AbstractScene): void;
  55269. /**
  55270. * Removes all the elements in the container from the scene
  55271. * @param container contains the elements to remove
  55272. * @param dispose if the removed element should be disposed (default: false)
  55273. */
  55274. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55275. /**
  55276. * Rebuilds the elements related to this component in case of
  55277. * context lost for instance.
  55278. */
  55279. dispose(): void;
  55280. private _gatherRenderTargets;
  55281. }
  55282. }
  55283. declare module "babylonjs/Lights/Shadows/index" {
  55284. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55285. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55286. }
  55287. declare module "babylonjs/Lights/pointLight" {
  55288. import { Scene } from "babylonjs/scene";
  55289. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55291. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55292. import { Effect } from "babylonjs/Materials/effect";
  55293. /**
  55294. * A point light is a light defined by an unique point in world space.
  55295. * The light is emitted in every direction from this point.
  55296. * A good example of a point light is a standard light bulb.
  55297. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55298. */
  55299. export class PointLight extends ShadowLight {
  55300. private _shadowAngle;
  55301. /**
  55302. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55303. * This specifies what angle the shadow will use to be created.
  55304. *
  55305. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55306. */
  55307. get shadowAngle(): number;
  55308. /**
  55309. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55310. * This specifies what angle the shadow will use to be created.
  55311. *
  55312. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55313. */
  55314. set shadowAngle(value: number);
  55315. /**
  55316. * Gets the direction if it has been set.
  55317. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55318. */
  55319. get direction(): Vector3;
  55320. /**
  55321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55322. */
  55323. set direction(value: Vector3);
  55324. /**
  55325. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55326. * A PointLight emits the light in every direction.
  55327. * It can cast shadows.
  55328. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55329. * ```javascript
  55330. * var pointLight = new PointLight("pl", camera.position, scene);
  55331. * ```
  55332. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55333. * @param name The light friendly name
  55334. * @param position The position of the point light in the scene
  55335. * @param scene The scene the lights belongs to
  55336. */
  55337. constructor(name: string, position: Vector3, scene: Scene);
  55338. /**
  55339. * Returns the string "PointLight"
  55340. * @returns the class name
  55341. */
  55342. getClassName(): string;
  55343. /**
  55344. * Returns the integer 0.
  55345. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55346. */
  55347. getTypeID(): number;
  55348. /**
  55349. * Specifies wether or not the shadowmap should be a cube texture.
  55350. * @returns true if the shadowmap needs to be a cube texture.
  55351. */
  55352. needCube(): boolean;
  55353. /**
  55354. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55355. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55356. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55357. */
  55358. getShadowDirection(faceIndex?: number): Vector3;
  55359. /**
  55360. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55361. * - fov = PI / 2
  55362. * - aspect ratio : 1.0
  55363. * - z-near and far equal to the active camera minZ and maxZ.
  55364. * Returns the PointLight.
  55365. */
  55366. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55367. protected _buildUniformLayout(): void;
  55368. /**
  55369. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55370. * @param effect The effect to update
  55371. * @param lightIndex The index of the light in the effect to update
  55372. * @returns The point light
  55373. */
  55374. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55376. /**
  55377. * Prepares the list of defines specific to the light type.
  55378. * @param defines the list of defines
  55379. * @param lightIndex defines the index of the light for the effect
  55380. */
  55381. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55382. }
  55383. }
  55384. declare module "babylonjs/Lights/index" {
  55385. export * from "babylonjs/Lights/light";
  55386. export * from "babylonjs/Lights/shadowLight";
  55387. export * from "babylonjs/Lights/Shadows/index";
  55388. export * from "babylonjs/Lights/directionalLight";
  55389. export * from "babylonjs/Lights/hemisphericLight";
  55390. export * from "babylonjs/Lights/pointLight";
  55391. export * from "babylonjs/Lights/spotLight";
  55392. }
  55393. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55394. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55395. /**
  55396. * Header information of HDR texture files.
  55397. */
  55398. export interface HDRInfo {
  55399. /**
  55400. * The height of the texture in pixels.
  55401. */
  55402. height: number;
  55403. /**
  55404. * The width of the texture in pixels.
  55405. */
  55406. width: number;
  55407. /**
  55408. * The index of the beginning of the data in the binary file.
  55409. */
  55410. dataPosition: number;
  55411. }
  55412. /**
  55413. * This groups tools to convert HDR texture to native colors array.
  55414. */
  55415. export class HDRTools {
  55416. private static Ldexp;
  55417. private static Rgbe2float;
  55418. private static readStringLine;
  55419. /**
  55420. * Reads header information from an RGBE texture stored in a native array.
  55421. * More information on this format are available here:
  55422. * https://en.wikipedia.org/wiki/RGBE_image_format
  55423. *
  55424. * @param uint8array The binary file stored in native array.
  55425. * @return The header information.
  55426. */
  55427. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55428. /**
  55429. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55430. * This RGBE texture needs to store the information as a panorama.
  55431. *
  55432. * More information on this format are available here:
  55433. * https://en.wikipedia.org/wiki/RGBE_image_format
  55434. *
  55435. * @param buffer The binary file stored in an array buffer.
  55436. * @param size The expected size of the extracted cubemap.
  55437. * @return The Cube Map information.
  55438. */
  55439. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55440. /**
  55441. * Returns the pixels data extracted from an RGBE texture.
  55442. * This pixels will be stored left to right up to down in the R G B order in one array.
  55443. *
  55444. * More information on this format are available here:
  55445. * https://en.wikipedia.org/wiki/RGBE_image_format
  55446. *
  55447. * @param uint8array The binary file stored in an array buffer.
  55448. * @param hdrInfo The header information of the file.
  55449. * @return The pixels data in RGB right to left up to down order.
  55450. */
  55451. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55452. private static RGBE_ReadPixels_RLE;
  55453. }
  55454. }
  55455. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55456. import { Nullable } from "babylonjs/types";
  55457. import { Scene } from "babylonjs/scene";
  55458. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55460. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55461. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55462. /**
  55463. * This represents a texture coming from an HDR input.
  55464. *
  55465. * The only supported format is currently panorama picture stored in RGBE format.
  55466. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55467. */
  55468. export class HDRCubeTexture extends BaseTexture {
  55469. private static _facesMapping;
  55470. private _generateHarmonics;
  55471. private _noMipmap;
  55472. private _textureMatrix;
  55473. private _size;
  55474. private _onLoad;
  55475. private _onError;
  55476. /**
  55477. * The texture URL.
  55478. */
  55479. url: string;
  55480. /**
  55481. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55482. */
  55483. coordinatesMode: number;
  55484. protected _isBlocking: boolean;
  55485. /**
  55486. * Sets wether or not the texture is blocking during loading.
  55487. */
  55488. set isBlocking(value: boolean);
  55489. /**
  55490. * Gets wether or not the texture is blocking during loading.
  55491. */
  55492. get isBlocking(): boolean;
  55493. protected _rotationY: number;
  55494. /**
  55495. * Sets texture matrix rotation angle around Y axis in radians.
  55496. */
  55497. set rotationY(value: number);
  55498. /**
  55499. * Gets texture matrix rotation angle around Y axis radians.
  55500. */
  55501. get rotationY(): number;
  55502. /**
  55503. * Gets or sets the center of the bounding box associated with the cube texture
  55504. * It must define where the camera used to render the texture was set
  55505. */
  55506. boundingBoxPosition: Vector3;
  55507. private _boundingBoxSize;
  55508. /**
  55509. * Gets or sets the size of the bounding box associated with the cube texture
  55510. * When defined, the cubemap will switch to local mode
  55511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55512. * @example https://www.babylonjs-playground.com/#RNASML
  55513. */
  55514. set boundingBoxSize(value: Vector3);
  55515. get boundingBoxSize(): Vector3;
  55516. /**
  55517. * Instantiates an HDRTexture from the following parameters.
  55518. *
  55519. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55520. * @param scene The scene the texture will be used in
  55521. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55522. * @param noMipmap Forces to not generate the mipmap if true
  55523. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55524. * @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)
  55525. * @param reserved Reserved flag for internal use.
  55526. */
  55527. 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>);
  55528. /**
  55529. * Get the current class name of the texture useful for serialization or dynamic coding.
  55530. * @returns "HDRCubeTexture"
  55531. */
  55532. getClassName(): string;
  55533. /**
  55534. * Occurs when the file is raw .hdr file.
  55535. */
  55536. private loadTexture;
  55537. clone(): HDRCubeTexture;
  55538. delayLoad(): void;
  55539. /**
  55540. * Get the texture reflection matrix used to rotate/transform the reflection.
  55541. * @returns the reflection matrix
  55542. */
  55543. getReflectionTextureMatrix(): Matrix;
  55544. /**
  55545. * Set the texture reflection matrix used to rotate/transform the reflection.
  55546. * @param value Define the reflection matrix to set
  55547. */
  55548. setReflectionTextureMatrix(value: Matrix): void;
  55549. /**
  55550. * Parses a JSON representation of an HDR Texture in order to create the texture
  55551. * @param parsedTexture Define the JSON representation
  55552. * @param scene Define the scene the texture should be created in
  55553. * @param rootUrl Define the root url in case we need to load relative dependencies
  55554. * @returns the newly created texture after parsing
  55555. */
  55556. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55557. serialize(): any;
  55558. }
  55559. }
  55560. declare module "babylonjs/Physics/physicsEngine" {
  55561. import { Nullable } from "babylonjs/types";
  55562. import { Vector3 } from "babylonjs/Maths/math.vector";
  55563. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55564. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55565. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55566. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55567. /**
  55568. * Class used to control physics engine
  55569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55570. */
  55571. export class PhysicsEngine implements IPhysicsEngine {
  55572. private _physicsPlugin;
  55573. /**
  55574. * Global value used to control the smallest number supported by the simulation
  55575. */
  55576. static Epsilon: number;
  55577. private _impostors;
  55578. private _joints;
  55579. private _subTimeStep;
  55580. /**
  55581. * Gets the gravity vector used by the simulation
  55582. */
  55583. gravity: Vector3;
  55584. /**
  55585. * Factory used to create the default physics plugin.
  55586. * @returns The default physics plugin
  55587. */
  55588. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55589. /**
  55590. * Creates a new Physics Engine
  55591. * @param gravity defines the gravity vector used by the simulation
  55592. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55593. */
  55594. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55595. /**
  55596. * Sets the gravity vector used by the simulation
  55597. * @param gravity defines the gravity vector to use
  55598. */
  55599. setGravity(gravity: Vector3): void;
  55600. /**
  55601. * Set the time step of the physics engine.
  55602. * Default is 1/60.
  55603. * To slow it down, enter 1/600 for example.
  55604. * To speed it up, 1/30
  55605. * @param newTimeStep defines the new timestep to apply to this world.
  55606. */
  55607. setTimeStep(newTimeStep?: number): void;
  55608. /**
  55609. * Get the time step of the physics engine.
  55610. * @returns the current time step
  55611. */
  55612. getTimeStep(): number;
  55613. /**
  55614. * Set the sub time step of the physics engine.
  55615. * Default is 0 meaning there is no sub steps
  55616. * To increase physics resolution precision, set a small value (like 1 ms)
  55617. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55618. */
  55619. setSubTimeStep(subTimeStep?: number): void;
  55620. /**
  55621. * Get the sub time step of the physics engine.
  55622. * @returns the current sub time step
  55623. */
  55624. getSubTimeStep(): number;
  55625. /**
  55626. * Release all resources
  55627. */
  55628. dispose(): void;
  55629. /**
  55630. * Gets the name of the current physics plugin
  55631. * @returns the name of the plugin
  55632. */
  55633. getPhysicsPluginName(): string;
  55634. /**
  55635. * Adding a new impostor for the impostor tracking.
  55636. * This will be done by the impostor itself.
  55637. * @param impostor the impostor to add
  55638. */
  55639. addImpostor(impostor: PhysicsImpostor): void;
  55640. /**
  55641. * Remove an impostor from the engine.
  55642. * This impostor and its mesh will not longer be updated by the physics engine.
  55643. * @param impostor the impostor to remove
  55644. */
  55645. removeImpostor(impostor: PhysicsImpostor): void;
  55646. /**
  55647. * Add a joint to the physics engine
  55648. * @param mainImpostor defines the main impostor to which the joint is added.
  55649. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55650. * @param joint defines the joint that will connect both impostors.
  55651. */
  55652. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55653. /**
  55654. * Removes a joint from the simulation
  55655. * @param mainImpostor defines the impostor used with the joint
  55656. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55657. * @param joint defines the joint to remove
  55658. */
  55659. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55660. /**
  55661. * Called by the scene. No need to call it.
  55662. * @param delta defines the timespam between frames
  55663. */
  55664. _step(delta: number): void;
  55665. /**
  55666. * Gets the current plugin used to run the simulation
  55667. * @returns current plugin
  55668. */
  55669. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55670. /**
  55671. * Gets the list of physic impostors
  55672. * @returns an array of PhysicsImpostor
  55673. */
  55674. getImpostors(): Array<PhysicsImpostor>;
  55675. /**
  55676. * Gets the impostor for a physics enabled object
  55677. * @param object defines the object impersonated by the impostor
  55678. * @returns the PhysicsImpostor or null if not found
  55679. */
  55680. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55681. /**
  55682. * Gets the impostor for a physics body object
  55683. * @param body defines physics body used by the impostor
  55684. * @returns the PhysicsImpostor or null if not found
  55685. */
  55686. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55687. /**
  55688. * Does a raycast in the physics world
  55689. * @param from when should the ray start?
  55690. * @param to when should the ray end?
  55691. * @returns PhysicsRaycastResult
  55692. */
  55693. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55694. }
  55695. }
  55696. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55697. import { Nullable } from "babylonjs/types";
  55698. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55700. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55701. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55702. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55703. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55704. /** @hidden */
  55705. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55706. private _useDeltaForWorldStep;
  55707. world: any;
  55708. name: string;
  55709. private _physicsMaterials;
  55710. private _fixedTimeStep;
  55711. private _cannonRaycastResult;
  55712. private _raycastResult;
  55713. private _physicsBodysToRemoveAfterStep;
  55714. BJSCANNON: any;
  55715. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55716. setGravity(gravity: Vector3): void;
  55717. setTimeStep(timeStep: number): void;
  55718. getTimeStep(): number;
  55719. executeStep(delta: number): void;
  55720. private _removeMarkedPhysicsBodiesFromWorld;
  55721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55724. private _processChildMeshes;
  55725. removePhysicsBody(impostor: PhysicsImpostor): void;
  55726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55727. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55728. private _addMaterial;
  55729. private _checkWithEpsilon;
  55730. private _createShape;
  55731. private _createHeightmap;
  55732. private _minus90X;
  55733. private _plus90X;
  55734. private _tmpPosition;
  55735. private _tmpDeltaPosition;
  55736. private _tmpUnityRotation;
  55737. private _updatePhysicsBodyTransformation;
  55738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55740. isSupported(): boolean;
  55741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55742. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55743. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55744. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55745. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55746. getBodyMass(impostor: PhysicsImpostor): number;
  55747. getBodyFriction(impostor: PhysicsImpostor): number;
  55748. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55749. getBodyRestitution(impostor: PhysicsImpostor): number;
  55750. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55751. sleepBody(impostor: PhysicsImpostor): void;
  55752. wakeUpBody(impostor: PhysicsImpostor): void;
  55753. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55754. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55755. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55756. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55757. getRadius(impostor: PhysicsImpostor): number;
  55758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55759. dispose(): void;
  55760. private _extendNamespace;
  55761. /**
  55762. * Does a raycast in the physics world
  55763. * @param from when should the ray start?
  55764. * @param to when should the ray end?
  55765. * @returns PhysicsRaycastResult
  55766. */
  55767. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55768. }
  55769. }
  55770. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55771. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55772. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55773. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55775. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55776. import { Nullable } from "babylonjs/types";
  55777. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55778. /** @hidden */
  55779. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55780. world: any;
  55781. name: string;
  55782. BJSOIMO: any;
  55783. private _raycastResult;
  55784. constructor(iterations?: number, oimoInjection?: any);
  55785. setGravity(gravity: Vector3): void;
  55786. setTimeStep(timeStep: number): void;
  55787. getTimeStep(): number;
  55788. private _tmpImpostorsArray;
  55789. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55790. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55791. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55792. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55793. private _tmpPositionVector;
  55794. removePhysicsBody(impostor: PhysicsImpostor): void;
  55795. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55796. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55797. isSupported(): boolean;
  55798. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55799. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55800. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55801. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55802. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55805. getBodyMass(impostor: PhysicsImpostor): number;
  55806. getBodyFriction(impostor: PhysicsImpostor): number;
  55807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55808. getBodyRestitution(impostor: PhysicsImpostor): number;
  55809. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55810. sleepBody(impostor: PhysicsImpostor): void;
  55811. wakeUpBody(impostor: PhysicsImpostor): void;
  55812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55813. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55816. getRadius(impostor: PhysicsImpostor): number;
  55817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55818. dispose(): void;
  55819. /**
  55820. * Does a raycast in the physics world
  55821. * @param from when should the ray start?
  55822. * @param to when should the ray end?
  55823. * @returns PhysicsRaycastResult
  55824. */
  55825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55826. }
  55827. }
  55828. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55829. import { Nullable } from "babylonjs/types";
  55830. import { Scene } from "babylonjs/scene";
  55831. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55832. import { Color4 } from "babylonjs/Maths/math.color";
  55833. import { Mesh } from "babylonjs/Meshes/mesh";
  55834. /**
  55835. * Class containing static functions to help procedurally build meshes
  55836. */
  55837. export class RibbonBuilder {
  55838. /**
  55839. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55840. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55841. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55842. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55843. * * 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
  55844. * * 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
  55845. * * 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
  55846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55849. * * 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
  55850. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55851. * * 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
  55852. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55854. * @param name defines the name of the mesh
  55855. * @param options defines the options used to create the mesh
  55856. * @param scene defines the hosting scene
  55857. * @returns the ribbon mesh
  55858. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55860. */
  55861. static CreateRibbon(name: string, options: {
  55862. pathArray: Vector3[][];
  55863. closeArray?: boolean;
  55864. closePath?: boolean;
  55865. offset?: number;
  55866. updatable?: boolean;
  55867. sideOrientation?: number;
  55868. frontUVs?: Vector4;
  55869. backUVs?: Vector4;
  55870. instance?: Mesh;
  55871. invertUV?: boolean;
  55872. uvs?: Vector2[];
  55873. colors?: Color4[];
  55874. }, scene?: Nullable<Scene>): Mesh;
  55875. }
  55876. }
  55877. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55878. import { Nullable } from "babylonjs/types";
  55879. import { Scene } from "babylonjs/scene";
  55880. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55881. import { Mesh } from "babylonjs/Meshes/mesh";
  55882. /**
  55883. * Class containing static functions to help procedurally build meshes
  55884. */
  55885. export class ShapeBuilder {
  55886. /**
  55887. * 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.
  55888. * * 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.
  55889. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55890. * * 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.
  55891. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55892. * * 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
  55893. * * 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
  55894. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55899. * @param name defines the name of the mesh
  55900. * @param options defines the options used to create the mesh
  55901. * @param scene defines the hosting scene
  55902. * @returns the extruded shape mesh
  55903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55905. */
  55906. static ExtrudeShape(name: string, options: {
  55907. shape: Vector3[];
  55908. path: Vector3[];
  55909. scale?: number;
  55910. rotation?: number;
  55911. cap?: number;
  55912. updatable?: boolean;
  55913. sideOrientation?: number;
  55914. frontUVs?: Vector4;
  55915. backUVs?: Vector4;
  55916. instance?: Mesh;
  55917. invertUV?: boolean;
  55918. }, scene?: Nullable<Scene>): Mesh;
  55919. /**
  55920. * Creates an custom extruded shape mesh.
  55921. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55922. * * 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.
  55923. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55924. * * 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
  55925. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55926. * * 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
  55927. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55928. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55929. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55930. * * 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
  55931. * * 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
  55932. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55937. * @param name defines the name of the mesh
  55938. * @param options defines the options used to create the mesh
  55939. * @param scene defines the hosting scene
  55940. * @returns the custom extruded shape mesh
  55941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55944. */
  55945. static ExtrudeShapeCustom(name: string, options: {
  55946. shape: Vector3[];
  55947. path: Vector3[];
  55948. scaleFunction?: any;
  55949. rotationFunction?: any;
  55950. ribbonCloseArray?: boolean;
  55951. ribbonClosePath?: boolean;
  55952. cap?: number;
  55953. updatable?: boolean;
  55954. sideOrientation?: number;
  55955. frontUVs?: Vector4;
  55956. backUVs?: Vector4;
  55957. instance?: Mesh;
  55958. invertUV?: boolean;
  55959. }, scene?: Nullable<Scene>): Mesh;
  55960. private static _ExtrudeShapeGeneric;
  55961. }
  55962. }
  55963. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  55964. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  55965. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55966. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55967. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55968. import { Nullable } from "babylonjs/types";
  55969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55970. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55971. /**
  55972. * AmmoJS Physics plugin
  55973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55974. * @see https://github.com/kripken/ammo.js/
  55975. */
  55976. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55977. private _useDeltaForWorldStep;
  55978. /**
  55979. * Reference to the Ammo library
  55980. */
  55981. bjsAMMO: any;
  55982. /**
  55983. * Created ammoJS world which physics bodies are added to
  55984. */
  55985. world: any;
  55986. /**
  55987. * Name of the plugin
  55988. */
  55989. name: string;
  55990. private _timeStep;
  55991. private _fixedTimeStep;
  55992. private _maxSteps;
  55993. private _tmpQuaternion;
  55994. private _tmpAmmoTransform;
  55995. private _tmpAmmoQuaternion;
  55996. private _tmpAmmoConcreteContactResultCallback;
  55997. private _collisionConfiguration;
  55998. private _dispatcher;
  55999. private _overlappingPairCache;
  56000. private _solver;
  56001. private _softBodySolver;
  56002. private _tmpAmmoVectorA;
  56003. private _tmpAmmoVectorB;
  56004. private _tmpAmmoVectorC;
  56005. private _tmpAmmoVectorD;
  56006. private _tmpContactCallbackResult;
  56007. private _tmpAmmoVectorRCA;
  56008. private _tmpAmmoVectorRCB;
  56009. private _raycastResult;
  56010. private static readonly DISABLE_COLLISION_FLAG;
  56011. private static readonly KINEMATIC_FLAG;
  56012. private static readonly DISABLE_DEACTIVATION_FLAG;
  56013. /**
  56014. * Initializes the ammoJS plugin
  56015. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56016. * @param ammoInjection can be used to inject your own ammo reference
  56017. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56018. */
  56019. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56020. /**
  56021. * Sets the gravity of the physics world (m/(s^2))
  56022. * @param gravity Gravity to set
  56023. */
  56024. setGravity(gravity: Vector3): void;
  56025. /**
  56026. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56027. * @param timeStep timestep to use in seconds
  56028. */
  56029. setTimeStep(timeStep: number): void;
  56030. /**
  56031. * 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)
  56032. * @param fixedTimeStep fixedTimeStep to use in seconds
  56033. */
  56034. setFixedTimeStep(fixedTimeStep: number): void;
  56035. /**
  56036. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56037. * @param maxSteps the maximum number of steps by the physics engine per frame
  56038. */
  56039. setMaxSteps(maxSteps: number): void;
  56040. /**
  56041. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56042. * @returns the current timestep in seconds
  56043. */
  56044. getTimeStep(): number;
  56045. /**
  56046. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56047. */
  56048. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56049. private _isImpostorInContact;
  56050. private _isImpostorPairInContact;
  56051. private _stepSimulation;
  56052. /**
  56053. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56054. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56055. * After the step the babylon meshes are set to the position of the physics imposters
  56056. * @param delta amount of time to step forward
  56057. * @param impostors array of imposters to update before/after the step
  56058. */
  56059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56060. /**
  56061. * Update babylon mesh to match physics world object
  56062. * @param impostor imposter to match
  56063. */
  56064. private _afterSoftStep;
  56065. /**
  56066. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56067. * @param impostor imposter to match
  56068. */
  56069. private _ropeStep;
  56070. /**
  56071. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56072. * @param impostor imposter to match
  56073. */
  56074. private _softbodyOrClothStep;
  56075. private _tmpVector;
  56076. private _tmpMatrix;
  56077. /**
  56078. * Applies an impulse on the imposter
  56079. * @param impostor imposter to apply impulse to
  56080. * @param force amount of force to be applied to the imposter
  56081. * @param contactPoint the location to apply the impulse on the imposter
  56082. */
  56083. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56084. /**
  56085. * Applies a force on the imposter
  56086. * @param impostor imposter to apply force
  56087. * @param force amount of force to be applied to the imposter
  56088. * @param contactPoint the location to apply the force on the imposter
  56089. */
  56090. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56091. /**
  56092. * Creates a physics body using the plugin
  56093. * @param impostor the imposter to create the physics body on
  56094. */
  56095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56096. /**
  56097. * Removes the physics body from the imposter and disposes of the body's memory
  56098. * @param impostor imposter to remove the physics body from
  56099. */
  56100. removePhysicsBody(impostor: PhysicsImpostor): void;
  56101. /**
  56102. * Generates a joint
  56103. * @param impostorJoint the imposter joint to create the joint with
  56104. */
  56105. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56106. /**
  56107. * Removes a joint
  56108. * @param impostorJoint the imposter joint to remove the joint from
  56109. */
  56110. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56111. private _addMeshVerts;
  56112. /**
  56113. * Initialise the soft body vertices to match its object's (mesh) vertices
  56114. * Softbody vertices (nodes) are in world space and to match this
  56115. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56116. * @param impostor to create the softbody for
  56117. */
  56118. private _softVertexData;
  56119. /**
  56120. * Create an impostor's soft body
  56121. * @param impostor to create the softbody for
  56122. */
  56123. private _createSoftbody;
  56124. /**
  56125. * Create cloth for an impostor
  56126. * @param impostor to create the softbody for
  56127. */
  56128. private _createCloth;
  56129. /**
  56130. * Create rope for an impostor
  56131. * @param impostor to create the softbody for
  56132. */
  56133. private _createRope;
  56134. /**
  56135. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56136. * @param impostor to create the custom physics shape for
  56137. */
  56138. private _createCustom;
  56139. private _addHullVerts;
  56140. private _createShape;
  56141. /**
  56142. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56143. * @param impostor imposter containing the physics body and babylon object
  56144. */
  56145. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56146. /**
  56147. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56148. * @param impostor imposter containing the physics body and babylon object
  56149. * @param newPosition new position
  56150. * @param newRotation new rotation
  56151. */
  56152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56153. /**
  56154. * If this plugin is supported
  56155. * @returns true if its supported
  56156. */
  56157. isSupported(): boolean;
  56158. /**
  56159. * Sets the linear velocity of the physics body
  56160. * @param impostor imposter to set the velocity on
  56161. * @param velocity velocity to set
  56162. */
  56163. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56164. /**
  56165. * Sets the angular velocity of the physics body
  56166. * @param impostor imposter to set the velocity on
  56167. * @param velocity velocity to set
  56168. */
  56169. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56170. /**
  56171. * gets the linear velocity
  56172. * @param impostor imposter to get linear velocity from
  56173. * @returns linear velocity
  56174. */
  56175. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56176. /**
  56177. * gets the angular velocity
  56178. * @param impostor imposter to get angular velocity from
  56179. * @returns angular velocity
  56180. */
  56181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56182. /**
  56183. * Sets the mass of physics body
  56184. * @param impostor imposter to set the mass on
  56185. * @param mass mass to set
  56186. */
  56187. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56188. /**
  56189. * Gets the mass of the physics body
  56190. * @param impostor imposter to get the mass from
  56191. * @returns mass
  56192. */
  56193. getBodyMass(impostor: PhysicsImpostor): number;
  56194. /**
  56195. * Gets friction of the impostor
  56196. * @param impostor impostor to get friction from
  56197. * @returns friction value
  56198. */
  56199. getBodyFriction(impostor: PhysicsImpostor): number;
  56200. /**
  56201. * Sets friction of the impostor
  56202. * @param impostor impostor to set friction on
  56203. * @param friction friction value
  56204. */
  56205. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56206. /**
  56207. * Gets restitution of the impostor
  56208. * @param impostor impostor to get restitution from
  56209. * @returns restitution value
  56210. */
  56211. getBodyRestitution(impostor: PhysicsImpostor): number;
  56212. /**
  56213. * Sets resitution of the impostor
  56214. * @param impostor impostor to set resitution on
  56215. * @param restitution resitution value
  56216. */
  56217. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56218. /**
  56219. * Gets pressure inside the impostor
  56220. * @param impostor impostor to get pressure from
  56221. * @returns pressure value
  56222. */
  56223. getBodyPressure(impostor: PhysicsImpostor): number;
  56224. /**
  56225. * Sets pressure inside a soft body impostor
  56226. * Cloth and rope must remain 0 pressure
  56227. * @param impostor impostor to set pressure on
  56228. * @param pressure pressure value
  56229. */
  56230. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56231. /**
  56232. * Gets stiffness of the impostor
  56233. * @param impostor impostor to get stiffness from
  56234. * @returns pressure value
  56235. */
  56236. getBodyStiffness(impostor: PhysicsImpostor): number;
  56237. /**
  56238. * Sets stiffness of the impostor
  56239. * @param impostor impostor to set stiffness on
  56240. * @param stiffness stiffness value from 0 to 1
  56241. */
  56242. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56243. /**
  56244. * Gets velocityIterations of the impostor
  56245. * @param impostor impostor to get velocity iterations from
  56246. * @returns velocityIterations value
  56247. */
  56248. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56249. /**
  56250. * Sets velocityIterations of the impostor
  56251. * @param impostor impostor to set velocity iterations on
  56252. * @param velocityIterations velocityIterations value
  56253. */
  56254. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56255. /**
  56256. * Gets positionIterations of the impostor
  56257. * @param impostor impostor to get position iterations from
  56258. * @returns positionIterations value
  56259. */
  56260. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56261. /**
  56262. * Sets positionIterations of the impostor
  56263. * @param impostor impostor to set position on
  56264. * @param positionIterations positionIterations value
  56265. */
  56266. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56267. /**
  56268. * Append an anchor to a cloth object
  56269. * @param impostor is the cloth impostor to add anchor to
  56270. * @param otherImpostor is the rigid impostor to anchor to
  56271. * @param width ratio across width from 0 to 1
  56272. * @param height ratio up height from 0 to 1
  56273. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56274. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56275. */
  56276. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56277. /**
  56278. * Append an hook to a rope object
  56279. * @param impostor is the rope impostor to add hook to
  56280. * @param otherImpostor is the rigid impostor to hook to
  56281. * @param length ratio along the rope from 0 to 1
  56282. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56283. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56284. */
  56285. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56286. /**
  56287. * Sleeps the physics body and stops it from being active
  56288. * @param impostor impostor to sleep
  56289. */
  56290. sleepBody(impostor: PhysicsImpostor): void;
  56291. /**
  56292. * Activates the physics body
  56293. * @param impostor impostor to activate
  56294. */
  56295. wakeUpBody(impostor: PhysicsImpostor): void;
  56296. /**
  56297. * Updates the distance parameters of the joint
  56298. * @param joint joint to update
  56299. * @param maxDistance maximum distance of the joint
  56300. * @param minDistance minimum distance of the joint
  56301. */
  56302. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56303. /**
  56304. * Sets a motor on the joint
  56305. * @param joint joint to set motor on
  56306. * @param speed speed of the motor
  56307. * @param maxForce maximum force of the motor
  56308. * @param motorIndex index of the motor
  56309. */
  56310. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56311. /**
  56312. * Sets the motors limit
  56313. * @param joint joint to set limit on
  56314. * @param upperLimit upper limit
  56315. * @param lowerLimit lower limit
  56316. */
  56317. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56318. /**
  56319. * Syncs the position and rotation of a mesh with the impostor
  56320. * @param mesh mesh to sync
  56321. * @param impostor impostor to update the mesh with
  56322. */
  56323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56324. /**
  56325. * Gets the radius of the impostor
  56326. * @param impostor impostor to get radius from
  56327. * @returns the radius
  56328. */
  56329. getRadius(impostor: PhysicsImpostor): number;
  56330. /**
  56331. * Gets the box size of the impostor
  56332. * @param impostor impostor to get box size from
  56333. * @param result the resulting box size
  56334. */
  56335. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56336. /**
  56337. * Disposes of the impostor
  56338. */
  56339. dispose(): void;
  56340. /**
  56341. * Does a raycast in the physics world
  56342. * @param from when should the ray start?
  56343. * @param to when should the ray end?
  56344. * @returns PhysicsRaycastResult
  56345. */
  56346. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56347. }
  56348. }
  56349. declare module "babylonjs/Probes/reflectionProbe" {
  56350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56351. import { Vector3 } from "babylonjs/Maths/math.vector";
  56352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56353. import { Nullable } from "babylonjs/types";
  56354. import { Scene } from "babylonjs/scene";
  56355. module "babylonjs/abstractScene" {
  56356. interface AbstractScene {
  56357. /**
  56358. * The list of reflection probes added to the scene
  56359. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56360. */
  56361. reflectionProbes: Array<ReflectionProbe>;
  56362. /**
  56363. * Removes the given reflection probe from this scene.
  56364. * @param toRemove The reflection probe to remove
  56365. * @returns The index of the removed reflection probe
  56366. */
  56367. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56368. /**
  56369. * Adds the given reflection probe to this scene.
  56370. * @param newReflectionProbe The reflection probe to add
  56371. */
  56372. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56373. }
  56374. }
  56375. /**
  56376. * Class used to generate realtime reflection / refraction cube textures
  56377. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56378. */
  56379. export class ReflectionProbe {
  56380. /** defines the name of the probe */
  56381. name: string;
  56382. private _scene;
  56383. private _renderTargetTexture;
  56384. private _projectionMatrix;
  56385. private _viewMatrix;
  56386. private _target;
  56387. private _add;
  56388. private _attachedMesh;
  56389. private _invertYAxis;
  56390. /** Gets or sets probe position (center of the cube map) */
  56391. position: Vector3;
  56392. /**
  56393. * Creates a new reflection probe
  56394. * @param name defines the name of the probe
  56395. * @param size defines the texture resolution (for each face)
  56396. * @param scene defines the hosting scene
  56397. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56398. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56399. */
  56400. constructor(
  56401. /** defines the name of the probe */
  56402. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56403. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56404. get samples(): number;
  56405. set samples(value: number);
  56406. /** Gets or sets the refresh rate to use (on every frame by default) */
  56407. get refreshRate(): number;
  56408. set refreshRate(value: number);
  56409. /**
  56410. * Gets the hosting scene
  56411. * @returns a Scene
  56412. */
  56413. getScene(): Scene;
  56414. /** Gets the internal CubeTexture used to render to */
  56415. get cubeTexture(): RenderTargetTexture;
  56416. /** Gets the list of meshes to render */
  56417. get renderList(): Nullable<AbstractMesh[]>;
  56418. /**
  56419. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56420. * @param mesh defines the mesh to attach to
  56421. */
  56422. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56423. /**
  56424. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56425. * @param renderingGroupId The rendering group id corresponding to its index
  56426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56427. */
  56428. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56429. /**
  56430. * Clean all associated resources
  56431. */
  56432. dispose(): void;
  56433. /**
  56434. * Converts the reflection probe information to a readable string for debug purpose.
  56435. * @param fullDetails Supports for multiple levels of logging within scene loading
  56436. * @returns the human readable reflection probe info
  56437. */
  56438. toString(fullDetails?: boolean): string;
  56439. /**
  56440. * Get the class name of the relfection probe.
  56441. * @returns "ReflectionProbe"
  56442. */
  56443. getClassName(): string;
  56444. /**
  56445. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56446. * @returns The JSON representation of the texture
  56447. */
  56448. serialize(): any;
  56449. /**
  56450. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56451. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56452. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56453. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56454. * @returns The parsed reflection probe if successful
  56455. */
  56456. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56457. }
  56458. }
  56459. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56460. /** @hidden */
  56461. export var _BabylonLoaderRegistered: boolean;
  56462. /**
  56463. * Helps setting up some configuration for the babylon file loader.
  56464. */
  56465. export class BabylonFileLoaderConfiguration {
  56466. /**
  56467. * The loader does not allow injecting custom physix engine into the plugins.
  56468. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56469. * So you could set this variable to your engine import to make it work.
  56470. */
  56471. static LoaderInjectedPhysicsEngine: any;
  56472. }
  56473. }
  56474. declare module "babylonjs/Loading/Plugins/index" {
  56475. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56476. }
  56477. declare module "babylonjs/Loading/index" {
  56478. export * from "babylonjs/Loading/loadingScreen";
  56479. export * from "babylonjs/Loading/Plugins/index";
  56480. export * from "babylonjs/Loading/sceneLoader";
  56481. export * from "babylonjs/Loading/sceneLoaderFlags";
  56482. }
  56483. declare module "babylonjs/Materials/Background/index" {
  56484. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56485. }
  56486. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56487. import { Scene } from "babylonjs/scene";
  56488. import { Color3 } from "babylonjs/Maths/math.color";
  56489. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56491. /**
  56492. * The Physically based simple base material of BJS.
  56493. *
  56494. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56495. * It is used as the base class for both the specGloss and metalRough conventions.
  56496. */
  56497. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56498. /**
  56499. * Number of Simultaneous lights allowed on the material.
  56500. */
  56501. maxSimultaneousLights: number;
  56502. /**
  56503. * If sets to true, disables all the lights affecting the material.
  56504. */
  56505. disableLighting: boolean;
  56506. /**
  56507. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56508. */
  56509. environmentTexture: BaseTexture;
  56510. /**
  56511. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56512. */
  56513. invertNormalMapX: boolean;
  56514. /**
  56515. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56516. */
  56517. invertNormalMapY: boolean;
  56518. /**
  56519. * Normal map used in the model.
  56520. */
  56521. normalTexture: BaseTexture;
  56522. /**
  56523. * Emissivie color used to self-illuminate the model.
  56524. */
  56525. emissiveColor: Color3;
  56526. /**
  56527. * Emissivie texture used to self-illuminate the model.
  56528. */
  56529. emissiveTexture: BaseTexture;
  56530. /**
  56531. * Occlusion Channel Strenght.
  56532. */
  56533. occlusionStrength: number;
  56534. /**
  56535. * Occlusion Texture of the material (adding extra occlusion effects).
  56536. */
  56537. occlusionTexture: BaseTexture;
  56538. /**
  56539. * Defines the alpha limits in alpha test mode.
  56540. */
  56541. alphaCutOff: number;
  56542. /**
  56543. * Gets the current double sided mode.
  56544. */
  56545. get doubleSided(): boolean;
  56546. /**
  56547. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56548. */
  56549. set doubleSided(value: boolean);
  56550. /**
  56551. * Stores the pre-calculated light information of a mesh in a texture.
  56552. */
  56553. lightmapTexture: BaseTexture;
  56554. /**
  56555. * If true, the light map contains occlusion information instead of lighting info.
  56556. */
  56557. useLightmapAsShadowmap: boolean;
  56558. /**
  56559. * Instantiates a new PBRMaterial instance.
  56560. *
  56561. * @param name The material name
  56562. * @param scene The scene the material will be use in.
  56563. */
  56564. constructor(name: string, scene: Scene);
  56565. getClassName(): string;
  56566. }
  56567. }
  56568. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56569. import { Scene } from "babylonjs/scene";
  56570. import { Color3 } from "babylonjs/Maths/math.color";
  56571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56572. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56573. /**
  56574. * The PBR material of BJS following the metal roughness convention.
  56575. *
  56576. * This fits to the PBR convention in the GLTF definition:
  56577. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56578. */
  56579. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56580. /**
  56581. * The base color has two different interpretations depending on the value of metalness.
  56582. * When the material is a metal, the base color is the specific measured reflectance value
  56583. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56584. * of the material.
  56585. */
  56586. baseColor: Color3;
  56587. /**
  56588. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56589. * well as opacity information in the alpha channel.
  56590. */
  56591. baseTexture: BaseTexture;
  56592. /**
  56593. * Specifies the metallic scalar value of the material.
  56594. * Can also be used to scale the metalness values of the metallic texture.
  56595. */
  56596. metallic: number;
  56597. /**
  56598. * Specifies the roughness scalar value of the material.
  56599. * Can also be used to scale the roughness values of the metallic texture.
  56600. */
  56601. roughness: number;
  56602. /**
  56603. * Texture containing both the metallic value in the B channel and the
  56604. * roughness value in the G channel to keep better precision.
  56605. */
  56606. metallicRoughnessTexture: BaseTexture;
  56607. /**
  56608. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56609. *
  56610. * @param name The material name
  56611. * @param scene The scene the material will be use in.
  56612. */
  56613. constructor(name: string, scene: Scene);
  56614. /**
  56615. * Return the currrent class name of the material.
  56616. */
  56617. getClassName(): string;
  56618. /**
  56619. * Makes a duplicate of the current material.
  56620. * @param name - name to use for the new material.
  56621. */
  56622. clone(name: string): PBRMetallicRoughnessMaterial;
  56623. /**
  56624. * Serialize the material to a parsable JSON object.
  56625. */
  56626. serialize(): any;
  56627. /**
  56628. * Parses a JSON object correponding to the serialize function.
  56629. */
  56630. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56631. }
  56632. }
  56633. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56634. import { Scene } from "babylonjs/scene";
  56635. import { Color3 } from "babylonjs/Maths/math.color";
  56636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56637. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56638. /**
  56639. * The PBR material of BJS following the specular glossiness convention.
  56640. *
  56641. * This fits to the PBR convention in the GLTF definition:
  56642. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56643. */
  56644. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56645. /**
  56646. * Specifies the diffuse color of the material.
  56647. */
  56648. diffuseColor: Color3;
  56649. /**
  56650. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56651. * channel.
  56652. */
  56653. diffuseTexture: BaseTexture;
  56654. /**
  56655. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56656. */
  56657. specularColor: Color3;
  56658. /**
  56659. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56660. */
  56661. glossiness: number;
  56662. /**
  56663. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56664. */
  56665. specularGlossinessTexture: BaseTexture;
  56666. /**
  56667. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56668. *
  56669. * @param name The material name
  56670. * @param scene The scene the material will be use in.
  56671. */
  56672. constructor(name: string, scene: Scene);
  56673. /**
  56674. * Return the currrent class name of the material.
  56675. */
  56676. getClassName(): string;
  56677. /**
  56678. * Makes a duplicate of the current material.
  56679. * @param name - name to use for the new material.
  56680. */
  56681. clone(name: string): PBRSpecularGlossinessMaterial;
  56682. /**
  56683. * Serialize the material to a parsable JSON object.
  56684. */
  56685. serialize(): any;
  56686. /**
  56687. * Parses a JSON object correponding to the serialize function.
  56688. */
  56689. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56690. }
  56691. }
  56692. declare module "babylonjs/Materials/PBR/index" {
  56693. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56694. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56695. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56696. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56697. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56698. }
  56699. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56700. import { Nullable } from "babylonjs/types";
  56701. import { Scene } from "babylonjs/scene";
  56702. import { Matrix } from "babylonjs/Maths/math.vector";
  56703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56704. /**
  56705. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56706. * It can help converting any input color in a desired output one. This can then be used to create effects
  56707. * from sepia, black and white to sixties or futuristic rendering...
  56708. *
  56709. * The only supported format is currently 3dl.
  56710. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56711. */
  56712. export class ColorGradingTexture extends BaseTexture {
  56713. /**
  56714. * The current texture matrix. (will always be identity in color grading texture)
  56715. */
  56716. private _textureMatrix;
  56717. /**
  56718. * The texture URL.
  56719. */
  56720. url: string;
  56721. /**
  56722. * Empty line regex stored for GC.
  56723. */
  56724. private static _noneEmptyLineRegex;
  56725. private _engine;
  56726. /**
  56727. * Instantiates a ColorGradingTexture from the following parameters.
  56728. *
  56729. * @param url The location of the color gradind data (currently only supporting 3dl)
  56730. * @param scene The scene the texture will be used in
  56731. */
  56732. constructor(url: string, scene: Scene);
  56733. /**
  56734. * Returns the texture matrix used in most of the material.
  56735. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56736. */
  56737. getTextureMatrix(): Matrix;
  56738. /**
  56739. * Occurs when the file being loaded is a .3dl LUT file.
  56740. */
  56741. private load3dlTexture;
  56742. /**
  56743. * Starts the loading process of the texture.
  56744. */
  56745. private loadTexture;
  56746. /**
  56747. * Clones the color gradind texture.
  56748. */
  56749. clone(): ColorGradingTexture;
  56750. /**
  56751. * Called during delayed load for textures.
  56752. */
  56753. delayLoad(): void;
  56754. /**
  56755. * Parses a color grading texture serialized by Babylon.
  56756. * @param parsedTexture The texture information being parsedTexture
  56757. * @param scene The scene to load the texture in
  56758. * @param rootUrl The root url of the data assets to load
  56759. * @return A color gradind texture
  56760. */
  56761. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56762. /**
  56763. * Serializes the LUT texture to json format.
  56764. */
  56765. serialize(): any;
  56766. }
  56767. }
  56768. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56770. import { Scene } from "babylonjs/scene";
  56771. import { Nullable } from "babylonjs/types";
  56772. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56773. /**
  56774. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56775. */
  56776. export class EquiRectangularCubeTexture extends BaseTexture {
  56777. /** The six faces of the cube. */
  56778. private static _FacesMapping;
  56779. private _noMipmap;
  56780. private _onLoad;
  56781. private _onError;
  56782. /** The size of the cubemap. */
  56783. private _size;
  56784. /** The buffer of the image. */
  56785. private _buffer;
  56786. /** The width of the input image. */
  56787. private _width;
  56788. /** The height of the input image. */
  56789. private _height;
  56790. /** The URL to the image. */
  56791. url: string;
  56792. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56793. coordinatesMode: number;
  56794. /**
  56795. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56796. * @param url The location of the image
  56797. * @param scene The scene the texture will be used in
  56798. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56799. * @param noMipmap Forces to not generate the mipmap if true
  56800. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56801. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56802. * @param onLoad — defines a callback called when texture is loaded
  56803. * @param onError — defines a callback called if there is an error
  56804. */
  56805. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56806. /**
  56807. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56808. */
  56809. private loadImage;
  56810. /**
  56811. * Convert the image buffer into a cubemap and create a CubeTexture.
  56812. */
  56813. private loadTexture;
  56814. /**
  56815. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56816. * @param buffer The ArrayBuffer that should be converted.
  56817. * @returns The buffer as Float32Array.
  56818. */
  56819. private getFloat32ArrayFromArrayBuffer;
  56820. /**
  56821. * Get the current class name of the texture useful for serialization or dynamic coding.
  56822. * @returns "EquiRectangularCubeTexture"
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56827. * @returns A clone of the current EquiRectangularCubeTexture.
  56828. */
  56829. clone(): EquiRectangularCubeTexture;
  56830. }
  56831. }
  56832. declare module "babylonjs/Misc/tga" {
  56833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56834. /**
  56835. * Based on jsTGALoader - Javascript loader for TGA file
  56836. * By Vincent Thibault
  56837. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56838. */
  56839. export class TGATools {
  56840. private static _TYPE_INDEXED;
  56841. private static _TYPE_RGB;
  56842. private static _TYPE_GREY;
  56843. private static _TYPE_RLE_INDEXED;
  56844. private static _TYPE_RLE_RGB;
  56845. private static _TYPE_RLE_GREY;
  56846. private static _ORIGIN_MASK;
  56847. private static _ORIGIN_SHIFT;
  56848. private static _ORIGIN_BL;
  56849. private static _ORIGIN_BR;
  56850. private static _ORIGIN_UL;
  56851. private static _ORIGIN_UR;
  56852. /**
  56853. * Gets the header of a TGA file
  56854. * @param data defines the TGA data
  56855. * @returns the header
  56856. */
  56857. static GetTGAHeader(data: Uint8Array): any;
  56858. /**
  56859. * Uploads TGA content to a Babylon Texture
  56860. * @hidden
  56861. */
  56862. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56863. /** @hidden */
  56864. 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;
  56865. /** @hidden */
  56866. 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;
  56867. /** @hidden */
  56868. 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;
  56869. /** @hidden */
  56870. 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;
  56871. /** @hidden */
  56872. 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;
  56873. /** @hidden */
  56874. 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;
  56875. }
  56876. }
  56877. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56878. import { Nullable } from "babylonjs/types";
  56879. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56880. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56881. /**
  56882. * Implementation of the TGA Texture Loader.
  56883. * @hidden
  56884. */
  56885. export class _TGATextureLoader implements IInternalTextureLoader {
  56886. /**
  56887. * Defines wether the loader supports cascade loading the different faces.
  56888. */
  56889. readonly supportCascades: boolean;
  56890. /**
  56891. * This returns if the loader support the current file information.
  56892. * @param extension defines the file extension of the file being loaded
  56893. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56894. * @param fallback defines the fallback internal texture if any
  56895. * @param isBase64 defines whether the texture is encoded as a base64
  56896. * @param isBuffer defines whether the texture data are stored as a buffer
  56897. * @returns true if the loader can load the specified file
  56898. */
  56899. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56900. /**
  56901. * Transform the url before loading if required.
  56902. * @param rootUrl the url of the texture
  56903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56904. * @returns the transformed texture
  56905. */
  56906. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56907. /**
  56908. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56909. * @param rootUrl the url of the texture
  56910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56911. * @returns the fallback texture
  56912. */
  56913. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56914. /**
  56915. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56916. * @param data contains the texture data
  56917. * @param texture defines the BabylonJS internal texture
  56918. * @param createPolynomials will be true if polynomials have been requested
  56919. * @param onLoad defines the callback to trigger once the texture is ready
  56920. * @param onError defines the callback to trigger in case of error
  56921. */
  56922. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56923. /**
  56924. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56925. * @param data contains the texture data
  56926. * @param texture defines the BabylonJS internal texture
  56927. * @param callback defines the method to call once ready to upload
  56928. */
  56929. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56930. }
  56931. }
  56932. declare module "babylonjs/Misc/basis" {
  56933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56934. /**
  56935. * Info about the .basis files
  56936. */
  56937. class BasisFileInfo {
  56938. /**
  56939. * If the file has alpha
  56940. */
  56941. hasAlpha: boolean;
  56942. /**
  56943. * Info about each image of the basis file
  56944. */
  56945. images: Array<{
  56946. levels: Array<{
  56947. width: number;
  56948. height: number;
  56949. transcodedPixels: ArrayBufferView;
  56950. }>;
  56951. }>;
  56952. }
  56953. /**
  56954. * Result of transcoding a basis file
  56955. */
  56956. class TranscodeResult {
  56957. /**
  56958. * Info about the .basis file
  56959. */
  56960. fileInfo: BasisFileInfo;
  56961. /**
  56962. * Format to use when loading the file
  56963. */
  56964. format: number;
  56965. }
  56966. /**
  56967. * Configuration options for the Basis transcoder
  56968. */
  56969. export class BasisTranscodeConfiguration {
  56970. /**
  56971. * Supported compression formats used to determine the supported output format of the transcoder
  56972. */
  56973. supportedCompressionFormats?: {
  56974. /**
  56975. * etc1 compression format
  56976. */
  56977. etc1?: boolean;
  56978. /**
  56979. * s3tc compression format
  56980. */
  56981. s3tc?: boolean;
  56982. /**
  56983. * pvrtc compression format
  56984. */
  56985. pvrtc?: boolean;
  56986. /**
  56987. * etc2 compression format
  56988. */
  56989. etc2?: boolean;
  56990. };
  56991. /**
  56992. * If mipmap levels should be loaded for transcoded images (Default: true)
  56993. */
  56994. loadMipmapLevels?: boolean;
  56995. /**
  56996. * Index of a single image to load (Default: all images)
  56997. */
  56998. loadSingleImage?: number;
  56999. }
  57000. /**
  57001. * Used to load .Basis files
  57002. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57003. */
  57004. export class BasisTools {
  57005. private static _IgnoreSupportedFormats;
  57006. /**
  57007. * URL to use when loading the basis transcoder
  57008. */
  57009. static JSModuleURL: string;
  57010. /**
  57011. * URL to use when loading the wasm module for the transcoder
  57012. */
  57013. static WasmModuleURL: string;
  57014. /**
  57015. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57016. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57017. * @returns internal format corresponding to the Basis format
  57018. */
  57019. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57020. private static _WorkerPromise;
  57021. private static _Worker;
  57022. private static _actionId;
  57023. private static _CreateWorkerAsync;
  57024. /**
  57025. * Transcodes a loaded image file to compressed pixel data
  57026. * @param imageData image data to transcode
  57027. * @param config configuration options for the transcoding
  57028. * @returns a promise resulting in the transcoded image
  57029. */
  57030. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57031. /**
  57032. * Loads a texture from the transcode result
  57033. * @param texture texture load to
  57034. * @param transcodeResult the result of transcoding the basis file to load from
  57035. */
  57036. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57037. }
  57038. }
  57039. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57040. import { Nullable } from "babylonjs/types";
  57041. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57042. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57043. /**
  57044. * Loader for .basis file format
  57045. */
  57046. export class _BasisTextureLoader implements IInternalTextureLoader {
  57047. /**
  57048. * Defines whether the loader supports cascade loading the different faces.
  57049. */
  57050. readonly supportCascades: boolean;
  57051. /**
  57052. * This returns if the loader support the current file information.
  57053. * @param extension defines the file extension of the file being loaded
  57054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57055. * @param fallback defines the fallback internal texture if any
  57056. * @param isBase64 defines whether the texture is encoded as a base64
  57057. * @param isBuffer defines whether the texture data are stored as a buffer
  57058. * @returns true if the loader can load the specified file
  57059. */
  57060. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57061. /**
  57062. * Transform the url before loading if required.
  57063. * @param rootUrl the url of the texture
  57064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57065. * @returns the transformed texture
  57066. */
  57067. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57068. /**
  57069. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57070. * @param rootUrl the url of the texture
  57071. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57072. * @returns the fallback texture
  57073. */
  57074. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57075. /**
  57076. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57077. * @param data contains the texture data
  57078. * @param texture defines the BabylonJS internal texture
  57079. * @param createPolynomials will be true if polynomials have been requested
  57080. * @param onLoad defines the callback to trigger once the texture is ready
  57081. * @param onError defines the callback to trigger in case of error
  57082. */
  57083. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57084. /**
  57085. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57086. * @param data contains the texture data
  57087. * @param texture defines the BabylonJS internal texture
  57088. * @param callback defines the method to call once ready to upload
  57089. */
  57090. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57091. }
  57092. }
  57093. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57094. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57095. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57096. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57097. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57098. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57099. }
  57100. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57101. import { Scene } from "babylonjs/scene";
  57102. import { Texture } from "babylonjs/Materials/Textures/texture";
  57103. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57104. /**
  57105. * 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.
  57106. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57107. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57108. */
  57109. export class CustomProceduralTexture extends ProceduralTexture {
  57110. private _animate;
  57111. private _time;
  57112. private _config;
  57113. private _texturePath;
  57114. /**
  57115. * Instantiates a new Custom Procedural Texture.
  57116. * 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.
  57117. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57118. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57119. * @param name Define the name of the texture
  57120. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57121. * @param size Define the size of the texture to create
  57122. * @param scene Define the scene the texture belongs to
  57123. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57124. * @param generateMipMaps Define if the texture should creates mip maps or not
  57125. */
  57126. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57127. private _loadJson;
  57128. /**
  57129. * Is the texture ready to be used ? (rendered at least once)
  57130. * @returns true if ready, otherwise, false.
  57131. */
  57132. isReady(): boolean;
  57133. /**
  57134. * Render the texture to its associated render target.
  57135. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57136. */
  57137. render(useCameraPostProcess?: boolean): void;
  57138. /**
  57139. * Update the list of dependant textures samplers in the shader.
  57140. */
  57141. updateTextures(): void;
  57142. /**
  57143. * Update the uniform values of the procedural texture in the shader.
  57144. */
  57145. updateShaderUniforms(): void;
  57146. /**
  57147. * Define if the texture animates or not.
  57148. */
  57149. get animate(): boolean;
  57150. set animate(value: boolean);
  57151. }
  57152. }
  57153. declare module "babylonjs/Shaders/noise.fragment" {
  57154. /** @hidden */
  57155. export var noisePixelShader: {
  57156. name: string;
  57157. shader: string;
  57158. };
  57159. }
  57160. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57161. import { Nullable } from "babylonjs/types";
  57162. import { Scene } from "babylonjs/scene";
  57163. import { Texture } from "babylonjs/Materials/Textures/texture";
  57164. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57165. import "babylonjs/Shaders/noise.fragment";
  57166. /**
  57167. * Class used to generate noise procedural textures
  57168. */
  57169. export class NoiseProceduralTexture extends ProceduralTexture {
  57170. private _time;
  57171. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57172. brightness: number;
  57173. /** Defines the number of octaves to process */
  57174. octaves: number;
  57175. /** Defines the level of persistence (0.8 by default) */
  57176. persistence: number;
  57177. /** Gets or sets animation speed factor (default is 1) */
  57178. animationSpeedFactor: number;
  57179. /**
  57180. * Creates a new NoiseProceduralTexture
  57181. * @param name defines the name fo the texture
  57182. * @param size defines the size of the texture (default is 256)
  57183. * @param scene defines the hosting scene
  57184. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57185. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57186. */
  57187. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57188. private _updateShaderUniforms;
  57189. protected _getDefines(): string;
  57190. /** Generate the current state of the procedural texture */
  57191. render(useCameraPostProcess?: boolean): void;
  57192. /**
  57193. * Serializes this noise procedural texture
  57194. * @returns a serialized noise procedural texture object
  57195. */
  57196. serialize(): any;
  57197. /**
  57198. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57199. * @param parsedTexture defines parsed texture data
  57200. * @param scene defines the current scene
  57201. * @param rootUrl defines the root URL containing noise procedural texture information
  57202. * @returns a parsed NoiseProceduralTexture
  57203. */
  57204. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57205. }
  57206. }
  57207. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57208. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57209. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57210. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57211. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57212. }
  57213. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57214. import { Nullable } from "babylonjs/types";
  57215. import { Scene } from "babylonjs/scene";
  57216. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57218. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57219. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57220. /**
  57221. * Raw cube texture where the raw buffers are passed in
  57222. */
  57223. export class RawCubeTexture extends CubeTexture {
  57224. /**
  57225. * Creates a cube texture where the raw buffers are passed in.
  57226. * @param scene defines the scene the texture is attached to
  57227. * @param data defines the array of data to use to create each face
  57228. * @param size defines the size of the textures
  57229. * @param format defines the format of the data
  57230. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57231. * @param generateMipMaps defines if the engine should generate the mip levels
  57232. * @param invertY defines if data must be stored with Y axis inverted
  57233. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57234. * @param compression defines the compression used (null by default)
  57235. */
  57236. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57237. /**
  57238. * Updates the raw cube texture.
  57239. * @param data defines the data to store
  57240. * @param format defines the data format
  57241. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57242. * @param invertY defines if data must be stored with Y axis inverted
  57243. * @param compression defines the compression used (null by default)
  57244. * @param level defines which level of the texture to update
  57245. */
  57246. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57247. /**
  57248. * Updates a raw cube texture with RGBD encoded data.
  57249. * @param data defines the array of data [mipmap][face] to use to create each face
  57250. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57251. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57252. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57253. * @returns a promsie that resolves when the operation is complete
  57254. */
  57255. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57256. /**
  57257. * Clones the raw cube texture.
  57258. * @return a new cube texture
  57259. */
  57260. clone(): CubeTexture;
  57261. /** @hidden */
  57262. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57263. }
  57264. }
  57265. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57266. import { Scene } from "babylonjs/scene";
  57267. import { Texture } from "babylonjs/Materials/Textures/texture";
  57268. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57269. /**
  57270. * Class used to store 3D textures containing user data
  57271. */
  57272. export class RawTexture3D extends Texture {
  57273. /** Gets or sets the texture format to use */
  57274. format: number;
  57275. private _engine;
  57276. /**
  57277. * Create a new RawTexture3D
  57278. * @param data defines the data of the texture
  57279. * @param width defines the width of the texture
  57280. * @param height defines the height of the texture
  57281. * @param depth defines the depth of the texture
  57282. * @param format defines the texture format to use
  57283. * @param scene defines the hosting scene
  57284. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57285. * @param invertY defines if texture must be stored with Y axis inverted
  57286. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57287. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57288. */
  57289. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57290. /** Gets or sets the texture format to use */
  57291. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57292. /**
  57293. * Update the texture with new data
  57294. * @param data defines the data to store in the texture
  57295. */
  57296. update(data: ArrayBufferView): void;
  57297. }
  57298. }
  57299. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57300. import { Scene } from "babylonjs/scene";
  57301. import { Texture } from "babylonjs/Materials/Textures/texture";
  57302. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57303. /**
  57304. * Class used to store 2D array textures containing user data
  57305. */
  57306. export class RawTexture2DArray extends Texture {
  57307. /** Gets or sets the texture format to use */
  57308. format: number;
  57309. private _engine;
  57310. /**
  57311. * Create a new RawTexture2DArray
  57312. * @param data defines the data of the texture
  57313. * @param width defines the width of the texture
  57314. * @param height defines the height of the texture
  57315. * @param depth defines the number of layers of the texture
  57316. * @param format defines the texture format to use
  57317. * @param scene defines the hosting scene
  57318. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57319. * @param invertY defines if texture must be stored with Y axis inverted
  57320. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57321. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57322. */
  57323. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57324. /** Gets or sets the texture format to use */
  57325. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57326. /**
  57327. * Update the texture with new data
  57328. * @param data defines the data to store in the texture
  57329. */
  57330. update(data: ArrayBufferView): void;
  57331. }
  57332. }
  57333. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57334. import { Scene } from "babylonjs/scene";
  57335. import { Plane } from "babylonjs/Maths/math.plane";
  57336. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57337. /**
  57338. * Creates a refraction texture used by refraction channel of the standard material.
  57339. * It is like a mirror but to see through a material.
  57340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57341. */
  57342. export class RefractionTexture extends RenderTargetTexture {
  57343. /**
  57344. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57345. * 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.
  57346. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57347. */
  57348. refractionPlane: Plane;
  57349. /**
  57350. * Define how deep under the surface we should see.
  57351. */
  57352. depth: number;
  57353. /**
  57354. * Creates a refraction texture used by refraction channel of the standard material.
  57355. * It is like a mirror but to see through a material.
  57356. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57357. * @param name Define the texture name
  57358. * @param size Define the size of the underlying texture
  57359. * @param scene Define the scene the refraction belongs to
  57360. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57361. */
  57362. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57363. /**
  57364. * Clone the refraction texture.
  57365. * @returns the cloned texture
  57366. */
  57367. clone(): RefractionTexture;
  57368. /**
  57369. * Serialize the texture to a JSON representation you could use in Parse later on
  57370. * @returns the serialized JSON representation
  57371. */
  57372. serialize(): any;
  57373. }
  57374. }
  57375. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57376. import { Nullable } from "babylonjs/types";
  57377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57378. import { Matrix } from "babylonjs/Maths/math.vector";
  57379. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57380. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57381. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57382. import { Scene } from "babylonjs/scene";
  57383. /**
  57384. * Defines the options related to the creation of an HtmlElementTexture
  57385. */
  57386. export interface IHtmlElementTextureOptions {
  57387. /**
  57388. * Defines wether mip maps should be created or not.
  57389. */
  57390. generateMipMaps?: boolean;
  57391. /**
  57392. * Defines the sampling mode of the texture.
  57393. */
  57394. samplingMode?: number;
  57395. /**
  57396. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57397. */
  57398. engine: Nullable<ThinEngine>;
  57399. /**
  57400. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57401. */
  57402. scene: Nullable<Scene>;
  57403. }
  57404. /**
  57405. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57406. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57407. * is automatically managed.
  57408. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57409. * in your application.
  57410. *
  57411. * As the update is not automatic, you need to call them manually.
  57412. */
  57413. export class HtmlElementTexture extends BaseTexture {
  57414. /**
  57415. * The texture URL.
  57416. */
  57417. element: HTMLVideoElement | HTMLCanvasElement;
  57418. private static readonly DefaultOptions;
  57419. private _textureMatrix;
  57420. private _engine;
  57421. private _isVideo;
  57422. private _generateMipMaps;
  57423. private _samplingMode;
  57424. /**
  57425. * Instantiates a HtmlElementTexture from the following parameters.
  57426. *
  57427. * @param name Defines the name of the texture
  57428. * @param element Defines the video or canvas the texture is filled with
  57429. * @param options Defines the other none mandatory texture creation options
  57430. */
  57431. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57432. private _createInternalTexture;
  57433. /**
  57434. * Returns the texture matrix used in most of the material.
  57435. */
  57436. getTextureMatrix(): Matrix;
  57437. /**
  57438. * Updates the content of the texture.
  57439. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57440. */
  57441. update(invertY?: Nullable<boolean>): void;
  57442. }
  57443. }
  57444. declare module "babylonjs/Materials/Textures/index" {
  57445. export * from "babylonjs/Materials/Textures/baseTexture";
  57446. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57447. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57448. export * from "babylonjs/Materials/Textures/cubeTexture";
  57449. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57450. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57451. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57452. export * from "babylonjs/Materials/Textures/internalTexture";
  57453. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57454. export * from "babylonjs/Materials/Textures/Loaders/index";
  57455. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57456. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57457. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57458. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57459. export * from "babylonjs/Materials/Textures/rawTexture";
  57460. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57461. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57462. export * from "babylonjs/Materials/Textures/refractionTexture";
  57463. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57464. export * from "babylonjs/Materials/Textures/texture";
  57465. export * from "babylonjs/Materials/Textures/videoTexture";
  57466. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57467. }
  57468. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57469. /**
  57470. * Enum used to define the target of a block
  57471. */
  57472. export enum NodeMaterialBlockTargets {
  57473. /** Vertex shader */
  57474. Vertex = 1,
  57475. /** Fragment shader */
  57476. Fragment = 2,
  57477. /** Neutral */
  57478. Neutral = 4,
  57479. /** Vertex and Fragment */
  57480. VertexAndFragment = 3
  57481. }
  57482. }
  57483. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57484. /**
  57485. * Defines the kind of connection point for node based material
  57486. */
  57487. export enum NodeMaterialBlockConnectionPointTypes {
  57488. /** Float */
  57489. Float = 1,
  57490. /** Int */
  57491. Int = 2,
  57492. /** Vector2 */
  57493. Vector2 = 4,
  57494. /** Vector3 */
  57495. Vector3 = 8,
  57496. /** Vector4 */
  57497. Vector4 = 16,
  57498. /** Color3 */
  57499. Color3 = 32,
  57500. /** Color4 */
  57501. Color4 = 64,
  57502. /** Matrix */
  57503. Matrix = 128,
  57504. /** Detect type based on connection */
  57505. AutoDetect = 1024,
  57506. /** Output type that will be defined by input type */
  57507. BasedOnInput = 2048
  57508. }
  57509. }
  57510. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57511. /**
  57512. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57513. */
  57514. export enum NodeMaterialBlockConnectionPointMode {
  57515. /** Value is an uniform */
  57516. Uniform = 0,
  57517. /** Value is a mesh attribute */
  57518. Attribute = 1,
  57519. /** Value is a varying between vertex and fragment shaders */
  57520. Varying = 2,
  57521. /** Mode is undefined */
  57522. Undefined = 3
  57523. }
  57524. }
  57525. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57526. /**
  57527. * Enum used to define system values e.g. values automatically provided by the system
  57528. */
  57529. export enum NodeMaterialSystemValues {
  57530. /** World */
  57531. World = 1,
  57532. /** View */
  57533. View = 2,
  57534. /** Projection */
  57535. Projection = 3,
  57536. /** ViewProjection */
  57537. ViewProjection = 4,
  57538. /** WorldView */
  57539. WorldView = 5,
  57540. /** WorldViewProjection */
  57541. WorldViewProjection = 6,
  57542. /** CameraPosition */
  57543. CameraPosition = 7,
  57544. /** Fog Color */
  57545. FogColor = 8,
  57546. /** Delta time */
  57547. DeltaTime = 9
  57548. }
  57549. }
  57550. declare module "babylonjs/Materials/Node/Enums/index" {
  57551. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57552. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57553. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57554. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57555. }
  57556. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57558. /**
  57559. * Root class for all node material optimizers
  57560. */
  57561. export class NodeMaterialOptimizer {
  57562. /**
  57563. * Function used to optimize a NodeMaterial graph
  57564. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57565. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57566. */
  57567. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57568. }
  57569. }
  57570. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57574. import { Scene } from "babylonjs/scene";
  57575. /**
  57576. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57577. */
  57578. export class TransformBlock extends NodeMaterialBlock {
  57579. /**
  57580. * Defines the value to use to complement W value to transform it to a Vector4
  57581. */
  57582. complementW: number;
  57583. /**
  57584. * Defines the value to use to complement z value to transform it to a Vector4
  57585. */
  57586. complementZ: number;
  57587. /**
  57588. * Creates a new TransformBlock
  57589. * @param name defines the block name
  57590. */
  57591. constructor(name: string);
  57592. /**
  57593. * Gets the current class name
  57594. * @returns the class name
  57595. */
  57596. getClassName(): string;
  57597. /**
  57598. * Gets the vector input
  57599. */
  57600. get vector(): NodeMaterialConnectionPoint;
  57601. /**
  57602. * Gets the output component
  57603. */
  57604. get output(): NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the matrix transform input
  57607. */
  57608. get transform(): NodeMaterialConnectionPoint;
  57609. protected _buildBlock(state: NodeMaterialBuildState): this;
  57610. serialize(): any;
  57611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57612. protected _dumpPropertiesCode(): string;
  57613. }
  57614. }
  57615. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57619. /**
  57620. * Block used to output the vertex position
  57621. */
  57622. export class VertexOutputBlock extends NodeMaterialBlock {
  57623. /**
  57624. * Creates a new VertexOutputBlock
  57625. * @param name defines the block name
  57626. */
  57627. constructor(name: string);
  57628. /**
  57629. * Gets the current class name
  57630. * @returns the class name
  57631. */
  57632. getClassName(): string;
  57633. /**
  57634. * Gets the vector input component
  57635. */
  57636. get vector(): NodeMaterialConnectionPoint;
  57637. protected _buildBlock(state: NodeMaterialBuildState): this;
  57638. }
  57639. }
  57640. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57644. /**
  57645. * Block used to output the final color
  57646. */
  57647. export class FragmentOutputBlock extends NodeMaterialBlock {
  57648. /**
  57649. * Create a new FragmentOutputBlock
  57650. * @param name defines the block name
  57651. */
  57652. constructor(name: string);
  57653. /**
  57654. * Gets the current class name
  57655. * @returns the class name
  57656. */
  57657. getClassName(): string;
  57658. /**
  57659. * Gets the rgba input component
  57660. */
  57661. get rgba(): NodeMaterialConnectionPoint;
  57662. /**
  57663. * Gets the rgb input component
  57664. */
  57665. get rgb(): NodeMaterialConnectionPoint;
  57666. /**
  57667. * Gets the a input component
  57668. */
  57669. get a(): NodeMaterialConnectionPoint;
  57670. protected _buildBlock(state: NodeMaterialBuildState): this;
  57671. }
  57672. }
  57673. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57679. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57680. import { Effect } from "babylonjs/Materials/effect";
  57681. import { Mesh } from "babylonjs/Meshes/mesh";
  57682. import { Nullable } from "babylonjs/types";
  57683. import { Scene } from "babylonjs/scene";
  57684. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57685. /**
  57686. * Block used to read a reflection texture from a sampler
  57687. */
  57688. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57689. private _define3DName;
  57690. private _defineCubicName;
  57691. private _defineExplicitName;
  57692. private _defineProjectionName;
  57693. private _defineLocalCubicName;
  57694. private _defineSphericalName;
  57695. private _definePlanarName;
  57696. private _defineEquirectangularName;
  57697. private _defineMirroredEquirectangularFixedName;
  57698. private _defineEquirectangularFixedName;
  57699. private _defineSkyboxName;
  57700. private _cubeSamplerName;
  57701. private _2DSamplerName;
  57702. private _positionUVWName;
  57703. private _directionWName;
  57704. private _reflectionCoordsName;
  57705. private _reflection2DCoordsName;
  57706. private _reflectionColorName;
  57707. private _reflectionMatrixName;
  57708. /**
  57709. * Gets or sets the texture associated with the node
  57710. */
  57711. texture: Nullable<BaseTexture>;
  57712. /**
  57713. * Create a new TextureBlock
  57714. * @param name defines the block name
  57715. */
  57716. constructor(name: string);
  57717. /**
  57718. * Gets the current class name
  57719. * @returns the class name
  57720. */
  57721. getClassName(): string;
  57722. /**
  57723. * Gets the world position input component
  57724. */
  57725. get position(): NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the world position input component
  57728. */
  57729. get worldPosition(): NodeMaterialConnectionPoint;
  57730. /**
  57731. * Gets the world normal input component
  57732. */
  57733. get worldNormal(): NodeMaterialConnectionPoint;
  57734. /**
  57735. * Gets the world input component
  57736. */
  57737. get world(): NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the camera (or eye) position component
  57740. */
  57741. get cameraPosition(): NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the view input component
  57744. */
  57745. get view(): NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the rgb output component
  57748. */
  57749. get rgb(): NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the r output component
  57752. */
  57753. get r(): NodeMaterialConnectionPoint;
  57754. /**
  57755. * Gets the g output component
  57756. */
  57757. get g(): NodeMaterialConnectionPoint;
  57758. /**
  57759. * Gets the b output component
  57760. */
  57761. get b(): NodeMaterialConnectionPoint;
  57762. autoConfigure(material: NodeMaterial): void;
  57763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57764. isReady(): boolean;
  57765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57766. private _injectVertexCode;
  57767. private _writeOutput;
  57768. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57769. protected _dumpPropertiesCode(): string;
  57770. serialize(): any;
  57771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57772. }
  57773. }
  57774. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57776. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57777. import { Scene } from "babylonjs/scene";
  57778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57779. import { Matrix } from "babylonjs/Maths/math.vector";
  57780. import { Mesh } from "babylonjs/Meshes/mesh";
  57781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57782. import { Observable } from "babylonjs/Misc/observable";
  57783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57784. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57785. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57786. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57787. import { Nullable } from "babylonjs/types";
  57788. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57789. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57790. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57791. /**
  57792. * Interface used to configure the node material editor
  57793. */
  57794. export interface INodeMaterialEditorOptions {
  57795. /** Define the URl to load node editor script */
  57796. editorURL?: string;
  57797. }
  57798. /** @hidden */
  57799. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57800. /** BONES */
  57801. NUM_BONE_INFLUENCERS: number;
  57802. BonesPerMesh: number;
  57803. BONETEXTURE: boolean;
  57804. /** MORPH TARGETS */
  57805. MORPHTARGETS: boolean;
  57806. MORPHTARGETS_NORMAL: boolean;
  57807. MORPHTARGETS_TANGENT: boolean;
  57808. MORPHTARGETS_UV: boolean;
  57809. NUM_MORPH_INFLUENCERS: number;
  57810. /** IMAGE PROCESSING */
  57811. IMAGEPROCESSING: boolean;
  57812. VIGNETTE: boolean;
  57813. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57814. VIGNETTEBLENDMODEOPAQUE: boolean;
  57815. TONEMAPPING: boolean;
  57816. TONEMAPPING_ACES: boolean;
  57817. CONTRAST: boolean;
  57818. EXPOSURE: boolean;
  57819. COLORCURVES: boolean;
  57820. COLORGRADING: boolean;
  57821. COLORGRADING3D: boolean;
  57822. SAMPLER3DGREENDEPTH: boolean;
  57823. SAMPLER3DBGRMAP: boolean;
  57824. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57825. /** MISC. */
  57826. BUMPDIRECTUV: number;
  57827. constructor();
  57828. setValue(name: string, value: boolean): void;
  57829. }
  57830. /**
  57831. * Class used to configure NodeMaterial
  57832. */
  57833. export interface INodeMaterialOptions {
  57834. /**
  57835. * Defines if blocks should emit comments
  57836. */
  57837. emitComments: boolean;
  57838. }
  57839. /**
  57840. * Class used to create a node based material built by assembling shader blocks
  57841. */
  57842. export class NodeMaterial extends PushMaterial {
  57843. private static _BuildIdGenerator;
  57844. private _options;
  57845. private _vertexCompilationState;
  57846. private _fragmentCompilationState;
  57847. private _sharedData;
  57848. private _buildId;
  57849. private _buildWasSuccessful;
  57850. private _cachedWorldViewMatrix;
  57851. private _cachedWorldViewProjectionMatrix;
  57852. private _optimizers;
  57853. private _animationFrame;
  57854. /** Define the URl to load node editor script */
  57855. static EditorURL: string;
  57856. private BJSNODEMATERIALEDITOR;
  57857. /** Get the inspector from bundle or global */
  57858. private _getGlobalNodeMaterialEditor;
  57859. /**
  57860. * Gets or sets data used by visual editor
  57861. * @see https://nme.babylonjs.com
  57862. */
  57863. editorData: any;
  57864. /**
  57865. * 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)
  57866. */
  57867. ignoreAlpha: boolean;
  57868. /**
  57869. * Defines the maximum number of lights that can be used in the material
  57870. */
  57871. maxSimultaneousLights: number;
  57872. /**
  57873. * Observable raised when the material is built
  57874. */
  57875. onBuildObservable: Observable<NodeMaterial>;
  57876. /**
  57877. * Gets or sets the root nodes of the material vertex shader
  57878. */
  57879. _vertexOutputNodes: NodeMaterialBlock[];
  57880. /**
  57881. * Gets or sets the root nodes of the material fragment (pixel) shader
  57882. */
  57883. _fragmentOutputNodes: NodeMaterialBlock[];
  57884. /** Gets or sets options to control the node material overall behavior */
  57885. get options(): INodeMaterialOptions;
  57886. set options(options: INodeMaterialOptions);
  57887. /**
  57888. * Default configuration related to image processing available in the standard Material.
  57889. */
  57890. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57891. /**
  57892. * Gets the image processing configuration used either in this material.
  57893. */
  57894. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57895. /**
  57896. * Sets the Default image processing configuration used either in the this material.
  57897. *
  57898. * If sets to null, the scene one is in use.
  57899. */
  57900. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57901. /**
  57902. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57903. */
  57904. attachedBlocks: NodeMaterialBlock[];
  57905. /**
  57906. * Create a new node based material
  57907. * @param name defines the material name
  57908. * @param scene defines the hosting scene
  57909. * @param options defines creation option
  57910. */
  57911. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57912. /**
  57913. * Gets the current class name of the material e.g. "NodeMaterial"
  57914. * @returns the class name
  57915. */
  57916. getClassName(): string;
  57917. /**
  57918. * Keep track of the image processing observer to allow dispose and replace.
  57919. */
  57920. private _imageProcessingObserver;
  57921. /**
  57922. * Attaches a new image processing configuration to the Standard Material.
  57923. * @param configuration
  57924. */
  57925. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57926. /**
  57927. * Get a block by its name
  57928. * @param name defines the name of the block to retrieve
  57929. * @returns the required block or null if not found
  57930. */
  57931. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57932. /**
  57933. * Get a block by its name
  57934. * @param predicate defines the predicate used to find the good candidate
  57935. * @returns the required block or null if not found
  57936. */
  57937. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57938. /**
  57939. * Get an input block by its name
  57940. * @param predicate defines the predicate used to find the good candidate
  57941. * @returns the required input block or null if not found
  57942. */
  57943. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57944. /**
  57945. * Gets the list of input blocks attached to this material
  57946. * @returns an array of InputBlocks
  57947. */
  57948. getInputBlocks(): InputBlock[];
  57949. /**
  57950. * Adds a new optimizer to the list of optimizers
  57951. * @param optimizer defines the optimizers to add
  57952. * @returns the current material
  57953. */
  57954. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57955. /**
  57956. * Remove an optimizer from the list of optimizers
  57957. * @param optimizer defines the optimizers to remove
  57958. * @returns the current material
  57959. */
  57960. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57961. /**
  57962. * Add a new block to the list of output nodes
  57963. * @param node defines the node to add
  57964. * @returns the current material
  57965. */
  57966. addOutputNode(node: NodeMaterialBlock): this;
  57967. /**
  57968. * Remove a block from the list of root nodes
  57969. * @param node defines the node to remove
  57970. * @returns the current material
  57971. */
  57972. removeOutputNode(node: NodeMaterialBlock): this;
  57973. private _addVertexOutputNode;
  57974. private _removeVertexOutputNode;
  57975. private _addFragmentOutputNode;
  57976. private _removeFragmentOutputNode;
  57977. /**
  57978. * Specifies if the material will require alpha blending
  57979. * @returns a boolean specifying if alpha blending is needed
  57980. */
  57981. needAlphaBlending(): boolean;
  57982. /**
  57983. * Specifies if this material should be rendered in alpha test mode
  57984. * @returns a boolean specifying if an alpha test is needed.
  57985. */
  57986. needAlphaTesting(): boolean;
  57987. private _initializeBlock;
  57988. private _resetDualBlocks;
  57989. /**
  57990. * Remove a block from the current node material
  57991. * @param block defines the block to remove
  57992. */
  57993. removeBlock(block: NodeMaterialBlock): void;
  57994. /**
  57995. * Build the material and generates the inner effect
  57996. * @param verbose defines if the build should log activity
  57997. */
  57998. build(verbose?: boolean): void;
  57999. /**
  58000. * Runs an otpimization phase to try to improve the shader code
  58001. */
  58002. optimize(): void;
  58003. private _prepareDefinesForAttributes;
  58004. /**
  58005. * Get if the submesh is ready to be used and all its information available.
  58006. * Child classes can use it to update shaders
  58007. * @param mesh defines the mesh to check
  58008. * @param subMesh defines which submesh to check
  58009. * @param useInstances specifies that instances should be used
  58010. * @returns a boolean indicating that the submesh is ready or not
  58011. */
  58012. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58013. /**
  58014. * Get a string representing the shaders built by the current node graph
  58015. */
  58016. get compiledShaders(): string;
  58017. /**
  58018. * Binds the world matrix to the material
  58019. * @param world defines the world transformation matrix
  58020. */
  58021. bindOnlyWorldMatrix(world: Matrix): void;
  58022. /**
  58023. * Binds the submesh to this material by preparing the effect and shader to draw
  58024. * @param world defines the world transformation matrix
  58025. * @param mesh defines the mesh containing the submesh
  58026. * @param subMesh defines the submesh to bind the material to
  58027. */
  58028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58029. /**
  58030. * Gets the active textures from the material
  58031. * @returns an array of textures
  58032. */
  58033. getActiveTextures(): BaseTexture[];
  58034. /**
  58035. * Gets the list of texture blocks
  58036. * @returns an array of texture blocks
  58037. */
  58038. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58039. /**
  58040. * Specifies if the material uses a texture
  58041. * @param texture defines the texture to check against the material
  58042. * @returns a boolean specifying if the material uses the texture
  58043. */
  58044. hasTexture(texture: BaseTexture): boolean;
  58045. /**
  58046. * Disposes the material
  58047. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58048. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58049. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58050. */
  58051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58052. /** Creates the node editor window. */
  58053. private _createNodeEditor;
  58054. /**
  58055. * Launch the node material editor
  58056. * @param config Define the configuration of the editor
  58057. * @return a promise fulfilled when the node editor is visible
  58058. */
  58059. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58060. /**
  58061. * Clear the current material
  58062. */
  58063. clear(): void;
  58064. /**
  58065. * Clear the current material and set it to a default state
  58066. */
  58067. setToDefault(): void;
  58068. /**
  58069. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58070. * @param url defines the url to load from
  58071. * @returns a promise that will fullfil when the material is fully loaded
  58072. */
  58073. loadAsync(url: string): Promise<void>;
  58074. private _gatherBlocks;
  58075. /**
  58076. * Generate a string containing the code declaration required to create an equivalent of this material
  58077. * @returns a string
  58078. */
  58079. generateCode(): string;
  58080. /**
  58081. * Serializes this material in a JSON representation
  58082. * @returns the serialized material object
  58083. */
  58084. serialize(): any;
  58085. private _restoreConnections;
  58086. /**
  58087. * Clear the current graph and load a new one from a serialization object
  58088. * @param source defines the JSON representation of the material
  58089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58090. */
  58091. loadFromSerialization(source: any, rootUrl?: string): void;
  58092. /**
  58093. * Creates a node material from parsed material data
  58094. * @param source defines the JSON representation of the material
  58095. * @param scene defines the hosting scene
  58096. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58097. * @returns a new node material
  58098. */
  58099. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58100. /**
  58101. * Creates a new node material set to default basic configuration
  58102. * @param name defines the name of the material
  58103. * @param scene defines the hosting scene
  58104. * @returns a new NodeMaterial
  58105. */
  58106. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58107. }
  58108. }
  58109. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58112. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58115. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58116. import { Effect } from "babylonjs/Materials/effect";
  58117. import { Mesh } from "babylonjs/Meshes/mesh";
  58118. import { Nullable } from "babylonjs/types";
  58119. import { Texture } from "babylonjs/Materials/Textures/texture";
  58120. import { Scene } from "babylonjs/scene";
  58121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58122. /**
  58123. * Block used to read a texture from a sampler
  58124. */
  58125. export class TextureBlock extends NodeMaterialBlock {
  58126. private _defineName;
  58127. private _linearDefineName;
  58128. private _tempTextureRead;
  58129. private _samplerName;
  58130. private _transformedUVName;
  58131. private _textureTransformName;
  58132. private _textureInfoName;
  58133. private _mainUVName;
  58134. private _mainUVDefineName;
  58135. /**
  58136. * Gets or sets the texture associated with the node
  58137. */
  58138. texture: Nullable<Texture>;
  58139. /**
  58140. * Create a new TextureBlock
  58141. * @param name defines the block name
  58142. */
  58143. constructor(name: string);
  58144. /**
  58145. * Gets the current class name
  58146. * @returns the class name
  58147. */
  58148. getClassName(): string;
  58149. /**
  58150. * Gets the uv input component
  58151. */
  58152. get uv(): NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the rgba output component
  58155. */
  58156. get rgba(): NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the rgb output component
  58159. */
  58160. get rgb(): NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the r output component
  58163. */
  58164. get r(): NodeMaterialConnectionPoint;
  58165. /**
  58166. * Gets the g output component
  58167. */
  58168. get g(): NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the b output component
  58171. */
  58172. get b(): NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the a output component
  58175. */
  58176. get a(): NodeMaterialConnectionPoint;
  58177. get target(): NodeMaterialBlockTargets;
  58178. autoConfigure(material: NodeMaterial): void;
  58179. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58181. private _getTextureBase;
  58182. isReady(): boolean;
  58183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58184. private get _isMixed();
  58185. private _injectVertexCode;
  58186. private _writeTextureRead;
  58187. private _writeOutput;
  58188. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58189. protected _dumpPropertiesCode(): string;
  58190. serialize(): any;
  58191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58192. }
  58193. }
  58194. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58197. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58198. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58199. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58200. import { Scene } from "babylonjs/scene";
  58201. /**
  58202. * Class used to store shared data between 2 NodeMaterialBuildState
  58203. */
  58204. export class NodeMaterialBuildStateSharedData {
  58205. /**
  58206. * Gets the list of emitted varyings
  58207. */
  58208. temps: string[];
  58209. /**
  58210. * Gets the list of emitted varyings
  58211. */
  58212. varyings: string[];
  58213. /**
  58214. * Gets the varying declaration string
  58215. */
  58216. varyingDeclaration: string;
  58217. /**
  58218. * Input blocks
  58219. */
  58220. inputBlocks: InputBlock[];
  58221. /**
  58222. * Input blocks
  58223. */
  58224. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58225. /**
  58226. * Bindable blocks (Blocks that need to set data to the effect)
  58227. */
  58228. bindableBlocks: NodeMaterialBlock[];
  58229. /**
  58230. * List of blocks that can provide a compilation fallback
  58231. */
  58232. blocksWithFallbacks: NodeMaterialBlock[];
  58233. /**
  58234. * List of blocks that can provide a define update
  58235. */
  58236. blocksWithDefines: NodeMaterialBlock[];
  58237. /**
  58238. * List of blocks that can provide a repeatable content
  58239. */
  58240. repeatableContentBlocks: NodeMaterialBlock[];
  58241. /**
  58242. * List of blocks that can provide a dynamic list of uniforms
  58243. */
  58244. dynamicUniformBlocks: NodeMaterialBlock[];
  58245. /**
  58246. * List of blocks that can block the isReady function for the material
  58247. */
  58248. blockingBlocks: NodeMaterialBlock[];
  58249. /**
  58250. * Gets the list of animated inputs
  58251. */
  58252. animatedInputs: InputBlock[];
  58253. /**
  58254. * Build Id used to avoid multiple recompilations
  58255. */
  58256. buildId: number;
  58257. /** List of emitted variables */
  58258. variableNames: {
  58259. [key: string]: number;
  58260. };
  58261. /** List of emitted defines */
  58262. defineNames: {
  58263. [key: string]: number;
  58264. };
  58265. /** Should emit comments? */
  58266. emitComments: boolean;
  58267. /** Emit build activity */
  58268. verbose: boolean;
  58269. /** Gets or sets the hosting scene */
  58270. scene: Scene;
  58271. /**
  58272. * Gets the compilation hints emitted at compilation time
  58273. */
  58274. hints: {
  58275. needWorldViewMatrix: boolean;
  58276. needWorldViewProjectionMatrix: boolean;
  58277. needAlphaBlending: boolean;
  58278. needAlphaTesting: boolean;
  58279. };
  58280. /**
  58281. * List of compilation checks
  58282. */
  58283. checks: {
  58284. emitVertex: boolean;
  58285. emitFragment: boolean;
  58286. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58287. };
  58288. /** Creates a new shared data */
  58289. constructor();
  58290. /**
  58291. * Emits console errors and exceptions if there is a failing check
  58292. */
  58293. emitErrors(): void;
  58294. }
  58295. }
  58296. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58297. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58298. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58299. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58300. /**
  58301. * Class used to store node based material build state
  58302. */
  58303. export class NodeMaterialBuildState {
  58304. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58305. supportUniformBuffers: boolean;
  58306. /**
  58307. * Gets the list of emitted attributes
  58308. */
  58309. attributes: string[];
  58310. /**
  58311. * Gets the list of emitted uniforms
  58312. */
  58313. uniforms: string[];
  58314. /**
  58315. * Gets the list of emitted constants
  58316. */
  58317. constants: string[];
  58318. /**
  58319. * Gets the list of emitted samplers
  58320. */
  58321. samplers: string[];
  58322. /**
  58323. * Gets the list of emitted functions
  58324. */
  58325. functions: {
  58326. [key: string]: string;
  58327. };
  58328. /**
  58329. * Gets the list of emitted extensions
  58330. */
  58331. extensions: {
  58332. [key: string]: string;
  58333. };
  58334. /**
  58335. * Gets the target of the compilation state
  58336. */
  58337. target: NodeMaterialBlockTargets;
  58338. /**
  58339. * Gets the list of emitted counters
  58340. */
  58341. counters: {
  58342. [key: string]: number;
  58343. };
  58344. /**
  58345. * Shared data between multiple NodeMaterialBuildState instances
  58346. */
  58347. sharedData: NodeMaterialBuildStateSharedData;
  58348. /** @hidden */
  58349. _vertexState: NodeMaterialBuildState;
  58350. /** @hidden */
  58351. _attributeDeclaration: string;
  58352. /** @hidden */
  58353. _uniformDeclaration: string;
  58354. /** @hidden */
  58355. _constantDeclaration: string;
  58356. /** @hidden */
  58357. _samplerDeclaration: string;
  58358. /** @hidden */
  58359. _varyingTransfer: string;
  58360. private _repeatableContentAnchorIndex;
  58361. /** @hidden */
  58362. _builtCompilationString: string;
  58363. /**
  58364. * Gets the emitted compilation strings
  58365. */
  58366. compilationString: string;
  58367. /**
  58368. * Finalize the compilation strings
  58369. * @param state defines the current compilation state
  58370. */
  58371. finalize(state: NodeMaterialBuildState): void;
  58372. /** @hidden */
  58373. get _repeatableContentAnchor(): string;
  58374. /** @hidden */
  58375. _getFreeVariableName(prefix: string): string;
  58376. /** @hidden */
  58377. _getFreeDefineName(prefix: string): string;
  58378. /** @hidden */
  58379. _excludeVariableName(name: string): void;
  58380. /** @hidden */
  58381. _emit2DSampler(name: string): void;
  58382. /** @hidden */
  58383. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58384. /** @hidden */
  58385. _emitExtension(name: string, extension: string): void;
  58386. /** @hidden */
  58387. _emitFunction(name: string, code: string, comments: string): void;
  58388. /** @hidden */
  58389. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58390. replaceStrings?: {
  58391. search: RegExp;
  58392. replace: string;
  58393. }[];
  58394. repeatKey?: string;
  58395. }): string;
  58396. /** @hidden */
  58397. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58398. repeatKey?: string;
  58399. removeAttributes?: boolean;
  58400. removeUniforms?: boolean;
  58401. removeVaryings?: boolean;
  58402. removeIfDef?: boolean;
  58403. replaceStrings?: {
  58404. search: RegExp;
  58405. replace: string;
  58406. }[];
  58407. }, storeKey?: string): void;
  58408. /** @hidden */
  58409. _registerTempVariable(name: string): boolean;
  58410. /** @hidden */
  58411. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58412. /** @hidden */
  58413. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58414. /** @hidden */
  58415. _emitFloat(value: number): string;
  58416. }
  58417. }
  58418. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58419. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58421. import { Nullable } from "babylonjs/types";
  58422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58423. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58424. import { Effect } from "babylonjs/Materials/effect";
  58425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58426. import { Mesh } from "babylonjs/Meshes/mesh";
  58427. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58428. import { Scene } from "babylonjs/scene";
  58429. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58430. /**
  58431. * Defines a block that can be used inside a node based material
  58432. */
  58433. export class NodeMaterialBlock {
  58434. private _buildId;
  58435. private _buildTarget;
  58436. private _target;
  58437. private _isFinalMerger;
  58438. private _isInput;
  58439. protected _isUnique: boolean;
  58440. /** @hidden */
  58441. _codeVariableName: string;
  58442. /** @hidden */
  58443. _inputs: NodeMaterialConnectionPoint[];
  58444. /** @hidden */
  58445. _outputs: NodeMaterialConnectionPoint[];
  58446. /** @hidden */
  58447. _preparationId: number;
  58448. /**
  58449. * Gets or sets the name of the block
  58450. */
  58451. name: string;
  58452. /**
  58453. * Gets or sets the unique id of the node
  58454. */
  58455. uniqueId: number;
  58456. /**
  58457. * Gets or sets the comments associated with this block
  58458. */
  58459. comments: string;
  58460. /**
  58461. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58462. */
  58463. get isUnique(): boolean;
  58464. /**
  58465. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58466. */
  58467. get isFinalMerger(): boolean;
  58468. /**
  58469. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58470. */
  58471. get isInput(): boolean;
  58472. /**
  58473. * Gets or sets the build Id
  58474. */
  58475. get buildId(): number;
  58476. set buildId(value: number);
  58477. /**
  58478. * Gets or sets the target of the block
  58479. */
  58480. get target(): NodeMaterialBlockTargets;
  58481. set target(value: NodeMaterialBlockTargets);
  58482. /**
  58483. * Gets the list of input points
  58484. */
  58485. get inputs(): NodeMaterialConnectionPoint[];
  58486. /** Gets the list of output points */
  58487. get outputs(): NodeMaterialConnectionPoint[];
  58488. /**
  58489. * Find an input by its name
  58490. * @param name defines the name of the input to look for
  58491. * @returns the input or null if not found
  58492. */
  58493. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58494. /**
  58495. * Find an output by its name
  58496. * @param name defines the name of the outputto look for
  58497. * @returns the output or null if not found
  58498. */
  58499. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58500. /**
  58501. * Creates a new NodeMaterialBlock
  58502. * @param name defines the block name
  58503. * @param target defines the target of that block (Vertex by default)
  58504. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58505. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58506. */
  58507. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58508. /**
  58509. * Initialize the block and prepare the context for build
  58510. * @param state defines the state that will be used for the build
  58511. */
  58512. initialize(state: NodeMaterialBuildState): void;
  58513. /**
  58514. * Bind data to effect. Will only be called for blocks with isBindable === true
  58515. * @param effect defines the effect to bind data to
  58516. * @param nodeMaterial defines the hosting NodeMaterial
  58517. * @param mesh defines the mesh that will be rendered
  58518. */
  58519. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58520. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58521. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58522. protected _writeFloat(value: number): string;
  58523. /**
  58524. * Gets the current class name e.g. "NodeMaterialBlock"
  58525. * @returns the class name
  58526. */
  58527. getClassName(): string;
  58528. /**
  58529. * Register a new input. Must be called inside a block constructor
  58530. * @param name defines the connection point name
  58531. * @param type defines the connection point type
  58532. * @param isOptional defines a boolean indicating that this input can be omitted
  58533. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58534. * @returns the current block
  58535. */
  58536. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58537. /**
  58538. * Register a new output. Must be called inside a block constructor
  58539. * @param name defines the connection point name
  58540. * @param type defines the connection point type
  58541. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58542. * @returns the current block
  58543. */
  58544. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58545. /**
  58546. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58547. * @param forOutput defines an optional connection point to check compatibility with
  58548. * @returns the first available input or null
  58549. */
  58550. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58551. /**
  58552. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58553. * @param forBlock defines an optional block to check compatibility with
  58554. * @returns the first available input or null
  58555. */
  58556. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58557. /**
  58558. * Gets the sibling of the given output
  58559. * @param current defines the current output
  58560. * @returns the next output in the list or null
  58561. */
  58562. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58563. /**
  58564. * Connect current block with another block
  58565. * @param other defines the block to connect with
  58566. * @param options define the various options to help pick the right connections
  58567. * @returns the current block
  58568. */
  58569. connectTo(other: NodeMaterialBlock, options?: {
  58570. input?: string;
  58571. output?: string;
  58572. outputSwizzle?: string;
  58573. }): this | undefined;
  58574. protected _buildBlock(state: NodeMaterialBuildState): void;
  58575. /**
  58576. * Add uniforms, samplers and uniform buffers at compilation time
  58577. * @param state defines the state to update
  58578. * @param nodeMaterial defines the node material requesting the update
  58579. * @param defines defines the material defines to update
  58580. * @param uniformBuffers defines the list of uniform buffer names
  58581. */
  58582. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58583. /**
  58584. * Add potential fallbacks if shader compilation fails
  58585. * @param mesh defines the mesh to be rendered
  58586. * @param fallbacks defines the current prioritized list of fallbacks
  58587. */
  58588. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58589. /**
  58590. * Initialize defines for shader compilation
  58591. * @param mesh defines the mesh to be rendered
  58592. * @param nodeMaterial defines the node material requesting the update
  58593. * @param defines defines the material defines to update
  58594. * @param useInstances specifies that instances should be used
  58595. */
  58596. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58597. /**
  58598. * Update defines for shader compilation
  58599. * @param mesh defines the mesh to be rendered
  58600. * @param nodeMaterial defines the node material requesting the update
  58601. * @param defines defines the material defines to update
  58602. * @param useInstances specifies that instances should be used
  58603. */
  58604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58605. /**
  58606. * Lets the block try to connect some inputs automatically
  58607. * @param material defines the hosting NodeMaterial
  58608. */
  58609. autoConfigure(material: NodeMaterial): void;
  58610. /**
  58611. * Function called when a block is declared as repeatable content generator
  58612. * @param vertexShaderState defines the current compilation state for the vertex shader
  58613. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58614. * @param mesh defines the mesh to be rendered
  58615. * @param defines defines the material defines to update
  58616. */
  58617. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58618. /**
  58619. * Checks if the block is ready
  58620. * @param mesh defines the mesh to be rendered
  58621. * @param nodeMaterial defines the node material requesting the update
  58622. * @param defines defines the material defines to update
  58623. * @param useInstances specifies that instances should be used
  58624. * @returns true if the block is ready
  58625. */
  58626. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58627. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58628. private _processBuild;
  58629. /**
  58630. * Compile the current node and generate the shader code
  58631. * @param state defines the current compilation state (uniforms, samplers, current string)
  58632. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58633. * @returns true if already built
  58634. */
  58635. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58636. protected _inputRename(name: string): string;
  58637. protected _outputRename(name: string): string;
  58638. protected _dumpPropertiesCode(): string;
  58639. /** @hidden */
  58640. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58641. /** @hidden */
  58642. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58643. /**
  58644. * Clone the current block to a new identical block
  58645. * @param scene defines the hosting scene
  58646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58647. * @returns a copy of the current block
  58648. */
  58649. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58650. /**
  58651. * Serializes this block in a JSON representation
  58652. * @returns the serialized block object
  58653. */
  58654. serialize(): any;
  58655. /** @hidden */
  58656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58657. /**
  58658. * Release resources
  58659. */
  58660. dispose(): void;
  58661. }
  58662. }
  58663. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58664. /**
  58665. * Enum defining the type of animations supported by InputBlock
  58666. */
  58667. export enum AnimatedInputBlockTypes {
  58668. /** No animation */
  58669. None = 0,
  58670. /** Time based animation. Will only work for floats */
  58671. Time = 1
  58672. }
  58673. }
  58674. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58676. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58677. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58678. import { Nullable } from "babylonjs/types";
  58679. import { Effect } from "babylonjs/Materials/effect";
  58680. import { Matrix } from "babylonjs/Maths/math.vector";
  58681. import { Scene } from "babylonjs/scene";
  58682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58684. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58685. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58686. /**
  58687. * Block used to expose an input value
  58688. */
  58689. export class InputBlock extends NodeMaterialBlock {
  58690. private _mode;
  58691. private _associatedVariableName;
  58692. private _storedValue;
  58693. private _valueCallback;
  58694. private _type;
  58695. private _animationType;
  58696. /** Gets or set a value used to limit the range of float values */
  58697. min: number;
  58698. /** Gets or set a value used to limit the range of float values */
  58699. max: number;
  58700. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58701. matrixMode: number;
  58702. /** @hidden */
  58703. _systemValue: Nullable<NodeMaterialSystemValues>;
  58704. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58705. visibleInInspector: boolean;
  58706. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58707. isConstant: boolean;
  58708. /** Gets or sets the group to use to display this block in the Inspector */
  58709. groupInInspector: string;
  58710. /**
  58711. * Gets or sets the connection point type (default is float)
  58712. */
  58713. get type(): NodeMaterialBlockConnectionPointTypes;
  58714. /**
  58715. * Creates a new InputBlock
  58716. * @param name defines the block name
  58717. * @param target defines the target of that block (Vertex by default)
  58718. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58719. */
  58720. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58721. /**
  58722. * Gets the output component
  58723. */
  58724. get output(): NodeMaterialConnectionPoint;
  58725. /**
  58726. * Set the source of this connection point to a vertex attribute
  58727. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58728. * @returns the current connection point
  58729. */
  58730. setAsAttribute(attributeName?: string): InputBlock;
  58731. /**
  58732. * Set the source of this connection point to a system value
  58733. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58734. * @returns the current connection point
  58735. */
  58736. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58737. /**
  58738. * Gets or sets the value of that point.
  58739. * Please note that this value will be ignored if valueCallback is defined
  58740. */
  58741. get value(): any;
  58742. set value(value: any);
  58743. /**
  58744. * Gets or sets a callback used to get the value of that point.
  58745. * Please note that setting this value will force the connection point to ignore the value property
  58746. */
  58747. get valueCallback(): () => any;
  58748. set valueCallback(value: () => any);
  58749. /**
  58750. * Gets or sets the associated variable name in the shader
  58751. */
  58752. get associatedVariableName(): string;
  58753. set associatedVariableName(value: string);
  58754. /** Gets or sets the type of animation applied to the input */
  58755. get animationType(): AnimatedInputBlockTypes;
  58756. set animationType(value: AnimatedInputBlockTypes);
  58757. /**
  58758. * Gets a boolean indicating that this connection point not defined yet
  58759. */
  58760. get isUndefined(): boolean;
  58761. /**
  58762. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58763. * In this case the connection point name must be the name of the uniform to use.
  58764. * Can only be set on inputs
  58765. */
  58766. get isUniform(): boolean;
  58767. set isUniform(value: boolean);
  58768. /**
  58769. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58770. * In this case the connection point name must be the name of the attribute to use
  58771. * Can only be set on inputs
  58772. */
  58773. get isAttribute(): boolean;
  58774. set isAttribute(value: boolean);
  58775. /**
  58776. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58777. * Can only be set on exit points
  58778. */
  58779. get isVarying(): boolean;
  58780. set isVarying(value: boolean);
  58781. /**
  58782. * Gets a boolean indicating that the current connection point is a system value
  58783. */
  58784. get isSystemValue(): boolean;
  58785. /**
  58786. * Gets or sets the current well known value or null if not defined as a system value
  58787. */
  58788. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58789. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58790. /**
  58791. * Gets the current class name
  58792. * @returns the class name
  58793. */
  58794. getClassName(): string;
  58795. /**
  58796. * Animate the input if animationType !== None
  58797. * @param scene defines the rendering scene
  58798. */
  58799. animate(scene: Scene): void;
  58800. private _emitDefine;
  58801. initialize(state: NodeMaterialBuildState): void;
  58802. /**
  58803. * Set the input block to its default value (based on its type)
  58804. */
  58805. setDefaultValue(): void;
  58806. private _emitConstant;
  58807. private _emit;
  58808. /** @hidden */
  58809. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58810. /** @hidden */
  58811. _transmit(effect: Effect, scene: Scene): void;
  58812. protected _buildBlock(state: NodeMaterialBuildState): void;
  58813. protected _dumpPropertiesCode(): string;
  58814. serialize(): any;
  58815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58816. }
  58817. }
  58818. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58819. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58820. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58821. import { Nullable } from "babylonjs/types";
  58822. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58823. import { Observable } from "babylonjs/Misc/observable";
  58824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58825. /**
  58826. * Enum used to define the compatibility state between two connection points
  58827. */
  58828. export enum NodeMaterialConnectionPointCompatibilityStates {
  58829. /** Points are compatibles */
  58830. Compatible = 0,
  58831. /** Points are incompatible because of their types */
  58832. TypeIncompatible = 1,
  58833. /** Points are incompatible because of their targets (vertex vs fragment) */
  58834. TargetIncompatible = 2
  58835. }
  58836. /**
  58837. * Defines the direction of a connection point
  58838. */
  58839. export enum NodeMaterialConnectionPointDirection {
  58840. /** Input */
  58841. Input = 0,
  58842. /** Output */
  58843. Output = 1
  58844. }
  58845. /**
  58846. * Defines a connection point for a block
  58847. */
  58848. export class NodeMaterialConnectionPoint {
  58849. /** @hidden */
  58850. _ownerBlock: NodeMaterialBlock;
  58851. /** @hidden */
  58852. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58853. private _endpoints;
  58854. private _associatedVariableName;
  58855. private _direction;
  58856. /** @hidden */
  58857. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58858. /** @hidden */
  58859. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58860. private _type;
  58861. /** @hidden */
  58862. _enforceAssociatedVariableName: boolean;
  58863. /** Gets the direction of the point */
  58864. get direction(): NodeMaterialConnectionPointDirection;
  58865. /**
  58866. * Gets or sets the additional types supported by this connection point
  58867. */
  58868. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58869. /**
  58870. * Gets or sets the additional types excluded by this connection point
  58871. */
  58872. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58873. /**
  58874. * Observable triggered when this point is connected
  58875. */
  58876. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58877. /**
  58878. * Gets or sets the associated variable name in the shader
  58879. */
  58880. get associatedVariableName(): string;
  58881. set associatedVariableName(value: string);
  58882. /**
  58883. * Gets or sets the connection point type (default is float)
  58884. */
  58885. get type(): NodeMaterialBlockConnectionPointTypes;
  58886. set type(value: NodeMaterialBlockConnectionPointTypes);
  58887. /**
  58888. * Gets or sets the connection point name
  58889. */
  58890. name: string;
  58891. /**
  58892. * Gets or sets a boolean indicating that this connection point can be omitted
  58893. */
  58894. isOptional: boolean;
  58895. /**
  58896. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58897. */
  58898. define: string;
  58899. /** @hidden */
  58900. _prioritizeVertex: boolean;
  58901. private _target;
  58902. /** Gets or sets the target of that connection point */
  58903. get target(): NodeMaterialBlockTargets;
  58904. set target(value: NodeMaterialBlockTargets);
  58905. /**
  58906. * Gets a boolean indicating that the current point is connected
  58907. */
  58908. get isConnected(): boolean;
  58909. /**
  58910. * Gets a boolean indicating that the current point is connected to an input block
  58911. */
  58912. get isConnectedToInputBlock(): boolean;
  58913. /**
  58914. * Gets a the connected input block (if any)
  58915. */
  58916. get connectInputBlock(): Nullable<InputBlock>;
  58917. /** Get the other side of the connection (if any) */
  58918. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58919. /** Get the block that owns this connection point */
  58920. get ownerBlock(): NodeMaterialBlock;
  58921. /** Get the block connected on the other side of this connection (if any) */
  58922. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58923. /** Get the block connected on the endpoints of this connection (if any) */
  58924. get connectedBlocks(): Array<NodeMaterialBlock>;
  58925. /** Gets the list of connected endpoints */
  58926. get endpoints(): NodeMaterialConnectionPoint[];
  58927. /** Gets a boolean indicating if that output point is connected to at least one input */
  58928. get hasEndpoints(): boolean;
  58929. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58930. get isConnectedInVertexShader(): boolean;
  58931. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58932. get isConnectedInFragmentShader(): boolean;
  58933. /**
  58934. * Creates a new connection point
  58935. * @param name defines the connection point name
  58936. * @param ownerBlock defines the block hosting this connection point
  58937. * @param direction defines the direction of the connection point
  58938. */
  58939. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58940. /**
  58941. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58942. * @returns the class name
  58943. */
  58944. getClassName(): string;
  58945. /**
  58946. * Gets a boolean indicating if the current point can be connected to another point
  58947. * @param connectionPoint defines the other connection point
  58948. * @returns a boolean
  58949. */
  58950. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58951. /**
  58952. * Gets a number indicating if the current point can be connected to another point
  58953. * @param connectionPoint defines the other connection point
  58954. * @returns a number defining the compatibility state
  58955. */
  58956. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58957. /**
  58958. * Connect this point to another connection point
  58959. * @param connectionPoint defines the other connection point
  58960. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58961. * @returns the current connection point
  58962. */
  58963. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58964. /**
  58965. * Disconnect this point from one of his endpoint
  58966. * @param endpoint defines the other connection point
  58967. * @returns the current connection point
  58968. */
  58969. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Serializes this point in a JSON representation
  58972. * @returns the serialized point object
  58973. */
  58974. serialize(): any;
  58975. /**
  58976. * Release resources
  58977. */
  58978. dispose(): void;
  58979. }
  58980. }
  58981. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  58982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58985. import { Mesh } from "babylonjs/Meshes/mesh";
  58986. import { Effect } from "babylonjs/Materials/effect";
  58987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58988. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58989. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58990. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58991. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58992. /**
  58993. * Block used to add support for vertex skinning (bones)
  58994. */
  58995. export class BonesBlock extends NodeMaterialBlock {
  58996. /**
  58997. * Creates a new BonesBlock
  58998. * @param name defines the block name
  58999. */
  59000. constructor(name: string);
  59001. /**
  59002. * Initialize the block and prepare the context for build
  59003. * @param state defines the state that will be used for the build
  59004. */
  59005. initialize(state: NodeMaterialBuildState): void;
  59006. /**
  59007. * Gets the current class name
  59008. * @returns the class name
  59009. */
  59010. getClassName(): string;
  59011. /**
  59012. * Gets the matrix indices input component
  59013. */
  59014. get matricesIndices(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the matrix weights input component
  59017. */
  59018. get matricesWeights(): NodeMaterialConnectionPoint;
  59019. /**
  59020. * Gets the extra matrix indices input component
  59021. */
  59022. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59023. /**
  59024. * Gets the extra matrix weights input component
  59025. */
  59026. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59027. /**
  59028. * Gets the world input component
  59029. */
  59030. get world(): NodeMaterialConnectionPoint;
  59031. /**
  59032. * Gets the output component
  59033. */
  59034. get output(): NodeMaterialConnectionPoint;
  59035. autoConfigure(material: NodeMaterial): void;
  59036. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59039. protected _buildBlock(state: NodeMaterialBuildState): this;
  59040. }
  59041. }
  59042. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59047. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59048. /**
  59049. * Block used to add support for instances
  59050. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59051. */
  59052. export class InstancesBlock extends NodeMaterialBlock {
  59053. /**
  59054. * Creates a new InstancesBlock
  59055. * @param name defines the block name
  59056. */
  59057. constructor(name: string);
  59058. /**
  59059. * Gets the current class name
  59060. * @returns the class name
  59061. */
  59062. getClassName(): string;
  59063. /**
  59064. * Gets the first world row input component
  59065. */
  59066. get world0(): NodeMaterialConnectionPoint;
  59067. /**
  59068. * Gets the second world row input component
  59069. */
  59070. get world1(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the third world row input component
  59073. */
  59074. get world2(): NodeMaterialConnectionPoint;
  59075. /**
  59076. * Gets the forth world row input component
  59077. */
  59078. get world3(): NodeMaterialConnectionPoint;
  59079. /**
  59080. * Gets the world input component
  59081. */
  59082. get world(): NodeMaterialConnectionPoint;
  59083. /**
  59084. * Gets the output component
  59085. */
  59086. get output(): NodeMaterialConnectionPoint;
  59087. autoConfigure(material: NodeMaterial): void;
  59088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59089. protected _buildBlock(state: NodeMaterialBuildState): this;
  59090. }
  59091. }
  59092. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59097. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59098. import { Effect } from "babylonjs/Materials/effect";
  59099. import { Mesh } from "babylonjs/Meshes/mesh";
  59100. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59102. /**
  59103. * Block used to add morph targets support to vertex shader
  59104. */
  59105. export class MorphTargetsBlock extends NodeMaterialBlock {
  59106. private _repeatableContentAnchor;
  59107. private _repeatebleContentGenerated;
  59108. /**
  59109. * Create a new MorphTargetsBlock
  59110. * @param name defines the block name
  59111. */
  59112. constructor(name: string);
  59113. /**
  59114. * Gets the current class name
  59115. * @returns the class name
  59116. */
  59117. getClassName(): string;
  59118. /**
  59119. * Gets the position input component
  59120. */
  59121. get position(): NodeMaterialConnectionPoint;
  59122. /**
  59123. * Gets the normal input component
  59124. */
  59125. get normal(): NodeMaterialConnectionPoint;
  59126. /**
  59127. * Gets the tangent input component
  59128. */
  59129. get tangent(): NodeMaterialConnectionPoint;
  59130. /**
  59131. * Gets the tangent input component
  59132. */
  59133. get uv(): NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the position output component
  59136. */
  59137. get positionOutput(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the normal output component
  59140. */
  59141. get normalOutput(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the tangent output component
  59144. */
  59145. get tangentOutput(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the tangent output component
  59148. */
  59149. get uvOutput(): NodeMaterialConnectionPoint;
  59150. initialize(state: NodeMaterialBuildState): void;
  59151. autoConfigure(material: NodeMaterial): void;
  59152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59154. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59155. protected _buildBlock(state: NodeMaterialBuildState): this;
  59156. }
  59157. }
  59158. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59162. import { Nullable } from "babylonjs/types";
  59163. import { Scene } from "babylonjs/scene";
  59164. import { Effect } from "babylonjs/Materials/effect";
  59165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59166. import { Mesh } from "babylonjs/Meshes/mesh";
  59167. import { Light } from "babylonjs/Lights/light";
  59168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59169. /**
  59170. * Block used to get data information from a light
  59171. */
  59172. export class LightInformationBlock extends NodeMaterialBlock {
  59173. private _lightDataUniformName;
  59174. private _lightColorUniformName;
  59175. private _lightTypeDefineName;
  59176. /**
  59177. * Gets or sets the light associated with this block
  59178. */
  59179. light: Nullable<Light>;
  59180. /**
  59181. * Creates a new LightInformationBlock
  59182. * @param name defines the block name
  59183. */
  59184. constructor(name: string);
  59185. /**
  59186. * Gets the current class name
  59187. * @returns the class name
  59188. */
  59189. getClassName(): string;
  59190. /**
  59191. * Gets the world position input component
  59192. */
  59193. get worldPosition(): NodeMaterialConnectionPoint;
  59194. /**
  59195. * Gets the direction output component
  59196. */
  59197. get direction(): NodeMaterialConnectionPoint;
  59198. /**
  59199. * Gets the direction output component
  59200. */
  59201. get color(): NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the direction output component
  59204. */
  59205. get intensity(): NodeMaterialConnectionPoint;
  59206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59208. protected _buildBlock(state: NodeMaterialBuildState): this;
  59209. serialize(): any;
  59210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59211. }
  59212. }
  59213. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59214. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59215. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59216. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59217. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59218. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59219. }
  59220. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59226. import { Effect } from "babylonjs/Materials/effect";
  59227. import { Mesh } from "babylonjs/Meshes/mesh";
  59228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59229. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59230. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59231. /**
  59232. * Block used to add image processing support to fragment shader
  59233. */
  59234. export class ImageProcessingBlock extends NodeMaterialBlock {
  59235. /**
  59236. * Create a new ImageProcessingBlock
  59237. * @param name defines the block name
  59238. */
  59239. constructor(name: string);
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the color input component
  59247. */
  59248. get color(): NodeMaterialConnectionPoint;
  59249. /**
  59250. * Gets the output component
  59251. */
  59252. get output(): NodeMaterialConnectionPoint;
  59253. /**
  59254. * Initialize the block and prepare the context for build
  59255. * @param state defines the state that will be used for the build
  59256. */
  59257. initialize(state: NodeMaterialBuildState): void;
  59258. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59261. protected _buildBlock(state: NodeMaterialBuildState): this;
  59262. }
  59263. }
  59264. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59268. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59270. import { Effect } from "babylonjs/Materials/effect";
  59271. import { Mesh } from "babylonjs/Meshes/mesh";
  59272. import { Scene } from "babylonjs/scene";
  59273. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59274. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59275. /**
  59276. * Block used to pertub normals based on a normal map
  59277. */
  59278. export class PerturbNormalBlock extends NodeMaterialBlock {
  59279. private _tangentSpaceParameterName;
  59280. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59281. invertX: boolean;
  59282. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59283. invertY: boolean;
  59284. /**
  59285. * Create a new PerturbNormalBlock
  59286. * @param name defines the block name
  59287. */
  59288. constructor(name: string);
  59289. /**
  59290. * Gets the current class name
  59291. * @returns the class name
  59292. */
  59293. getClassName(): string;
  59294. /**
  59295. * Gets the world position input component
  59296. */
  59297. get worldPosition(): NodeMaterialConnectionPoint;
  59298. /**
  59299. * Gets the world normal input component
  59300. */
  59301. get worldNormal(): NodeMaterialConnectionPoint;
  59302. /**
  59303. * Gets the uv input component
  59304. */
  59305. get uv(): NodeMaterialConnectionPoint;
  59306. /**
  59307. * Gets the normal map color input component
  59308. */
  59309. get normalMapColor(): NodeMaterialConnectionPoint;
  59310. /**
  59311. * Gets the strength input component
  59312. */
  59313. get strength(): NodeMaterialConnectionPoint;
  59314. /**
  59315. * Gets the output component
  59316. */
  59317. get output(): NodeMaterialConnectionPoint;
  59318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59320. autoConfigure(material: NodeMaterial): void;
  59321. protected _buildBlock(state: NodeMaterialBuildState): this;
  59322. protected _dumpPropertiesCode(): string;
  59323. serialize(): any;
  59324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59325. }
  59326. }
  59327. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59331. /**
  59332. * Block used to discard a pixel if a value is smaller than a cutoff
  59333. */
  59334. export class DiscardBlock extends NodeMaterialBlock {
  59335. /**
  59336. * Create a new DiscardBlock
  59337. * @param name defines the block name
  59338. */
  59339. constructor(name: string);
  59340. /**
  59341. * Gets the current class name
  59342. * @returns the class name
  59343. */
  59344. getClassName(): string;
  59345. /**
  59346. * Gets the color input component
  59347. */
  59348. get value(): NodeMaterialConnectionPoint;
  59349. /**
  59350. * Gets the cutoff input component
  59351. */
  59352. get cutoff(): NodeMaterialConnectionPoint;
  59353. protected _buildBlock(state: NodeMaterialBuildState): this;
  59354. }
  59355. }
  59356. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59360. /**
  59361. * Block used to test if the fragment shader is front facing
  59362. */
  59363. export class FrontFacingBlock extends NodeMaterialBlock {
  59364. /**
  59365. * Creates a new FrontFacingBlock
  59366. * @param name defines the block name
  59367. */
  59368. constructor(name: string);
  59369. /**
  59370. * Gets the current class name
  59371. * @returns the class name
  59372. */
  59373. getClassName(): string;
  59374. /**
  59375. * Gets the output component
  59376. */
  59377. get output(): NodeMaterialConnectionPoint;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59385. /**
  59386. * Block used to get the derivative value on x and y of a given input
  59387. */
  59388. export class DerivativeBlock extends NodeMaterialBlock {
  59389. /**
  59390. * Create a new DerivativeBlock
  59391. * @param name defines the block name
  59392. */
  59393. constructor(name: string);
  59394. /**
  59395. * Gets the current class name
  59396. * @returns the class name
  59397. */
  59398. getClassName(): string;
  59399. /**
  59400. * Gets the input component
  59401. */
  59402. get input(): NodeMaterialConnectionPoint;
  59403. /**
  59404. * Gets the derivative output on x
  59405. */
  59406. get dx(): NodeMaterialConnectionPoint;
  59407. /**
  59408. * Gets the derivative output on y
  59409. */
  59410. get dy(): NodeMaterialConnectionPoint;
  59411. protected _buildBlock(state: NodeMaterialBuildState): this;
  59412. }
  59413. }
  59414. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59415. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59416. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59417. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59418. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59419. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59420. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59421. }
  59422. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59425. import { Mesh } from "babylonjs/Meshes/mesh";
  59426. import { Effect } from "babylonjs/Materials/effect";
  59427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59429. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59430. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59431. /**
  59432. * Block used to add support for scene fog
  59433. */
  59434. export class FogBlock extends NodeMaterialBlock {
  59435. private _fogDistanceName;
  59436. private _fogParameters;
  59437. /**
  59438. * Create a new FogBlock
  59439. * @param name defines the block name
  59440. */
  59441. constructor(name: string);
  59442. /**
  59443. * Gets the current class name
  59444. * @returns the class name
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Gets the world position input component
  59449. */
  59450. get worldPosition(): NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the view input component
  59453. */
  59454. get view(): NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the color input component
  59457. */
  59458. get input(): NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the fog color input component
  59461. */
  59462. get fogColor(): NodeMaterialConnectionPoint;
  59463. /**
  59464. * Gets the output component
  59465. */
  59466. get output(): NodeMaterialConnectionPoint;
  59467. autoConfigure(material: NodeMaterial): void;
  59468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59470. protected _buildBlock(state: NodeMaterialBuildState): this;
  59471. }
  59472. }
  59473. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59478. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59479. import { Effect } from "babylonjs/Materials/effect";
  59480. import { Mesh } from "babylonjs/Meshes/mesh";
  59481. import { Light } from "babylonjs/Lights/light";
  59482. import { Nullable } from "babylonjs/types";
  59483. import { Scene } from "babylonjs/scene";
  59484. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59485. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59486. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59487. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59488. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59489. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59490. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59491. /**
  59492. * Block used to add light in the fragment shader
  59493. */
  59494. export class LightBlock extends NodeMaterialBlock {
  59495. private _lightId;
  59496. /**
  59497. * Gets or sets the light associated with this block
  59498. */
  59499. light: Nullable<Light>;
  59500. /**
  59501. * Create a new LightBlock
  59502. * @param name defines the block name
  59503. */
  59504. constructor(name: string);
  59505. /**
  59506. * Gets the current class name
  59507. * @returns the class name
  59508. */
  59509. getClassName(): string;
  59510. /**
  59511. * Gets the world position input component
  59512. */
  59513. get worldPosition(): NodeMaterialConnectionPoint;
  59514. /**
  59515. * Gets the world normal input component
  59516. */
  59517. get worldNormal(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the camera (or eye) position component
  59520. */
  59521. get cameraPosition(): NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the glossiness component
  59524. */
  59525. get glossiness(): NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the glossinness power component
  59528. */
  59529. get glossPower(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the diffuse color component
  59532. */
  59533. get diffuseColor(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the specular color component
  59536. */
  59537. get specularColor(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the diffuse output component
  59540. */
  59541. get diffuseOutput(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the specular output component
  59544. */
  59545. get specularOutput(): NodeMaterialConnectionPoint;
  59546. autoConfigure(material: NodeMaterial): void;
  59547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59548. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59550. private _injectVertexCode;
  59551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59552. serialize(): any;
  59553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59554. }
  59555. }
  59556. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59557. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59558. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59559. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59560. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59561. }
  59562. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59563. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59564. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59565. }
  59566. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59570. /**
  59571. * Block used to multiply 2 values
  59572. */
  59573. export class MultiplyBlock extends NodeMaterialBlock {
  59574. /**
  59575. * Creates a new MultiplyBlock
  59576. * @param name defines the block name
  59577. */
  59578. constructor(name: string);
  59579. /**
  59580. * Gets the current class name
  59581. * @returns the class name
  59582. */
  59583. getClassName(): string;
  59584. /**
  59585. * Gets the left operand input component
  59586. */
  59587. get left(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the right operand input component
  59590. */
  59591. get right(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the output component
  59594. */
  59595. get output(): NodeMaterialConnectionPoint;
  59596. protected _buildBlock(state: NodeMaterialBuildState): this;
  59597. }
  59598. }
  59599. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59603. /**
  59604. * Block used to add 2 vectors
  59605. */
  59606. export class AddBlock extends NodeMaterialBlock {
  59607. /**
  59608. * Creates a new AddBlock
  59609. * @param name defines the block name
  59610. */
  59611. constructor(name: string);
  59612. /**
  59613. * Gets the current class name
  59614. * @returns the class name
  59615. */
  59616. getClassName(): string;
  59617. /**
  59618. * Gets the left operand input component
  59619. */
  59620. get left(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the right operand input component
  59623. */
  59624. get right(): NodeMaterialConnectionPoint;
  59625. /**
  59626. * Gets the output component
  59627. */
  59628. get output(): NodeMaterialConnectionPoint;
  59629. protected _buildBlock(state: NodeMaterialBuildState): this;
  59630. }
  59631. }
  59632. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59636. /**
  59637. * Block used to scale a vector by a float
  59638. */
  59639. export class ScaleBlock extends NodeMaterialBlock {
  59640. /**
  59641. * Creates a new ScaleBlock
  59642. * @param name defines the block name
  59643. */
  59644. constructor(name: string);
  59645. /**
  59646. * Gets the current class name
  59647. * @returns the class name
  59648. */
  59649. getClassName(): string;
  59650. /**
  59651. * Gets the input component
  59652. */
  59653. get input(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the factor input component
  59656. */
  59657. get factor(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the output component
  59660. */
  59661. get output(): NodeMaterialConnectionPoint;
  59662. protected _buildBlock(state: NodeMaterialBuildState): this;
  59663. }
  59664. }
  59665. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59666. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59669. import { Scene } from "babylonjs/scene";
  59670. /**
  59671. * Block used to clamp a float
  59672. */
  59673. export class ClampBlock extends NodeMaterialBlock {
  59674. /** Gets or sets the minimum range */
  59675. minimum: number;
  59676. /** Gets or sets the maximum range */
  59677. maximum: number;
  59678. /**
  59679. * Creates a new ClampBlock
  59680. * @param name defines the block name
  59681. */
  59682. constructor(name: string);
  59683. /**
  59684. * Gets the current class name
  59685. * @returns the class name
  59686. */
  59687. getClassName(): string;
  59688. /**
  59689. * Gets the value input component
  59690. */
  59691. get value(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the output component
  59694. */
  59695. get output(): NodeMaterialConnectionPoint;
  59696. protected _buildBlock(state: NodeMaterialBuildState): this;
  59697. protected _dumpPropertiesCode(): string;
  59698. serialize(): any;
  59699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59700. }
  59701. }
  59702. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59706. /**
  59707. * Block used to apply a cross product between 2 vectors
  59708. */
  59709. export class CrossBlock extends NodeMaterialBlock {
  59710. /**
  59711. * Creates a new CrossBlock
  59712. * @param name defines the block name
  59713. */
  59714. constructor(name: string);
  59715. /**
  59716. * Gets the current class name
  59717. * @returns the class name
  59718. */
  59719. getClassName(): string;
  59720. /**
  59721. * Gets the left operand input component
  59722. */
  59723. get left(): NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the right operand input component
  59726. */
  59727. get right(): NodeMaterialConnectionPoint;
  59728. /**
  59729. * Gets the output component
  59730. */
  59731. get output(): NodeMaterialConnectionPoint;
  59732. protected _buildBlock(state: NodeMaterialBuildState): this;
  59733. }
  59734. }
  59735. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59739. /**
  59740. * Block used to apply a dot product between 2 vectors
  59741. */
  59742. export class DotBlock extends NodeMaterialBlock {
  59743. /**
  59744. * Creates a new DotBlock
  59745. * @param name defines the block name
  59746. */
  59747. constructor(name: string);
  59748. /**
  59749. * Gets the current class name
  59750. * @returns the class name
  59751. */
  59752. getClassName(): string;
  59753. /**
  59754. * Gets the left operand input component
  59755. */
  59756. get left(): NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the right operand input component
  59759. */
  59760. get right(): NodeMaterialConnectionPoint;
  59761. /**
  59762. * Gets the output component
  59763. */
  59764. get output(): NodeMaterialConnectionPoint;
  59765. protected _buildBlock(state: NodeMaterialBuildState): this;
  59766. }
  59767. }
  59768. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59772. import { Vector2 } from "babylonjs/Maths/math.vector";
  59773. import { Scene } from "babylonjs/scene";
  59774. /**
  59775. * Block used to remap a float from a range to a new one
  59776. */
  59777. export class RemapBlock extends NodeMaterialBlock {
  59778. /**
  59779. * Gets or sets the source range
  59780. */
  59781. sourceRange: Vector2;
  59782. /**
  59783. * Gets or sets the target range
  59784. */
  59785. targetRange: Vector2;
  59786. /**
  59787. * Creates a new RemapBlock
  59788. * @param name defines the block name
  59789. */
  59790. constructor(name: string);
  59791. /**
  59792. * Gets the current class name
  59793. * @returns the class name
  59794. */
  59795. getClassName(): string;
  59796. /**
  59797. * Gets the input component
  59798. */
  59799. get input(): NodeMaterialConnectionPoint;
  59800. /**
  59801. * Gets the source min input component
  59802. */
  59803. get sourceMin(): NodeMaterialConnectionPoint;
  59804. /**
  59805. * Gets the source max input component
  59806. */
  59807. get sourceMax(): NodeMaterialConnectionPoint;
  59808. /**
  59809. * Gets the target min input component
  59810. */
  59811. get targetMin(): NodeMaterialConnectionPoint;
  59812. /**
  59813. * Gets the target max input component
  59814. */
  59815. get targetMax(): NodeMaterialConnectionPoint;
  59816. /**
  59817. * Gets the output component
  59818. */
  59819. get output(): NodeMaterialConnectionPoint;
  59820. protected _buildBlock(state: NodeMaterialBuildState): this;
  59821. protected _dumpPropertiesCode(): string;
  59822. serialize(): any;
  59823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59824. }
  59825. }
  59826. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59830. /**
  59831. * Block used to normalize a vector
  59832. */
  59833. export class NormalizeBlock extends NodeMaterialBlock {
  59834. /**
  59835. * Creates a new NormalizeBlock
  59836. * @param name defines the block name
  59837. */
  59838. constructor(name: string);
  59839. /**
  59840. * Gets the current class name
  59841. * @returns the class name
  59842. */
  59843. getClassName(): string;
  59844. /**
  59845. * Gets the input component
  59846. */
  59847. get input(): NodeMaterialConnectionPoint;
  59848. /**
  59849. * Gets the output component
  59850. */
  59851. get output(): NodeMaterialConnectionPoint;
  59852. protected _buildBlock(state: NodeMaterialBuildState): this;
  59853. }
  59854. }
  59855. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59859. import { Scene } from "babylonjs/scene";
  59860. /**
  59861. * Operations supported by the Trigonometry block
  59862. */
  59863. export enum TrigonometryBlockOperations {
  59864. /** Cos */
  59865. Cos = 0,
  59866. /** Sin */
  59867. Sin = 1,
  59868. /** Abs */
  59869. Abs = 2,
  59870. /** Exp */
  59871. Exp = 3,
  59872. /** Exp2 */
  59873. Exp2 = 4,
  59874. /** Round */
  59875. Round = 5,
  59876. /** Floor */
  59877. Floor = 6,
  59878. /** Ceiling */
  59879. Ceiling = 7,
  59880. /** Square root */
  59881. Sqrt = 8,
  59882. /** Log */
  59883. Log = 9,
  59884. /** Tangent */
  59885. Tan = 10,
  59886. /** Arc tangent */
  59887. ArcTan = 11,
  59888. /** Arc cosinus */
  59889. ArcCos = 12,
  59890. /** Arc sinus */
  59891. ArcSin = 13,
  59892. /** Fraction */
  59893. Fract = 14,
  59894. /** Sign */
  59895. Sign = 15,
  59896. /** To radians (from degrees) */
  59897. Radians = 16,
  59898. /** To degrees (from radians) */
  59899. Degrees = 17
  59900. }
  59901. /**
  59902. * Block used to apply trigonometry operation to floats
  59903. */
  59904. export class TrigonometryBlock extends NodeMaterialBlock {
  59905. /**
  59906. * Gets or sets the operation applied by the block
  59907. */
  59908. operation: TrigonometryBlockOperations;
  59909. /**
  59910. * Creates a new TrigonometryBlock
  59911. * @param name defines the block name
  59912. */
  59913. constructor(name: string);
  59914. /**
  59915. * Gets the current class name
  59916. * @returns the class name
  59917. */
  59918. getClassName(): string;
  59919. /**
  59920. * Gets the input component
  59921. */
  59922. get input(): NodeMaterialConnectionPoint;
  59923. /**
  59924. * Gets the output component
  59925. */
  59926. get output(): NodeMaterialConnectionPoint;
  59927. protected _buildBlock(state: NodeMaterialBuildState): this;
  59928. serialize(): any;
  59929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59930. protected _dumpPropertiesCode(): string;
  59931. }
  59932. }
  59933. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  59934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59937. /**
  59938. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59939. */
  59940. export class ColorMergerBlock extends NodeMaterialBlock {
  59941. /**
  59942. * Create a new ColorMergerBlock
  59943. * @param name defines the block name
  59944. */
  59945. constructor(name: string);
  59946. /**
  59947. * Gets the current class name
  59948. * @returns the class name
  59949. */
  59950. getClassName(): string;
  59951. /**
  59952. * Gets the rgb component (input)
  59953. */
  59954. get rgbIn(): NodeMaterialConnectionPoint;
  59955. /**
  59956. * Gets the r component (input)
  59957. */
  59958. get r(): NodeMaterialConnectionPoint;
  59959. /**
  59960. * Gets the g component (input)
  59961. */
  59962. get g(): NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the b component (input)
  59965. */
  59966. get b(): NodeMaterialConnectionPoint;
  59967. /**
  59968. * Gets the a component (input)
  59969. */
  59970. get a(): NodeMaterialConnectionPoint;
  59971. /**
  59972. * Gets the rgba component (output)
  59973. */
  59974. get rgba(): NodeMaterialConnectionPoint;
  59975. /**
  59976. * Gets the rgb component (output)
  59977. */
  59978. get rgbOut(): NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the rgb component (output)
  59981. * @deprecated Please use rgbOut instead.
  59982. */
  59983. get rgb(): NodeMaterialConnectionPoint;
  59984. protected _buildBlock(state: NodeMaterialBuildState): this;
  59985. }
  59986. }
  59987. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  59988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59991. /**
  59992. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59993. */
  59994. export class VectorMergerBlock extends NodeMaterialBlock {
  59995. /**
  59996. * Create a new VectorMergerBlock
  59997. * @param name defines the block name
  59998. */
  59999. constructor(name: string);
  60000. /**
  60001. * Gets the current class name
  60002. * @returns the class name
  60003. */
  60004. getClassName(): string;
  60005. /**
  60006. * Gets the xyz component (input)
  60007. */
  60008. get xyzIn(): NodeMaterialConnectionPoint;
  60009. /**
  60010. * Gets the xy component (input)
  60011. */
  60012. get xyIn(): NodeMaterialConnectionPoint;
  60013. /**
  60014. * Gets the x component (input)
  60015. */
  60016. get x(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the y component (input)
  60019. */
  60020. get y(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the z component (input)
  60023. */
  60024. get z(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the w component (input)
  60027. */
  60028. get w(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the xyzw component (output)
  60031. */
  60032. get xyzw(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the xyz component (output)
  60035. */
  60036. get xyzOut(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the xy component (output)
  60039. */
  60040. get xyOut(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the xy component (output)
  60043. * @deprecated Please use xyOut instead.
  60044. */
  60045. get xy(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the xyz component (output)
  60048. * @deprecated Please use xyzOut instead.
  60049. */
  60050. get xyz(): NodeMaterialConnectionPoint;
  60051. protected _buildBlock(state: NodeMaterialBuildState): this;
  60052. }
  60053. }
  60054. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60058. /**
  60059. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60060. */
  60061. export class ColorSplitterBlock extends NodeMaterialBlock {
  60062. /**
  60063. * Create a new ColorSplitterBlock
  60064. * @param name defines the block name
  60065. */
  60066. constructor(name: string);
  60067. /**
  60068. * Gets the current class name
  60069. * @returns the class name
  60070. */
  60071. getClassName(): string;
  60072. /**
  60073. * Gets the rgba component (input)
  60074. */
  60075. get rgba(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the rgb component (input)
  60078. */
  60079. get rgbIn(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the rgb component (output)
  60082. */
  60083. get rgbOut(): NodeMaterialConnectionPoint;
  60084. /**
  60085. * Gets the r component (output)
  60086. */
  60087. get r(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the g component (output)
  60090. */
  60091. get g(): NodeMaterialConnectionPoint;
  60092. /**
  60093. * Gets the b component (output)
  60094. */
  60095. get b(): NodeMaterialConnectionPoint;
  60096. /**
  60097. * Gets the a component (output)
  60098. */
  60099. get a(): NodeMaterialConnectionPoint;
  60100. protected _inputRename(name: string): string;
  60101. protected _outputRename(name: string): string;
  60102. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60103. }
  60104. }
  60105. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60109. /**
  60110. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60111. */
  60112. export class VectorSplitterBlock extends NodeMaterialBlock {
  60113. /**
  60114. * Create a new VectorSplitterBlock
  60115. * @param name defines the block name
  60116. */
  60117. constructor(name: string);
  60118. /**
  60119. * Gets the current class name
  60120. * @returns the class name
  60121. */
  60122. getClassName(): string;
  60123. /**
  60124. * Gets the xyzw component (input)
  60125. */
  60126. get xyzw(): NodeMaterialConnectionPoint;
  60127. /**
  60128. * Gets the xyz component (input)
  60129. */
  60130. get xyzIn(): NodeMaterialConnectionPoint;
  60131. /**
  60132. * Gets the xy component (input)
  60133. */
  60134. get xyIn(): NodeMaterialConnectionPoint;
  60135. /**
  60136. * Gets the xyz component (output)
  60137. */
  60138. get xyzOut(): NodeMaterialConnectionPoint;
  60139. /**
  60140. * Gets the xy component (output)
  60141. */
  60142. get xyOut(): NodeMaterialConnectionPoint;
  60143. /**
  60144. * Gets the x component (output)
  60145. */
  60146. get x(): NodeMaterialConnectionPoint;
  60147. /**
  60148. * Gets the y component (output)
  60149. */
  60150. get y(): NodeMaterialConnectionPoint;
  60151. /**
  60152. * Gets the z component (output)
  60153. */
  60154. get z(): NodeMaterialConnectionPoint;
  60155. /**
  60156. * Gets the w component (output)
  60157. */
  60158. get w(): NodeMaterialConnectionPoint;
  60159. protected _inputRename(name: string): string;
  60160. protected _outputRename(name: string): string;
  60161. protected _buildBlock(state: NodeMaterialBuildState): this;
  60162. }
  60163. }
  60164. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60168. /**
  60169. * Block used to lerp between 2 values
  60170. */
  60171. export class LerpBlock extends NodeMaterialBlock {
  60172. /**
  60173. * Creates a new LerpBlock
  60174. * @param name defines the block name
  60175. */
  60176. constructor(name: string);
  60177. /**
  60178. * Gets the current class name
  60179. * @returns the class name
  60180. */
  60181. getClassName(): string;
  60182. /**
  60183. * Gets the left operand input component
  60184. */
  60185. get left(): NodeMaterialConnectionPoint;
  60186. /**
  60187. * Gets the right operand input component
  60188. */
  60189. get right(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the gradient operand input component
  60192. */
  60193. get gradient(): NodeMaterialConnectionPoint;
  60194. /**
  60195. * Gets the output component
  60196. */
  60197. get output(): NodeMaterialConnectionPoint;
  60198. protected _buildBlock(state: NodeMaterialBuildState): this;
  60199. }
  60200. }
  60201. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60205. /**
  60206. * Block used to divide 2 vectors
  60207. */
  60208. export class DivideBlock extends NodeMaterialBlock {
  60209. /**
  60210. * Creates a new DivideBlock
  60211. * @param name defines the block name
  60212. */
  60213. constructor(name: string);
  60214. /**
  60215. * Gets the current class name
  60216. * @returns the class name
  60217. */
  60218. getClassName(): string;
  60219. /**
  60220. * Gets the left operand input component
  60221. */
  60222. get left(): NodeMaterialConnectionPoint;
  60223. /**
  60224. * Gets the right operand input component
  60225. */
  60226. get right(): NodeMaterialConnectionPoint;
  60227. /**
  60228. * Gets the output component
  60229. */
  60230. get output(): NodeMaterialConnectionPoint;
  60231. protected _buildBlock(state: NodeMaterialBuildState): this;
  60232. }
  60233. }
  60234. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60238. /**
  60239. * Block used to subtract 2 vectors
  60240. */
  60241. export class SubtractBlock extends NodeMaterialBlock {
  60242. /**
  60243. * Creates a new SubtractBlock
  60244. * @param name defines the block name
  60245. */
  60246. constructor(name: string);
  60247. /**
  60248. * Gets the current class name
  60249. * @returns the class name
  60250. */
  60251. getClassName(): string;
  60252. /**
  60253. * Gets the left operand input component
  60254. */
  60255. get left(): NodeMaterialConnectionPoint;
  60256. /**
  60257. * Gets the right operand input component
  60258. */
  60259. get right(): NodeMaterialConnectionPoint;
  60260. /**
  60261. * Gets the output component
  60262. */
  60263. get output(): NodeMaterialConnectionPoint;
  60264. protected _buildBlock(state: NodeMaterialBuildState): this;
  60265. }
  60266. }
  60267. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60271. /**
  60272. * Block used to step a value
  60273. */
  60274. export class StepBlock extends NodeMaterialBlock {
  60275. /**
  60276. * Creates a new StepBlock
  60277. * @param name defines the block name
  60278. */
  60279. constructor(name: string);
  60280. /**
  60281. * Gets the current class name
  60282. * @returns the class name
  60283. */
  60284. getClassName(): string;
  60285. /**
  60286. * Gets the value operand input component
  60287. */
  60288. get value(): NodeMaterialConnectionPoint;
  60289. /**
  60290. * Gets the edge operand input component
  60291. */
  60292. get edge(): NodeMaterialConnectionPoint;
  60293. /**
  60294. * Gets the output component
  60295. */
  60296. get output(): NodeMaterialConnectionPoint;
  60297. protected _buildBlock(state: NodeMaterialBuildState): this;
  60298. }
  60299. }
  60300. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60304. /**
  60305. * Block used to get the opposite (1 - x) of a value
  60306. */
  60307. export class OneMinusBlock extends NodeMaterialBlock {
  60308. /**
  60309. * Creates a new OneMinusBlock
  60310. * @param name defines the block name
  60311. */
  60312. constructor(name: string);
  60313. /**
  60314. * Gets the current class name
  60315. * @returns the class name
  60316. */
  60317. getClassName(): string;
  60318. /**
  60319. * Gets the input component
  60320. */
  60321. get input(): NodeMaterialConnectionPoint;
  60322. /**
  60323. * Gets the output component
  60324. */
  60325. get output(): NodeMaterialConnectionPoint;
  60326. protected _buildBlock(state: NodeMaterialBuildState): this;
  60327. }
  60328. }
  60329. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60333. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60334. /**
  60335. * Block used to get the view direction
  60336. */
  60337. export class ViewDirectionBlock extends NodeMaterialBlock {
  60338. /**
  60339. * Creates a new ViewDirectionBlock
  60340. * @param name defines the block name
  60341. */
  60342. constructor(name: string);
  60343. /**
  60344. * Gets the current class name
  60345. * @returns the class name
  60346. */
  60347. getClassName(): string;
  60348. /**
  60349. * Gets the world position component
  60350. */
  60351. get worldPosition(): NodeMaterialConnectionPoint;
  60352. /**
  60353. * Gets the camera position component
  60354. */
  60355. get cameraPosition(): NodeMaterialConnectionPoint;
  60356. /**
  60357. * Gets the output component
  60358. */
  60359. get output(): NodeMaterialConnectionPoint;
  60360. autoConfigure(material: NodeMaterial): void;
  60361. protected _buildBlock(state: NodeMaterialBuildState): this;
  60362. }
  60363. }
  60364. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60368. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60369. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60370. /**
  60371. * Block used to compute fresnel value
  60372. */
  60373. export class FresnelBlock extends NodeMaterialBlock {
  60374. /**
  60375. * Create a new FresnelBlock
  60376. * @param name defines the block name
  60377. */
  60378. constructor(name: string);
  60379. /**
  60380. * Gets the current class name
  60381. * @returns the class name
  60382. */
  60383. getClassName(): string;
  60384. /**
  60385. * Gets the world normal input component
  60386. */
  60387. get worldNormal(): NodeMaterialConnectionPoint;
  60388. /**
  60389. * Gets the view direction input component
  60390. */
  60391. get viewDirection(): NodeMaterialConnectionPoint;
  60392. /**
  60393. * Gets the bias input component
  60394. */
  60395. get bias(): NodeMaterialConnectionPoint;
  60396. /**
  60397. * Gets the camera (or eye) position component
  60398. */
  60399. get power(): NodeMaterialConnectionPoint;
  60400. /**
  60401. * Gets the fresnel output component
  60402. */
  60403. get fresnel(): NodeMaterialConnectionPoint;
  60404. autoConfigure(material: NodeMaterial): void;
  60405. protected _buildBlock(state: NodeMaterialBuildState): this;
  60406. }
  60407. }
  60408. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60412. /**
  60413. * Block used to get the max of 2 values
  60414. */
  60415. export class MaxBlock extends NodeMaterialBlock {
  60416. /**
  60417. * Creates a new MaxBlock
  60418. * @param name defines the block name
  60419. */
  60420. constructor(name: string);
  60421. /**
  60422. * Gets the current class name
  60423. * @returns the class name
  60424. */
  60425. getClassName(): string;
  60426. /**
  60427. * Gets the left operand input component
  60428. */
  60429. get left(): NodeMaterialConnectionPoint;
  60430. /**
  60431. * Gets the right operand input component
  60432. */
  60433. get right(): NodeMaterialConnectionPoint;
  60434. /**
  60435. * Gets the output component
  60436. */
  60437. get output(): NodeMaterialConnectionPoint;
  60438. protected _buildBlock(state: NodeMaterialBuildState): this;
  60439. }
  60440. }
  60441. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60445. /**
  60446. * Block used to get the min of 2 values
  60447. */
  60448. export class MinBlock extends NodeMaterialBlock {
  60449. /**
  60450. * Creates a new MinBlock
  60451. * @param name defines the block name
  60452. */
  60453. constructor(name: string);
  60454. /**
  60455. * Gets the current class name
  60456. * @returns the class name
  60457. */
  60458. getClassName(): string;
  60459. /**
  60460. * Gets the left operand input component
  60461. */
  60462. get left(): NodeMaterialConnectionPoint;
  60463. /**
  60464. * Gets the right operand input component
  60465. */
  60466. get right(): NodeMaterialConnectionPoint;
  60467. /**
  60468. * Gets the output component
  60469. */
  60470. get output(): NodeMaterialConnectionPoint;
  60471. protected _buildBlock(state: NodeMaterialBuildState): this;
  60472. }
  60473. }
  60474. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60478. /**
  60479. * Block used to get the distance between 2 values
  60480. */
  60481. export class DistanceBlock extends NodeMaterialBlock {
  60482. /**
  60483. * Creates a new DistanceBlock
  60484. * @param name defines the block name
  60485. */
  60486. constructor(name: string);
  60487. /**
  60488. * Gets the current class name
  60489. * @returns the class name
  60490. */
  60491. getClassName(): string;
  60492. /**
  60493. * Gets the left operand input component
  60494. */
  60495. get left(): NodeMaterialConnectionPoint;
  60496. /**
  60497. * Gets the right operand input component
  60498. */
  60499. get right(): NodeMaterialConnectionPoint;
  60500. /**
  60501. * Gets the output component
  60502. */
  60503. get output(): NodeMaterialConnectionPoint;
  60504. protected _buildBlock(state: NodeMaterialBuildState): this;
  60505. }
  60506. }
  60507. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60511. /**
  60512. * Block used to get the length of a vector
  60513. */
  60514. export class LengthBlock extends NodeMaterialBlock {
  60515. /**
  60516. * Creates a new LengthBlock
  60517. * @param name defines the block name
  60518. */
  60519. constructor(name: string);
  60520. /**
  60521. * Gets the current class name
  60522. * @returns the class name
  60523. */
  60524. getClassName(): string;
  60525. /**
  60526. * Gets the value input component
  60527. */
  60528. get value(): NodeMaterialConnectionPoint;
  60529. /**
  60530. * Gets the output component
  60531. */
  60532. get output(): NodeMaterialConnectionPoint;
  60533. protected _buildBlock(state: NodeMaterialBuildState): this;
  60534. }
  60535. }
  60536. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60540. /**
  60541. * Block used to get negative version of a value (i.e. x * -1)
  60542. */
  60543. export class NegateBlock extends NodeMaterialBlock {
  60544. /**
  60545. * Creates a new NegateBlock
  60546. * @param name defines the block name
  60547. */
  60548. constructor(name: string);
  60549. /**
  60550. * Gets the current class name
  60551. * @returns the class name
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Gets the value input component
  60556. */
  60557. get value(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the output component
  60560. */
  60561. get output(): NodeMaterialConnectionPoint;
  60562. protected _buildBlock(state: NodeMaterialBuildState): this;
  60563. }
  60564. }
  60565. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60569. /**
  60570. * Block used to get the value of the first parameter raised to the power of the second
  60571. */
  60572. export class PowBlock extends NodeMaterialBlock {
  60573. /**
  60574. * Creates a new PowBlock
  60575. * @param name defines the block name
  60576. */
  60577. constructor(name: string);
  60578. /**
  60579. * Gets the current class name
  60580. * @returns the class name
  60581. */
  60582. getClassName(): string;
  60583. /**
  60584. * Gets the value operand input component
  60585. */
  60586. get value(): NodeMaterialConnectionPoint;
  60587. /**
  60588. * Gets the power operand input component
  60589. */
  60590. get power(): NodeMaterialConnectionPoint;
  60591. /**
  60592. * Gets the output component
  60593. */
  60594. get output(): NodeMaterialConnectionPoint;
  60595. protected _buildBlock(state: NodeMaterialBuildState): this;
  60596. }
  60597. }
  60598. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60603. /**
  60604. * Block used to get a random number
  60605. */
  60606. export class RandomNumberBlock extends NodeMaterialBlock {
  60607. /**
  60608. * Creates a new RandomNumberBlock
  60609. * @param name defines the block name
  60610. */
  60611. constructor(name: string);
  60612. /**
  60613. * Gets the current class name
  60614. * @returns the class name
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Gets the seed input component
  60619. */
  60620. get seed(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the output component
  60623. */
  60624. get output(): NodeMaterialConnectionPoint;
  60625. protected _buildBlock(state: NodeMaterialBuildState): this;
  60626. }
  60627. }
  60628. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60632. /**
  60633. * Block used to compute arc tangent of 2 values
  60634. */
  60635. export class ArcTan2Block extends NodeMaterialBlock {
  60636. /**
  60637. * Creates a new ArcTan2Block
  60638. * @param name defines the block name
  60639. */
  60640. constructor(name: string);
  60641. /**
  60642. * Gets the current class name
  60643. * @returns the class name
  60644. */
  60645. getClassName(): string;
  60646. /**
  60647. * Gets the x operand input component
  60648. */
  60649. get x(): NodeMaterialConnectionPoint;
  60650. /**
  60651. * Gets the y operand input component
  60652. */
  60653. get y(): NodeMaterialConnectionPoint;
  60654. /**
  60655. * Gets the output component
  60656. */
  60657. get output(): NodeMaterialConnectionPoint;
  60658. protected _buildBlock(state: NodeMaterialBuildState): this;
  60659. }
  60660. }
  60661. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60665. /**
  60666. * Block used to smooth step a value
  60667. */
  60668. export class SmoothStepBlock extends NodeMaterialBlock {
  60669. /**
  60670. * Creates a new SmoothStepBlock
  60671. * @param name defines the block name
  60672. */
  60673. constructor(name: string);
  60674. /**
  60675. * Gets the current class name
  60676. * @returns the class name
  60677. */
  60678. getClassName(): string;
  60679. /**
  60680. * Gets the value operand input component
  60681. */
  60682. get value(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the first edge operand input component
  60685. */
  60686. get edge0(): NodeMaterialConnectionPoint;
  60687. /**
  60688. * Gets the second edge operand input component
  60689. */
  60690. get edge1(): NodeMaterialConnectionPoint;
  60691. /**
  60692. * Gets the output component
  60693. */
  60694. get output(): NodeMaterialConnectionPoint;
  60695. protected _buildBlock(state: NodeMaterialBuildState): this;
  60696. }
  60697. }
  60698. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60702. /**
  60703. * Block used to get the reciprocal (1 / x) of a value
  60704. */
  60705. export class ReciprocalBlock extends NodeMaterialBlock {
  60706. /**
  60707. * Creates a new ReciprocalBlock
  60708. * @param name defines the block name
  60709. */
  60710. constructor(name: string);
  60711. /**
  60712. * Gets the current class name
  60713. * @returns the class name
  60714. */
  60715. getClassName(): string;
  60716. /**
  60717. * Gets the input component
  60718. */
  60719. get input(): NodeMaterialConnectionPoint;
  60720. /**
  60721. * Gets the output component
  60722. */
  60723. get output(): NodeMaterialConnectionPoint;
  60724. protected _buildBlock(state: NodeMaterialBuildState): this;
  60725. }
  60726. }
  60727. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60731. /**
  60732. * Block used to replace a color by another one
  60733. */
  60734. export class ReplaceColorBlock extends NodeMaterialBlock {
  60735. /**
  60736. * Creates a new ReplaceColorBlock
  60737. * @param name defines the block name
  60738. */
  60739. constructor(name: string);
  60740. /**
  60741. * Gets the current class name
  60742. * @returns the class name
  60743. */
  60744. getClassName(): string;
  60745. /**
  60746. * Gets the value input component
  60747. */
  60748. get value(): NodeMaterialConnectionPoint;
  60749. /**
  60750. * Gets the reference input component
  60751. */
  60752. get reference(): NodeMaterialConnectionPoint;
  60753. /**
  60754. * Gets the distance input component
  60755. */
  60756. get distance(): NodeMaterialConnectionPoint;
  60757. /**
  60758. * Gets the replacement input component
  60759. */
  60760. get replacement(): NodeMaterialConnectionPoint;
  60761. /**
  60762. * Gets the output component
  60763. */
  60764. get output(): NodeMaterialConnectionPoint;
  60765. protected _buildBlock(state: NodeMaterialBuildState): this;
  60766. }
  60767. }
  60768. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60772. /**
  60773. * Block used to posterize a value
  60774. * @see https://en.wikipedia.org/wiki/Posterization
  60775. */
  60776. export class PosterizeBlock extends NodeMaterialBlock {
  60777. /**
  60778. * Creates a new PosterizeBlock
  60779. * @param name defines the block name
  60780. */
  60781. constructor(name: string);
  60782. /**
  60783. * Gets the current class name
  60784. * @returns the class name
  60785. */
  60786. getClassName(): string;
  60787. /**
  60788. * Gets the value input component
  60789. */
  60790. get value(): NodeMaterialConnectionPoint;
  60791. /**
  60792. * Gets the steps input component
  60793. */
  60794. get steps(): NodeMaterialConnectionPoint;
  60795. /**
  60796. * Gets the output component
  60797. */
  60798. get output(): NodeMaterialConnectionPoint;
  60799. protected _buildBlock(state: NodeMaterialBuildState): this;
  60800. }
  60801. }
  60802. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60806. import { Scene } from "babylonjs/scene";
  60807. /**
  60808. * Operations supported by the Wave block
  60809. */
  60810. export enum WaveBlockKind {
  60811. /** SawTooth */
  60812. SawTooth = 0,
  60813. /** Square */
  60814. Square = 1,
  60815. /** Triangle */
  60816. Triangle = 2
  60817. }
  60818. /**
  60819. * Block used to apply wave operation to floats
  60820. */
  60821. export class WaveBlock extends NodeMaterialBlock {
  60822. /**
  60823. * Gets or sets the kibnd of wave to be applied by the block
  60824. */
  60825. kind: WaveBlockKind;
  60826. /**
  60827. * Creates a new WaveBlock
  60828. * @param name defines the block name
  60829. */
  60830. constructor(name: string);
  60831. /**
  60832. * Gets the current class name
  60833. * @returns the class name
  60834. */
  60835. getClassName(): string;
  60836. /**
  60837. * Gets the input component
  60838. */
  60839. get input(): NodeMaterialConnectionPoint;
  60840. /**
  60841. * Gets the output component
  60842. */
  60843. get output(): NodeMaterialConnectionPoint;
  60844. protected _buildBlock(state: NodeMaterialBuildState): this;
  60845. serialize(): any;
  60846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60847. }
  60848. }
  60849. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60853. import { Color3 } from "babylonjs/Maths/math.color";
  60854. import { Scene } from "babylonjs/scene";
  60855. /**
  60856. * Class used to store a color step for the GradientBlock
  60857. */
  60858. export class GradientBlockColorStep {
  60859. /**
  60860. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60861. */
  60862. step: number;
  60863. /**
  60864. * Gets or sets the color associated with this step
  60865. */
  60866. color: Color3;
  60867. /**
  60868. * Creates a new GradientBlockColorStep
  60869. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60870. * @param color defines the color associated with this step
  60871. */
  60872. constructor(
  60873. /**
  60874. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60875. */
  60876. step: number,
  60877. /**
  60878. * Gets or sets the color associated with this step
  60879. */
  60880. color: Color3);
  60881. }
  60882. /**
  60883. * Block used to return a color from a gradient based on an input value between 0 and 1
  60884. */
  60885. export class GradientBlock extends NodeMaterialBlock {
  60886. /**
  60887. * Gets or sets the list of color steps
  60888. */
  60889. colorSteps: GradientBlockColorStep[];
  60890. /**
  60891. * Creates a new GradientBlock
  60892. * @param name defines the block name
  60893. */
  60894. constructor(name: string);
  60895. /**
  60896. * Gets the current class name
  60897. * @returns the class name
  60898. */
  60899. getClassName(): string;
  60900. /**
  60901. * Gets the gradient input component
  60902. */
  60903. get gradient(): NodeMaterialConnectionPoint;
  60904. /**
  60905. * Gets the output component
  60906. */
  60907. get output(): NodeMaterialConnectionPoint;
  60908. private _writeColorConstant;
  60909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60910. serialize(): any;
  60911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60912. protected _dumpPropertiesCode(): string;
  60913. }
  60914. }
  60915. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60919. /**
  60920. * Block used to normalize lerp between 2 values
  60921. */
  60922. export class NLerpBlock extends NodeMaterialBlock {
  60923. /**
  60924. * Creates a new NLerpBlock
  60925. * @param name defines the block name
  60926. */
  60927. constructor(name: string);
  60928. /**
  60929. * Gets the current class name
  60930. * @returns the class name
  60931. */
  60932. getClassName(): string;
  60933. /**
  60934. * Gets the left operand input component
  60935. */
  60936. get left(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the right operand input component
  60939. */
  60940. get right(): NodeMaterialConnectionPoint;
  60941. /**
  60942. * Gets the gradient operand input component
  60943. */
  60944. get gradient(): NodeMaterialConnectionPoint;
  60945. /**
  60946. * Gets the output component
  60947. */
  60948. get output(): NodeMaterialConnectionPoint;
  60949. protected _buildBlock(state: NodeMaterialBuildState): this;
  60950. }
  60951. }
  60952. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  60953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60956. import { Scene } from "babylonjs/scene";
  60957. /**
  60958. * block used to Generate a Worley Noise 3D Noise Pattern
  60959. */
  60960. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60961. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60962. manhattanDistance: boolean;
  60963. /**
  60964. * Creates a new WorleyNoise3DBlock
  60965. * @param name defines the block name
  60966. */
  60967. constructor(name: string);
  60968. /**
  60969. * Gets the current class name
  60970. * @returns the class name
  60971. */
  60972. getClassName(): string;
  60973. /**
  60974. * Gets the seed input component
  60975. */
  60976. get seed(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the jitter input component
  60979. */
  60980. get jitter(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the output component
  60983. */
  60984. get output(): NodeMaterialConnectionPoint;
  60985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60986. /**
  60987. * Exposes the properties to the UI?
  60988. */
  60989. protected _dumpPropertiesCode(): string;
  60990. /**
  60991. * Exposes the properties to the Seralize?
  60992. */
  60993. serialize(): any;
  60994. /**
  60995. * Exposes the properties to the deseralize?
  60996. */
  60997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60998. }
  60999. }
  61000. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61004. /**
  61005. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61006. */
  61007. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61008. /**
  61009. * Creates a new SimplexPerlin3DBlock
  61010. * @param name defines the block name
  61011. */
  61012. constructor(name: string);
  61013. /**
  61014. * Gets the current class name
  61015. * @returns the class name
  61016. */
  61017. getClassName(): string;
  61018. /**
  61019. * Gets the seed operand input component
  61020. */
  61021. get seed(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the output component
  61024. */
  61025. get output(): NodeMaterialConnectionPoint;
  61026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61027. }
  61028. }
  61029. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61033. /**
  61034. * Block used to blend normals
  61035. */
  61036. export class NormalBlendBlock extends NodeMaterialBlock {
  61037. /**
  61038. * Creates a new NormalBlendBlock
  61039. * @param name defines the block name
  61040. */
  61041. constructor(name: string);
  61042. /**
  61043. * Gets the current class name
  61044. * @returns the class name
  61045. */
  61046. getClassName(): string;
  61047. /**
  61048. * Gets the first input component
  61049. */
  61050. get normalMap0(): NodeMaterialConnectionPoint;
  61051. /**
  61052. * Gets the second input component
  61053. */
  61054. get normalMap1(): NodeMaterialConnectionPoint;
  61055. /**
  61056. * Gets the output component
  61057. */
  61058. get output(): NodeMaterialConnectionPoint;
  61059. protected _buildBlock(state: NodeMaterialBuildState): this;
  61060. }
  61061. }
  61062. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61066. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61067. /**
  61068. * Block used to rotate a 2d vector by a given angle
  61069. */
  61070. export class Rotate2dBlock extends NodeMaterialBlock {
  61071. /**
  61072. * Creates a new Rotate2dBlock
  61073. * @param name defines the block name
  61074. */
  61075. constructor(name: string);
  61076. /**
  61077. * Gets the current class name
  61078. * @returns the class name
  61079. */
  61080. getClassName(): string;
  61081. /**
  61082. * Gets the input vector
  61083. */
  61084. get input(): NodeMaterialConnectionPoint;
  61085. /**
  61086. * Gets the input angle
  61087. */
  61088. get angle(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the output component
  61091. */
  61092. get output(): NodeMaterialConnectionPoint;
  61093. autoConfigure(material: NodeMaterial): void;
  61094. protected _buildBlock(state: NodeMaterialBuildState): this;
  61095. }
  61096. }
  61097. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61101. /**
  61102. * Block used to get the reflected vector from a direction and a normal
  61103. */
  61104. export class ReflectBlock extends NodeMaterialBlock {
  61105. /**
  61106. * Creates a new ReflectBlock
  61107. * @param name defines the block name
  61108. */
  61109. constructor(name: string);
  61110. /**
  61111. * Gets the current class name
  61112. * @returns the class name
  61113. */
  61114. getClassName(): string;
  61115. /**
  61116. * Gets the incident component
  61117. */
  61118. get incident(): NodeMaterialConnectionPoint;
  61119. /**
  61120. * Gets the normal component
  61121. */
  61122. get normal(): NodeMaterialConnectionPoint;
  61123. /**
  61124. * Gets the output component
  61125. */
  61126. get output(): NodeMaterialConnectionPoint;
  61127. protected _buildBlock(state: NodeMaterialBuildState): this;
  61128. }
  61129. }
  61130. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61134. /**
  61135. * Block used to get the refracted vector from a direction and a normal
  61136. */
  61137. export class RefractBlock extends NodeMaterialBlock {
  61138. /**
  61139. * Creates a new RefractBlock
  61140. * @param name defines the block name
  61141. */
  61142. constructor(name: string);
  61143. /**
  61144. * Gets the current class name
  61145. * @returns the class name
  61146. */
  61147. getClassName(): string;
  61148. /**
  61149. * Gets the incident component
  61150. */
  61151. get incident(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the normal component
  61154. */
  61155. get normal(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the index of refraction component
  61158. */
  61159. get ior(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the output component
  61162. */
  61163. get output(): NodeMaterialConnectionPoint;
  61164. protected _buildBlock(state: NodeMaterialBuildState): this;
  61165. }
  61166. }
  61167. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61171. /**
  61172. * Block used to desaturate a color
  61173. */
  61174. export class DesaturateBlock extends NodeMaterialBlock {
  61175. /**
  61176. * Creates a new DesaturateBlock
  61177. * @param name defines the block name
  61178. */
  61179. constructor(name: string);
  61180. /**
  61181. * Gets the current class name
  61182. * @returns the class name
  61183. */
  61184. getClassName(): string;
  61185. /**
  61186. * Gets the color operand input component
  61187. */
  61188. get color(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Gets the level operand input component
  61191. */
  61192. get level(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the output component
  61195. */
  61196. get output(): NodeMaterialConnectionPoint;
  61197. protected _buildBlock(state: NodeMaterialBuildState): this;
  61198. }
  61199. }
  61200. declare module "babylonjs/Materials/Node/Blocks/index" {
  61201. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61202. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61203. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61204. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61205. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61206. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61207. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61208. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61209. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61210. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61211. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61212. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61213. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61214. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61215. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61216. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61217. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61218. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61219. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61220. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61221. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61222. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61223. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61224. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61225. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61226. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61227. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61228. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61229. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61230. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61231. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61232. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61233. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61234. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61235. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61236. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61237. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61238. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61239. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61240. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61241. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61242. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61243. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61244. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61245. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61246. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61247. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61248. }
  61249. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61250. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61251. }
  61252. declare module "babylonjs/Materials/Node/index" {
  61253. export * from "babylonjs/Materials/Node/Enums/index";
  61254. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61255. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61256. export * from "babylonjs/Materials/Node/nodeMaterial";
  61257. export * from "babylonjs/Materials/Node/Blocks/index";
  61258. export * from "babylonjs/Materials/Node/Optimizers/index";
  61259. }
  61260. declare module "babylonjs/Materials/effectRenderer" {
  61261. import { Nullable } from "babylonjs/types";
  61262. import { Texture } from "babylonjs/Materials/Textures/texture";
  61263. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61264. import { Viewport } from "babylonjs/Maths/math.viewport";
  61265. import { Observable } from "babylonjs/Misc/observable";
  61266. import { Effect } from "babylonjs/Materials/effect";
  61267. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61268. import "babylonjs/Shaders/postprocess.vertex";
  61269. /**
  61270. * Effect Render Options
  61271. */
  61272. export interface IEffectRendererOptions {
  61273. /**
  61274. * Defines the vertices positions.
  61275. */
  61276. positions?: number[];
  61277. /**
  61278. * Defines the indices.
  61279. */
  61280. indices?: number[];
  61281. }
  61282. /**
  61283. * Helper class to render one or more effects
  61284. */
  61285. export class EffectRenderer {
  61286. private engine;
  61287. private static _DefaultOptions;
  61288. private _vertexBuffers;
  61289. private _indexBuffer;
  61290. private _ringBufferIndex;
  61291. private _ringScreenBuffer;
  61292. private _fullscreenViewport;
  61293. private _getNextFrameBuffer;
  61294. /**
  61295. * Creates an effect renderer
  61296. * @param engine the engine to use for rendering
  61297. * @param options defines the options of the effect renderer
  61298. */
  61299. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61300. /**
  61301. * Sets the current viewport in normalized coordinates 0-1
  61302. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61303. */
  61304. setViewport(viewport?: Viewport): void;
  61305. /**
  61306. * Binds the embedded attributes buffer to the effect.
  61307. * @param effect Defines the effect to bind the attributes for
  61308. */
  61309. bindBuffers(effect: Effect): void;
  61310. /**
  61311. * Sets the current effect wrapper to use during draw.
  61312. * The effect needs to be ready before calling this api.
  61313. * This also sets the default full screen position attribute.
  61314. * @param effectWrapper Defines the effect to draw with
  61315. */
  61316. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61317. /**
  61318. * Draws a full screen quad.
  61319. */
  61320. draw(): void;
  61321. /**
  61322. * renders one or more effects to a specified texture
  61323. * @param effectWrappers list of effects to renderer
  61324. * @param outputTexture texture to draw to, if null it will render to the screen
  61325. */
  61326. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61327. /**
  61328. * Disposes of the effect renderer
  61329. */
  61330. dispose(): void;
  61331. }
  61332. /**
  61333. * Options to create an EffectWrapper
  61334. */
  61335. interface EffectWrapperCreationOptions {
  61336. /**
  61337. * Engine to use to create the effect
  61338. */
  61339. engine: ThinEngine;
  61340. /**
  61341. * Fragment shader for the effect
  61342. */
  61343. fragmentShader: string;
  61344. /**
  61345. * Vertex shader for the effect
  61346. */
  61347. vertexShader?: string;
  61348. /**
  61349. * Attributes to use in the shader
  61350. */
  61351. attributeNames?: Array<string>;
  61352. /**
  61353. * Uniforms to use in the shader
  61354. */
  61355. uniformNames?: Array<string>;
  61356. /**
  61357. * Texture sampler names to use in the shader
  61358. */
  61359. samplerNames?: Array<string>;
  61360. /**
  61361. * The friendly name of the effect displayed in Spector.
  61362. */
  61363. name?: string;
  61364. }
  61365. /**
  61366. * Wraps an effect to be used for rendering
  61367. */
  61368. export class EffectWrapper {
  61369. /**
  61370. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61371. */
  61372. onApplyObservable: Observable<{}>;
  61373. /**
  61374. * The underlying effect
  61375. */
  61376. effect: Effect;
  61377. /**
  61378. * Creates an effect to be renderer
  61379. * @param creationOptions options to create the effect
  61380. */
  61381. constructor(creationOptions: EffectWrapperCreationOptions);
  61382. /**
  61383. * Disposes of the effect wrapper
  61384. */
  61385. dispose(): void;
  61386. }
  61387. }
  61388. declare module "babylonjs/Materials/index" {
  61389. export * from "babylonjs/Materials/Background/index";
  61390. export * from "babylonjs/Materials/colorCurves";
  61391. export * from "babylonjs/Materials/iEffectFallbacks";
  61392. export * from "babylonjs/Materials/effectFallbacks";
  61393. export * from "babylonjs/Materials/effect";
  61394. export * from "babylonjs/Materials/fresnelParameters";
  61395. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61396. export * from "babylonjs/Materials/material";
  61397. export * from "babylonjs/Materials/materialDefines";
  61398. export * from "babylonjs/Materials/materialHelper";
  61399. export * from "babylonjs/Materials/multiMaterial";
  61400. export * from "babylonjs/Materials/PBR/index";
  61401. export * from "babylonjs/Materials/pushMaterial";
  61402. export * from "babylonjs/Materials/shaderMaterial";
  61403. export * from "babylonjs/Materials/standardMaterial";
  61404. export * from "babylonjs/Materials/Textures/index";
  61405. export * from "babylonjs/Materials/uniformBuffer";
  61406. export * from "babylonjs/Materials/materialFlags";
  61407. export * from "babylonjs/Materials/Node/index";
  61408. export * from "babylonjs/Materials/effectRenderer";
  61409. }
  61410. declare module "babylonjs/Maths/index" {
  61411. export * from "babylonjs/Maths/math.scalar";
  61412. export * from "babylonjs/Maths/math";
  61413. export * from "babylonjs/Maths/sphericalPolynomial";
  61414. }
  61415. declare module "babylonjs/Misc/workerPool" {
  61416. import { IDisposable } from "babylonjs/scene";
  61417. /**
  61418. * Helper class to push actions to a pool of workers.
  61419. */
  61420. export class WorkerPool implements IDisposable {
  61421. private _workerInfos;
  61422. private _pendingActions;
  61423. /**
  61424. * Constructor
  61425. * @param workers Array of workers to use for actions
  61426. */
  61427. constructor(workers: Array<Worker>);
  61428. /**
  61429. * Terminates all workers and clears any pending actions.
  61430. */
  61431. dispose(): void;
  61432. /**
  61433. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61434. * pended until a worker has completed its action.
  61435. * @param action The action to perform. Call onComplete when the action is complete.
  61436. */
  61437. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61438. private _execute;
  61439. }
  61440. }
  61441. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61442. import { IDisposable } from "babylonjs/scene";
  61443. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61444. /**
  61445. * Configuration for Draco compression
  61446. */
  61447. export interface IDracoCompressionConfiguration {
  61448. /**
  61449. * Configuration for the decoder.
  61450. */
  61451. decoder: {
  61452. /**
  61453. * The url to the WebAssembly module.
  61454. */
  61455. wasmUrl?: string;
  61456. /**
  61457. * The url to the WebAssembly binary.
  61458. */
  61459. wasmBinaryUrl?: string;
  61460. /**
  61461. * The url to the fallback JavaScript module.
  61462. */
  61463. fallbackUrl?: string;
  61464. };
  61465. }
  61466. /**
  61467. * Draco compression (https://google.github.io/draco/)
  61468. *
  61469. * This class wraps the Draco module.
  61470. *
  61471. * **Encoder**
  61472. *
  61473. * The encoder is not currently implemented.
  61474. *
  61475. * **Decoder**
  61476. *
  61477. * 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.
  61478. *
  61479. * To update the configuration, use the following code:
  61480. * ```javascript
  61481. * DracoCompression.Configuration = {
  61482. * decoder: {
  61483. * wasmUrl: "<url to the WebAssembly library>",
  61484. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61485. * fallbackUrl: "<url to the fallback JavaScript library>",
  61486. * }
  61487. * };
  61488. * ```
  61489. *
  61490. * 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.
  61491. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61492. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61493. *
  61494. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61495. * ```javascript
  61496. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61497. * ```
  61498. *
  61499. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61500. */
  61501. export class DracoCompression implements IDisposable {
  61502. private _workerPoolPromise?;
  61503. private _decoderModulePromise?;
  61504. /**
  61505. * The configuration. Defaults to the following urls:
  61506. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61507. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61508. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61509. */
  61510. static Configuration: IDracoCompressionConfiguration;
  61511. /**
  61512. * Returns true if the decoder configuration is available.
  61513. */
  61514. static get DecoderAvailable(): boolean;
  61515. /**
  61516. * Default number of workers to create when creating the draco compression object.
  61517. */
  61518. static DefaultNumWorkers: number;
  61519. private static GetDefaultNumWorkers;
  61520. private static _Default;
  61521. /**
  61522. * Default instance for the draco compression object.
  61523. */
  61524. static get Default(): DracoCompression;
  61525. /**
  61526. * Constructor
  61527. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61528. */
  61529. constructor(numWorkers?: number);
  61530. /**
  61531. * Stop all async operations and release resources.
  61532. */
  61533. dispose(): void;
  61534. /**
  61535. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61536. * @returns a promise that resolves when ready
  61537. */
  61538. whenReadyAsync(): Promise<void>;
  61539. /**
  61540. * Decode Draco compressed mesh data to vertex data.
  61541. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61542. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61543. * @returns A promise that resolves with the decoded vertex data
  61544. */
  61545. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61546. [kind: string]: number;
  61547. }): Promise<VertexData>;
  61548. }
  61549. }
  61550. declare module "babylonjs/Meshes/Compression/index" {
  61551. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61552. }
  61553. declare module "babylonjs/Meshes/csg" {
  61554. import { Nullable } from "babylonjs/types";
  61555. import { Scene } from "babylonjs/scene";
  61556. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61557. import { Mesh } from "babylonjs/Meshes/mesh";
  61558. import { Material } from "babylonjs/Materials/material";
  61559. /**
  61560. * Class for building Constructive Solid Geometry
  61561. */
  61562. export class CSG {
  61563. private polygons;
  61564. /**
  61565. * The world matrix
  61566. */
  61567. matrix: Matrix;
  61568. /**
  61569. * Stores the position
  61570. */
  61571. position: Vector3;
  61572. /**
  61573. * Stores the rotation
  61574. */
  61575. rotation: Vector3;
  61576. /**
  61577. * Stores the rotation quaternion
  61578. */
  61579. rotationQuaternion: Nullable<Quaternion>;
  61580. /**
  61581. * Stores the scaling vector
  61582. */
  61583. scaling: Vector3;
  61584. /**
  61585. * Convert the Mesh to CSG
  61586. * @param mesh The Mesh to convert to CSG
  61587. * @returns A new CSG from the Mesh
  61588. */
  61589. static FromMesh(mesh: Mesh): CSG;
  61590. /**
  61591. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61592. * @param polygons Polygons used to construct a CSG solid
  61593. */
  61594. private static FromPolygons;
  61595. /**
  61596. * Clones, or makes a deep copy, of the CSG
  61597. * @returns A new CSG
  61598. */
  61599. clone(): CSG;
  61600. /**
  61601. * Unions this CSG with another CSG
  61602. * @param csg The CSG to union against this CSG
  61603. * @returns The unioned CSG
  61604. */
  61605. union(csg: CSG): CSG;
  61606. /**
  61607. * Unions this CSG with another CSG in place
  61608. * @param csg The CSG to union against this CSG
  61609. */
  61610. unionInPlace(csg: CSG): void;
  61611. /**
  61612. * Subtracts this CSG with another CSG
  61613. * @param csg The CSG to subtract against this CSG
  61614. * @returns A new CSG
  61615. */
  61616. subtract(csg: CSG): CSG;
  61617. /**
  61618. * Subtracts this CSG with another CSG in place
  61619. * @param csg The CSG to subtact against this CSG
  61620. */
  61621. subtractInPlace(csg: CSG): void;
  61622. /**
  61623. * Intersect this CSG with another CSG
  61624. * @param csg The CSG to intersect against this CSG
  61625. * @returns A new CSG
  61626. */
  61627. intersect(csg: CSG): CSG;
  61628. /**
  61629. * Intersects this CSG with another CSG in place
  61630. * @param csg The CSG to intersect against this CSG
  61631. */
  61632. intersectInPlace(csg: CSG): void;
  61633. /**
  61634. * Return a new CSG solid with solid and empty space switched. This solid is
  61635. * not modified.
  61636. * @returns A new CSG solid with solid and empty space switched
  61637. */
  61638. inverse(): CSG;
  61639. /**
  61640. * Inverses the CSG in place
  61641. */
  61642. inverseInPlace(): void;
  61643. /**
  61644. * This is used to keep meshes transformations so they can be restored
  61645. * when we build back a Babylon Mesh
  61646. * NB : All CSG operations are performed in world coordinates
  61647. * @param csg The CSG to copy the transform attributes from
  61648. * @returns This CSG
  61649. */
  61650. copyTransformAttributes(csg: CSG): CSG;
  61651. /**
  61652. * Build Raw mesh from CSG
  61653. * Coordinates here are in world space
  61654. * @param name The name of the mesh geometry
  61655. * @param scene The Scene
  61656. * @param keepSubMeshes Specifies if the submeshes should be kept
  61657. * @returns A new Mesh
  61658. */
  61659. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61660. /**
  61661. * Build Mesh from CSG taking material and transforms into account
  61662. * @param name The name of the Mesh
  61663. * @param material The material of the Mesh
  61664. * @param scene The Scene
  61665. * @param keepSubMeshes Specifies if submeshes should be kept
  61666. * @returns The new Mesh
  61667. */
  61668. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61669. }
  61670. }
  61671. declare module "babylonjs/Meshes/trailMesh" {
  61672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61673. import { Mesh } from "babylonjs/Meshes/mesh";
  61674. import { Scene } from "babylonjs/scene";
  61675. /**
  61676. * Class used to create a trail following a mesh
  61677. */
  61678. export class TrailMesh extends Mesh {
  61679. private _generator;
  61680. private _autoStart;
  61681. private _running;
  61682. private _diameter;
  61683. private _length;
  61684. private _sectionPolygonPointsCount;
  61685. private _sectionVectors;
  61686. private _sectionNormalVectors;
  61687. private _beforeRenderObserver;
  61688. /**
  61689. * @constructor
  61690. * @param name The value used by scene.getMeshByName() to do a lookup.
  61691. * @param generator The mesh to generate a trail.
  61692. * @param scene The scene to add this mesh to.
  61693. * @param diameter Diameter of trailing mesh. Default is 1.
  61694. * @param length Length of trailing mesh. Default is 60.
  61695. * @param autoStart Automatically start trailing mesh. Default true.
  61696. */
  61697. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61698. /**
  61699. * "TrailMesh"
  61700. * @returns "TrailMesh"
  61701. */
  61702. getClassName(): string;
  61703. private _createMesh;
  61704. /**
  61705. * Start trailing mesh.
  61706. */
  61707. start(): void;
  61708. /**
  61709. * Stop trailing mesh.
  61710. */
  61711. stop(): void;
  61712. /**
  61713. * Update trailing mesh geometry.
  61714. */
  61715. update(): void;
  61716. /**
  61717. * Returns a new TrailMesh object.
  61718. * @param name is a string, the name given to the new mesh
  61719. * @param newGenerator use new generator object for cloned trail mesh
  61720. * @returns a new mesh
  61721. */
  61722. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61723. /**
  61724. * Serializes this trail mesh
  61725. * @param serializationObject object to write serialization to
  61726. */
  61727. serialize(serializationObject: any): void;
  61728. /**
  61729. * Parses a serialized trail mesh
  61730. * @param parsedMesh the serialized mesh
  61731. * @param scene the scene to create the trail mesh in
  61732. * @returns the created trail mesh
  61733. */
  61734. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61735. }
  61736. }
  61737. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61738. import { Nullable } from "babylonjs/types";
  61739. import { Scene } from "babylonjs/scene";
  61740. import { Vector4 } from "babylonjs/Maths/math.vector";
  61741. import { Color4 } from "babylonjs/Maths/math.color";
  61742. import { Mesh } from "babylonjs/Meshes/mesh";
  61743. /**
  61744. * Class containing static functions to help procedurally build meshes
  61745. */
  61746. export class TiledBoxBuilder {
  61747. /**
  61748. * Creates a box mesh
  61749. * 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)
  61750. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61754. * @param name defines the name of the mesh
  61755. * @param options defines the options used to create the mesh
  61756. * @param scene defines the hosting scene
  61757. * @returns the box mesh
  61758. */
  61759. static CreateTiledBox(name: string, options: {
  61760. pattern?: number;
  61761. width?: number;
  61762. height?: number;
  61763. depth?: number;
  61764. tileSize?: number;
  61765. tileWidth?: number;
  61766. tileHeight?: number;
  61767. alignHorizontal?: number;
  61768. alignVertical?: number;
  61769. faceUV?: Vector4[];
  61770. faceColors?: Color4[];
  61771. sideOrientation?: number;
  61772. updatable?: boolean;
  61773. }, scene?: Nullable<Scene>): Mesh;
  61774. }
  61775. }
  61776. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61777. import { Vector4 } from "babylonjs/Maths/math.vector";
  61778. import { Mesh } from "babylonjs/Meshes/mesh";
  61779. /**
  61780. * Class containing static functions to help procedurally build meshes
  61781. */
  61782. export class TorusKnotBuilder {
  61783. /**
  61784. * Creates a torus knot mesh
  61785. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61786. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61787. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61788. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61792. * @param name defines the name of the mesh
  61793. * @param options defines the options used to create the mesh
  61794. * @param scene defines the hosting scene
  61795. * @returns the torus knot mesh
  61796. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61797. */
  61798. static CreateTorusKnot(name: string, options: {
  61799. radius?: number;
  61800. tube?: number;
  61801. radialSegments?: number;
  61802. tubularSegments?: number;
  61803. p?: number;
  61804. q?: number;
  61805. updatable?: boolean;
  61806. sideOrientation?: number;
  61807. frontUVs?: Vector4;
  61808. backUVs?: Vector4;
  61809. }, scene: any): Mesh;
  61810. }
  61811. }
  61812. declare module "babylonjs/Meshes/polygonMesh" {
  61813. import { Scene } from "babylonjs/scene";
  61814. import { Vector2 } from "babylonjs/Maths/math.vector";
  61815. import { Mesh } from "babylonjs/Meshes/mesh";
  61816. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61817. import { Path2 } from "babylonjs/Maths/math.path";
  61818. /**
  61819. * Polygon
  61820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61821. */
  61822. export class Polygon {
  61823. /**
  61824. * Creates a rectangle
  61825. * @param xmin bottom X coord
  61826. * @param ymin bottom Y coord
  61827. * @param xmax top X coord
  61828. * @param ymax top Y coord
  61829. * @returns points that make the resulting rectation
  61830. */
  61831. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61832. /**
  61833. * Creates a circle
  61834. * @param radius radius of circle
  61835. * @param cx scale in x
  61836. * @param cy scale in y
  61837. * @param numberOfSides number of sides that make up the circle
  61838. * @returns points that make the resulting circle
  61839. */
  61840. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61841. /**
  61842. * Creates a polygon from input string
  61843. * @param input Input polygon data
  61844. * @returns the parsed points
  61845. */
  61846. static Parse(input: string): Vector2[];
  61847. /**
  61848. * Starts building a polygon from x and y coordinates
  61849. * @param x x coordinate
  61850. * @param y y coordinate
  61851. * @returns the started path2
  61852. */
  61853. static StartingAt(x: number, y: number): Path2;
  61854. }
  61855. /**
  61856. * Builds a polygon
  61857. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61858. */
  61859. export class PolygonMeshBuilder {
  61860. private _points;
  61861. private _outlinepoints;
  61862. private _holes;
  61863. private _name;
  61864. private _scene;
  61865. private _epoints;
  61866. private _eholes;
  61867. private _addToepoint;
  61868. /**
  61869. * Babylon reference to the earcut plugin.
  61870. */
  61871. bjsEarcut: any;
  61872. /**
  61873. * Creates a PolygonMeshBuilder
  61874. * @param name name of the builder
  61875. * @param contours Path of the polygon
  61876. * @param scene scene to add to when creating the mesh
  61877. * @param earcutInjection can be used to inject your own earcut reference
  61878. */
  61879. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61880. /**
  61881. * Adds a whole within the polygon
  61882. * @param hole Array of points defining the hole
  61883. * @returns this
  61884. */
  61885. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61886. /**
  61887. * Creates the polygon
  61888. * @param updatable If the mesh should be updatable
  61889. * @param depth The depth of the mesh created
  61890. * @returns the created mesh
  61891. */
  61892. build(updatable?: boolean, depth?: number): Mesh;
  61893. /**
  61894. * Creates the polygon
  61895. * @param depth The depth of the mesh created
  61896. * @returns the created VertexData
  61897. */
  61898. buildVertexData(depth?: number): VertexData;
  61899. /**
  61900. * Adds a side to the polygon
  61901. * @param positions points that make the polygon
  61902. * @param normals normals of the polygon
  61903. * @param uvs uvs of the polygon
  61904. * @param indices indices of the polygon
  61905. * @param bounds bounds of the polygon
  61906. * @param points points of the polygon
  61907. * @param depth depth of the polygon
  61908. * @param flip flip of the polygon
  61909. */
  61910. private addSide;
  61911. }
  61912. }
  61913. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61914. import { Scene } from "babylonjs/scene";
  61915. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61916. import { Color4 } from "babylonjs/Maths/math.color";
  61917. import { Mesh } from "babylonjs/Meshes/mesh";
  61918. import { Nullable } from "babylonjs/types";
  61919. /**
  61920. * Class containing static functions to help procedurally build meshes
  61921. */
  61922. export class PolygonBuilder {
  61923. /**
  61924. * Creates a polygon mesh
  61925. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61926. * * 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
  61927. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61930. * * Remember you can only change the shape positions, not their number when updating a polygon
  61931. * @param name defines the name of the mesh
  61932. * @param options defines the options used to create the mesh
  61933. * @param scene defines the hosting scene
  61934. * @param earcutInjection can be used to inject your own earcut reference
  61935. * @returns the polygon mesh
  61936. */
  61937. static CreatePolygon(name: string, options: {
  61938. shape: Vector3[];
  61939. holes?: Vector3[][];
  61940. depth?: number;
  61941. faceUV?: Vector4[];
  61942. faceColors?: Color4[];
  61943. updatable?: boolean;
  61944. sideOrientation?: number;
  61945. frontUVs?: Vector4;
  61946. backUVs?: Vector4;
  61947. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61948. /**
  61949. * Creates an extruded polygon mesh, with depth in the Y direction.
  61950. * * 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)
  61951. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61952. * @param name defines the name of the mesh
  61953. * @param options defines the options used to create the mesh
  61954. * @param scene defines the hosting scene
  61955. * @param earcutInjection can be used to inject your own earcut reference
  61956. * @returns the polygon mesh
  61957. */
  61958. static ExtrudePolygon(name: string, options: {
  61959. shape: Vector3[];
  61960. holes?: Vector3[][];
  61961. depth?: number;
  61962. faceUV?: Vector4[];
  61963. faceColors?: Color4[];
  61964. updatable?: boolean;
  61965. sideOrientation?: number;
  61966. frontUVs?: Vector4;
  61967. backUVs?: Vector4;
  61968. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61969. }
  61970. }
  61971. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  61972. import { Scene } from "babylonjs/scene";
  61973. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61974. import { Mesh } from "babylonjs/Meshes/mesh";
  61975. import { Nullable } from "babylonjs/types";
  61976. /**
  61977. * Class containing static functions to help procedurally build meshes
  61978. */
  61979. export class LatheBuilder {
  61980. /**
  61981. * Creates lathe mesh.
  61982. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61983. * * 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
  61984. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61985. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61986. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61987. * * 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
  61988. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61989. * * 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
  61990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61994. * @param name defines the name of the mesh
  61995. * @param options defines the options used to create the mesh
  61996. * @param scene defines the hosting scene
  61997. * @returns the lathe mesh
  61998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61999. */
  62000. static CreateLathe(name: string, options: {
  62001. shape: Vector3[];
  62002. radius?: number;
  62003. tessellation?: number;
  62004. clip?: number;
  62005. arc?: number;
  62006. closed?: boolean;
  62007. updatable?: boolean;
  62008. sideOrientation?: number;
  62009. frontUVs?: Vector4;
  62010. backUVs?: Vector4;
  62011. cap?: number;
  62012. invertUV?: boolean;
  62013. }, scene?: Nullable<Scene>): Mesh;
  62014. }
  62015. }
  62016. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62017. import { Nullable } from "babylonjs/types";
  62018. import { Scene } from "babylonjs/scene";
  62019. import { Vector4 } from "babylonjs/Maths/math.vector";
  62020. import { Mesh } from "babylonjs/Meshes/mesh";
  62021. /**
  62022. * Class containing static functions to help procedurally build meshes
  62023. */
  62024. export class TiledPlaneBuilder {
  62025. /**
  62026. * Creates a tiled plane mesh
  62027. * * The parameter `pattern` will, depending on value, do nothing or
  62028. * * * flip (reflect about central vertical) alternate tiles across and up
  62029. * * * flip every tile on alternate rows
  62030. * * * rotate (180 degs) alternate tiles across and up
  62031. * * * rotate every tile on alternate rows
  62032. * * * flip and rotate alternate tiles across and up
  62033. * * * flip and rotate every tile on alternate rows
  62034. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62035. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62038. * * 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)
  62039. * * 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)
  62040. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62041. * @param name defines the name of the mesh
  62042. * @param options defines the options used to create the mesh
  62043. * @param scene defines the hosting scene
  62044. * @returns the box mesh
  62045. */
  62046. static CreateTiledPlane(name: string, options: {
  62047. pattern?: number;
  62048. tileSize?: number;
  62049. tileWidth?: number;
  62050. tileHeight?: number;
  62051. size?: number;
  62052. width?: number;
  62053. height?: number;
  62054. alignHorizontal?: number;
  62055. alignVertical?: number;
  62056. sideOrientation?: number;
  62057. frontUVs?: Vector4;
  62058. backUVs?: Vector4;
  62059. updatable?: boolean;
  62060. }, scene?: Nullable<Scene>): Mesh;
  62061. }
  62062. }
  62063. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62064. import { Nullable } from "babylonjs/types";
  62065. import { Scene } from "babylonjs/scene";
  62066. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62067. import { Mesh } from "babylonjs/Meshes/mesh";
  62068. /**
  62069. * Class containing static functions to help procedurally build meshes
  62070. */
  62071. export class TubeBuilder {
  62072. /**
  62073. * Creates a tube mesh.
  62074. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62075. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62076. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62077. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62078. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62079. * * 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)
  62080. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62081. * * 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
  62082. * * 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
  62083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62087. * @param name defines the name of the mesh
  62088. * @param options defines the options used to create the mesh
  62089. * @param scene defines the hosting scene
  62090. * @returns the tube mesh
  62091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62092. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62093. */
  62094. static CreateTube(name: string, options: {
  62095. path: Vector3[];
  62096. radius?: number;
  62097. tessellation?: number;
  62098. radiusFunction?: {
  62099. (i: number, distance: number): number;
  62100. };
  62101. cap?: number;
  62102. arc?: number;
  62103. updatable?: boolean;
  62104. sideOrientation?: number;
  62105. frontUVs?: Vector4;
  62106. backUVs?: Vector4;
  62107. instance?: Mesh;
  62108. invertUV?: boolean;
  62109. }, scene?: Nullable<Scene>): Mesh;
  62110. }
  62111. }
  62112. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62113. import { Scene } from "babylonjs/scene";
  62114. import { Vector4 } from "babylonjs/Maths/math.vector";
  62115. import { Mesh } from "babylonjs/Meshes/mesh";
  62116. import { Nullable } from "babylonjs/types";
  62117. /**
  62118. * Class containing static functions to help procedurally build meshes
  62119. */
  62120. export class IcoSphereBuilder {
  62121. /**
  62122. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62123. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62124. * * 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`)
  62125. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62126. * * 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
  62127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62130. * @param name defines the name of the mesh
  62131. * @param options defines the options used to create the mesh
  62132. * @param scene defines the hosting scene
  62133. * @returns the icosahedron mesh
  62134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62135. */
  62136. static CreateIcoSphere(name: string, options: {
  62137. radius?: number;
  62138. radiusX?: number;
  62139. radiusY?: number;
  62140. radiusZ?: number;
  62141. flat?: boolean;
  62142. subdivisions?: number;
  62143. sideOrientation?: number;
  62144. frontUVs?: Vector4;
  62145. backUVs?: Vector4;
  62146. updatable?: boolean;
  62147. }, scene?: Nullable<Scene>): Mesh;
  62148. }
  62149. }
  62150. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62151. import { Vector3 } from "babylonjs/Maths/math.vector";
  62152. import { Mesh } from "babylonjs/Meshes/mesh";
  62153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62154. /**
  62155. * Class containing static functions to help procedurally build meshes
  62156. */
  62157. export class DecalBuilder {
  62158. /**
  62159. * Creates a decal mesh.
  62160. * 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
  62161. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62162. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62163. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62164. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62165. * @param name defines the name of the mesh
  62166. * @param sourceMesh defines the mesh where the decal must be applied
  62167. * @param options defines the options used to create the mesh
  62168. * @param scene defines the hosting scene
  62169. * @returns the decal mesh
  62170. * @see https://doc.babylonjs.com/how_to/decals
  62171. */
  62172. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62173. position?: Vector3;
  62174. normal?: Vector3;
  62175. size?: Vector3;
  62176. angle?: number;
  62177. }): Mesh;
  62178. }
  62179. }
  62180. declare module "babylonjs/Meshes/meshBuilder" {
  62181. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62182. import { Nullable } from "babylonjs/types";
  62183. import { Scene } from "babylonjs/scene";
  62184. import { Mesh } from "babylonjs/Meshes/mesh";
  62185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62186. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62188. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62189. import { Plane } from "babylonjs/Maths/math.plane";
  62190. /**
  62191. * Class containing static functions to help procedurally build meshes
  62192. */
  62193. export class MeshBuilder {
  62194. /**
  62195. * Creates a box mesh
  62196. * * The parameter `size` sets the size (float) of each box side (default 1)
  62197. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62198. * * 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)
  62199. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62203. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62204. * @param name defines the name of the mesh
  62205. * @param options defines the options used to create the mesh
  62206. * @param scene defines the hosting scene
  62207. * @returns the box mesh
  62208. */
  62209. static CreateBox(name: string, options: {
  62210. size?: number;
  62211. width?: number;
  62212. height?: number;
  62213. depth?: number;
  62214. faceUV?: Vector4[];
  62215. faceColors?: Color4[];
  62216. sideOrientation?: number;
  62217. frontUVs?: Vector4;
  62218. backUVs?: Vector4;
  62219. updatable?: boolean;
  62220. }, scene?: Nullable<Scene>): Mesh;
  62221. /**
  62222. * Creates a tiled box mesh
  62223. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62225. * @param name defines the name of the mesh
  62226. * @param options defines the options used to create the mesh
  62227. * @param scene defines the hosting scene
  62228. * @returns the tiled box mesh
  62229. */
  62230. static CreateTiledBox(name: string, options: {
  62231. pattern?: number;
  62232. size?: number;
  62233. width?: number;
  62234. height?: number;
  62235. depth: number;
  62236. tileSize?: number;
  62237. tileWidth?: number;
  62238. tileHeight?: number;
  62239. faceUV?: Vector4[];
  62240. faceColors?: Color4[];
  62241. alignHorizontal?: number;
  62242. alignVertical?: number;
  62243. sideOrientation?: number;
  62244. updatable?: boolean;
  62245. }, scene?: Nullable<Scene>): Mesh;
  62246. /**
  62247. * Creates a sphere mesh
  62248. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62249. * * 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`)
  62250. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62251. * * 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
  62252. * * 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)
  62253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62256. * @param name defines the name of the mesh
  62257. * @param options defines the options used to create the mesh
  62258. * @param scene defines the hosting scene
  62259. * @returns the sphere mesh
  62260. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62261. */
  62262. static CreateSphere(name: string, options: {
  62263. segments?: number;
  62264. diameter?: number;
  62265. diameterX?: number;
  62266. diameterY?: number;
  62267. diameterZ?: number;
  62268. arc?: number;
  62269. slice?: number;
  62270. sideOrientation?: number;
  62271. frontUVs?: Vector4;
  62272. backUVs?: Vector4;
  62273. updatable?: boolean;
  62274. }, scene?: Nullable<Scene>): Mesh;
  62275. /**
  62276. * Creates a plane polygonal mesh. By default, this is a disc
  62277. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62278. * * 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
  62279. * * 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
  62280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62283. * @param name defines the name of the mesh
  62284. * @param options defines the options used to create the mesh
  62285. * @param scene defines the hosting scene
  62286. * @returns the plane polygonal mesh
  62287. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62288. */
  62289. static CreateDisc(name: string, options: {
  62290. radius?: number;
  62291. tessellation?: number;
  62292. arc?: number;
  62293. updatable?: boolean;
  62294. sideOrientation?: number;
  62295. frontUVs?: Vector4;
  62296. backUVs?: Vector4;
  62297. }, scene?: Nullable<Scene>): Mesh;
  62298. /**
  62299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62301. * * 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`)
  62302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62303. * * 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
  62304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62307. * @param name defines the name of the mesh
  62308. * @param options defines the options used to create the mesh
  62309. * @param scene defines the hosting scene
  62310. * @returns the icosahedron mesh
  62311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62312. */
  62313. static CreateIcoSphere(name: string, options: {
  62314. radius?: number;
  62315. radiusX?: number;
  62316. radiusY?: number;
  62317. radiusZ?: number;
  62318. flat?: boolean;
  62319. subdivisions?: number;
  62320. sideOrientation?: number;
  62321. frontUVs?: Vector4;
  62322. backUVs?: Vector4;
  62323. updatable?: boolean;
  62324. }, scene?: Nullable<Scene>): Mesh;
  62325. /**
  62326. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62327. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62328. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62329. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62330. * * 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
  62331. * * 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
  62332. * * 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
  62333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62336. * * 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
  62337. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62338. * * 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
  62339. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62341. * @param name defines the name of the mesh
  62342. * @param options defines the options used to create the mesh
  62343. * @param scene defines the hosting scene
  62344. * @returns the ribbon mesh
  62345. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62347. */
  62348. static CreateRibbon(name: string, options: {
  62349. pathArray: Vector3[][];
  62350. closeArray?: boolean;
  62351. closePath?: boolean;
  62352. offset?: number;
  62353. updatable?: boolean;
  62354. sideOrientation?: number;
  62355. frontUVs?: Vector4;
  62356. backUVs?: Vector4;
  62357. instance?: Mesh;
  62358. invertUV?: boolean;
  62359. uvs?: Vector2[];
  62360. colors?: Color4[];
  62361. }, scene?: Nullable<Scene>): Mesh;
  62362. /**
  62363. * Creates a cylinder or a cone mesh
  62364. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62365. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62366. * * 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.
  62367. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62368. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62369. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62370. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62371. * * 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).
  62372. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62373. * * 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).
  62374. * * 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
  62375. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62376. * * 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
  62377. * * 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.
  62378. * * If `enclose` is false, a ring surface is one element.
  62379. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62380. * * 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
  62381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62384. * @param name defines the name of the mesh
  62385. * @param options defines the options used to create the mesh
  62386. * @param scene defines the hosting scene
  62387. * @returns the cylinder mesh
  62388. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62389. */
  62390. static CreateCylinder(name: string, options: {
  62391. height?: number;
  62392. diameterTop?: number;
  62393. diameterBottom?: number;
  62394. diameter?: number;
  62395. tessellation?: number;
  62396. subdivisions?: number;
  62397. arc?: number;
  62398. faceColors?: Color4[];
  62399. faceUV?: Vector4[];
  62400. updatable?: boolean;
  62401. hasRings?: boolean;
  62402. enclose?: boolean;
  62403. cap?: number;
  62404. sideOrientation?: number;
  62405. frontUVs?: Vector4;
  62406. backUVs?: Vector4;
  62407. }, scene?: Nullable<Scene>): Mesh;
  62408. /**
  62409. * Creates a torus mesh
  62410. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62411. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62412. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62416. * @param name defines the name of the mesh
  62417. * @param options defines the options used to create the mesh
  62418. * @param scene defines the hosting scene
  62419. * @returns the torus mesh
  62420. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62421. */
  62422. static CreateTorus(name: string, options: {
  62423. diameter?: number;
  62424. thickness?: number;
  62425. tessellation?: number;
  62426. updatable?: boolean;
  62427. sideOrientation?: number;
  62428. frontUVs?: Vector4;
  62429. backUVs?: Vector4;
  62430. }, scene?: Nullable<Scene>): Mesh;
  62431. /**
  62432. * Creates a torus knot mesh
  62433. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62434. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62435. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62436. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62440. * @param name defines the name of the mesh
  62441. * @param options defines the options used to create the mesh
  62442. * @param scene defines the hosting scene
  62443. * @returns the torus knot mesh
  62444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62445. */
  62446. static CreateTorusKnot(name: string, options: {
  62447. radius?: number;
  62448. tube?: number;
  62449. radialSegments?: number;
  62450. tubularSegments?: number;
  62451. p?: number;
  62452. q?: number;
  62453. updatable?: boolean;
  62454. sideOrientation?: number;
  62455. frontUVs?: Vector4;
  62456. backUVs?: Vector4;
  62457. }, scene?: Nullable<Scene>): Mesh;
  62458. /**
  62459. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62460. * * 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
  62461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62462. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62463. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62464. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62466. * * 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
  62467. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62470. * @param name defines the name of the new line system
  62471. * @param options defines the options used to create the line system
  62472. * @param scene defines the hosting scene
  62473. * @returns a new line system mesh
  62474. */
  62475. static CreateLineSystem(name: string, options: {
  62476. lines: Vector3[][];
  62477. updatable?: boolean;
  62478. instance?: Nullable<LinesMesh>;
  62479. colors?: Nullable<Color4[][]>;
  62480. useVertexAlpha?: boolean;
  62481. }, scene: Nullable<Scene>): LinesMesh;
  62482. /**
  62483. * Creates a line mesh
  62484. * 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
  62485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62486. * * The parameter `points` is an array successive Vector3
  62487. * * 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
  62488. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62489. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62490. * * When updating an instance, remember that only point positions can change, not the number of points
  62491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62493. * @param name defines the name of the new line system
  62494. * @param options defines the options used to create the line system
  62495. * @param scene defines the hosting scene
  62496. * @returns a new line mesh
  62497. */
  62498. static CreateLines(name: string, options: {
  62499. points: Vector3[];
  62500. updatable?: boolean;
  62501. instance?: Nullable<LinesMesh>;
  62502. colors?: Color4[];
  62503. useVertexAlpha?: boolean;
  62504. }, scene?: Nullable<Scene>): LinesMesh;
  62505. /**
  62506. * Creates a dashed line mesh
  62507. * * 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
  62508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62509. * * The parameter `points` is an array successive Vector3
  62510. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62511. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62512. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62513. * * 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
  62514. * * When updating an instance, remember that only point positions can change, not the number of points
  62515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62516. * @param name defines the name of the mesh
  62517. * @param options defines the options used to create the mesh
  62518. * @param scene defines the hosting scene
  62519. * @returns the dashed line mesh
  62520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62521. */
  62522. static CreateDashedLines(name: string, options: {
  62523. points: Vector3[];
  62524. dashSize?: number;
  62525. gapSize?: number;
  62526. dashNb?: number;
  62527. updatable?: boolean;
  62528. instance?: LinesMesh;
  62529. }, scene?: Nullable<Scene>): LinesMesh;
  62530. /**
  62531. * 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.
  62532. * * 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.
  62533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62534. * * 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.
  62535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62536. * * 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
  62537. * * 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
  62538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62543. * @param name defines the name of the mesh
  62544. * @param options defines the options used to create the mesh
  62545. * @param scene defines the hosting scene
  62546. * @returns the extruded shape mesh
  62547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62549. */
  62550. static ExtrudeShape(name: string, options: {
  62551. shape: Vector3[];
  62552. path: Vector3[];
  62553. scale?: number;
  62554. rotation?: number;
  62555. cap?: number;
  62556. updatable?: boolean;
  62557. sideOrientation?: number;
  62558. frontUVs?: Vector4;
  62559. backUVs?: Vector4;
  62560. instance?: Mesh;
  62561. invertUV?: boolean;
  62562. }, scene?: Nullable<Scene>): Mesh;
  62563. /**
  62564. * Creates an custom extruded shape mesh.
  62565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62566. * * 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.
  62567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62568. * * 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
  62569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62570. * * 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
  62571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62574. * * 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
  62575. * * 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
  62576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62581. * @param name defines the name of the mesh
  62582. * @param options defines the options used to create the mesh
  62583. * @param scene defines the hosting scene
  62584. * @returns the custom extruded shape mesh
  62585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62588. */
  62589. static ExtrudeShapeCustom(name: string, options: {
  62590. shape: Vector3[];
  62591. path: Vector3[];
  62592. scaleFunction?: any;
  62593. rotationFunction?: any;
  62594. ribbonCloseArray?: boolean;
  62595. ribbonClosePath?: boolean;
  62596. cap?: number;
  62597. updatable?: boolean;
  62598. sideOrientation?: number;
  62599. frontUVs?: Vector4;
  62600. backUVs?: Vector4;
  62601. instance?: Mesh;
  62602. invertUV?: boolean;
  62603. }, scene?: Nullable<Scene>): Mesh;
  62604. /**
  62605. * Creates lathe mesh.
  62606. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62607. * * 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
  62608. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62609. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62610. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62611. * * 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
  62612. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62613. * * 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
  62614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62618. * @param name defines the name of the mesh
  62619. * @param options defines the options used to create the mesh
  62620. * @param scene defines the hosting scene
  62621. * @returns the lathe mesh
  62622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62623. */
  62624. static CreateLathe(name: string, options: {
  62625. shape: Vector3[];
  62626. radius?: number;
  62627. tessellation?: number;
  62628. clip?: number;
  62629. arc?: number;
  62630. closed?: boolean;
  62631. updatable?: boolean;
  62632. sideOrientation?: number;
  62633. frontUVs?: Vector4;
  62634. backUVs?: Vector4;
  62635. cap?: number;
  62636. invertUV?: boolean;
  62637. }, scene?: Nullable<Scene>): Mesh;
  62638. /**
  62639. * Creates a tiled plane mesh
  62640. * * You can set a limited pattern arrangement with the tiles
  62641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62644. * @param name defines the name of the mesh
  62645. * @param options defines the options used to create the mesh
  62646. * @param scene defines the hosting scene
  62647. * @returns the plane mesh
  62648. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62649. */
  62650. static CreateTiledPlane(name: string, options: {
  62651. pattern?: number;
  62652. tileSize?: number;
  62653. tileWidth?: number;
  62654. tileHeight?: number;
  62655. size?: number;
  62656. width?: number;
  62657. height?: number;
  62658. alignHorizontal?: number;
  62659. alignVertical?: number;
  62660. sideOrientation?: number;
  62661. frontUVs?: Vector4;
  62662. backUVs?: Vector4;
  62663. updatable?: boolean;
  62664. }, scene?: Nullable<Scene>): Mesh;
  62665. /**
  62666. * Creates a plane mesh
  62667. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62668. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62669. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62673. * @param name defines the name of the mesh
  62674. * @param options defines the options used to create the mesh
  62675. * @param scene defines the hosting scene
  62676. * @returns the plane mesh
  62677. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62678. */
  62679. static CreatePlane(name: string, options: {
  62680. size?: number;
  62681. width?: number;
  62682. height?: number;
  62683. sideOrientation?: number;
  62684. frontUVs?: Vector4;
  62685. backUVs?: Vector4;
  62686. updatable?: boolean;
  62687. sourcePlane?: Plane;
  62688. }, scene?: Nullable<Scene>): Mesh;
  62689. /**
  62690. * Creates a ground mesh
  62691. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62692. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62694. * @param name defines the name of the mesh
  62695. * @param options defines the options used to create the mesh
  62696. * @param scene defines the hosting scene
  62697. * @returns the ground mesh
  62698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62699. */
  62700. static CreateGround(name: string, options: {
  62701. width?: number;
  62702. height?: number;
  62703. subdivisions?: number;
  62704. subdivisionsX?: number;
  62705. subdivisionsY?: number;
  62706. updatable?: boolean;
  62707. }, scene?: Nullable<Scene>): Mesh;
  62708. /**
  62709. * Creates a tiled ground mesh
  62710. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62711. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62712. * * 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
  62713. * * 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
  62714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62715. * @param name defines the name of the mesh
  62716. * @param options defines the options used to create the mesh
  62717. * @param scene defines the hosting scene
  62718. * @returns the tiled ground mesh
  62719. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62720. */
  62721. static CreateTiledGround(name: string, options: {
  62722. xmin: number;
  62723. zmin: number;
  62724. xmax: number;
  62725. zmax: number;
  62726. subdivisions?: {
  62727. w: number;
  62728. h: number;
  62729. };
  62730. precision?: {
  62731. w: number;
  62732. h: number;
  62733. };
  62734. updatable?: boolean;
  62735. }, scene?: Nullable<Scene>): Mesh;
  62736. /**
  62737. * Creates a ground mesh from a height map
  62738. * * The parameter `url` sets the URL of the height map image resource.
  62739. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62740. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62741. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62742. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62743. * * 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.
  62744. * * 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).
  62745. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62747. * @param name defines the name of the mesh
  62748. * @param url defines the url to the height map
  62749. * @param options defines the options used to create the mesh
  62750. * @param scene defines the hosting scene
  62751. * @returns the ground mesh
  62752. * @see https://doc.babylonjs.com/babylon101/height_map
  62753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62754. */
  62755. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62756. width?: number;
  62757. height?: number;
  62758. subdivisions?: number;
  62759. minHeight?: number;
  62760. maxHeight?: number;
  62761. colorFilter?: Color3;
  62762. alphaFilter?: number;
  62763. updatable?: boolean;
  62764. onReady?: (mesh: GroundMesh) => void;
  62765. }, scene?: Nullable<Scene>): GroundMesh;
  62766. /**
  62767. * Creates a polygon mesh
  62768. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62769. * * 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
  62770. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62773. * * Remember you can only change the shape positions, not their number when updating a polygon
  62774. * @param name defines the name of the mesh
  62775. * @param options defines the options used to create the mesh
  62776. * @param scene defines the hosting scene
  62777. * @param earcutInjection can be used to inject your own earcut reference
  62778. * @returns the polygon mesh
  62779. */
  62780. static CreatePolygon(name: string, options: {
  62781. shape: Vector3[];
  62782. holes?: Vector3[][];
  62783. depth?: number;
  62784. faceUV?: Vector4[];
  62785. faceColors?: Color4[];
  62786. updatable?: boolean;
  62787. sideOrientation?: number;
  62788. frontUVs?: Vector4;
  62789. backUVs?: Vector4;
  62790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62791. /**
  62792. * Creates an extruded polygon mesh, with depth in the Y direction.
  62793. * * 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)
  62794. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62795. * @param name defines the name of the mesh
  62796. * @param options defines the options used to create the mesh
  62797. * @param scene defines the hosting scene
  62798. * @param earcutInjection can be used to inject your own earcut reference
  62799. * @returns the polygon mesh
  62800. */
  62801. static ExtrudePolygon(name: string, options: {
  62802. shape: Vector3[];
  62803. holes?: Vector3[][];
  62804. depth?: number;
  62805. faceUV?: Vector4[];
  62806. faceColors?: Color4[];
  62807. updatable?: boolean;
  62808. sideOrientation?: number;
  62809. frontUVs?: Vector4;
  62810. backUVs?: Vector4;
  62811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62812. /**
  62813. * Creates a tube mesh.
  62814. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62815. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62816. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62817. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62818. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62819. * * 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)
  62820. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62821. * * 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
  62822. * * 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
  62823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62827. * @param name defines the name of the mesh
  62828. * @param options defines the options used to create the mesh
  62829. * @param scene defines the hosting scene
  62830. * @returns the tube mesh
  62831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62832. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62833. */
  62834. static CreateTube(name: string, options: {
  62835. path: Vector3[];
  62836. radius?: number;
  62837. tessellation?: number;
  62838. radiusFunction?: {
  62839. (i: number, distance: number): number;
  62840. };
  62841. cap?: number;
  62842. arc?: number;
  62843. updatable?: boolean;
  62844. sideOrientation?: number;
  62845. frontUVs?: Vector4;
  62846. backUVs?: Vector4;
  62847. instance?: Mesh;
  62848. invertUV?: boolean;
  62849. }, scene?: Nullable<Scene>): Mesh;
  62850. /**
  62851. * Creates a polyhedron mesh
  62852. * * 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
  62853. * * The parameter `size` (positive float, default 1) sets the polygon size
  62854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62855. * * 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`
  62856. * * 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
  62857. * * 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)`)
  62858. * * 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
  62859. * * 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
  62860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62863. * @param name defines the name of the mesh
  62864. * @param options defines the options used to create the mesh
  62865. * @param scene defines the hosting scene
  62866. * @returns the polyhedron mesh
  62867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62868. */
  62869. static CreatePolyhedron(name: string, options: {
  62870. type?: number;
  62871. size?: number;
  62872. sizeX?: number;
  62873. sizeY?: number;
  62874. sizeZ?: number;
  62875. custom?: any;
  62876. faceUV?: Vector4[];
  62877. faceColors?: Color4[];
  62878. flat?: boolean;
  62879. updatable?: boolean;
  62880. sideOrientation?: number;
  62881. frontUVs?: Vector4;
  62882. backUVs?: Vector4;
  62883. }, scene?: Nullable<Scene>): Mesh;
  62884. /**
  62885. * Creates a decal mesh.
  62886. * 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
  62887. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62888. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62889. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62890. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62891. * @param name defines the name of the mesh
  62892. * @param sourceMesh defines the mesh where the decal must be applied
  62893. * @param options defines the options used to create the mesh
  62894. * @param scene defines the hosting scene
  62895. * @returns the decal mesh
  62896. * @see https://doc.babylonjs.com/how_to/decals
  62897. */
  62898. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62899. position?: Vector3;
  62900. normal?: Vector3;
  62901. size?: Vector3;
  62902. angle?: number;
  62903. }): Mesh;
  62904. }
  62905. }
  62906. declare module "babylonjs/Meshes/meshSimplification" {
  62907. import { Mesh } from "babylonjs/Meshes/mesh";
  62908. /**
  62909. * A simplifier interface for future simplification implementations
  62910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62911. */
  62912. export interface ISimplifier {
  62913. /**
  62914. * Simplification of a given mesh according to the given settings.
  62915. * Since this requires computation, it is assumed that the function runs async.
  62916. * @param settings The settings of the simplification, including quality and distance
  62917. * @param successCallback A callback that will be called after the mesh was simplified.
  62918. * @param errorCallback in case of an error, this callback will be called. optional.
  62919. */
  62920. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62921. }
  62922. /**
  62923. * Expected simplification settings.
  62924. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62925. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62926. */
  62927. export interface ISimplificationSettings {
  62928. /**
  62929. * Gets or sets the expected quality
  62930. */
  62931. quality: number;
  62932. /**
  62933. * Gets or sets the distance when this optimized version should be used
  62934. */
  62935. distance: number;
  62936. /**
  62937. * Gets an already optimized mesh
  62938. */
  62939. optimizeMesh?: boolean;
  62940. }
  62941. /**
  62942. * Class used to specify simplification options
  62943. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62944. */
  62945. export class SimplificationSettings implements ISimplificationSettings {
  62946. /** expected quality */
  62947. quality: number;
  62948. /** distance when this optimized version should be used */
  62949. distance: number;
  62950. /** already optimized mesh */
  62951. optimizeMesh?: boolean | undefined;
  62952. /**
  62953. * Creates a SimplificationSettings
  62954. * @param quality expected quality
  62955. * @param distance distance when this optimized version should be used
  62956. * @param optimizeMesh already optimized mesh
  62957. */
  62958. constructor(
  62959. /** expected quality */
  62960. quality: number,
  62961. /** distance when this optimized version should be used */
  62962. distance: number,
  62963. /** already optimized mesh */
  62964. optimizeMesh?: boolean | undefined);
  62965. }
  62966. /**
  62967. * Interface used to define a simplification task
  62968. */
  62969. export interface ISimplificationTask {
  62970. /**
  62971. * Array of settings
  62972. */
  62973. settings: Array<ISimplificationSettings>;
  62974. /**
  62975. * Simplification type
  62976. */
  62977. simplificationType: SimplificationType;
  62978. /**
  62979. * Mesh to simplify
  62980. */
  62981. mesh: Mesh;
  62982. /**
  62983. * Callback called on success
  62984. */
  62985. successCallback?: () => void;
  62986. /**
  62987. * Defines if parallel processing can be used
  62988. */
  62989. parallelProcessing: boolean;
  62990. }
  62991. /**
  62992. * Queue used to order the simplification tasks
  62993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62994. */
  62995. export class SimplificationQueue {
  62996. private _simplificationArray;
  62997. /**
  62998. * Gets a boolean indicating that the process is still running
  62999. */
  63000. running: boolean;
  63001. /**
  63002. * Creates a new queue
  63003. */
  63004. constructor();
  63005. /**
  63006. * Adds a new simplification task
  63007. * @param task defines a task to add
  63008. */
  63009. addTask(task: ISimplificationTask): void;
  63010. /**
  63011. * Execute next task
  63012. */
  63013. executeNext(): void;
  63014. /**
  63015. * Execute a simplification task
  63016. * @param task defines the task to run
  63017. */
  63018. runSimplification(task: ISimplificationTask): void;
  63019. private getSimplifier;
  63020. }
  63021. /**
  63022. * The implemented types of simplification
  63023. * At the moment only Quadratic Error Decimation is implemented
  63024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63025. */
  63026. export enum SimplificationType {
  63027. /** Quadratic error decimation */
  63028. QUADRATIC = 0
  63029. }
  63030. }
  63031. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63032. import { Scene } from "babylonjs/scene";
  63033. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63034. import { ISceneComponent } from "babylonjs/sceneComponent";
  63035. module "babylonjs/scene" {
  63036. interface Scene {
  63037. /** @hidden (Backing field) */
  63038. _simplificationQueue: SimplificationQueue;
  63039. /**
  63040. * Gets or sets the simplification queue attached to the scene
  63041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63042. */
  63043. simplificationQueue: SimplificationQueue;
  63044. }
  63045. }
  63046. module "babylonjs/Meshes/mesh" {
  63047. interface Mesh {
  63048. /**
  63049. * Simplify the mesh according to the given array of settings.
  63050. * Function will return immediately and will simplify async
  63051. * @param settings a collection of simplification settings
  63052. * @param parallelProcessing should all levels calculate parallel or one after the other
  63053. * @param simplificationType the type of simplification to run
  63054. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63055. * @returns the current mesh
  63056. */
  63057. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63058. }
  63059. }
  63060. /**
  63061. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63062. * created in a scene
  63063. */
  63064. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63065. /**
  63066. * The component name helpfull to identify the component in the list of scene components.
  63067. */
  63068. readonly name: string;
  63069. /**
  63070. * The scene the component belongs to.
  63071. */
  63072. scene: Scene;
  63073. /**
  63074. * Creates a new instance of the component for the given scene
  63075. * @param scene Defines the scene to register the component in
  63076. */
  63077. constructor(scene: Scene);
  63078. /**
  63079. * Registers the component in a given scene
  63080. */
  63081. register(): void;
  63082. /**
  63083. * Rebuilds the elements related to this component in case of
  63084. * context lost for instance.
  63085. */
  63086. rebuild(): void;
  63087. /**
  63088. * Disposes the component and the associated ressources
  63089. */
  63090. dispose(): void;
  63091. private _beforeCameraUpdate;
  63092. }
  63093. }
  63094. declare module "babylonjs/Meshes/Builders/index" {
  63095. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63096. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63097. export * from "babylonjs/Meshes/Builders/discBuilder";
  63098. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63099. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63100. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63101. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63102. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63103. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63104. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63105. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63106. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63107. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63108. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63109. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63110. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63111. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63112. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63113. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63114. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63115. }
  63116. declare module "babylonjs/Meshes/index" {
  63117. export * from "babylonjs/Meshes/abstractMesh";
  63118. export * from "babylonjs/Meshes/buffer";
  63119. export * from "babylonjs/Meshes/Compression/index";
  63120. export * from "babylonjs/Meshes/csg";
  63121. export * from "babylonjs/Meshes/geometry";
  63122. export * from "babylonjs/Meshes/groundMesh";
  63123. export * from "babylonjs/Meshes/trailMesh";
  63124. export * from "babylonjs/Meshes/instancedMesh";
  63125. export * from "babylonjs/Meshes/linesMesh";
  63126. export * from "babylonjs/Meshes/mesh";
  63127. export * from "babylonjs/Meshes/mesh.vertexData";
  63128. export * from "babylonjs/Meshes/meshBuilder";
  63129. export * from "babylonjs/Meshes/meshSimplification";
  63130. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63131. export * from "babylonjs/Meshes/polygonMesh";
  63132. export * from "babylonjs/Meshes/subMesh";
  63133. export * from "babylonjs/Meshes/meshLODLevel";
  63134. export * from "babylonjs/Meshes/transformNode";
  63135. export * from "babylonjs/Meshes/Builders/index";
  63136. export * from "babylonjs/Meshes/dataBuffer";
  63137. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63138. }
  63139. declare module "babylonjs/Morph/index" {
  63140. export * from "babylonjs/Morph/morphTarget";
  63141. export * from "babylonjs/Morph/morphTargetManager";
  63142. }
  63143. declare module "babylonjs/Navigation/INavigationEngine" {
  63144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63145. import { Vector3 } from "babylonjs/Maths/math";
  63146. import { Mesh } from "babylonjs/Meshes/mesh";
  63147. import { Scene } from "babylonjs/scene";
  63148. /**
  63149. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63150. */
  63151. export interface INavigationEnginePlugin {
  63152. /**
  63153. * plugin name
  63154. */
  63155. name: string;
  63156. /**
  63157. * Creates a navigation mesh
  63158. * @param meshes array of all the geometry used to compute the navigatio mesh
  63159. * @param parameters bunch of parameters used to filter geometry
  63160. */
  63161. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63162. /**
  63163. * Create a navigation mesh debug mesh
  63164. * @param scene is where the mesh will be added
  63165. * @returns debug display mesh
  63166. */
  63167. createDebugNavMesh(scene: Scene): Mesh;
  63168. /**
  63169. * Get a navigation mesh constrained position, closest to the parameter position
  63170. * @param position world position
  63171. * @returns the closest point to position constrained by the navigation mesh
  63172. */
  63173. getClosestPoint(position: Vector3): Vector3;
  63174. /**
  63175. * Get a navigation mesh constrained position, within a particular radius
  63176. * @param position world position
  63177. * @param maxRadius the maximum distance to the constrained world position
  63178. * @returns the closest point to position constrained by the navigation mesh
  63179. */
  63180. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63181. /**
  63182. * Compute the final position from a segment made of destination-position
  63183. * @param position world position
  63184. * @param destination world position
  63185. * @returns the resulting point along the navmesh
  63186. */
  63187. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63188. /**
  63189. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63190. * @param start world position
  63191. * @param end world position
  63192. * @returns array containing world position composing the path
  63193. */
  63194. computePath(start: Vector3, end: Vector3): Vector3[];
  63195. /**
  63196. * If this plugin is supported
  63197. * @returns true if plugin is supported
  63198. */
  63199. isSupported(): boolean;
  63200. /**
  63201. * Create a new Crowd so you can add agents
  63202. * @param maxAgents the maximum agent count in the crowd
  63203. * @param maxAgentRadius the maximum radius an agent can have
  63204. * @param scene to attach the crowd to
  63205. * @returns the crowd you can add agents to
  63206. */
  63207. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63208. /**
  63209. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63210. * The queries will try to find a solution within those bounds
  63211. * default is (1,1,1)
  63212. * @param extent x,y,z value that define the extent around the queries point of reference
  63213. */
  63214. setDefaultQueryExtent(extent: Vector3): void;
  63215. /**
  63216. * Get the Bounding box extent specified by setDefaultQueryExtent
  63217. * @returns the box extent values
  63218. */
  63219. getDefaultQueryExtent(): Vector3;
  63220. /**
  63221. * Release all resources
  63222. */
  63223. dispose(): void;
  63224. }
  63225. /**
  63226. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63227. */
  63228. export interface ICrowd {
  63229. /**
  63230. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63231. * You can attach anything to that node. The node position is updated in the scene update tick.
  63232. * @param pos world position that will be constrained by the navigation mesh
  63233. * @param parameters agent parameters
  63234. * @param transform hooked to the agent that will be update by the scene
  63235. * @returns agent index
  63236. */
  63237. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63238. /**
  63239. * Returns the agent position in world space
  63240. * @param index agent index returned by addAgent
  63241. * @returns world space position
  63242. */
  63243. getAgentPosition(index: number): Vector3;
  63244. /**
  63245. * Gets the agent velocity in world space
  63246. * @param index agent index returned by addAgent
  63247. * @returns world space velocity
  63248. */
  63249. getAgentVelocity(index: number): Vector3;
  63250. /**
  63251. * remove a particular agent previously created
  63252. * @param index agent index returned by addAgent
  63253. */
  63254. removeAgent(index: number): void;
  63255. /**
  63256. * get the list of all agents attached to this crowd
  63257. * @returns list of agent indices
  63258. */
  63259. getAgents(): number[];
  63260. /**
  63261. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63262. * @param deltaTime in seconds
  63263. */
  63264. update(deltaTime: number): void;
  63265. /**
  63266. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63267. * @param index agent index returned by addAgent
  63268. * @param destination targeted world position
  63269. */
  63270. agentGoto(index: number, destination: Vector3): void;
  63271. /**
  63272. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63273. * The queries will try to find a solution within those bounds
  63274. * default is (1,1,1)
  63275. * @param extent x,y,z value that define the extent around the queries point of reference
  63276. */
  63277. setDefaultQueryExtent(extent: Vector3): void;
  63278. /**
  63279. * Get the Bounding box extent specified by setDefaultQueryExtent
  63280. * @returns the box extent values
  63281. */
  63282. getDefaultQueryExtent(): Vector3;
  63283. /**
  63284. * Release all resources
  63285. */
  63286. dispose(): void;
  63287. }
  63288. /**
  63289. * Configures an agent
  63290. */
  63291. export interface IAgentParameters {
  63292. /**
  63293. * Agent radius. [Limit: >= 0]
  63294. */
  63295. radius: number;
  63296. /**
  63297. * Agent height. [Limit: > 0]
  63298. */
  63299. height: number;
  63300. /**
  63301. * Maximum allowed acceleration. [Limit: >= 0]
  63302. */
  63303. maxAcceleration: number;
  63304. /**
  63305. * Maximum allowed speed. [Limit: >= 0]
  63306. */
  63307. maxSpeed: number;
  63308. /**
  63309. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63310. */
  63311. collisionQueryRange: number;
  63312. /**
  63313. * The path visibility optimization range. [Limit: > 0]
  63314. */
  63315. pathOptimizationRange: number;
  63316. /**
  63317. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63318. */
  63319. separationWeight: number;
  63320. }
  63321. /**
  63322. * Configures the navigation mesh creation
  63323. */
  63324. export interface INavMeshParameters {
  63325. /**
  63326. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63327. */
  63328. cs: number;
  63329. /**
  63330. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63331. */
  63332. ch: number;
  63333. /**
  63334. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63335. */
  63336. walkableSlopeAngle: number;
  63337. /**
  63338. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63339. * be considered walkable. [Limit: >= 3] [Units: vx]
  63340. */
  63341. walkableHeight: number;
  63342. /**
  63343. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63344. */
  63345. walkableClimb: number;
  63346. /**
  63347. * The distance to erode/shrink the walkable area of the heightfield away from
  63348. * obstructions. [Limit: >=0] [Units: vx]
  63349. */
  63350. walkableRadius: number;
  63351. /**
  63352. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63353. */
  63354. maxEdgeLen: number;
  63355. /**
  63356. * The maximum distance a simplfied contour's border edges should deviate
  63357. * the original raw contour. [Limit: >=0] [Units: vx]
  63358. */
  63359. maxSimplificationError: number;
  63360. /**
  63361. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63362. */
  63363. minRegionArea: number;
  63364. /**
  63365. * Any regions with a span count smaller than this value will, if possible,
  63366. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63367. */
  63368. mergeRegionArea: number;
  63369. /**
  63370. * The maximum number of vertices allowed for polygons generated during the
  63371. * contour to polygon conversion process. [Limit: >= 3]
  63372. */
  63373. maxVertsPerPoly: number;
  63374. /**
  63375. * Sets the sampling distance to use when generating the detail mesh.
  63376. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63377. */
  63378. detailSampleDist: number;
  63379. /**
  63380. * The maximum distance the detail mesh surface should deviate from heightfield
  63381. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63382. */
  63383. detailSampleMaxError: number;
  63384. }
  63385. }
  63386. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63387. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63388. import { Mesh } from "babylonjs/Meshes/mesh";
  63389. import { Scene } from "babylonjs/scene";
  63390. import { Vector3 } from "babylonjs/Maths/math";
  63391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63392. /**
  63393. * RecastJS navigation plugin
  63394. */
  63395. export class RecastJSPlugin implements INavigationEnginePlugin {
  63396. /**
  63397. * Reference to the Recast library
  63398. */
  63399. bjsRECAST: any;
  63400. /**
  63401. * plugin name
  63402. */
  63403. name: string;
  63404. /**
  63405. * the first navmesh created. We might extend this to support multiple navmeshes
  63406. */
  63407. navMesh: any;
  63408. /**
  63409. * Initializes the recastJS plugin
  63410. * @param recastInjection can be used to inject your own recast reference
  63411. */
  63412. constructor(recastInjection?: any);
  63413. /**
  63414. * Creates a navigation mesh
  63415. * @param meshes array of all the geometry used to compute the navigatio mesh
  63416. * @param parameters bunch of parameters used to filter geometry
  63417. */
  63418. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63419. /**
  63420. * Create a navigation mesh debug mesh
  63421. * @param scene is where the mesh will be added
  63422. * @returns debug display mesh
  63423. */
  63424. createDebugNavMesh(scene: Scene): Mesh;
  63425. /**
  63426. * Get a navigation mesh constrained position, closest to the parameter position
  63427. * @param position world position
  63428. * @returns the closest point to position constrained by the navigation mesh
  63429. */
  63430. getClosestPoint(position: Vector3): Vector3;
  63431. /**
  63432. * Get a navigation mesh constrained position, within a particular radius
  63433. * @param position world position
  63434. * @param maxRadius the maximum distance to the constrained world position
  63435. * @returns the closest point to position constrained by the navigation mesh
  63436. */
  63437. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63438. /**
  63439. * Compute the final position from a segment made of destination-position
  63440. * @param position world position
  63441. * @param destination world position
  63442. * @returns the resulting point along the navmesh
  63443. */
  63444. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63445. /**
  63446. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63447. * @param start world position
  63448. * @param end world position
  63449. * @returns array containing world position composing the path
  63450. */
  63451. computePath(start: Vector3, end: Vector3): Vector3[];
  63452. /**
  63453. * Create a new Crowd so you can add agents
  63454. * @param maxAgents the maximum agent count in the crowd
  63455. * @param maxAgentRadius the maximum radius an agent can have
  63456. * @param scene to attach the crowd to
  63457. * @returns the crowd you can add agents to
  63458. */
  63459. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63460. /**
  63461. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63462. * The queries will try to find a solution within those bounds
  63463. * default is (1,1,1)
  63464. * @param extent x,y,z value that define the extent around the queries point of reference
  63465. */
  63466. setDefaultQueryExtent(extent: Vector3): void;
  63467. /**
  63468. * Get the Bounding box extent specified by setDefaultQueryExtent
  63469. * @returns the box extent values
  63470. */
  63471. getDefaultQueryExtent(): Vector3;
  63472. /**
  63473. * Disposes
  63474. */
  63475. dispose(): void;
  63476. /**
  63477. * If this plugin is supported
  63478. * @returns true if plugin is supported
  63479. */
  63480. isSupported(): boolean;
  63481. }
  63482. /**
  63483. * Recast detour crowd implementation
  63484. */
  63485. export class RecastJSCrowd implements ICrowd {
  63486. /**
  63487. * Recast/detour plugin
  63488. */
  63489. bjsRECASTPlugin: RecastJSPlugin;
  63490. /**
  63491. * Link to the detour crowd
  63492. */
  63493. recastCrowd: any;
  63494. /**
  63495. * One transform per agent
  63496. */
  63497. transforms: TransformNode[];
  63498. /**
  63499. * All agents created
  63500. */
  63501. agents: number[];
  63502. /**
  63503. * Link to the scene is kept to unregister the crowd from the scene
  63504. */
  63505. private _scene;
  63506. /**
  63507. * Observer for crowd updates
  63508. */
  63509. private _onBeforeAnimationsObserver;
  63510. /**
  63511. * Constructor
  63512. * @param plugin recastJS plugin
  63513. * @param maxAgents the maximum agent count in the crowd
  63514. * @param maxAgentRadius the maximum radius an agent can have
  63515. * @param scene to attach the crowd to
  63516. * @returns the crowd you can add agents to
  63517. */
  63518. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63519. /**
  63520. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63521. * You can attach anything to that node. The node position is updated in the scene update tick.
  63522. * @param pos world position that will be constrained by the navigation mesh
  63523. * @param parameters agent parameters
  63524. * @param transform hooked to the agent that will be update by the scene
  63525. * @returns agent index
  63526. */
  63527. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63528. /**
  63529. * Returns the agent position in world space
  63530. * @param index agent index returned by addAgent
  63531. * @returns world space position
  63532. */
  63533. getAgentPosition(index: number): Vector3;
  63534. /**
  63535. * Returns the agent velocity in world space
  63536. * @param index agent index returned by addAgent
  63537. * @returns world space velocity
  63538. */
  63539. getAgentVelocity(index: number): Vector3;
  63540. /**
  63541. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63542. * @param index agent index returned by addAgent
  63543. * @param destination targeted world position
  63544. */
  63545. agentGoto(index: number, destination: Vector3): void;
  63546. /**
  63547. * remove a particular agent previously created
  63548. * @param index agent index returned by addAgent
  63549. */
  63550. removeAgent(index: number): void;
  63551. /**
  63552. * get the list of all agents attached to this crowd
  63553. * @returns list of agent indices
  63554. */
  63555. getAgents(): number[];
  63556. /**
  63557. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63558. * @param deltaTime in seconds
  63559. */
  63560. update(deltaTime: number): void;
  63561. /**
  63562. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63563. * The queries will try to find a solution within those bounds
  63564. * default is (1,1,1)
  63565. * @param extent x,y,z value that define the extent around the queries point of reference
  63566. */
  63567. setDefaultQueryExtent(extent: Vector3): void;
  63568. /**
  63569. * Get the Bounding box extent specified by setDefaultQueryExtent
  63570. * @returns the box extent values
  63571. */
  63572. getDefaultQueryExtent(): Vector3;
  63573. /**
  63574. * Release all resources
  63575. */
  63576. dispose(): void;
  63577. }
  63578. }
  63579. declare module "babylonjs/Navigation/Plugins/index" {
  63580. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63581. }
  63582. declare module "babylonjs/Navigation/index" {
  63583. export * from "babylonjs/Navigation/INavigationEngine";
  63584. export * from "babylonjs/Navigation/Plugins/index";
  63585. }
  63586. declare module "babylonjs/Offline/database" {
  63587. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63588. /**
  63589. * Class used to enable access to IndexedDB
  63590. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63591. */
  63592. export class Database implements IOfflineProvider {
  63593. private _callbackManifestChecked;
  63594. private _currentSceneUrl;
  63595. private _db;
  63596. private _enableSceneOffline;
  63597. private _enableTexturesOffline;
  63598. private _manifestVersionFound;
  63599. private _mustUpdateRessources;
  63600. private _hasReachedQuota;
  63601. private _isSupported;
  63602. private _idbFactory;
  63603. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63604. private static IsUASupportingBlobStorage;
  63605. /**
  63606. * Gets a boolean indicating if Database storate is enabled (off by default)
  63607. */
  63608. static IDBStorageEnabled: boolean;
  63609. /**
  63610. * Gets a boolean indicating if scene must be saved in the database
  63611. */
  63612. get enableSceneOffline(): boolean;
  63613. /**
  63614. * Gets a boolean indicating if textures must be saved in the database
  63615. */
  63616. get enableTexturesOffline(): boolean;
  63617. /**
  63618. * Creates a new Database
  63619. * @param urlToScene defines the url to load the scene
  63620. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63621. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63622. */
  63623. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63624. private static _ParseURL;
  63625. private static _ReturnFullUrlLocation;
  63626. private _checkManifestFile;
  63627. /**
  63628. * Open the database and make it available
  63629. * @param successCallback defines the callback to call on success
  63630. * @param errorCallback defines the callback to call on error
  63631. */
  63632. open(successCallback: () => void, errorCallback: () => void): void;
  63633. /**
  63634. * Loads an image from the database
  63635. * @param url defines the url to load from
  63636. * @param image defines the target DOM image
  63637. */
  63638. loadImage(url: string, image: HTMLImageElement): void;
  63639. private _loadImageFromDBAsync;
  63640. private _saveImageIntoDBAsync;
  63641. private _checkVersionFromDB;
  63642. private _loadVersionFromDBAsync;
  63643. private _saveVersionIntoDBAsync;
  63644. /**
  63645. * Loads a file from database
  63646. * @param url defines the URL to load from
  63647. * @param sceneLoaded defines a callback to call on success
  63648. * @param progressCallBack defines a callback to call when progress changed
  63649. * @param errorCallback defines a callback to call on error
  63650. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63651. */
  63652. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63653. private _loadFileAsync;
  63654. private _saveFileAsync;
  63655. /**
  63656. * Validates if xhr data is correct
  63657. * @param xhr defines the request to validate
  63658. * @param dataType defines the expected data type
  63659. * @returns true if data is correct
  63660. */
  63661. private static _ValidateXHRData;
  63662. }
  63663. }
  63664. declare module "babylonjs/Offline/index" {
  63665. export * from "babylonjs/Offline/database";
  63666. export * from "babylonjs/Offline/IOfflineProvider";
  63667. }
  63668. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63669. /** @hidden */
  63670. export var gpuUpdateParticlesPixelShader: {
  63671. name: string;
  63672. shader: string;
  63673. };
  63674. }
  63675. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63676. /** @hidden */
  63677. export var gpuUpdateParticlesVertexShader: {
  63678. name: string;
  63679. shader: string;
  63680. };
  63681. }
  63682. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63683. /** @hidden */
  63684. export var clipPlaneFragmentDeclaration2: {
  63685. name: string;
  63686. shader: string;
  63687. };
  63688. }
  63689. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63691. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63692. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63693. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63695. /** @hidden */
  63696. export var gpuRenderParticlesPixelShader: {
  63697. name: string;
  63698. shader: string;
  63699. };
  63700. }
  63701. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63702. /** @hidden */
  63703. export var clipPlaneVertexDeclaration2: {
  63704. name: string;
  63705. shader: string;
  63706. };
  63707. }
  63708. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63709. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63710. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63711. /** @hidden */
  63712. export var gpuRenderParticlesVertexShader: {
  63713. name: string;
  63714. shader: string;
  63715. };
  63716. }
  63717. declare module "babylonjs/Particles/gpuParticleSystem" {
  63718. import { Nullable } from "babylonjs/types";
  63719. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63720. import { Observable } from "babylonjs/Misc/observable";
  63721. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63723. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63724. import { Scene, IDisposable } from "babylonjs/scene";
  63725. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63726. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63727. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63728. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63729. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63730. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63731. /**
  63732. * This represents a GPU particle system in Babylon
  63733. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63734. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63735. */
  63736. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63737. /**
  63738. * The layer mask we are rendering the particles through.
  63739. */
  63740. layerMask: number;
  63741. private _capacity;
  63742. private _activeCount;
  63743. private _currentActiveCount;
  63744. private _accumulatedCount;
  63745. private _renderEffect;
  63746. private _updateEffect;
  63747. private _buffer0;
  63748. private _buffer1;
  63749. private _spriteBuffer;
  63750. private _updateVAO;
  63751. private _renderVAO;
  63752. private _targetIndex;
  63753. private _sourceBuffer;
  63754. private _targetBuffer;
  63755. private _engine;
  63756. private _currentRenderId;
  63757. private _started;
  63758. private _stopped;
  63759. private _timeDelta;
  63760. private _randomTexture;
  63761. private _randomTexture2;
  63762. private _attributesStrideSize;
  63763. private _updateEffectOptions;
  63764. private _randomTextureSize;
  63765. private _actualFrame;
  63766. private readonly _rawTextureWidth;
  63767. /**
  63768. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63769. */
  63770. static get IsSupported(): boolean;
  63771. /**
  63772. * An event triggered when the system is disposed.
  63773. */
  63774. onDisposeObservable: Observable<GPUParticleSystem>;
  63775. /**
  63776. * Gets the maximum number of particles active at the same time.
  63777. * @returns The max number of active particles.
  63778. */
  63779. getCapacity(): number;
  63780. /**
  63781. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63782. * to override the particles.
  63783. */
  63784. forceDepthWrite: boolean;
  63785. /**
  63786. * Gets or set the number of active particles
  63787. */
  63788. get activeParticleCount(): number;
  63789. set activeParticleCount(value: number);
  63790. private _preWarmDone;
  63791. /**
  63792. * Is this system ready to be used/rendered
  63793. * @return true if the system is ready
  63794. */
  63795. isReady(): boolean;
  63796. /**
  63797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63798. * @returns True if it has been started, otherwise false.
  63799. */
  63800. isStarted(): boolean;
  63801. /**
  63802. * Starts the particle system and begins to emit
  63803. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63804. */
  63805. start(delay?: number): void;
  63806. /**
  63807. * Stops the particle system.
  63808. */
  63809. stop(): void;
  63810. /**
  63811. * Remove all active particles
  63812. */
  63813. reset(): void;
  63814. /**
  63815. * Returns the string "GPUParticleSystem"
  63816. * @returns a string containing the class name
  63817. */
  63818. getClassName(): string;
  63819. private _colorGradientsTexture;
  63820. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63821. /**
  63822. * Adds a new color gradient
  63823. * @param gradient defines the gradient to use (between 0 and 1)
  63824. * @param color1 defines the color to affect to the specified gradient
  63825. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63826. * @returns the current particle system
  63827. */
  63828. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63829. /**
  63830. * Remove a specific color gradient
  63831. * @param gradient defines the gradient to remove
  63832. * @returns the current particle system
  63833. */
  63834. removeColorGradient(gradient: number): GPUParticleSystem;
  63835. private _angularSpeedGradientsTexture;
  63836. private _sizeGradientsTexture;
  63837. private _velocityGradientsTexture;
  63838. private _limitVelocityGradientsTexture;
  63839. private _dragGradientsTexture;
  63840. private _addFactorGradient;
  63841. /**
  63842. * Adds a new size gradient
  63843. * @param gradient defines the gradient to use (between 0 and 1)
  63844. * @param factor defines the size factor to affect to the specified gradient
  63845. * @returns the current particle system
  63846. */
  63847. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63848. /**
  63849. * Remove a specific size gradient
  63850. * @param gradient defines the gradient to remove
  63851. * @returns the current particle system
  63852. */
  63853. removeSizeGradient(gradient: number): GPUParticleSystem;
  63854. /**
  63855. * Adds a new angular speed gradient
  63856. * @param gradient defines the gradient to use (between 0 and 1)
  63857. * @param factor defines the angular speed to affect to the specified gradient
  63858. * @returns the current particle system
  63859. */
  63860. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63861. /**
  63862. * Remove a specific angular speed gradient
  63863. * @param gradient defines the gradient to remove
  63864. * @returns the current particle system
  63865. */
  63866. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63867. /**
  63868. * Adds a new velocity gradient
  63869. * @param gradient defines the gradient to use (between 0 and 1)
  63870. * @param factor defines the velocity to affect to the specified gradient
  63871. * @returns the current particle system
  63872. */
  63873. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63874. /**
  63875. * Remove a specific velocity gradient
  63876. * @param gradient defines the gradient to remove
  63877. * @returns the current particle system
  63878. */
  63879. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63880. /**
  63881. * Adds a new limit velocity gradient
  63882. * @param gradient defines the gradient to use (between 0 and 1)
  63883. * @param factor defines the limit velocity value to affect to the specified gradient
  63884. * @returns the current particle system
  63885. */
  63886. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63887. /**
  63888. * Remove a specific limit velocity gradient
  63889. * @param gradient defines the gradient to remove
  63890. * @returns the current particle system
  63891. */
  63892. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63893. /**
  63894. * Adds a new drag gradient
  63895. * @param gradient defines the gradient to use (between 0 and 1)
  63896. * @param factor defines the drag value to affect to the specified gradient
  63897. * @returns the current particle system
  63898. */
  63899. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63900. /**
  63901. * Remove a specific drag gradient
  63902. * @param gradient defines the gradient to remove
  63903. * @returns the current particle system
  63904. */
  63905. removeDragGradient(gradient: number): GPUParticleSystem;
  63906. /**
  63907. * Not supported by GPUParticleSystem
  63908. * @param gradient defines the gradient to use (between 0 and 1)
  63909. * @param factor defines the emit rate value to affect to the specified gradient
  63910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63911. * @returns the current particle system
  63912. */
  63913. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63914. /**
  63915. * Not supported by GPUParticleSystem
  63916. * @param gradient defines the gradient to remove
  63917. * @returns the current particle system
  63918. */
  63919. removeEmitRateGradient(gradient: number): IParticleSystem;
  63920. /**
  63921. * Not supported by GPUParticleSystem
  63922. * @param gradient defines the gradient to use (between 0 and 1)
  63923. * @param factor defines the start size value to affect to the specified gradient
  63924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63925. * @returns the current particle system
  63926. */
  63927. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63928. /**
  63929. * Not supported by GPUParticleSystem
  63930. * @param gradient defines the gradient to remove
  63931. * @returns the current particle system
  63932. */
  63933. removeStartSizeGradient(gradient: number): IParticleSystem;
  63934. /**
  63935. * Not supported by GPUParticleSystem
  63936. * @param gradient defines the gradient to use (between 0 and 1)
  63937. * @param min defines the color remap minimal range
  63938. * @param max defines the color remap maximal range
  63939. * @returns the current particle system
  63940. */
  63941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63942. /**
  63943. * Not supported by GPUParticleSystem
  63944. * @param gradient defines the gradient to remove
  63945. * @returns the current particle system
  63946. */
  63947. removeColorRemapGradient(): IParticleSystem;
  63948. /**
  63949. * Not supported by GPUParticleSystem
  63950. * @param gradient defines the gradient to use (between 0 and 1)
  63951. * @param min defines the alpha remap minimal range
  63952. * @param max defines the alpha remap maximal range
  63953. * @returns the current particle system
  63954. */
  63955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63956. /**
  63957. * Not supported by GPUParticleSystem
  63958. * @param gradient defines the gradient to remove
  63959. * @returns the current particle system
  63960. */
  63961. removeAlphaRemapGradient(): IParticleSystem;
  63962. /**
  63963. * Not supported by GPUParticleSystem
  63964. * @param gradient defines the gradient to use (between 0 and 1)
  63965. * @param color defines the color to affect to the specified gradient
  63966. * @returns the current particle system
  63967. */
  63968. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63969. /**
  63970. * Not supported by GPUParticleSystem
  63971. * @param gradient defines the gradient to remove
  63972. * @returns the current particle system
  63973. */
  63974. removeRampGradient(): IParticleSystem;
  63975. /**
  63976. * Not supported by GPUParticleSystem
  63977. * @returns the list of ramp gradients
  63978. */
  63979. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63980. /**
  63981. * Not supported by GPUParticleSystem
  63982. * Gets or sets a boolean indicating that ramp gradients must be used
  63983. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63984. */
  63985. get useRampGradients(): boolean;
  63986. set useRampGradients(value: boolean);
  63987. /**
  63988. * Not supported by GPUParticleSystem
  63989. * @param gradient defines the gradient to use (between 0 and 1)
  63990. * @param factor defines the life time factor to affect to the specified gradient
  63991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63992. * @returns the current particle system
  63993. */
  63994. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63995. /**
  63996. * Not supported by GPUParticleSystem
  63997. * @param gradient defines the gradient to remove
  63998. * @returns the current particle system
  63999. */
  64000. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64001. /**
  64002. * Instantiates a GPU particle system.
  64003. * 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.
  64004. * @param name The name of the particle system
  64005. * @param options The options used to create the system
  64006. * @param scene The scene the particle system belongs to
  64007. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64008. */
  64009. constructor(name: string, options: Partial<{
  64010. capacity: number;
  64011. randomTextureSize: number;
  64012. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64013. protected _reset(): void;
  64014. private _createUpdateVAO;
  64015. private _createRenderVAO;
  64016. private _initialize;
  64017. /** @hidden */
  64018. _recreateUpdateEffect(): void;
  64019. /** @hidden */
  64020. _recreateRenderEffect(): void;
  64021. /**
  64022. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64023. * @param preWarm defines if we are in the pre-warmimg phase
  64024. */
  64025. animate(preWarm?: boolean): void;
  64026. private _createFactorGradientTexture;
  64027. private _createSizeGradientTexture;
  64028. private _createAngularSpeedGradientTexture;
  64029. private _createVelocityGradientTexture;
  64030. private _createLimitVelocityGradientTexture;
  64031. private _createDragGradientTexture;
  64032. private _createColorGradientTexture;
  64033. /**
  64034. * Renders the particle system in its current state
  64035. * @param preWarm defines if the system should only update the particles but not render them
  64036. * @returns the current number of particles
  64037. */
  64038. render(preWarm?: boolean): number;
  64039. /**
  64040. * Rebuilds the particle system
  64041. */
  64042. rebuild(): void;
  64043. private _releaseBuffers;
  64044. private _releaseVAOs;
  64045. /**
  64046. * Disposes the particle system and free the associated resources
  64047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64048. */
  64049. dispose(disposeTexture?: boolean): void;
  64050. /**
  64051. * Clones the particle system.
  64052. * @param name The name of the cloned object
  64053. * @param newEmitter The new emitter to use
  64054. * @returns the cloned particle system
  64055. */
  64056. clone(name: string, newEmitter: any): GPUParticleSystem;
  64057. /**
  64058. * Serializes the particle system to a JSON object.
  64059. * @returns the JSON object
  64060. */
  64061. serialize(): any;
  64062. /**
  64063. * Parses a JSON object to create a GPU particle system.
  64064. * @param parsedParticleSystem The JSON object to parse
  64065. * @param scene The scene to create the particle system in
  64066. * @param rootUrl The root url to use to load external dependencies like texture
  64067. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64068. * @returns the parsed GPU particle system
  64069. */
  64070. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64071. }
  64072. }
  64073. declare module "babylonjs/Particles/particleSystemSet" {
  64074. import { Nullable } from "babylonjs/types";
  64075. import { Color3 } from "babylonjs/Maths/math.color";
  64076. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64079. import { Scene, IDisposable } from "babylonjs/scene";
  64080. /**
  64081. * Represents a set of particle systems working together to create a specific effect
  64082. */
  64083. export class ParticleSystemSet implements IDisposable {
  64084. /**
  64085. * Gets or sets base Assets URL
  64086. */
  64087. static BaseAssetsUrl: string;
  64088. private _emitterCreationOptions;
  64089. private _emitterNode;
  64090. /**
  64091. * Gets the particle system list
  64092. */
  64093. systems: IParticleSystem[];
  64094. /**
  64095. * Gets the emitter node used with this set
  64096. */
  64097. get emitterNode(): Nullable<TransformNode>;
  64098. /**
  64099. * Creates a new emitter mesh as a sphere
  64100. * @param options defines the options used to create the sphere
  64101. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64102. * @param scene defines the hosting scene
  64103. */
  64104. setEmitterAsSphere(options: {
  64105. diameter: number;
  64106. segments: number;
  64107. color: Color3;
  64108. }, renderingGroupId: number, scene: Scene): void;
  64109. /**
  64110. * Starts all particle systems of the set
  64111. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64112. */
  64113. start(emitter?: AbstractMesh): void;
  64114. /**
  64115. * Release all associated resources
  64116. */
  64117. dispose(): void;
  64118. /**
  64119. * Serialize the set into a JSON compatible object
  64120. * @returns a JSON compatible representation of the set
  64121. */
  64122. serialize(): any;
  64123. /**
  64124. * Parse a new ParticleSystemSet from a serialized source
  64125. * @param data defines a JSON compatible representation of the set
  64126. * @param scene defines the hosting scene
  64127. * @param gpu defines if we want GPU particles or CPU particles
  64128. * @returns a new ParticleSystemSet
  64129. */
  64130. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64131. }
  64132. }
  64133. declare module "babylonjs/Particles/particleHelper" {
  64134. import { Nullable } from "babylonjs/types";
  64135. import { Scene } from "babylonjs/scene";
  64136. import { Vector3 } from "babylonjs/Maths/math.vector";
  64137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64138. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64139. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64140. /**
  64141. * This class is made for on one-liner static method to help creating particle system set.
  64142. */
  64143. export class ParticleHelper {
  64144. /**
  64145. * Gets or sets base Assets URL
  64146. */
  64147. static BaseAssetsUrl: string;
  64148. /**
  64149. * Create a default particle system that you can tweak
  64150. * @param emitter defines the emitter to use
  64151. * @param capacity defines the system capacity (default is 500 particles)
  64152. * @param scene defines the hosting scene
  64153. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64154. * @returns the new Particle system
  64155. */
  64156. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64157. /**
  64158. * This is the main static method (one-liner) of this helper to create different particle systems
  64159. * @param type This string represents the type to the particle system to create
  64160. * @param scene The scene where the particle system should live
  64161. * @param gpu If the system will use gpu
  64162. * @returns the ParticleSystemSet created
  64163. */
  64164. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64165. /**
  64166. * Static function used to export a particle system to a ParticleSystemSet variable.
  64167. * Please note that the emitter shape is not exported
  64168. * @param systems defines the particle systems to export
  64169. * @returns the created particle system set
  64170. */
  64171. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64172. }
  64173. }
  64174. declare module "babylonjs/Particles/particleSystemComponent" {
  64175. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64176. import { Effect } from "babylonjs/Materials/effect";
  64177. import "babylonjs/Shaders/particles.vertex";
  64178. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64179. module "babylonjs/Engines/engine" {
  64180. interface Engine {
  64181. /**
  64182. * Create an effect to use with particle systems.
  64183. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64184. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64185. * @param uniformsNames defines a list of attribute names
  64186. * @param samplers defines an array of string used to represent textures
  64187. * @param defines defines the string containing the defines to use to compile the shaders
  64188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64189. * @param onCompiled defines a function to call when the effect creation is successful
  64190. * @param onError defines a function to call when the effect creation has failed
  64191. * @returns the new Effect
  64192. */
  64193. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64194. }
  64195. }
  64196. module "babylonjs/Meshes/mesh" {
  64197. interface Mesh {
  64198. /**
  64199. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64200. * @returns an array of IParticleSystem
  64201. */
  64202. getEmittedParticleSystems(): IParticleSystem[];
  64203. /**
  64204. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64205. * @returns an array of IParticleSystem
  64206. */
  64207. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64208. }
  64209. }
  64210. /**
  64211. * @hidden
  64212. */
  64213. export var _IDoNeedToBeInTheBuild: number;
  64214. }
  64215. declare module "babylonjs/Particles/pointsCloudSystem" {
  64216. import { Color4 } from "babylonjs/Maths/math";
  64217. import { Mesh } from "babylonjs/Meshes/mesh";
  64218. import { Scene, IDisposable } from "babylonjs/scene";
  64219. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64220. /** Defines the 4 color options */
  64221. export enum PointColor {
  64222. /** color value */
  64223. Color = 2,
  64224. /** uv value */
  64225. UV = 1,
  64226. /** random value */
  64227. Random = 0,
  64228. /** stated value */
  64229. Stated = 3
  64230. }
  64231. /**
  64232. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64233. * 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.
  64234. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64235. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64236. *
  64237. * Full documentation here : TO BE ENTERED
  64238. */
  64239. export class PointsCloudSystem implements IDisposable {
  64240. /**
  64241. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64242. * Example : var p = SPS.particles[i];
  64243. */
  64244. particles: CloudPoint[];
  64245. /**
  64246. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64247. */
  64248. nbParticles: number;
  64249. /**
  64250. * This a counter for your own usage. It's not set by any SPS functions.
  64251. */
  64252. counter: number;
  64253. /**
  64254. * The PCS name. This name is also given to the underlying mesh.
  64255. */
  64256. name: string;
  64257. /**
  64258. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64259. */
  64260. mesh: Mesh;
  64261. /**
  64262. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64263. * Please read :
  64264. */
  64265. vars: any;
  64266. /**
  64267. * @hidden
  64268. */
  64269. _size: number;
  64270. private _scene;
  64271. private _promises;
  64272. private _positions;
  64273. private _indices;
  64274. private _normals;
  64275. private _colors;
  64276. private _uvs;
  64277. private _indices32;
  64278. private _positions32;
  64279. private _colors32;
  64280. private _uvs32;
  64281. private _updatable;
  64282. private _isVisibilityBoxLocked;
  64283. private _alwaysVisible;
  64284. private _groups;
  64285. private _groupCounter;
  64286. private _computeParticleColor;
  64287. private _computeParticleTexture;
  64288. private _computeParticleRotation;
  64289. private _computeBoundingBox;
  64290. private _isReady;
  64291. /**
  64292. * Creates a PCS (Points Cloud System) object
  64293. * @param name (String) is the PCS name, this will be the underlying mesh name
  64294. * @param pointSize (number) is the size for each point
  64295. * @param scene (Scene) is the scene in which the PCS is added
  64296. * @param options defines the options of the PCS e.g.
  64297. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64298. */
  64299. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64300. updatable?: boolean;
  64301. });
  64302. /**
  64303. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64304. * If no points were added to the PCS, the returned mesh is just a single point.
  64305. * @returns a promise for the created mesh
  64306. */
  64307. buildMeshAsync(): Promise<Mesh>;
  64308. /**
  64309. * @hidden
  64310. */
  64311. private _buildMesh;
  64312. private _addParticle;
  64313. private _randomUnitVector;
  64314. private _getColorIndicesForCoord;
  64315. private _setPointsColorOrUV;
  64316. private _colorFromTexture;
  64317. private _calculateDensity;
  64318. /**
  64319. * Adds points to the PCS in random positions within a unit sphere
  64320. * @param nb (positive integer) the number of particles to be created from this model
  64321. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64322. * @returns the number of groups in the system
  64323. */
  64324. addPoints(nb: number, pointFunction?: any): number;
  64325. /**
  64326. * Adds points to the PCS from the surface of the model shape
  64327. * @param mesh is any Mesh object that will be used as a surface model for the points
  64328. * @param nb (positive integer) the number of particles to be created from this model
  64329. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64330. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64331. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64332. * @returns the number of groups in the system
  64333. */
  64334. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64335. /**
  64336. * Adds points to the PCS inside the model shape
  64337. * @param mesh is any Mesh object that will be used as a surface model for the points
  64338. * @param nb (positive integer) the number of particles to be created from this model
  64339. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64340. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64341. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64342. * @returns the number of groups in the system
  64343. */
  64344. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64345. /**
  64346. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64347. * This method calls `updateParticle()` for each particle of the SPS.
  64348. * For an animated SPS, it is usually called within the render loop.
  64349. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64350. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64351. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64352. * @returns the PCS.
  64353. */
  64354. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64355. /**
  64356. * Disposes the PCS.
  64357. */
  64358. dispose(): void;
  64359. /**
  64360. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64361. * doc :
  64362. * @returns the PCS.
  64363. */
  64364. refreshVisibleSize(): PointsCloudSystem;
  64365. /**
  64366. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64367. * @param size the size (float) of the visibility box
  64368. * note : this doesn't lock the PCS mesh bounding box.
  64369. * doc :
  64370. */
  64371. setVisibilityBox(size: number): void;
  64372. /**
  64373. * Gets whether the PCS is always visible or not
  64374. * doc :
  64375. */
  64376. get isAlwaysVisible(): boolean;
  64377. /**
  64378. * Sets the PCS as always visible or not
  64379. * doc :
  64380. */
  64381. set isAlwaysVisible(val: boolean);
  64382. /**
  64383. * Tells to `setParticles()` to compute the particle rotations or not
  64384. * Default value : false. The PCS is faster when it's set to false
  64385. * Note : particle rotations are only applied to parent particles
  64386. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64387. */
  64388. set computeParticleRotation(val: boolean);
  64389. /**
  64390. * Tells to `setParticles()` to compute the particle colors or not.
  64391. * Default value : true. The PCS is faster when it's set to false.
  64392. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64393. */
  64394. set computeParticleColor(val: boolean);
  64395. set computeParticleTexture(val: boolean);
  64396. /**
  64397. * Gets if `setParticles()` computes the particle colors or not.
  64398. * Default value : false. The PCS is faster when it's set to false.
  64399. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64400. */
  64401. get computeParticleColor(): boolean;
  64402. /**
  64403. * Gets if `setParticles()` computes the particle textures or not.
  64404. * Default value : false. The PCS is faster when it's set to false.
  64405. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64406. */
  64407. get computeParticleTexture(): boolean;
  64408. /**
  64409. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64410. */
  64411. set computeBoundingBox(val: boolean);
  64412. /**
  64413. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64414. */
  64415. get computeBoundingBox(): boolean;
  64416. /**
  64417. * This function does nothing. It may be overwritten to set all the particle first values.
  64418. * The PCS doesn't call this function, you may have to call it by your own.
  64419. * doc :
  64420. */
  64421. initParticles(): void;
  64422. /**
  64423. * This function does nothing. It may be overwritten to recycle a particle
  64424. * The PCS doesn't call this function, you can to call it
  64425. * doc :
  64426. * @param particle The particle to recycle
  64427. * @returns the recycled particle
  64428. */
  64429. recycleParticle(particle: CloudPoint): CloudPoint;
  64430. /**
  64431. * Updates a particle : this function should be overwritten by the user.
  64432. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64433. * doc :
  64434. * @example : just set a particle position or velocity and recycle conditions
  64435. * @param particle The particle to update
  64436. * @returns the updated particle
  64437. */
  64438. updateParticle(particle: CloudPoint): CloudPoint;
  64439. /**
  64440. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64441. * This does nothing and may be overwritten by the user.
  64442. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64443. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64444. * @param update the boolean update value actually passed to setParticles()
  64445. */
  64446. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64447. /**
  64448. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64449. * This will be passed three parameters.
  64450. * This does nothing and may be overwritten by the user.
  64451. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64452. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64453. * @param update the boolean update value actually passed to setParticles()
  64454. */
  64455. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64456. }
  64457. }
  64458. declare module "babylonjs/Particles/cloudPoint" {
  64459. import { Nullable } from "babylonjs/types";
  64460. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64461. import { Mesh } from "babylonjs/Meshes/mesh";
  64462. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64463. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64464. /**
  64465. * Represents one particle of a points cloud system.
  64466. */
  64467. export class CloudPoint {
  64468. /**
  64469. * particle global index
  64470. */
  64471. idx: number;
  64472. /**
  64473. * The color of the particle
  64474. */
  64475. color: Nullable<Color4>;
  64476. /**
  64477. * The world space position of the particle.
  64478. */
  64479. position: Vector3;
  64480. /**
  64481. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64482. */
  64483. rotation: Vector3;
  64484. /**
  64485. * The world space rotation quaternion of the particle.
  64486. */
  64487. rotationQuaternion: Nullable<Quaternion>;
  64488. /**
  64489. * The uv of the particle.
  64490. */
  64491. uv: Nullable<Vector2>;
  64492. /**
  64493. * The current speed of the particle.
  64494. */
  64495. velocity: Vector3;
  64496. /**
  64497. * The pivot point in the particle local space.
  64498. */
  64499. pivot: Vector3;
  64500. /**
  64501. * Must the particle be translated from its pivot point in its local space ?
  64502. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64503. * Default : false
  64504. */
  64505. translateFromPivot: boolean;
  64506. /**
  64507. * Index of this particle in the global "positions" array (Internal use)
  64508. * @hidden
  64509. */
  64510. _pos: number;
  64511. /**
  64512. * @hidden Index of this particle in the global "indices" array (Internal use)
  64513. */
  64514. _ind: number;
  64515. /**
  64516. * Group this particle belongs to
  64517. */
  64518. _group: PointsGroup;
  64519. /**
  64520. * Group id of this particle
  64521. */
  64522. groupId: number;
  64523. /**
  64524. * Index of the particle in its group id (Internal use)
  64525. */
  64526. idxInGroup: number;
  64527. /**
  64528. * @hidden Particle BoundingInfo object (Internal use)
  64529. */
  64530. _boundingInfo: BoundingInfo;
  64531. /**
  64532. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64533. */
  64534. _pcs: PointsCloudSystem;
  64535. /**
  64536. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64537. */
  64538. _stillInvisible: boolean;
  64539. /**
  64540. * @hidden Last computed particle rotation matrix
  64541. */
  64542. _rotationMatrix: number[];
  64543. /**
  64544. * Parent particle Id, if any.
  64545. * Default null.
  64546. */
  64547. parentId: Nullable<number>;
  64548. /**
  64549. * @hidden Internal global position in the PCS.
  64550. */
  64551. _globalPosition: Vector3;
  64552. /**
  64553. * Creates a Point Cloud object.
  64554. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64555. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64556. * @param group (PointsGroup) is the group the particle belongs to
  64557. * @param groupId (integer) is the group identifier in the PCS.
  64558. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64559. * @param pcs defines the PCS it is associated to
  64560. */
  64561. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64562. /**
  64563. * get point size
  64564. */
  64565. get size(): Vector3;
  64566. /**
  64567. * Set point size
  64568. */
  64569. set size(scale: Vector3);
  64570. /**
  64571. * Legacy support, changed quaternion to rotationQuaternion
  64572. */
  64573. get quaternion(): Nullable<Quaternion>;
  64574. /**
  64575. * Legacy support, changed quaternion to rotationQuaternion
  64576. */
  64577. set quaternion(q: Nullable<Quaternion>);
  64578. /**
  64579. * Returns a boolean. True if the particle intersects a mesh, else false
  64580. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64581. * @param target is the object (point or mesh) what the intersection is computed against
  64582. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64583. * @returns true if it intersects
  64584. */
  64585. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64586. /**
  64587. * get the rotation matrix of the particle
  64588. * @hidden
  64589. */
  64590. getRotationMatrix(m: Matrix): void;
  64591. }
  64592. /**
  64593. * Represents a group of points in a points cloud system
  64594. * * PCS internal tool, don't use it manually.
  64595. */
  64596. export class PointsGroup {
  64597. /**
  64598. * The group id
  64599. * @hidden
  64600. */
  64601. groupID: number;
  64602. /**
  64603. * image data for group (internal use)
  64604. * @hidden
  64605. */
  64606. _groupImageData: Nullable<ArrayBufferView>;
  64607. /**
  64608. * Image Width (internal use)
  64609. * @hidden
  64610. */
  64611. _groupImgWidth: number;
  64612. /**
  64613. * Image Height (internal use)
  64614. * @hidden
  64615. */
  64616. _groupImgHeight: number;
  64617. /**
  64618. * Custom position function (internal use)
  64619. * @hidden
  64620. */
  64621. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64622. /**
  64623. * density per facet for surface points
  64624. * @hidden
  64625. */
  64626. _groupDensity: number[];
  64627. /**
  64628. * Only when points are colored by texture carries pointer to texture list array
  64629. * @hidden
  64630. */
  64631. _textureNb: number;
  64632. /**
  64633. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64634. * PCS internal tool, don't use it manually.
  64635. * @hidden
  64636. */
  64637. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64638. }
  64639. }
  64640. declare module "babylonjs/Particles/index" {
  64641. export * from "babylonjs/Particles/baseParticleSystem";
  64642. export * from "babylonjs/Particles/EmitterTypes/index";
  64643. export * from "babylonjs/Particles/gpuParticleSystem";
  64644. export * from "babylonjs/Particles/IParticleSystem";
  64645. export * from "babylonjs/Particles/particle";
  64646. export * from "babylonjs/Particles/particleHelper";
  64647. export * from "babylonjs/Particles/particleSystem";
  64648. export * from "babylonjs/Particles/particleSystemComponent";
  64649. export * from "babylonjs/Particles/particleSystemSet";
  64650. export * from "babylonjs/Particles/solidParticle";
  64651. export * from "babylonjs/Particles/solidParticleSystem";
  64652. export * from "babylonjs/Particles/cloudPoint";
  64653. export * from "babylonjs/Particles/pointsCloudSystem";
  64654. export * from "babylonjs/Particles/subEmitter";
  64655. }
  64656. declare module "babylonjs/Physics/physicsEngineComponent" {
  64657. import { Nullable } from "babylonjs/types";
  64658. import { Observable, Observer } from "babylonjs/Misc/observable";
  64659. import { Vector3 } from "babylonjs/Maths/math.vector";
  64660. import { Mesh } from "babylonjs/Meshes/mesh";
  64661. import { ISceneComponent } from "babylonjs/sceneComponent";
  64662. import { Scene } from "babylonjs/scene";
  64663. import { Node } from "babylonjs/node";
  64664. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64666. module "babylonjs/scene" {
  64667. interface Scene {
  64668. /** @hidden (Backing field) */
  64669. _physicsEngine: Nullable<IPhysicsEngine>;
  64670. /** @hidden */
  64671. _physicsTimeAccumulator: number;
  64672. /**
  64673. * Gets the current physics engine
  64674. * @returns a IPhysicsEngine or null if none attached
  64675. */
  64676. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64677. /**
  64678. * Enables physics to the current scene
  64679. * @param gravity defines the scene's gravity for the physics engine
  64680. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64681. * @return a boolean indicating if the physics engine was initialized
  64682. */
  64683. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64684. /**
  64685. * Disables and disposes the physics engine associated with the scene
  64686. */
  64687. disablePhysicsEngine(): void;
  64688. /**
  64689. * Gets a boolean indicating if there is an active physics engine
  64690. * @returns a boolean indicating if there is an active physics engine
  64691. */
  64692. isPhysicsEnabled(): boolean;
  64693. /**
  64694. * Deletes a physics compound impostor
  64695. * @param compound defines the compound to delete
  64696. */
  64697. deleteCompoundImpostor(compound: any): void;
  64698. /**
  64699. * An event triggered when physic simulation is about to be run
  64700. */
  64701. onBeforePhysicsObservable: Observable<Scene>;
  64702. /**
  64703. * An event triggered when physic simulation has been done
  64704. */
  64705. onAfterPhysicsObservable: Observable<Scene>;
  64706. }
  64707. }
  64708. module "babylonjs/Meshes/abstractMesh" {
  64709. interface AbstractMesh {
  64710. /** @hidden */
  64711. _physicsImpostor: Nullable<PhysicsImpostor>;
  64712. /**
  64713. * Gets or sets impostor used for physic simulation
  64714. * @see http://doc.babylonjs.com/features/physics_engine
  64715. */
  64716. physicsImpostor: Nullable<PhysicsImpostor>;
  64717. /**
  64718. * Gets the current physics impostor
  64719. * @see http://doc.babylonjs.com/features/physics_engine
  64720. * @returns a physics impostor or null
  64721. */
  64722. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64723. /** Apply a physic impulse to the mesh
  64724. * @param force defines the force to apply
  64725. * @param contactPoint defines where to apply the force
  64726. * @returns the current mesh
  64727. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64728. */
  64729. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64730. /**
  64731. * Creates a physic joint between two meshes
  64732. * @param otherMesh defines the other mesh to use
  64733. * @param pivot1 defines the pivot to use on this mesh
  64734. * @param pivot2 defines the pivot to use on the other mesh
  64735. * @param options defines additional options (can be plugin dependent)
  64736. * @returns the current mesh
  64737. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64738. */
  64739. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64740. /** @hidden */
  64741. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64742. }
  64743. }
  64744. /**
  64745. * Defines the physics engine scene component responsible to manage a physics engine
  64746. */
  64747. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64748. /**
  64749. * The component name helpful to identify the component in the list of scene components.
  64750. */
  64751. readonly name: string;
  64752. /**
  64753. * The scene the component belongs to.
  64754. */
  64755. scene: Scene;
  64756. /**
  64757. * Creates a new instance of the component for the given scene
  64758. * @param scene Defines the scene to register the component in
  64759. */
  64760. constructor(scene: Scene);
  64761. /**
  64762. * Registers the component in a given scene
  64763. */
  64764. register(): void;
  64765. /**
  64766. * Rebuilds the elements related to this component in case of
  64767. * context lost for instance.
  64768. */
  64769. rebuild(): void;
  64770. /**
  64771. * Disposes the component and the associated ressources
  64772. */
  64773. dispose(): void;
  64774. }
  64775. }
  64776. declare module "babylonjs/Physics/physicsHelper" {
  64777. import { Nullable } from "babylonjs/types";
  64778. import { Vector3 } from "babylonjs/Maths/math.vector";
  64779. import { Mesh } from "babylonjs/Meshes/mesh";
  64780. import { Scene } from "babylonjs/scene";
  64781. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64782. /**
  64783. * A helper for physics simulations
  64784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64785. */
  64786. export class PhysicsHelper {
  64787. private _scene;
  64788. private _physicsEngine;
  64789. /**
  64790. * Initializes the Physics helper
  64791. * @param scene Babylon.js scene
  64792. */
  64793. constructor(scene: Scene);
  64794. /**
  64795. * Applies a radial explosion impulse
  64796. * @param origin the origin of the explosion
  64797. * @param radiusOrEventOptions the radius or the options of radial explosion
  64798. * @param strength the explosion strength
  64799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64800. * @returns A physics radial explosion event, or null
  64801. */
  64802. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64803. /**
  64804. * Applies a radial explosion force
  64805. * @param origin the origin of the explosion
  64806. * @param radiusOrEventOptions the radius or the options of radial explosion
  64807. * @param strength the explosion strength
  64808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64809. * @returns A physics radial explosion event, or null
  64810. */
  64811. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64812. /**
  64813. * Creates a gravitational field
  64814. * @param origin the origin of the explosion
  64815. * @param radiusOrEventOptions the radius or the options of radial explosion
  64816. * @param strength the explosion strength
  64817. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64818. * @returns A physics gravitational field event, or null
  64819. */
  64820. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64821. /**
  64822. * Creates a physics updraft event
  64823. * @param origin the origin of the updraft
  64824. * @param radiusOrEventOptions the radius or the options of the updraft
  64825. * @param strength the strength of the updraft
  64826. * @param height the height of the updraft
  64827. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64828. * @returns A physics updraft event, or null
  64829. */
  64830. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64831. /**
  64832. * Creates a physics vortex event
  64833. * @param origin the of the vortex
  64834. * @param radiusOrEventOptions the radius or the options of the vortex
  64835. * @param strength the strength of the vortex
  64836. * @param height the height of the vortex
  64837. * @returns a Physics vortex event, or null
  64838. * A physics vortex event or null
  64839. */
  64840. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64841. }
  64842. /**
  64843. * Represents a physics radial explosion event
  64844. */
  64845. class PhysicsRadialExplosionEvent {
  64846. private _scene;
  64847. private _options;
  64848. private _sphere;
  64849. private _dataFetched;
  64850. /**
  64851. * Initializes a radial explosioin event
  64852. * @param _scene BabylonJS scene
  64853. * @param _options The options for the vortex event
  64854. */
  64855. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64856. /**
  64857. * Returns the data related to the radial explosion event (sphere).
  64858. * @returns The radial explosion event data
  64859. */
  64860. getData(): PhysicsRadialExplosionEventData;
  64861. /**
  64862. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64863. * @param impostor A physics imposter
  64864. * @param origin the origin of the explosion
  64865. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64866. */
  64867. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64868. /**
  64869. * Triggers affecterd impostors callbacks
  64870. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64871. */
  64872. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64873. /**
  64874. * Disposes the sphere.
  64875. * @param force Specifies if the sphere should be disposed by force
  64876. */
  64877. dispose(force?: boolean): void;
  64878. /*** Helpers ***/
  64879. private _prepareSphere;
  64880. private _intersectsWithSphere;
  64881. }
  64882. /**
  64883. * Represents a gravitational field event
  64884. */
  64885. class PhysicsGravitationalFieldEvent {
  64886. private _physicsHelper;
  64887. private _scene;
  64888. private _origin;
  64889. private _options;
  64890. private _tickCallback;
  64891. private _sphere;
  64892. private _dataFetched;
  64893. /**
  64894. * Initializes the physics gravitational field event
  64895. * @param _physicsHelper A physics helper
  64896. * @param _scene BabylonJS scene
  64897. * @param _origin The origin position of the gravitational field event
  64898. * @param _options The options for the vortex event
  64899. */
  64900. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64901. /**
  64902. * Returns the data related to the gravitational field event (sphere).
  64903. * @returns A gravitational field event
  64904. */
  64905. getData(): PhysicsGravitationalFieldEventData;
  64906. /**
  64907. * Enables the gravitational field.
  64908. */
  64909. enable(): void;
  64910. /**
  64911. * Disables the gravitational field.
  64912. */
  64913. disable(): void;
  64914. /**
  64915. * Disposes the sphere.
  64916. * @param force The force to dispose from the gravitational field event
  64917. */
  64918. dispose(force?: boolean): void;
  64919. private _tick;
  64920. }
  64921. /**
  64922. * Represents a physics updraft event
  64923. */
  64924. class PhysicsUpdraftEvent {
  64925. private _scene;
  64926. private _origin;
  64927. private _options;
  64928. private _physicsEngine;
  64929. private _originTop;
  64930. private _originDirection;
  64931. private _tickCallback;
  64932. private _cylinder;
  64933. private _cylinderPosition;
  64934. private _dataFetched;
  64935. /**
  64936. * Initializes the physics updraft event
  64937. * @param _scene BabylonJS scene
  64938. * @param _origin The origin position of the updraft
  64939. * @param _options The options for the updraft event
  64940. */
  64941. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64942. /**
  64943. * Returns the data related to the updraft event (cylinder).
  64944. * @returns A physics updraft event
  64945. */
  64946. getData(): PhysicsUpdraftEventData;
  64947. /**
  64948. * Enables the updraft.
  64949. */
  64950. enable(): void;
  64951. /**
  64952. * Disables the updraft.
  64953. */
  64954. disable(): void;
  64955. /**
  64956. * Disposes the cylinder.
  64957. * @param force Specifies if the updraft should be disposed by force
  64958. */
  64959. dispose(force?: boolean): void;
  64960. private getImpostorHitData;
  64961. private _tick;
  64962. /*** Helpers ***/
  64963. private _prepareCylinder;
  64964. private _intersectsWithCylinder;
  64965. }
  64966. /**
  64967. * Represents a physics vortex event
  64968. */
  64969. class PhysicsVortexEvent {
  64970. private _scene;
  64971. private _origin;
  64972. private _options;
  64973. private _physicsEngine;
  64974. private _originTop;
  64975. private _tickCallback;
  64976. private _cylinder;
  64977. private _cylinderPosition;
  64978. private _dataFetched;
  64979. /**
  64980. * Initializes the physics vortex event
  64981. * @param _scene The BabylonJS scene
  64982. * @param _origin The origin position of the vortex
  64983. * @param _options The options for the vortex event
  64984. */
  64985. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64986. /**
  64987. * Returns the data related to the vortex event (cylinder).
  64988. * @returns The physics vortex event data
  64989. */
  64990. getData(): PhysicsVortexEventData;
  64991. /**
  64992. * Enables the vortex.
  64993. */
  64994. enable(): void;
  64995. /**
  64996. * Disables the cortex.
  64997. */
  64998. disable(): void;
  64999. /**
  65000. * Disposes the sphere.
  65001. * @param force
  65002. */
  65003. dispose(force?: boolean): void;
  65004. private getImpostorHitData;
  65005. private _tick;
  65006. /*** Helpers ***/
  65007. private _prepareCylinder;
  65008. private _intersectsWithCylinder;
  65009. }
  65010. /**
  65011. * Options fot the radial explosion event
  65012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65013. */
  65014. export class PhysicsRadialExplosionEventOptions {
  65015. /**
  65016. * The radius of the sphere for the radial explosion.
  65017. */
  65018. radius: number;
  65019. /**
  65020. * The strenth of the explosion.
  65021. */
  65022. strength: number;
  65023. /**
  65024. * The strenght of the force in correspondence to the distance of the affected object
  65025. */
  65026. falloff: PhysicsRadialImpulseFalloff;
  65027. /**
  65028. * Sphere options for the radial explosion.
  65029. */
  65030. sphere: {
  65031. segments: number;
  65032. diameter: number;
  65033. };
  65034. /**
  65035. * Sphere options for the radial explosion.
  65036. */
  65037. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65038. }
  65039. /**
  65040. * Options fot the updraft event
  65041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65042. */
  65043. export class PhysicsUpdraftEventOptions {
  65044. /**
  65045. * The radius of the cylinder for the vortex
  65046. */
  65047. radius: number;
  65048. /**
  65049. * The strenth of the updraft.
  65050. */
  65051. strength: number;
  65052. /**
  65053. * The height of the cylinder for the updraft.
  65054. */
  65055. height: number;
  65056. /**
  65057. * The mode for the the updraft.
  65058. */
  65059. updraftMode: PhysicsUpdraftMode;
  65060. }
  65061. /**
  65062. * Options fot the vortex event
  65063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65064. */
  65065. export class PhysicsVortexEventOptions {
  65066. /**
  65067. * The radius of the cylinder for the vortex
  65068. */
  65069. radius: number;
  65070. /**
  65071. * The strenth of the vortex.
  65072. */
  65073. strength: number;
  65074. /**
  65075. * The height of the cylinder for the vortex.
  65076. */
  65077. height: number;
  65078. /**
  65079. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65080. */
  65081. centripetalForceThreshold: number;
  65082. /**
  65083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65084. */
  65085. centripetalForceMultiplier: number;
  65086. /**
  65087. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65088. */
  65089. centrifugalForceMultiplier: number;
  65090. /**
  65091. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65092. */
  65093. updraftForceMultiplier: number;
  65094. }
  65095. /**
  65096. * The strenght of the force in correspondence to the distance of the affected object
  65097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65098. */
  65099. export enum PhysicsRadialImpulseFalloff {
  65100. /** Defines that impulse is constant in strength across it's whole radius */
  65101. Constant = 0,
  65102. /** Defines that impulse gets weaker if it's further from the origin */
  65103. Linear = 1
  65104. }
  65105. /**
  65106. * The strength of the force in correspondence to the distance of the affected object
  65107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65108. */
  65109. export enum PhysicsUpdraftMode {
  65110. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65111. Center = 0,
  65112. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65113. Perpendicular = 1
  65114. }
  65115. /**
  65116. * Interface for a physics hit data
  65117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65118. */
  65119. export interface PhysicsHitData {
  65120. /**
  65121. * The force applied at the contact point
  65122. */
  65123. force: Vector3;
  65124. /**
  65125. * The contact point
  65126. */
  65127. contactPoint: Vector3;
  65128. /**
  65129. * The distance from the origin to the contact point
  65130. */
  65131. distanceFromOrigin: number;
  65132. }
  65133. /**
  65134. * Interface for radial explosion event data
  65135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65136. */
  65137. export interface PhysicsRadialExplosionEventData {
  65138. /**
  65139. * A sphere used for the radial explosion event
  65140. */
  65141. sphere: Mesh;
  65142. }
  65143. /**
  65144. * Interface for gravitational field event data
  65145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65146. */
  65147. export interface PhysicsGravitationalFieldEventData {
  65148. /**
  65149. * A sphere mesh used for the gravitational field event
  65150. */
  65151. sphere: Mesh;
  65152. }
  65153. /**
  65154. * Interface for updraft event data
  65155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65156. */
  65157. export interface PhysicsUpdraftEventData {
  65158. /**
  65159. * A cylinder used for the updraft event
  65160. */
  65161. cylinder: Mesh;
  65162. }
  65163. /**
  65164. * Interface for vortex event data
  65165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65166. */
  65167. export interface PhysicsVortexEventData {
  65168. /**
  65169. * A cylinder used for the vortex event
  65170. */
  65171. cylinder: Mesh;
  65172. }
  65173. /**
  65174. * Interface for an affected physics impostor
  65175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65176. */
  65177. export interface PhysicsAffectedImpostorWithData {
  65178. /**
  65179. * The impostor affected by the effect
  65180. */
  65181. impostor: PhysicsImpostor;
  65182. /**
  65183. * The data about the hit/horce from the explosion
  65184. */
  65185. hitData: PhysicsHitData;
  65186. }
  65187. }
  65188. declare module "babylonjs/Physics/Plugins/index" {
  65189. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65190. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65191. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65192. }
  65193. declare module "babylonjs/Physics/index" {
  65194. export * from "babylonjs/Physics/IPhysicsEngine";
  65195. export * from "babylonjs/Physics/physicsEngine";
  65196. export * from "babylonjs/Physics/physicsEngineComponent";
  65197. export * from "babylonjs/Physics/physicsHelper";
  65198. export * from "babylonjs/Physics/physicsImpostor";
  65199. export * from "babylonjs/Physics/physicsJoint";
  65200. export * from "babylonjs/Physics/Plugins/index";
  65201. }
  65202. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65203. /** @hidden */
  65204. export var blackAndWhitePixelShader: {
  65205. name: string;
  65206. shader: string;
  65207. };
  65208. }
  65209. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65210. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65211. import { Camera } from "babylonjs/Cameras/camera";
  65212. import { Engine } from "babylonjs/Engines/engine";
  65213. import "babylonjs/Shaders/blackAndWhite.fragment";
  65214. /**
  65215. * Post process used to render in black and white
  65216. */
  65217. export class BlackAndWhitePostProcess extends PostProcess {
  65218. /**
  65219. * Linear about to convert he result to black and white (default: 1)
  65220. */
  65221. degree: number;
  65222. /**
  65223. * Creates a black and white post process
  65224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65225. * @param name The name of the effect.
  65226. * @param options The required width/height ratio to downsize to before computing the render pass.
  65227. * @param camera The camera to apply the render pass to.
  65228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65229. * @param engine The engine which the post process will be applied. (default: current engine)
  65230. * @param reusable If the post process can be reused on the same frame. (default: false)
  65231. */
  65232. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65233. }
  65234. }
  65235. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65236. import { Nullable } from "babylonjs/types";
  65237. import { Camera } from "babylonjs/Cameras/camera";
  65238. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65239. import { Engine } from "babylonjs/Engines/engine";
  65240. /**
  65241. * This represents a set of one or more post processes in Babylon.
  65242. * A post process can be used to apply a shader to a texture after it is rendered.
  65243. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65244. */
  65245. export class PostProcessRenderEffect {
  65246. private _postProcesses;
  65247. private _getPostProcesses;
  65248. private _singleInstance;
  65249. private _cameras;
  65250. private _indicesForCamera;
  65251. /**
  65252. * Name of the effect
  65253. * @hidden
  65254. */
  65255. _name: string;
  65256. /**
  65257. * Instantiates a post process render effect.
  65258. * A post process can be used to apply a shader to a texture after it is rendered.
  65259. * @param engine The engine the effect is tied to
  65260. * @param name The name of the effect
  65261. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65262. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65263. */
  65264. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65265. /**
  65266. * Checks if all the post processes in the effect are supported.
  65267. */
  65268. get isSupported(): boolean;
  65269. /**
  65270. * Updates the current state of the effect
  65271. * @hidden
  65272. */
  65273. _update(): void;
  65274. /**
  65275. * Attaches the effect on cameras
  65276. * @param cameras The camera to attach to.
  65277. * @hidden
  65278. */
  65279. _attachCameras(cameras: Camera): void;
  65280. /**
  65281. * Attaches the effect on cameras
  65282. * @param cameras The camera to attach to.
  65283. * @hidden
  65284. */
  65285. _attachCameras(cameras: Camera[]): void;
  65286. /**
  65287. * Detaches the effect on cameras
  65288. * @param cameras The camera to detatch from.
  65289. * @hidden
  65290. */
  65291. _detachCameras(cameras: Camera): void;
  65292. /**
  65293. * Detatches the effect on cameras
  65294. * @param cameras The camera to detatch from.
  65295. * @hidden
  65296. */
  65297. _detachCameras(cameras: Camera[]): void;
  65298. /**
  65299. * Enables the effect on given cameras
  65300. * @param cameras The camera to enable.
  65301. * @hidden
  65302. */
  65303. _enable(cameras: Camera): void;
  65304. /**
  65305. * Enables the effect on given cameras
  65306. * @param cameras The camera to enable.
  65307. * @hidden
  65308. */
  65309. _enable(cameras: Nullable<Camera[]>): void;
  65310. /**
  65311. * Disables the effect on the given cameras
  65312. * @param cameras The camera to disable.
  65313. * @hidden
  65314. */
  65315. _disable(cameras: Camera): void;
  65316. /**
  65317. * Disables the effect on the given cameras
  65318. * @param cameras The camera to disable.
  65319. * @hidden
  65320. */
  65321. _disable(cameras: Nullable<Camera[]>): void;
  65322. /**
  65323. * Gets a list of the post processes contained in the effect.
  65324. * @param camera The camera to get the post processes on.
  65325. * @returns The list of the post processes in the effect.
  65326. */
  65327. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65328. }
  65329. }
  65330. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65332. /** @hidden */
  65333. export var extractHighlightsPixelShader: {
  65334. name: string;
  65335. shader: string;
  65336. };
  65337. }
  65338. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65339. import { Nullable } from "babylonjs/types";
  65340. import { Camera } from "babylonjs/Cameras/camera";
  65341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65342. import { Engine } from "babylonjs/Engines/engine";
  65343. import "babylonjs/Shaders/extractHighlights.fragment";
  65344. /**
  65345. * 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.
  65346. */
  65347. export class ExtractHighlightsPostProcess extends PostProcess {
  65348. /**
  65349. * The luminance threshold, pixels below this value will be set to black.
  65350. */
  65351. threshold: number;
  65352. /** @hidden */
  65353. _exposure: number;
  65354. /**
  65355. * Post process which has the input texture to be used when performing highlight extraction
  65356. * @hidden
  65357. */
  65358. _inputPostProcess: Nullable<PostProcess>;
  65359. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65360. }
  65361. }
  65362. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65363. /** @hidden */
  65364. export var bloomMergePixelShader: {
  65365. name: string;
  65366. shader: string;
  65367. };
  65368. }
  65369. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65371. import { Nullable } from "babylonjs/types";
  65372. import { Engine } from "babylonjs/Engines/engine";
  65373. import { Camera } from "babylonjs/Cameras/camera";
  65374. import "babylonjs/Shaders/bloomMerge.fragment";
  65375. /**
  65376. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65377. */
  65378. export class BloomMergePostProcess extends PostProcess {
  65379. /** Weight of the bloom to be added to the original input. */
  65380. weight: number;
  65381. /**
  65382. * Creates a new instance of @see BloomMergePostProcess
  65383. * @param name The name of the effect.
  65384. * @param originalFromInput Post process which's input will be used for the merge.
  65385. * @param blurred Blurred highlights post process which's output will be used.
  65386. * @param weight Weight of the bloom to be added to the original input.
  65387. * @param options The required width/height ratio to downsize to before computing the render pass.
  65388. * @param camera The camera to apply the render pass to.
  65389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65390. * @param engine The engine which the post process will be applied. (default: current engine)
  65391. * @param reusable If the post process can be reused on the same frame. (default: false)
  65392. * @param textureType Type of textures used when performing the post process. (default: 0)
  65393. * @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)
  65394. */
  65395. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65396. /** Weight of the bloom to be added to the original input. */
  65397. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65398. }
  65399. }
  65400. declare module "babylonjs/PostProcesses/bloomEffect" {
  65401. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65403. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65404. import { Camera } from "babylonjs/Cameras/camera";
  65405. import { Scene } from "babylonjs/scene";
  65406. /**
  65407. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65408. */
  65409. export class BloomEffect extends PostProcessRenderEffect {
  65410. private bloomScale;
  65411. /**
  65412. * @hidden Internal
  65413. */
  65414. _effects: Array<PostProcess>;
  65415. /**
  65416. * @hidden Internal
  65417. */
  65418. _downscale: ExtractHighlightsPostProcess;
  65419. private _blurX;
  65420. private _blurY;
  65421. private _merge;
  65422. /**
  65423. * The luminance threshold to find bright areas of the image to bloom.
  65424. */
  65425. get threshold(): number;
  65426. set threshold(value: number);
  65427. /**
  65428. * The strength of the bloom.
  65429. */
  65430. get weight(): number;
  65431. set weight(value: number);
  65432. /**
  65433. * Specifies the size of the bloom blur kernel, relative to the final output size
  65434. */
  65435. get kernel(): number;
  65436. set kernel(value: number);
  65437. /**
  65438. * Creates a new instance of @see BloomEffect
  65439. * @param scene The scene the effect belongs to.
  65440. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65441. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65442. * @param bloomWeight The the strength of bloom.
  65443. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65444. * @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)
  65445. */
  65446. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65447. /**
  65448. * Disposes each of the internal effects for a given camera.
  65449. * @param camera The camera to dispose the effect on.
  65450. */
  65451. disposeEffects(camera: Camera): void;
  65452. /**
  65453. * @hidden Internal
  65454. */
  65455. _updateEffects(): void;
  65456. /**
  65457. * Internal
  65458. * @returns if all the contained post processes are ready.
  65459. * @hidden
  65460. */
  65461. _isReady(): boolean;
  65462. }
  65463. }
  65464. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65465. /** @hidden */
  65466. export var chromaticAberrationPixelShader: {
  65467. name: string;
  65468. shader: string;
  65469. };
  65470. }
  65471. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65472. import { Vector2 } from "babylonjs/Maths/math.vector";
  65473. import { Nullable } from "babylonjs/types";
  65474. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65475. import { Camera } from "babylonjs/Cameras/camera";
  65476. import { Engine } from "babylonjs/Engines/engine";
  65477. import "babylonjs/Shaders/chromaticAberration.fragment";
  65478. /**
  65479. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65480. */
  65481. export class ChromaticAberrationPostProcess extends PostProcess {
  65482. /**
  65483. * The amount of seperation of rgb channels (default: 30)
  65484. */
  65485. aberrationAmount: number;
  65486. /**
  65487. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65488. */
  65489. radialIntensity: number;
  65490. /**
  65491. * 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))
  65492. */
  65493. direction: Vector2;
  65494. /**
  65495. * 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))
  65496. */
  65497. centerPosition: Vector2;
  65498. /**
  65499. * Creates a new instance ChromaticAberrationPostProcess
  65500. * @param name The name of the effect.
  65501. * @param screenWidth The width of the screen to apply the effect on.
  65502. * @param screenHeight The height of the screen to apply the effect on.
  65503. * @param options The required width/height ratio to downsize to before computing the render pass.
  65504. * @param camera The camera to apply the render pass to.
  65505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65506. * @param engine The engine which the post process will be applied. (default: current engine)
  65507. * @param reusable If the post process can be reused on the same frame. (default: false)
  65508. * @param textureType Type of textures used when performing the post process. (default: 0)
  65509. * @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)
  65510. */
  65511. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65512. }
  65513. }
  65514. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65515. /** @hidden */
  65516. export var circleOfConfusionPixelShader: {
  65517. name: string;
  65518. shader: string;
  65519. };
  65520. }
  65521. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65522. import { Nullable } from "babylonjs/types";
  65523. import { Engine } from "babylonjs/Engines/engine";
  65524. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65526. import { Camera } from "babylonjs/Cameras/camera";
  65527. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65528. /**
  65529. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65530. */
  65531. export class CircleOfConfusionPostProcess extends PostProcess {
  65532. /**
  65533. * 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.
  65534. */
  65535. lensSize: number;
  65536. /**
  65537. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65538. */
  65539. fStop: number;
  65540. /**
  65541. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65542. */
  65543. focusDistance: number;
  65544. /**
  65545. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65546. */
  65547. focalLength: number;
  65548. private _depthTexture;
  65549. /**
  65550. * Creates a new instance CircleOfConfusionPostProcess
  65551. * @param name The name of the effect.
  65552. * @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.
  65553. * @param options The required width/height ratio to downsize to before computing the render pass.
  65554. * @param camera The camera to apply the render pass to.
  65555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65556. * @param engine The engine which the post process will be applied. (default: current engine)
  65557. * @param reusable If the post process can be reused on the same frame. (default: false)
  65558. * @param textureType Type of textures used when performing the post process. (default: 0)
  65559. * @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)
  65560. */
  65561. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65562. /**
  65563. * 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.
  65564. */
  65565. set depthTexture(value: RenderTargetTexture);
  65566. }
  65567. }
  65568. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65569. /** @hidden */
  65570. export var colorCorrectionPixelShader: {
  65571. name: string;
  65572. shader: string;
  65573. };
  65574. }
  65575. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65577. import { Engine } from "babylonjs/Engines/engine";
  65578. import { Camera } from "babylonjs/Cameras/camera";
  65579. import "babylonjs/Shaders/colorCorrection.fragment";
  65580. /**
  65581. *
  65582. * This post-process allows the modification of rendered colors by using
  65583. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65584. *
  65585. * The object needs to be provided an url to a texture containing the color
  65586. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65587. * Use an image editing software to tweak the LUT to match your needs.
  65588. *
  65589. * For an example of a color LUT, see here:
  65590. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65591. * For explanations on color grading, see here:
  65592. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65593. *
  65594. */
  65595. export class ColorCorrectionPostProcess extends PostProcess {
  65596. private _colorTableTexture;
  65597. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65598. }
  65599. }
  65600. declare module "babylonjs/Shaders/convolution.fragment" {
  65601. /** @hidden */
  65602. export var convolutionPixelShader: {
  65603. name: string;
  65604. shader: string;
  65605. };
  65606. }
  65607. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65608. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65609. import { Nullable } from "babylonjs/types";
  65610. import { Camera } from "babylonjs/Cameras/camera";
  65611. import { Engine } from "babylonjs/Engines/engine";
  65612. import "babylonjs/Shaders/convolution.fragment";
  65613. /**
  65614. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65615. * input texture to perform effects such as edge detection or sharpening
  65616. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65617. */
  65618. export class ConvolutionPostProcess extends PostProcess {
  65619. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65620. kernel: number[];
  65621. /**
  65622. * Creates a new instance ConvolutionPostProcess
  65623. * @param name The name of the effect.
  65624. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65625. * @param options The required width/height ratio to downsize to before computing the render pass.
  65626. * @param camera The camera to apply the render pass to.
  65627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65628. * @param engine The engine which the post process will be applied. (default: current engine)
  65629. * @param reusable If the post process can be reused on the same frame. (default: false)
  65630. * @param textureType Type of textures used when performing the post process. (default: 0)
  65631. */
  65632. constructor(name: string,
  65633. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65634. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65635. /**
  65636. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65637. */
  65638. static EdgeDetect0Kernel: number[];
  65639. /**
  65640. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65641. */
  65642. static EdgeDetect1Kernel: number[];
  65643. /**
  65644. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65645. */
  65646. static EdgeDetect2Kernel: number[];
  65647. /**
  65648. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65649. */
  65650. static SharpenKernel: number[];
  65651. /**
  65652. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65653. */
  65654. static EmbossKernel: number[];
  65655. /**
  65656. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65657. */
  65658. static GaussianKernel: number[];
  65659. }
  65660. }
  65661. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65662. import { Nullable } from "babylonjs/types";
  65663. import { Vector2 } from "babylonjs/Maths/math.vector";
  65664. import { Camera } from "babylonjs/Cameras/camera";
  65665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65666. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65667. import { Engine } from "babylonjs/Engines/engine";
  65668. import { Scene } from "babylonjs/scene";
  65669. /**
  65670. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65671. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65672. * based on samples that have a large difference in distance than the center pixel.
  65673. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65674. */
  65675. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65676. direction: Vector2;
  65677. /**
  65678. * Creates a new instance CircleOfConfusionPostProcess
  65679. * @param name The name of the effect.
  65680. * @param scene The scene the effect belongs to.
  65681. * @param direction The direction the blur should be applied.
  65682. * @param kernel The size of the kernel used to blur.
  65683. * @param options The required width/height ratio to downsize to before computing the render pass.
  65684. * @param camera The camera to apply the render pass to.
  65685. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65686. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65688. * @param engine The engine which the post process will be applied. (default: current engine)
  65689. * @param reusable If the post process can be reused on the same frame. (default: false)
  65690. * @param textureType Type of textures used when performing the post process. (default: 0)
  65691. * @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)
  65692. */
  65693. 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);
  65694. }
  65695. }
  65696. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65697. /** @hidden */
  65698. export var depthOfFieldMergePixelShader: {
  65699. name: string;
  65700. shader: string;
  65701. };
  65702. }
  65703. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65704. import { Nullable } from "babylonjs/types";
  65705. import { Camera } from "babylonjs/Cameras/camera";
  65706. import { Effect } from "babylonjs/Materials/effect";
  65707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65708. import { Engine } from "babylonjs/Engines/engine";
  65709. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65710. /**
  65711. * Options to be set when merging outputs from the default pipeline.
  65712. */
  65713. export class DepthOfFieldMergePostProcessOptions {
  65714. /**
  65715. * The original image to merge on top of
  65716. */
  65717. originalFromInput: PostProcess;
  65718. /**
  65719. * Parameters to perform the merge of the depth of field effect
  65720. */
  65721. depthOfField?: {
  65722. circleOfConfusion: PostProcess;
  65723. blurSteps: Array<PostProcess>;
  65724. };
  65725. /**
  65726. * Parameters to perform the merge of bloom effect
  65727. */
  65728. bloom?: {
  65729. blurred: PostProcess;
  65730. weight: number;
  65731. };
  65732. }
  65733. /**
  65734. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65735. */
  65736. export class DepthOfFieldMergePostProcess extends PostProcess {
  65737. private blurSteps;
  65738. /**
  65739. * Creates a new instance of DepthOfFieldMergePostProcess
  65740. * @param name The name of the effect.
  65741. * @param originalFromInput Post process which's input will be used for the merge.
  65742. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65743. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65744. * @param options The required width/height ratio to downsize to before computing the render pass.
  65745. * @param camera The camera to apply the render pass to.
  65746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65747. * @param engine The engine which the post process will be applied. (default: current engine)
  65748. * @param reusable If the post process can be reused on the same frame. (default: false)
  65749. * @param textureType Type of textures used when performing the post process. (default: 0)
  65750. * @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)
  65751. */
  65752. 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);
  65753. /**
  65754. * Updates the effect with the current post process compile time values and recompiles the shader.
  65755. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65756. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65757. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65758. * @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
  65759. * @param onCompiled Called when the shader has been compiled.
  65760. * @param onError Called if there is an error when compiling a shader.
  65761. */
  65762. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65763. }
  65764. }
  65765. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65766. import { Nullable } from "babylonjs/types";
  65767. import { Camera } from "babylonjs/Cameras/camera";
  65768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65769. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65770. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65771. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65772. import { Scene } from "babylonjs/scene";
  65773. /**
  65774. * Specifies the level of max blur that should be applied when using the depth of field effect
  65775. */
  65776. export enum DepthOfFieldEffectBlurLevel {
  65777. /**
  65778. * Subtle blur
  65779. */
  65780. Low = 0,
  65781. /**
  65782. * Medium blur
  65783. */
  65784. Medium = 1,
  65785. /**
  65786. * Large blur
  65787. */
  65788. High = 2
  65789. }
  65790. /**
  65791. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65792. */
  65793. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65794. private _circleOfConfusion;
  65795. /**
  65796. * @hidden Internal, blurs from high to low
  65797. */
  65798. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65799. private _depthOfFieldBlurY;
  65800. private _dofMerge;
  65801. /**
  65802. * @hidden Internal post processes in depth of field effect
  65803. */
  65804. _effects: Array<PostProcess>;
  65805. /**
  65806. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65807. */
  65808. set focalLength(value: number);
  65809. get focalLength(): number;
  65810. /**
  65811. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65812. */
  65813. set fStop(value: number);
  65814. get fStop(): number;
  65815. /**
  65816. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65817. */
  65818. set focusDistance(value: number);
  65819. get focusDistance(): number;
  65820. /**
  65821. * 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.
  65822. */
  65823. set lensSize(value: number);
  65824. get lensSize(): number;
  65825. /**
  65826. * Creates a new instance DepthOfFieldEffect
  65827. * @param scene The scene the effect belongs to.
  65828. * @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.
  65829. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65830. * @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)
  65831. */
  65832. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65833. /**
  65834. * Get the current class name of the current effet
  65835. * @returns "DepthOfFieldEffect"
  65836. */
  65837. getClassName(): string;
  65838. /**
  65839. * 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.
  65840. */
  65841. set depthTexture(value: RenderTargetTexture);
  65842. /**
  65843. * Disposes each of the internal effects for a given camera.
  65844. * @param camera The camera to dispose the effect on.
  65845. */
  65846. disposeEffects(camera: Camera): void;
  65847. /**
  65848. * @hidden Internal
  65849. */
  65850. _updateEffects(): void;
  65851. /**
  65852. * Internal
  65853. * @returns if all the contained post processes are ready.
  65854. * @hidden
  65855. */
  65856. _isReady(): boolean;
  65857. }
  65858. }
  65859. declare module "babylonjs/Shaders/displayPass.fragment" {
  65860. /** @hidden */
  65861. export var displayPassPixelShader: {
  65862. name: string;
  65863. shader: string;
  65864. };
  65865. }
  65866. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65867. import { Nullable } from "babylonjs/types";
  65868. import { Camera } from "babylonjs/Cameras/camera";
  65869. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65870. import { Engine } from "babylonjs/Engines/engine";
  65871. import "babylonjs/Shaders/displayPass.fragment";
  65872. /**
  65873. * DisplayPassPostProcess which produces an output the same as it's input
  65874. */
  65875. export class DisplayPassPostProcess extends PostProcess {
  65876. /**
  65877. * Creates the DisplayPassPostProcess
  65878. * @param name The name of the effect.
  65879. * @param options The required width/height ratio to downsize to before computing the render pass.
  65880. * @param camera The camera to apply the render pass to.
  65881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65882. * @param engine The engine which the post process will be applied. (default: current engine)
  65883. * @param reusable If the post process can be reused on the same frame. (default: false)
  65884. */
  65885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65886. }
  65887. }
  65888. declare module "babylonjs/Shaders/filter.fragment" {
  65889. /** @hidden */
  65890. export var filterPixelShader: {
  65891. name: string;
  65892. shader: string;
  65893. };
  65894. }
  65895. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65896. import { Nullable } from "babylonjs/types";
  65897. import { Matrix } from "babylonjs/Maths/math.vector";
  65898. import { Camera } from "babylonjs/Cameras/camera";
  65899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65900. import { Engine } from "babylonjs/Engines/engine";
  65901. import "babylonjs/Shaders/filter.fragment";
  65902. /**
  65903. * Applies a kernel filter to the image
  65904. */
  65905. export class FilterPostProcess extends PostProcess {
  65906. /** The matrix to be applied to the image */
  65907. kernelMatrix: Matrix;
  65908. /**
  65909. *
  65910. * @param name The name of the effect.
  65911. * @param kernelMatrix The matrix to be applied to the image
  65912. * @param options The required width/height ratio to downsize to before computing the render pass.
  65913. * @param camera The camera to apply the render pass to.
  65914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65915. * @param engine The engine which the post process will be applied. (default: current engine)
  65916. * @param reusable If the post process can be reused on the same frame. (default: false)
  65917. */
  65918. constructor(name: string,
  65919. /** The matrix to be applied to the image */
  65920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65921. }
  65922. }
  65923. declare module "babylonjs/Shaders/fxaa.fragment" {
  65924. /** @hidden */
  65925. export var fxaaPixelShader: {
  65926. name: string;
  65927. shader: string;
  65928. };
  65929. }
  65930. declare module "babylonjs/Shaders/fxaa.vertex" {
  65931. /** @hidden */
  65932. export var fxaaVertexShader: {
  65933. name: string;
  65934. shader: string;
  65935. };
  65936. }
  65937. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  65938. import { Nullable } from "babylonjs/types";
  65939. import { Camera } from "babylonjs/Cameras/camera";
  65940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65941. import { Engine } from "babylonjs/Engines/engine";
  65942. import "babylonjs/Shaders/fxaa.fragment";
  65943. import "babylonjs/Shaders/fxaa.vertex";
  65944. /**
  65945. * Fxaa post process
  65946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65947. */
  65948. export class FxaaPostProcess extends PostProcess {
  65949. /** @hidden */
  65950. texelWidth: number;
  65951. /** @hidden */
  65952. texelHeight: number;
  65953. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65954. private _getDefines;
  65955. }
  65956. }
  65957. declare module "babylonjs/Shaders/grain.fragment" {
  65958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65959. /** @hidden */
  65960. export var grainPixelShader: {
  65961. name: string;
  65962. shader: string;
  65963. };
  65964. }
  65965. declare module "babylonjs/PostProcesses/grainPostProcess" {
  65966. import { Nullable } from "babylonjs/types";
  65967. import { Camera } from "babylonjs/Cameras/camera";
  65968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65969. import { Engine } from "babylonjs/Engines/engine";
  65970. import "babylonjs/Shaders/grain.fragment";
  65971. /**
  65972. * The GrainPostProcess adds noise to the image at mid luminance levels
  65973. */
  65974. export class GrainPostProcess extends PostProcess {
  65975. /**
  65976. * The intensity of the grain added (default: 30)
  65977. */
  65978. intensity: number;
  65979. /**
  65980. * If the grain should be randomized on every frame
  65981. */
  65982. animated: boolean;
  65983. /**
  65984. * Creates a new instance of @see GrainPostProcess
  65985. * @param name The name of the effect.
  65986. * @param options The required width/height ratio to downsize to before computing the render pass.
  65987. * @param camera The camera to apply the render pass to.
  65988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65989. * @param engine The engine which the post process will be applied. (default: current engine)
  65990. * @param reusable If the post process can be reused on the same frame. (default: false)
  65991. * @param textureType Type of textures used when performing the post process. (default: 0)
  65992. * @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)
  65993. */
  65994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65995. }
  65996. }
  65997. declare module "babylonjs/Shaders/highlights.fragment" {
  65998. /** @hidden */
  65999. export var highlightsPixelShader: {
  66000. name: string;
  66001. shader: string;
  66002. };
  66003. }
  66004. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66005. import { Nullable } from "babylonjs/types";
  66006. import { Camera } from "babylonjs/Cameras/camera";
  66007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66008. import { Engine } from "babylonjs/Engines/engine";
  66009. import "babylonjs/Shaders/highlights.fragment";
  66010. /**
  66011. * Extracts highlights from the image
  66012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66013. */
  66014. export class HighlightsPostProcess extends PostProcess {
  66015. /**
  66016. * Extracts highlights from the image
  66017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66018. * @param name The name of the effect.
  66019. * @param options The required width/height ratio to downsize to before computing the render pass.
  66020. * @param camera The camera to apply the render pass to.
  66021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66022. * @param engine The engine which the post process will be applied. (default: current engine)
  66023. * @param reusable If the post process can be reused on the same frame. (default: false)
  66024. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66025. */
  66026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66027. }
  66028. }
  66029. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66030. /** @hidden */
  66031. export var mrtFragmentDeclaration: {
  66032. name: string;
  66033. shader: string;
  66034. };
  66035. }
  66036. declare module "babylonjs/Shaders/geometry.fragment" {
  66037. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66038. /** @hidden */
  66039. export var geometryPixelShader: {
  66040. name: string;
  66041. shader: string;
  66042. };
  66043. }
  66044. declare module "babylonjs/Shaders/geometry.vertex" {
  66045. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66046. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66047. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66048. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66049. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66050. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66051. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66052. /** @hidden */
  66053. export var geometryVertexShader: {
  66054. name: string;
  66055. shader: string;
  66056. };
  66057. }
  66058. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66059. import { Matrix } from "babylonjs/Maths/math.vector";
  66060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66061. import { Mesh } from "babylonjs/Meshes/mesh";
  66062. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66063. import { Effect } from "babylonjs/Materials/effect";
  66064. import { Scene } from "babylonjs/scene";
  66065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66066. import "babylonjs/Shaders/geometry.fragment";
  66067. import "babylonjs/Shaders/geometry.vertex";
  66068. /** @hidden */
  66069. interface ISavedTransformationMatrix {
  66070. world: Matrix;
  66071. viewProjection: Matrix;
  66072. }
  66073. /**
  66074. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66075. */
  66076. export class GeometryBufferRenderer {
  66077. /**
  66078. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66079. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66080. */
  66081. static readonly POSITION_TEXTURE_TYPE: number;
  66082. /**
  66083. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66084. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66085. */
  66086. static readonly VELOCITY_TEXTURE_TYPE: number;
  66087. /**
  66088. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66089. * in order to compute objects velocities when enableVelocity is set to "true"
  66090. * @hidden
  66091. */
  66092. _previousTransformationMatrices: {
  66093. [index: number]: ISavedTransformationMatrix;
  66094. };
  66095. /**
  66096. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66097. * in order to compute objects velocities when enableVelocity is set to "true"
  66098. * @hidden
  66099. */
  66100. _previousBonesTransformationMatrices: {
  66101. [index: number]: Float32Array;
  66102. };
  66103. /**
  66104. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66105. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66106. */
  66107. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66108. private _scene;
  66109. private _multiRenderTarget;
  66110. private _ratio;
  66111. private _enablePosition;
  66112. private _enableVelocity;
  66113. private _positionIndex;
  66114. private _velocityIndex;
  66115. protected _effect: Effect;
  66116. protected _cachedDefines: string;
  66117. /**
  66118. * Set the render list (meshes to be rendered) used in the G buffer.
  66119. */
  66120. set renderList(meshes: Mesh[]);
  66121. /**
  66122. * Gets wether or not G buffer are supported by the running hardware.
  66123. * This requires draw buffer supports
  66124. */
  66125. get isSupported(): boolean;
  66126. /**
  66127. * Returns the index of the given texture type in the G-Buffer textures array
  66128. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66129. * @returns the index of the given texture type in the G-Buffer textures array
  66130. */
  66131. getTextureIndex(textureType: number): number;
  66132. /**
  66133. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66134. */
  66135. get enablePosition(): boolean;
  66136. /**
  66137. * Sets whether or not objects positions are enabled for the G buffer.
  66138. */
  66139. set enablePosition(enable: boolean);
  66140. /**
  66141. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66142. */
  66143. get enableVelocity(): boolean;
  66144. /**
  66145. * Sets wether or not objects velocities are enabled for the G buffer.
  66146. */
  66147. set enableVelocity(enable: boolean);
  66148. /**
  66149. * Gets the scene associated with the buffer.
  66150. */
  66151. get scene(): Scene;
  66152. /**
  66153. * Gets the ratio used by the buffer during its creation.
  66154. * How big is the buffer related to the main canvas.
  66155. */
  66156. get ratio(): number;
  66157. /** @hidden */
  66158. static _SceneComponentInitialization: (scene: Scene) => void;
  66159. /**
  66160. * Creates a new G Buffer for the scene
  66161. * @param scene The scene the buffer belongs to
  66162. * @param ratio How big is the buffer related to the main canvas.
  66163. */
  66164. constructor(scene: Scene, ratio?: number);
  66165. /**
  66166. * Checks wether everything is ready to render a submesh to the G buffer.
  66167. * @param subMesh the submesh to check readiness for
  66168. * @param useInstances is the mesh drawn using instance or not
  66169. * @returns true if ready otherwise false
  66170. */
  66171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66172. /**
  66173. * Gets the current underlying G Buffer.
  66174. * @returns the buffer
  66175. */
  66176. getGBuffer(): MultiRenderTarget;
  66177. /**
  66178. * Gets the number of samples used to render the buffer (anti aliasing).
  66179. */
  66180. get samples(): number;
  66181. /**
  66182. * Sets the number of samples used to render the buffer (anti aliasing).
  66183. */
  66184. set samples(value: number);
  66185. /**
  66186. * Disposes the renderer and frees up associated resources.
  66187. */
  66188. dispose(): void;
  66189. protected _createRenderTargets(): void;
  66190. private _copyBonesTransformationMatrices;
  66191. }
  66192. }
  66193. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66194. import { Nullable } from "babylonjs/types";
  66195. import { Scene } from "babylonjs/scene";
  66196. import { ISceneComponent } from "babylonjs/sceneComponent";
  66197. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66198. module "babylonjs/scene" {
  66199. interface Scene {
  66200. /** @hidden (Backing field) */
  66201. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66202. /**
  66203. * Gets or Sets the current geometry buffer associated to the scene.
  66204. */
  66205. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66206. /**
  66207. * Enables a GeometryBufferRender and associates it with the scene
  66208. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66209. * @returns the GeometryBufferRenderer
  66210. */
  66211. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66212. /**
  66213. * Disables the GeometryBufferRender associated with the scene
  66214. */
  66215. disableGeometryBufferRenderer(): void;
  66216. }
  66217. }
  66218. /**
  66219. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66220. * in several rendering techniques.
  66221. */
  66222. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66223. /**
  66224. * The component name helpful to identify the component in the list of scene components.
  66225. */
  66226. readonly name: string;
  66227. /**
  66228. * The scene the component belongs to.
  66229. */
  66230. scene: Scene;
  66231. /**
  66232. * Creates a new instance of the component for the given scene
  66233. * @param scene Defines the scene to register the component in
  66234. */
  66235. constructor(scene: Scene);
  66236. /**
  66237. * Registers the component in a given scene
  66238. */
  66239. register(): void;
  66240. /**
  66241. * Rebuilds the elements related to this component in case of
  66242. * context lost for instance.
  66243. */
  66244. rebuild(): void;
  66245. /**
  66246. * Disposes the component and the associated ressources
  66247. */
  66248. dispose(): void;
  66249. private _gatherRenderTargets;
  66250. }
  66251. }
  66252. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66253. /** @hidden */
  66254. export var motionBlurPixelShader: {
  66255. name: string;
  66256. shader: string;
  66257. };
  66258. }
  66259. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66260. import { Nullable } from "babylonjs/types";
  66261. import { Camera } from "babylonjs/Cameras/camera";
  66262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66263. import { Scene } from "babylonjs/scene";
  66264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66265. import "babylonjs/Animations/animatable";
  66266. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66267. import "babylonjs/Shaders/motionBlur.fragment";
  66268. import { Engine } from "babylonjs/Engines/engine";
  66269. /**
  66270. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66271. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66272. * As an example, all you have to do is to create the post-process:
  66273. * var mb = new BABYLON.MotionBlurPostProcess(
  66274. * 'mb', // The name of the effect.
  66275. * scene, // The scene containing the objects to blur according to their velocity.
  66276. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66277. * camera // The camera to apply the render pass to.
  66278. * );
  66279. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66280. */
  66281. export class MotionBlurPostProcess extends PostProcess {
  66282. /**
  66283. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66284. */
  66285. motionStrength: number;
  66286. /**
  66287. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66288. */
  66289. get motionBlurSamples(): number;
  66290. /**
  66291. * Sets the number of iterations to be used for motion blur quality
  66292. */
  66293. set motionBlurSamples(samples: number);
  66294. private _motionBlurSamples;
  66295. private _geometryBufferRenderer;
  66296. /**
  66297. * Creates a new instance MotionBlurPostProcess
  66298. * @param name The name of the effect.
  66299. * @param scene The scene containing the objects to blur according to their velocity.
  66300. * @param options The required width/height ratio to downsize to before computing the render pass.
  66301. * @param camera The camera to apply the render pass to.
  66302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66303. * @param engine The engine which the post process will be applied. (default: current engine)
  66304. * @param reusable If the post process can be reused on the same frame. (default: false)
  66305. * @param textureType Type of textures used when performing the post process. (default: 0)
  66306. * @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)
  66307. */
  66308. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66309. /**
  66310. * Excludes the given skinned mesh from computing bones velocities.
  66311. * 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.
  66312. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66313. */
  66314. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66315. /**
  66316. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66317. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66318. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66319. */
  66320. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66321. /**
  66322. * Disposes the post process.
  66323. * @param camera The camera to dispose the post process on.
  66324. */
  66325. dispose(camera?: Camera): void;
  66326. }
  66327. }
  66328. declare module "babylonjs/Shaders/refraction.fragment" {
  66329. /** @hidden */
  66330. export var refractionPixelShader: {
  66331. name: string;
  66332. shader: string;
  66333. };
  66334. }
  66335. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66336. import { Color3 } from "babylonjs/Maths/math.color";
  66337. import { Camera } from "babylonjs/Cameras/camera";
  66338. import { Texture } from "babylonjs/Materials/Textures/texture";
  66339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66340. import { Engine } from "babylonjs/Engines/engine";
  66341. import "babylonjs/Shaders/refraction.fragment";
  66342. /**
  66343. * Post process which applies a refractin texture
  66344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66345. */
  66346. export class RefractionPostProcess extends PostProcess {
  66347. /** the base color of the refraction (used to taint the rendering) */
  66348. color: Color3;
  66349. /** simulated refraction depth */
  66350. depth: number;
  66351. /** the coefficient of the base color (0 to remove base color tainting) */
  66352. colorLevel: number;
  66353. private _refTexture;
  66354. private _ownRefractionTexture;
  66355. /**
  66356. * Gets or sets the refraction texture
  66357. * Please note that you are responsible for disposing the texture if you set it manually
  66358. */
  66359. get refractionTexture(): Texture;
  66360. set refractionTexture(value: Texture);
  66361. /**
  66362. * Initializes the RefractionPostProcess
  66363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66364. * @param name The name of the effect.
  66365. * @param refractionTextureUrl Url of the refraction texture to use
  66366. * @param color the base color of the refraction (used to taint the rendering)
  66367. * @param depth simulated refraction depth
  66368. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66369. * @param camera The camera to apply the render pass to.
  66370. * @param options The required width/height ratio to downsize to before computing the render pass.
  66371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66372. * @param engine The engine which the post process will be applied. (default: current engine)
  66373. * @param reusable If the post process can be reused on the same frame. (default: false)
  66374. */
  66375. constructor(name: string, refractionTextureUrl: string,
  66376. /** the base color of the refraction (used to taint the rendering) */
  66377. color: Color3,
  66378. /** simulated refraction depth */
  66379. depth: number,
  66380. /** the coefficient of the base color (0 to remove base color tainting) */
  66381. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66382. /**
  66383. * Disposes of the post process
  66384. * @param camera Camera to dispose post process on
  66385. */
  66386. dispose(camera: Camera): void;
  66387. }
  66388. }
  66389. declare module "babylonjs/Shaders/sharpen.fragment" {
  66390. /** @hidden */
  66391. export var sharpenPixelShader: {
  66392. name: string;
  66393. shader: string;
  66394. };
  66395. }
  66396. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66397. import { Nullable } from "babylonjs/types";
  66398. import { Camera } from "babylonjs/Cameras/camera";
  66399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66400. import "babylonjs/Shaders/sharpen.fragment";
  66401. import { Engine } from "babylonjs/Engines/engine";
  66402. /**
  66403. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66404. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66405. */
  66406. export class SharpenPostProcess extends PostProcess {
  66407. /**
  66408. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66409. */
  66410. colorAmount: number;
  66411. /**
  66412. * How much sharpness should be applied (default: 0.3)
  66413. */
  66414. edgeAmount: number;
  66415. /**
  66416. * Creates a new instance ConvolutionPostProcess
  66417. * @param name The name of the effect.
  66418. * @param options The required width/height ratio to downsize to before computing the render pass.
  66419. * @param camera The camera to apply the render pass to.
  66420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66421. * @param engine The engine which the post process will be applied. (default: current engine)
  66422. * @param reusable If the post process can be reused on the same frame. (default: false)
  66423. * @param textureType Type of textures used when performing the post process. (default: 0)
  66424. * @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)
  66425. */
  66426. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66427. }
  66428. }
  66429. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66430. import { Nullable } from "babylonjs/types";
  66431. import { Camera } from "babylonjs/Cameras/camera";
  66432. import { Engine } from "babylonjs/Engines/engine";
  66433. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66434. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66435. /**
  66436. * PostProcessRenderPipeline
  66437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66438. */
  66439. export class PostProcessRenderPipeline {
  66440. private engine;
  66441. private _renderEffects;
  66442. private _renderEffectsForIsolatedPass;
  66443. /**
  66444. * List of inspectable custom properties (used by the Inspector)
  66445. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66446. */
  66447. inspectableCustomProperties: IInspectable[];
  66448. /**
  66449. * @hidden
  66450. */
  66451. protected _cameras: Camera[];
  66452. /** @hidden */
  66453. _name: string;
  66454. /**
  66455. * Gets pipeline name
  66456. */
  66457. get name(): string;
  66458. /** Gets the list of attached cameras */
  66459. get cameras(): Camera[];
  66460. /**
  66461. * Initializes a PostProcessRenderPipeline
  66462. * @param engine engine to add the pipeline to
  66463. * @param name name of the pipeline
  66464. */
  66465. constructor(engine: Engine, name: string);
  66466. /**
  66467. * Gets the class name
  66468. * @returns "PostProcessRenderPipeline"
  66469. */
  66470. getClassName(): string;
  66471. /**
  66472. * If all the render effects in the pipeline are supported
  66473. */
  66474. get isSupported(): boolean;
  66475. /**
  66476. * Adds an effect to the pipeline
  66477. * @param renderEffect the effect to add
  66478. */
  66479. addEffect(renderEffect: PostProcessRenderEffect): void;
  66480. /** @hidden */
  66481. _rebuild(): void;
  66482. /** @hidden */
  66483. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66484. /** @hidden */
  66485. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66486. /** @hidden */
  66487. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66488. /** @hidden */
  66489. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66490. /** @hidden */
  66491. _attachCameras(cameras: Camera, unique: boolean): void;
  66492. /** @hidden */
  66493. _attachCameras(cameras: Camera[], unique: boolean): void;
  66494. /** @hidden */
  66495. _detachCameras(cameras: Camera): void;
  66496. /** @hidden */
  66497. _detachCameras(cameras: Nullable<Camera[]>): void;
  66498. /** @hidden */
  66499. _update(): void;
  66500. /** @hidden */
  66501. _reset(): void;
  66502. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66503. /**
  66504. * Disposes of the pipeline
  66505. */
  66506. dispose(): void;
  66507. }
  66508. }
  66509. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66510. import { Camera } from "babylonjs/Cameras/camera";
  66511. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66512. /**
  66513. * PostProcessRenderPipelineManager class
  66514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66515. */
  66516. export class PostProcessRenderPipelineManager {
  66517. private _renderPipelines;
  66518. /**
  66519. * Initializes a PostProcessRenderPipelineManager
  66520. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66521. */
  66522. constructor();
  66523. /**
  66524. * Gets the list of supported render pipelines
  66525. */
  66526. get supportedPipelines(): PostProcessRenderPipeline[];
  66527. /**
  66528. * Adds a pipeline to the manager
  66529. * @param renderPipeline The pipeline to add
  66530. */
  66531. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66532. /**
  66533. * Attaches a camera to the pipeline
  66534. * @param renderPipelineName The name of the pipeline to attach to
  66535. * @param cameras the camera to attach
  66536. * @param unique if the camera can be attached multiple times to the pipeline
  66537. */
  66538. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66539. /**
  66540. * Detaches a camera from the pipeline
  66541. * @param renderPipelineName The name of the pipeline to detach from
  66542. * @param cameras the camera to detach
  66543. */
  66544. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66545. /**
  66546. * Enables an effect by name on a pipeline
  66547. * @param renderPipelineName the name of the pipeline to enable the effect in
  66548. * @param renderEffectName the name of the effect to enable
  66549. * @param cameras the cameras that the effect should be enabled on
  66550. */
  66551. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66552. /**
  66553. * Disables an effect by name on a pipeline
  66554. * @param renderPipelineName the name of the pipeline to disable the effect in
  66555. * @param renderEffectName the name of the effect to disable
  66556. * @param cameras the cameras that the effect should be disabled on
  66557. */
  66558. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66559. /**
  66560. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66561. */
  66562. update(): void;
  66563. /** @hidden */
  66564. _rebuild(): void;
  66565. /**
  66566. * Disposes of the manager and pipelines
  66567. */
  66568. dispose(): void;
  66569. }
  66570. }
  66571. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66572. import { ISceneComponent } from "babylonjs/sceneComponent";
  66573. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66574. import { Scene } from "babylonjs/scene";
  66575. module "babylonjs/scene" {
  66576. interface Scene {
  66577. /** @hidden (Backing field) */
  66578. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66579. /**
  66580. * Gets the postprocess render pipeline manager
  66581. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66582. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66583. */
  66584. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66585. }
  66586. }
  66587. /**
  66588. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66589. */
  66590. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66591. /**
  66592. * The component name helpfull to identify the component in the list of scene components.
  66593. */
  66594. readonly name: string;
  66595. /**
  66596. * The scene the component belongs to.
  66597. */
  66598. scene: Scene;
  66599. /**
  66600. * Creates a new instance of the component for the given scene
  66601. * @param scene Defines the scene to register the component in
  66602. */
  66603. constructor(scene: Scene);
  66604. /**
  66605. * Registers the component in a given scene
  66606. */
  66607. register(): void;
  66608. /**
  66609. * Rebuilds the elements related to this component in case of
  66610. * context lost for instance.
  66611. */
  66612. rebuild(): void;
  66613. /**
  66614. * Disposes the component and the associated ressources
  66615. */
  66616. dispose(): void;
  66617. private _gatherRenderTargets;
  66618. }
  66619. }
  66620. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66621. import { Nullable } from "babylonjs/types";
  66622. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66623. import { Camera } from "babylonjs/Cameras/camera";
  66624. import { IDisposable } from "babylonjs/scene";
  66625. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66626. import { Scene } from "babylonjs/scene";
  66627. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66628. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66629. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66630. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66631. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66632. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66633. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66634. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66635. import { Animation } from "babylonjs/Animations/animation";
  66636. /**
  66637. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66638. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66639. */
  66640. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66641. private _scene;
  66642. private _camerasToBeAttached;
  66643. /**
  66644. * ID of the sharpen post process,
  66645. */
  66646. private readonly SharpenPostProcessId;
  66647. /**
  66648. * @ignore
  66649. * ID of the image processing post process;
  66650. */
  66651. readonly ImageProcessingPostProcessId: string;
  66652. /**
  66653. * @ignore
  66654. * ID of the Fast Approximate Anti-Aliasing post process;
  66655. */
  66656. readonly FxaaPostProcessId: string;
  66657. /**
  66658. * ID of the chromatic aberration post process,
  66659. */
  66660. private readonly ChromaticAberrationPostProcessId;
  66661. /**
  66662. * ID of the grain post process
  66663. */
  66664. private readonly GrainPostProcessId;
  66665. /**
  66666. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66667. */
  66668. sharpen: SharpenPostProcess;
  66669. private _sharpenEffect;
  66670. private bloom;
  66671. /**
  66672. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66673. */
  66674. depthOfField: DepthOfFieldEffect;
  66675. /**
  66676. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66677. */
  66678. fxaa: FxaaPostProcess;
  66679. /**
  66680. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66681. */
  66682. imageProcessing: ImageProcessingPostProcess;
  66683. /**
  66684. * Chromatic aberration post process which will shift rgb colors in the image
  66685. */
  66686. chromaticAberration: ChromaticAberrationPostProcess;
  66687. private _chromaticAberrationEffect;
  66688. /**
  66689. * Grain post process which add noise to the image
  66690. */
  66691. grain: GrainPostProcess;
  66692. private _grainEffect;
  66693. /**
  66694. * Glow post process which adds a glow to emissive areas of the image
  66695. */
  66696. private _glowLayer;
  66697. /**
  66698. * Animations which can be used to tweak settings over a period of time
  66699. */
  66700. animations: Animation[];
  66701. private _imageProcessingConfigurationObserver;
  66702. private _sharpenEnabled;
  66703. private _bloomEnabled;
  66704. private _depthOfFieldEnabled;
  66705. private _depthOfFieldBlurLevel;
  66706. private _fxaaEnabled;
  66707. private _imageProcessingEnabled;
  66708. private _defaultPipelineTextureType;
  66709. private _bloomScale;
  66710. private _chromaticAberrationEnabled;
  66711. private _grainEnabled;
  66712. private _buildAllowed;
  66713. /**
  66714. * Gets active scene
  66715. */
  66716. get scene(): Scene;
  66717. /**
  66718. * Enable or disable the sharpen process from the pipeline
  66719. */
  66720. set sharpenEnabled(enabled: boolean);
  66721. get sharpenEnabled(): boolean;
  66722. private _resizeObserver;
  66723. private _hardwareScaleLevel;
  66724. private _bloomKernel;
  66725. /**
  66726. * Specifies the size of the bloom blur kernel, relative to the final output size
  66727. */
  66728. get bloomKernel(): number;
  66729. set bloomKernel(value: number);
  66730. /**
  66731. * Specifies the weight of the bloom in the final rendering
  66732. */
  66733. private _bloomWeight;
  66734. /**
  66735. * Specifies the luma threshold for the area that will be blurred by the bloom
  66736. */
  66737. private _bloomThreshold;
  66738. private _hdr;
  66739. /**
  66740. * The strength of the bloom.
  66741. */
  66742. set bloomWeight(value: number);
  66743. get bloomWeight(): number;
  66744. /**
  66745. * The strength of the bloom.
  66746. */
  66747. set bloomThreshold(value: number);
  66748. get bloomThreshold(): number;
  66749. /**
  66750. * The scale of the bloom, lower value will provide better performance.
  66751. */
  66752. set bloomScale(value: number);
  66753. get bloomScale(): number;
  66754. /**
  66755. * Enable or disable the bloom from the pipeline
  66756. */
  66757. set bloomEnabled(enabled: boolean);
  66758. get bloomEnabled(): boolean;
  66759. private _rebuildBloom;
  66760. /**
  66761. * If the depth of field is enabled.
  66762. */
  66763. get depthOfFieldEnabled(): boolean;
  66764. set depthOfFieldEnabled(enabled: boolean);
  66765. /**
  66766. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66767. */
  66768. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66769. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66770. /**
  66771. * If the anti aliasing is enabled.
  66772. */
  66773. set fxaaEnabled(enabled: boolean);
  66774. get fxaaEnabled(): boolean;
  66775. private _samples;
  66776. /**
  66777. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66778. */
  66779. set samples(sampleCount: number);
  66780. get samples(): number;
  66781. /**
  66782. * If image processing is enabled.
  66783. */
  66784. set imageProcessingEnabled(enabled: boolean);
  66785. get imageProcessingEnabled(): boolean;
  66786. /**
  66787. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66788. */
  66789. set glowLayerEnabled(enabled: boolean);
  66790. get glowLayerEnabled(): boolean;
  66791. /**
  66792. * Gets the glow layer (or null if not defined)
  66793. */
  66794. get glowLayer(): Nullable<GlowLayer>;
  66795. /**
  66796. * Enable or disable the chromaticAberration process from the pipeline
  66797. */
  66798. set chromaticAberrationEnabled(enabled: boolean);
  66799. get chromaticAberrationEnabled(): boolean;
  66800. /**
  66801. * Enable or disable the grain process from the pipeline
  66802. */
  66803. set grainEnabled(enabled: boolean);
  66804. get grainEnabled(): boolean;
  66805. /**
  66806. * @constructor
  66807. * @param name - The rendering pipeline name (default: "")
  66808. * @param hdr - If high dynamic range textures should be used (default: true)
  66809. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66810. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66811. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66812. */
  66813. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66814. /**
  66815. * Get the class name
  66816. * @returns "DefaultRenderingPipeline"
  66817. */
  66818. getClassName(): string;
  66819. /**
  66820. * Force the compilation of the entire pipeline.
  66821. */
  66822. prepare(): void;
  66823. private _hasCleared;
  66824. private _prevPostProcess;
  66825. private _prevPrevPostProcess;
  66826. private _setAutoClearAndTextureSharing;
  66827. private _depthOfFieldSceneObserver;
  66828. private _buildPipeline;
  66829. private _disposePostProcesses;
  66830. /**
  66831. * Adds a camera to the pipeline
  66832. * @param camera the camera to be added
  66833. */
  66834. addCamera(camera: Camera): void;
  66835. /**
  66836. * Removes a camera from the pipeline
  66837. * @param camera the camera to remove
  66838. */
  66839. removeCamera(camera: Camera): void;
  66840. /**
  66841. * Dispose of the pipeline and stop all post processes
  66842. */
  66843. dispose(): void;
  66844. /**
  66845. * Serialize the rendering pipeline (Used when exporting)
  66846. * @returns the serialized object
  66847. */
  66848. serialize(): any;
  66849. /**
  66850. * Parse the serialized pipeline
  66851. * @param source Source pipeline.
  66852. * @param scene The scene to load the pipeline to.
  66853. * @param rootUrl The URL of the serialized pipeline.
  66854. * @returns An instantiated pipeline from the serialized object.
  66855. */
  66856. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66857. }
  66858. }
  66859. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66860. /** @hidden */
  66861. export var lensHighlightsPixelShader: {
  66862. name: string;
  66863. shader: string;
  66864. };
  66865. }
  66866. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66867. /** @hidden */
  66868. export var depthOfFieldPixelShader: {
  66869. name: string;
  66870. shader: string;
  66871. };
  66872. }
  66873. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66874. import { Camera } from "babylonjs/Cameras/camera";
  66875. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66876. import { Scene } from "babylonjs/scene";
  66877. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66878. import "babylonjs/Shaders/chromaticAberration.fragment";
  66879. import "babylonjs/Shaders/lensHighlights.fragment";
  66880. import "babylonjs/Shaders/depthOfField.fragment";
  66881. /**
  66882. * BABYLON.JS Chromatic Aberration GLSL Shader
  66883. * Author: Olivier Guyot
  66884. * Separates very slightly R, G and B colors on the edges of the screen
  66885. * Inspired by Francois Tarlier & Martins Upitis
  66886. */
  66887. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66888. /**
  66889. * @ignore
  66890. * The chromatic aberration PostProcess id in the pipeline
  66891. */
  66892. LensChromaticAberrationEffect: string;
  66893. /**
  66894. * @ignore
  66895. * The highlights enhancing PostProcess id in the pipeline
  66896. */
  66897. HighlightsEnhancingEffect: string;
  66898. /**
  66899. * @ignore
  66900. * The depth-of-field PostProcess id in the pipeline
  66901. */
  66902. LensDepthOfFieldEffect: string;
  66903. private _scene;
  66904. private _depthTexture;
  66905. private _grainTexture;
  66906. private _chromaticAberrationPostProcess;
  66907. private _highlightsPostProcess;
  66908. private _depthOfFieldPostProcess;
  66909. private _edgeBlur;
  66910. private _grainAmount;
  66911. private _chromaticAberration;
  66912. private _distortion;
  66913. private _highlightsGain;
  66914. private _highlightsThreshold;
  66915. private _dofDistance;
  66916. private _dofAperture;
  66917. private _dofDarken;
  66918. private _dofPentagon;
  66919. private _blurNoise;
  66920. /**
  66921. * @constructor
  66922. *
  66923. * Effect parameters are as follow:
  66924. * {
  66925. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66926. * edge_blur: number; // from 0 to x (1 for realism)
  66927. * distortion: number; // from 0 to x (1 for realism)
  66928. * grain_amount: number; // from 0 to 1
  66929. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66930. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66931. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66932. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66933. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66934. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66935. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66936. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66937. * }
  66938. * Note: if an effect parameter is unset, effect is disabled
  66939. *
  66940. * @param name The rendering pipeline name
  66941. * @param parameters - An object containing all parameters (see above)
  66942. * @param scene The scene linked to this pipeline
  66943. * @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)
  66944. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66945. */
  66946. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66947. /**
  66948. * Get the class name
  66949. * @returns "LensRenderingPipeline"
  66950. */
  66951. getClassName(): string;
  66952. /**
  66953. * Gets associated scene
  66954. */
  66955. get scene(): Scene;
  66956. /**
  66957. * Gets or sets the edge blur
  66958. */
  66959. get edgeBlur(): number;
  66960. set edgeBlur(value: number);
  66961. /**
  66962. * Gets or sets the grain amount
  66963. */
  66964. get grainAmount(): number;
  66965. set grainAmount(value: number);
  66966. /**
  66967. * Gets or sets the chromatic aberration amount
  66968. */
  66969. get chromaticAberration(): number;
  66970. set chromaticAberration(value: number);
  66971. /**
  66972. * Gets or sets the depth of field aperture
  66973. */
  66974. get dofAperture(): number;
  66975. set dofAperture(value: number);
  66976. /**
  66977. * Gets or sets the edge distortion
  66978. */
  66979. get edgeDistortion(): number;
  66980. set edgeDistortion(value: number);
  66981. /**
  66982. * Gets or sets the depth of field distortion
  66983. */
  66984. get dofDistortion(): number;
  66985. set dofDistortion(value: number);
  66986. /**
  66987. * Gets or sets the darken out of focus amount
  66988. */
  66989. get darkenOutOfFocus(): number;
  66990. set darkenOutOfFocus(value: number);
  66991. /**
  66992. * Gets or sets a boolean indicating if blur noise is enabled
  66993. */
  66994. get blurNoise(): boolean;
  66995. set blurNoise(value: boolean);
  66996. /**
  66997. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66998. */
  66999. get pentagonBokeh(): boolean;
  67000. set pentagonBokeh(value: boolean);
  67001. /**
  67002. * Gets or sets the highlight grain amount
  67003. */
  67004. get highlightsGain(): number;
  67005. set highlightsGain(value: number);
  67006. /**
  67007. * Gets or sets the highlight threshold
  67008. */
  67009. get highlightsThreshold(): number;
  67010. set highlightsThreshold(value: number);
  67011. /**
  67012. * Sets the amount of blur at the edges
  67013. * @param amount blur amount
  67014. */
  67015. setEdgeBlur(amount: number): void;
  67016. /**
  67017. * Sets edge blur to 0
  67018. */
  67019. disableEdgeBlur(): void;
  67020. /**
  67021. * Sets the amout of grain
  67022. * @param amount Amount of grain
  67023. */
  67024. setGrainAmount(amount: number): void;
  67025. /**
  67026. * Set grain amount to 0
  67027. */
  67028. disableGrain(): void;
  67029. /**
  67030. * Sets the chromatic aberration amount
  67031. * @param amount amount of chromatic aberration
  67032. */
  67033. setChromaticAberration(amount: number): void;
  67034. /**
  67035. * Sets chromatic aberration amount to 0
  67036. */
  67037. disableChromaticAberration(): void;
  67038. /**
  67039. * Sets the EdgeDistortion amount
  67040. * @param amount amount of EdgeDistortion
  67041. */
  67042. setEdgeDistortion(amount: number): void;
  67043. /**
  67044. * Sets edge distortion to 0
  67045. */
  67046. disableEdgeDistortion(): void;
  67047. /**
  67048. * Sets the FocusDistance amount
  67049. * @param amount amount of FocusDistance
  67050. */
  67051. setFocusDistance(amount: number): void;
  67052. /**
  67053. * Disables depth of field
  67054. */
  67055. disableDepthOfField(): void;
  67056. /**
  67057. * Sets the Aperture amount
  67058. * @param amount amount of Aperture
  67059. */
  67060. setAperture(amount: number): void;
  67061. /**
  67062. * Sets the DarkenOutOfFocus amount
  67063. * @param amount amount of DarkenOutOfFocus
  67064. */
  67065. setDarkenOutOfFocus(amount: number): void;
  67066. private _pentagonBokehIsEnabled;
  67067. /**
  67068. * Creates a pentagon bokeh effect
  67069. */
  67070. enablePentagonBokeh(): void;
  67071. /**
  67072. * Disables the pentagon bokeh effect
  67073. */
  67074. disablePentagonBokeh(): void;
  67075. /**
  67076. * Enables noise blur
  67077. */
  67078. enableNoiseBlur(): void;
  67079. /**
  67080. * Disables noise blur
  67081. */
  67082. disableNoiseBlur(): void;
  67083. /**
  67084. * Sets the HighlightsGain amount
  67085. * @param amount amount of HighlightsGain
  67086. */
  67087. setHighlightsGain(amount: number): void;
  67088. /**
  67089. * Sets the HighlightsThreshold amount
  67090. * @param amount amount of HighlightsThreshold
  67091. */
  67092. setHighlightsThreshold(amount: number): void;
  67093. /**
  67094. * Disables highlights
  67095. */
  67096. disableHighlights(): void;
  67097. /**
  67098. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67099. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67100. */
  67101. dispose(disableDepthRender?: boolean): void;
  67102. private _createChromaticAberrationPostProcess;
  67103. private _createHighlightsPostProcess;
  67104. private _createDepthOfFieldPostProcess;
  67105. private _createGrainTexture;
  67106. }
  67107. }
  67108. declare module "babylonjs/Shaders/ssao2.fragment" {
  67109. /** @hidden */
  67110. export var ssao2PixelShader: {
  67111. name: string;
  67112. shader: string;
  67113. };
  67114. }
  67115. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67116. /** @hidden */
  67117. export var ssaoCombinePixelShader: {
  67118. name: string;
  67119. shader: string;
  67120. };
  67121. }
  67122. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67123. import { Camera } from "babylonjs/Cameras/camera";
  67124. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67125. import { Scene } from "babylonjs/scene";
  67126. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67127. import "babylonjs/Shaders/ssao2.fragment";
  67128. import "babylonjs/Shaders/ssaoCombine.fragment";
  67129. /**
  67130. * Render pipeline to produce ssao effect
  67131. */
  67132. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67133. /**
  67134. * @ignore
  67135. * The PassPostProcess id in the pipeline that contains the original scene color
  67136. */
  67137. SSAOOriginalSceneColorEffect: string;
  67138. /**
  67139. * @ignore
  67140. * The SSAO PostProcess id in the pipeline
  67141. */
  67142. SSAORenderEffect: string;
  67143. /**
  67144. * @ignore
  67145. * The horizontal blur PostProcess id in the pipeline
  67146. */
  67147. SSAOBlurHRenderEffect: string;
  67148. /**
  67149. * @ignore
  67150. * The vertical blur PostProcess id in the pipeline
  67151. */
  67152. SSAOBlurVRenderEffect: string;
  67153. /**
  67154. * @ignore
  67155. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67156. */
  67157. SSAOCombineRenderEffect: string;
  67158. /**
  67159. * The output strength of the SSAO post-process. Default value is 1.0.
  67160. */
  67161. totalStrength: number;
  67162. /**
  67163. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67164. */
  67165. maxZ: number;
  67166. /**
  67167. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67168. */
  67169. minZAspect: number;
  67170. private _samples;
  67171. /**
  67172. * Number of samples used for the SSAO calculations. Default value is 8
  67173. */
  67174. set samples(n: number);
  67175. get samples(): number;
  67176. private _textureSamples;
  67177. /**
  67178. * Number of samples to use for antialiasing
  67179. */
  67180. set textureSamples(n: number);
  67181. get textureSamples(): number;
  67182. /**
  67183. * Ratio object used for SSAO ratio and blur ratio
  67184. */
  67185. private _ratio;
  67186. /**
  67187. * Dynamically generated sphere sampler.
  67188. */
  67189. private _sampleSphere;
  67190. /**
  67191. * Blur filter offsets
  67192. */
  67193. private _samplerOffsets;
  67194. private _expensiveBlur;
  67195. /**
  67196. * If bilateral blur should be used
  67197. */
  67198. set expensiveBlur(b: boolean);
  67199. get expensiveBlur(): boolean;
  67200. /**
  67201. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67202. */
  67203. radius: number;
  67204. /**
  67205. * The base color of the SSAO post-process
  67206. * The final result is "base + ssao" between [0, 1]
  67207. */
  67208. base: number;
  67209. /**
  67210. * Support test.
  67211. */
  67212. static get IsSupported(): boolean;
  67213. private _scene;
  67214. private _depthTexture;
  67215. private _normalTexture;
  67216. private _randomTexture;
  67217. private _originalColorPostProcess;
  67218. private _ssaoPostProcess;
  67219. private _blurHPostProcess;
  67220. private _blurVPostProcess;
  67221. private _ssaoCombinePostProcess;
  67222. /**
  67223. * Gets active scene
  67224. */
  67225. get scene(): Scene;
  67226. /**
  67227. * @constructor
  67228. * @param name The rendering pipeline name
  67229. * @param scene The scene linked to this pipeline
  67230. * @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 }
  67231. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67232. */
  67233. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67234. /**
  67235. * Get the class name
  67236. * @returns "SSAO2RenderingPipeline"
  67237. */
  67238. getClassName(): string;
  67239. /**
  67240. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67241. */
  67242. dispose(disableGeometryBufferRenderer?: boolean): void;
  67243. private _createBlurPostProcess;
  67244. /** @hidden */
  67245. _rebuild(): void;
  67246. private _bits;
  67247. private _radicalInverse_VdC;
  67248. private _hammersley;
  67249. private _hemisphereSample_uniform;
  67250. private _generateHemisphere;
  67251. private _createSSAOPostProcess;
  67252. private _createSSAOCombinePostProcess;
  67253. private _createRandomTexture;
  67254. /**
  67255. * Serialize the rendering pipeline (Used when exporting)
  67256. * @returns the serialized object
  67257. */
  67258. serialize(): any;
  67259. /**
  67260. * Parse the serialized pipeline
  67261. * @param source Source pipeline.
  67262. * @param scene The scene to load the pipeline to.
  67263. * @param rootUrl The URL of the serialized pipeline.
  67264. * @returns An instantiated pipeline from the serialized object.
  67265. */
  67266. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67267. }
  67268. }
  67269. declare module "babylonjs/Shaders/ssao.fragment" {
  67270. /** @hidden */
  67271. export var ssaoPixelShader: {
  67272. name: string;
  67273. shader: string;
  67274. };
  67275. }
  67276. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67277. import { Camera } from "babylonjs/Cameras/camera";
  67278. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67279. import { Scene } from "babylonjs/scene";
  67280. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67281. import "babylonjs/Shaders/ssao.fragment";
  67282. import "babylonjs/Shaders/ssaoCombine.fragment";
  67283. /**
  67284. * Render pipeline to produce ssao effect
  67285. */
  67286. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67287. /**
  67288. * @ignore
  67289. * The PassPostProcess id in the pipeline that contains the original scene color
  67290. */
  67291. SSAOOriginalSceneColorEffect: string;
  67292. /**
  67293. * @ignore
  67294. * The SSAO PostProcess id in the pipeline
  67295. */
  67296. SSAORenderEffect: string;
  67297. /**
  67298. * @ignore
  67299. * The horizontal blur PostProcess id in the pipeline
  67300. */
  67301. SSAOBlurHRenderEffect: string;
  67302. /**
  67303. * @ignore
  67304. * The vertical blur PostProcess id in the pipeline
  67305. */
  67306. SSAOBlurVRenderEffect: string;
  67307. /**
  67308. * @ignore
  67309. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67310. */
  67311. SSAOCombineRenderEffect: string;
  67312. /**
  67313. * The output strength of the SSAO post-process. Default value is 1.0.
  67314. */
  67315. totalStrength: number;
  67316. /**
  67317. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67318. */
  67319. radius: number;
  67320. /**
  67321. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67322. * Must not be equal to fallOff and superior to fallOff.
  67323. * Default value is 0.0075
  67324. */
  67325. area: number;
  67326. /**
  67327. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67328. * Must not be equal to area and inferior to area.
  67329. * Default value is 0.000001
  67330. */
  67331. fallOff: number;
  67332. /**
  67333. * The base color of the SSAO post-process
  67334. * The final result is "base + ssao" between [0, 1]
  67335. */
  67336. base: number;
  67337. private _scene;
  67338. private _depthTexture;
  67339. private _randomTexture;
  67340. private _originalColorPostProcess;
  67341. private _ssaoPostProcess;
  67342. private _blurHPostProcess;
  67343. private _blurVPostProcess;
  67344. private _ssaoCombinePostProcess;
  67345. private _firstUpdate;
  67346. /**
  67347. * Gets active scene
  67348. */
  67349. get scene(): Scene;
  67350. /**
  67351. * @constructor
  67352. * @param name - The rendering pipeline name
  67353. * @param scene - The scene linked to this pipeline
  67354. * @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 }
  67355. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67356. */
  67357. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67358. /**
  67359. * Get the class name
  67360. * @returns "SSAORenderingPipeline"
  67361. */
  67362. getClassName(): string;
  67363. /**
  67364. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67365. */
  67366. dispose(disableDepthRender?: boolean): void;
  67367. private _createBlurPostProcess;
  67368. /** @hidden */
  67369. _rebuild(): void;
  67370. private _createSSAOPostProcess;
  67371. private _createSSAOCombinePostProcess;
  67372. private _createRandomTexture;
  67373. }
  67374. }
  67375. declare module "babylonjs/Shaders/standard.fragment" {
  67376. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67377. /** @hidden */
  67378. export var standardPixelShader: {
  67379. name: string;
  67380. shader: string;
  67381. };
  67382. }
  67383. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67384. import { Nullable } from "babylonjs/types";
  67385. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67386. import { Camera } from "babylonjs/Cameras/camera";
  67387. import { Texture } from "babylonjs/Materials/Textures/texture";
  67388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67389. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67390. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67391. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67392. import { IDisposable } from "babylonjs/scene";
  67393. import { SpotLight } from "babylonjs/Lights/spotLight";
  67394. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67395. import { Scene } from "babylonjs/scene";
  67396. import { Animation } from "babylonjs/Animations/animation";
  67397. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67398. import "babylonjs/Shaders/standard.fragment";
  67399. /**
  67400. * Standard rendering pipeline
  67401. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67402. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67403. */
  67404. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67405. /**
  67406. * Public members
  67407. */
  67408. /**
  67409. * Post-process which contains the original scene color before the pipeline applies all the effects
  67410. */
  67411. originalPostProcess: Nullable<PostProcess>;
  67412. /**
  67413. * Post-process used to down scale an image x4
  67414. */
  67415. downSampleX4PostProcess: Nullable<PostProcess>;
  67416. /**
  67417. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67418. */
  67419. brightPassPostProcess: Nullable<PostProcess>;
  67420. /**
  67421. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67422. */
  67423. blurHPostProcesses: PostProcess[];
  67424. /**
  67425. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67426. */
  67427. blurVPostProcesses: PostProcess[];
  67428. /**
  67429. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67430. */
  67431. textureAdderPostProcess: Nullable<PostProcess>;
  67432. /**
  67433. * Post-process used to create volumetric lighting effect
  67434. */
  67435. volumetricLightPostProcess: Nullable<PostProcess>;
  67436. /**
  67437. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67438. */
  67439. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67440. /**
  67441. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67442. */
  67443. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67444. /**
  67445. * Post-process used to merge the volumetric light effect and the real scene color
  67446. */
  67447. volumetricLightMergePostProces: Nullable<PostProcess>;
  67448. /**
  67449. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67450. */
  67451. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67452. /**
  67453. * Base post-process used to calculate the average luminance of the final image for HDR
  67454. */
  67455. luminancePostProcess: Nullable<PostProcess>;
  67456. /**
  67457. * Post-processes used to create down sample post-processes in order to get
  67458. * the average luminance of the final image for HDR
  67459. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67460. */
  67461. luminanceDownSamplePostProcesses: PostProcess[];
  67462. /**
  67463. * Post-process used to create a HDR effect (light adaptation)
  67464. */
  67465. hdrPostProcess: Nullable<PostProcess>;
  67466. /**
  67467. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67468. */
  67469. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67470. /**
  67471. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67472. */
  67473. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67474. /**
  67475. * Post-process used to merge the final HDR post-process and the real scene color
  67476. */
  67477. hdrFinalPostProcess: Nullable<PostProcess>;
  67478. /**
  67479. * Post-process used to create a lens flare effect
  67480. */
  67481. lensFlarePostProcess: Nullable<PostProcess>;
  67482. /**
  67483. * Post-process that merges the result of the lens flare post-process and the real scene color
  67484. */
  67485. lensFlareComposePostProcess: Nullable<PostProcess>;
  67486. /**
  67487. * Post-process used to create a motion blur effect
  67488. */
  67489. motionBlurPostProcess: Nullable<PostProcess>;
  67490. /**
  67491. * Post-process used to create a depth of field effect
  67492. */
  67493. depthOfFieldPostProcess: Nullable<PostProcess>;
  67494. /**
  67495. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67496. */
  67497. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67498. /**
  67499. * Represents the brightness threshold in order to configure the illuminated surfaces
  67500. */
  67501. brightThreshold: number;
  67502. /**
  67503. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67504. */
  67505. blurWidth: number;
  67506. /**
  67507. * Sets if the blur for highlighted surfaces must be only horizontal
  67508. */
  67509. horizontalBlur: boolean;
  67510. /**
  67511. * Gets the overall exposure used by the pipeline
  67512. */
  67513. get exposure(): number;
  67514. /**
  67515. * Sets the overall exposure used by the pipeline
  67516. */
  67517. set exposure(value: number);
  67518. /**
  67519. * Texture used typically to simulate "dirty" on camera lens
  67520. */
  67521. lensTexture: Nullable<Texture>;
  67522. /**
  67523. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67524. */
  67525. volumetricLightCoefficient: number;
  67526. /**
  67527. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67528. */
  67529. volumetricLightPower: number;
  67530. /**
  67531. * Used the set the blur intensity to smooth the volumetric lights
  67532. */
  67533. volumetricLightBlurScale: number;
  67534. /**
  67535. * Light (spot or directional) used to generate the volumetric lights rays
  67536. * The source light must have a shadow generate so the pipeline can get its
  67537. * depth map
  67538. */
  67539. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67540. /**
  67541. * For eye adaptation, represents the minimum luminance the eye can see
  67542. */
  67543. hdrMinimumLuminance: number;
  67544. /**
  67545. * For eye adaptation, represents the decrease luminance speed
  67546. */
  67547. hdrDecreaseRate: number;
  67548. /**
  67549. * For eye adaptation, represents the increase luminance speed
  67550. */
  67551. hdrIncreaseRate: number;
  67552. /**
  67553. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67554. */
  67555. get hdrAutoExposure(): boolean;
  67556. /**
  67557. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67558. */
  67559. set hdrAutoExposure(value: boolean);
  67560. /**
  67561. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67562. */
  67563. lensColorTexture: Nullable<Texture>;
  67564. /**
  67565. * The overall strengh for the lens flare effect
  67566. */
  67567. lensFlareStrength: number;
  67568. /**
  67569. * Dispersion coefficient for lens flare ghosts
  67570. */
  67571. lensFlareGhostDispersal: number;
  67572. /**
  67573. * Main lens flare halo width
  67574. */
  67575. lensFlareHaloWidth: number;
  67576. /**
  67577. * Based on the lens distortion effect, defines how much the lens flare result
  67578. * is distorted
  67579. */
  67580. lensFlareDistortionStrength: number;
  67581. /**
  67582. * Configures the blur intensity used for for lens flare (halo)
  67583. */
  67584. lensFlareBlurWidth: number;
  67585. /**
  67586. * Lens star texture must be used to simulate rays on the flares and is available
  67587. * in the documentation
  67588. */
  67589. lensStarTexture: Nullable<Texture>;
  67590. /**
  67591. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67592. * flare effect by taking account of the dirt texture
  67593. */
  67594. lensFlareDirtTexture: Nullable<Texture>;
  67595. /**
  67596. * Represents the focal length for the depth of field effect
  67597. */
  67598. depthOfFieldDistance: number;
  67599. /**
  67600. * Represents the blur intensity for the blurred part of the depth of field effect
  67601. */
  67602. depthOfFieldBlurWidth: number;
  67603. /**
  67604. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67605. */
  67606. get motionStrength(): number;
  67607. /**
  67608. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67609. */
  67610. set motionStrength(strength: number);
  67611. /**
  67612. * Gets wether or not the motion blur post-process is object based or screen based.
  67613. */
  67614. get objectBasedMotionBlur(): boolean;
  67615. /**
  67616. * Sets wether or not the motion blur post-process should be object based or screen based
  67617. */
  67618. set objectBasedMotionBlur(value: boolean);
  67619. /**
  67620. * List of animations for the pipeline (IAnimatable implementation)
  67621. */
  67622. animations: Animation[];
  67623. /**
  67624. * Private members
  67625. */
  67626. private _scene;
  67627. private _currentDepthOfFieldSource;
  67628. private _basePostProcess;
  67629. private _fixedExposure;
  67630. private _currentExposure;
  67631. private _hdrAutoExposure;
  67632. private _hdrCurrentLuminance;
  67633. private _motionStrength;
  67634. private _isObjectBasedMotionBlur;
  67635. private _floatTextureType;
  67636. private _camerasToBeAttached;
  67637. private _ratio;
  67638. private _bloomEnabled;
  67639. private _depthOfFieldEnabled;
  67640. private _vlsEnabled;
  67641. private _lensFlareEnabled;
  67642. private _hdrEnabled;
  67643. private _motionBlurEnabled;
  67644. private _fxaaEnabled;
  67645. private _motionBlurSamples;
  67646. private _volumetricLightStepsCount;
  67647. private _samples;
  67648. /**
  67649. * @ignore
  67650. * Specifies if the bloom pipeline is enabled
  67651. */
  67652. get BloomEnabled(): boolean;
  67653. set BloomEnabled(enabled: boolean);
  67654. /**
  67655. * @ignore
  67656. * Specifies if the depth of field pipeline is enabed
  67657. */
  67658. get DepthOfFieldEnabled(): boolean;
  67659. set DepthOfFieldEnabled(enabled: boolean);
  67660. /**
  67661. * @ignore
  67662. * Specifies if the lens flare pipeline is enabed
  67663. */
  67664. get LensFlareEnabled(): boolean;
  67665. set LensFlareEnabled(enabled: boolean);
  67666. /**
  67667. * @ignore
  67668. * Specifies if the HDR pipeline is enabled
  67669. */
  67670. get HDREnabled(): boolean;
  67671. set HDREnabled(enabled: boolean);
  67672. /**
  67673. * @ignore
  67674. * Specifies if the volumetric lights scattering effect is enabled
  67675. */
  67676. get VLSEnabled(): boolean;
  67677. set VLSEnabled(enabled: boolean);
  67678. /**
  67679. * @ignore
  67680. * Specifies if the motion blur effect is enabled
  67681. */
  67682. get MotionBlurEnabled(): boolean;
  67683. set MotionBlurEnabled(enabled: boolean);
  67684. /**
  67685. * Specifies if anti-aliasing is enabled
  67686. */
  67687. get fxaaEnabled(): boolean;
  67688. set fxaaEnabled(enabled: boolean);
  67689. /**
  67690. * Specifies the number of steps used to calculate the volumetric lights
  67691. * Typically in interval [50, 200]
  67692. */
  67693. get volumetricLightStepsCount(): number;
  67694. set volumetricLightStepsCount(count: number);
  67695. /**
  67696. * Specifies the number of samples used for the motion blur effect
  67697. * Typically in interval [16, 64]
  67698. */
  67699. get motionBlurSamples(): number;
  67700. set motionBlurSamples(samples: number);
  67701. /**
  67702. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67703. */
  67704. get samples(): number;
  67705. set samples(sampleCount: number);
  67706. /**
  67707. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67708. * @constructor
  67709. * @param name The rendering pipeline name
  67710. * @param scene The scene linked to this pipeline
  67711. * @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)
  67712. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67713. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67714. */
  67715. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67716. private _buildPipeline;
  67717. private _createDownSampleX4PostProcess;
  67718. private _createBrightPassPostProcess;
  67719. private _createBlurPostProcesses;
  67720. private _createTextureAdderPostProcess;
  67721. private _createVolumetricLightPostProcess;
  67722. private _createLuminancePostProcesses;
  67723. private _createHdrPostProcess;
  67724. private _createLensFlarePostProcess;
  67725. private _createDepthOfFieldPostProcess;
  67726. private _createMotionBlurPostProcess;
  67727. private _getDepthTexture;
  67728. private _disposePostProcesses;
  67729. /**
  67730. * Dispose of the pipeline and stop all post processes
  67731. */
  67732. dispose(): void;
  67733. /**
  67734. * Serialize the rendering pipeline (Used when exporting)
  67735. * @returns the serialized object
  67736. */
  67737. serialize(): any;
  67738. /**
  67739. * Parse the serialized pipeline
  67740. * @param source Source pipeline.
  67741. * @param scene The scene to load the pipeline to.
  67742. * @param rootUrl The URL of the serialized pipeline.
  67743. * @returns An instantiated pipeline from the serialized object.
  67744. */
  67745. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67746. /**
  67747. * Luminance steps
  67748. */
  67749. static LuminanceSteps: number;
  67750. }
  67751. }
  67752. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67753. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67754. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67755. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67756. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67757. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67758. }
  67759. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67760. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67761. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67762. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67763. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67764. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67765. }
  67766. declare module "babylonjs/Shaders/tonemap.fragment" {
  67767. /** @hidden */
  67768. export var tonemapPixelShader: {
  67769. name: string;
  67770. shader: string;
  67771. };
  67772. }
  67773. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67774. import { Camera } from "babylonjs/Cameras/camera";
  67775. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67776. import "babylonjs/Shaders/tonemap.fragment";
  67777. import { Engine } from "babylonjs/Engines/engine";
  67778. /** Defines operator used for tonemapping */
  67779. export enum TonemappingOperator {
  67780. /** Hable */
  67781. Hable = 0,
  67782. /** Reinhard */
  67783. Reinhard = 1,
  67784. /** HejiDawson */
  67785. HejiDawson = 2,
  67786. /** Photographic */
  67787. Photographic = 3
  67788. }
  67789. /**
  67790. * Defines a post process to apply tone mapping
  67791. */
  67792. export class TonemapPostProcess extends PostProcess {
  67793. private _operator;
  67794. /** Defines the required exposure adjustement */
  67795. exposureAdjustment: number;
  67796. /**
  67797. * Creates a new TonemapPostProcess
  67798. * @param name defines the name of the postprocess
  67799. * @param _operator defines the operator to use
  67800. * @param exposureAdjustment defines the required exposure adjustement
  67801. * @param camera defines the camera to use (can be null)
  67802. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67803. * @param engine defines the hosting engine (can be ignore if camera is set)
  67804. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67805. */
  67806. constructor(name: string, _operator: TonemappingOperator,
  67807. /** Defines the required exposure adjustement */
  67808. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67809. }
  67810. }
  67811. declare module "babylonjs/Shaders/depth.vertex" {
  67812. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67815. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67817. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67818. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67819. /** @hidden */
  67820. export var depthVertexShader: {
  67821. name: string;
  67822. shader: string;
  67823. };
  67824. }
  67825. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67826. /** @hidden */
  67827. export var volumetricLightScatteringPixelShader: {
  67828. name: string;
  67829. shader: string;
  67830. };
  67831. }
  67832. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67833. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67837. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67838. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67839. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67840. /** @hidden */
  67841. export var volumetricLightScatteringPassVertexShader: {
  67842. name: string;
  67843. shader: string;
  67844. };
  67845. }
  67846. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67847. /** @hidden */
  67848. export var volumetricLightScatteringPassPixelShader: {
  67849. name: string;
  67850. shader: string;
  67851. };
  67852. }
  67853. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67854. import { Vector3 } from "babylonjs/Maths/math.vector";
  67855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67856. import { Mesh } from "babylonjs/Meshes/mesh";
  67857. import { Camera } from "babylonjs/Cameras/camera";
  67858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67859. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67860. import { Scene } from "babylonjs/scene";
  67861. import "babylonjs/Meshes/Builders/planeBuilder";
  67862. import "babylonjs/Shaders/depth.vertex";
  67863. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67864. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67865. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67866. import { Engine } from "babylonjs/Engines/engine";
  67867. /**
  67868. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67869. */
  67870. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67871. private _volumetricLightScatteringPass;
  67872. private _volumetricLightScatteringRTT;
  67873. private _viewPort;
  67874. private _screenCoordinates;
  67875. private _cachedDefines;
  67876. /**
  67877. * If not undefined, the mesh position is computed from the attached node position
  67878. */
  67879. attachedNode: {
  67880. position: Vector3;
  67881. };
  67882. /**
  67883. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67884. */
  67885. customMeshPosition: Vector3;
  67886. /**
  67887. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67888. */
  67889. useCustomMeshPosition: boolean;
  67890. /**
  67891. * If the post-process should inverse the light scattering direction
  67892. */
  67893. invert: boolean;
  67894. /**
  67895. * The internal mesh used by the post-process
  67896. */
  67897. mesh: Mesh;
  67898. /**
  67899. * @hidden
  67900. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67901. */
  67902. get useDiffuseColor(): boolean;
  67903. set useDiffuseColor(useDiffuseColor: boolean);
  67904. /**
  67905. * Array containing the excluded meshes not rendered in the internal pass
  67906. */
  67907. excludedMeshes: AbstractMesh[];
  67908. /**
  67909. * Controls the overall intensity of the post-process
  67910. */
  67911. exposure: number;
  67912. /**
  67913. * Dissipates each sample's contribution in range [0, 1]
  67914. */
  67915. decay: number;
  67916. /**
  67917. * Controls the overall intensity of each sample
  67918. */
  67919. weight: number;
  67920. /**
  67921. * Controls the density of each sample
  67922. */
  67923. density: number;
  67924. /**
  67925. * @constructor
  67926. * @param name The post-process name
  67927. * @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)
  67928. * @param camera The camera that the post-process will be attached to
  67929. * @param mesh The mesh used to create the light scattering
  67930. * @param samples The post-process quality, default 100
  67931. * @param samplingModeThe post-process filtering mode
  67932. * @param engine The babylon engine
  67933. * @param reusable If the post-process is reusable
  67934. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67935. */
  67936. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67937. /**
  67938. * Returns the string "VolumetricLightScatteringPostProcess"
  67939. * @returns "VolumetricLightScatteringPostProcess"
  67940. */
  67941. getClassName(): string;
  67942. private _isReady;
  67943. /**
  67944. * Sets the new light position for light scattering effect
  67945. * @param position The new custom light position
  67946. */
  67947. setCustomMeshPosition(position: Vector3): void;
  67948. /**
  67949. * Returns the light position for light scattering effect
  67950. * @return Vector3 The custom light position
  67951. */
  67952. getCustomMeshPosition(): Vector3;
  67953. /**
  67954. * Disposes the internal assets and detaches the post-process from the camera
  67955. */
  67956. dispose(camera: Camera): void;
  67957. /**
  67958. * Returns the render target texture used by the post-process
  67959. * @return the render target texture used by the post-process
  67960. */
  67961. getPass(): RenderTargetTexture;
  67962. private _meshExcluded;
  67963. private _createPass;
  67964. private _updateMeshScreenCoordinates;
  67965. /**
  67966. * Creates a default mesh for the Volumeric Light Scattering post-process
  67967. * @param name The mesh name
  67968. * @param scene The scene where to create the mesh
  67969. * @return the default mesh
  67970. */
  67971. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67972. }
  67973. }
  67974. declare module "babylonjs/PostProcesses/index" {
  67975. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  67976. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  67977. export * from "babylonjs/PostProcesses/bloomEffect";
  67978. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  67979. export * from "babylonjs/PostProcesses/blurPostProcess";
  67980. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67981. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  67982. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  67983. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  67984. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67985. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  67986. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  67987. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  67988. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67989. export * from "babylonjs/PostProcesses/filterPostProcess";
  67990. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  67991. export * from "babylonjs/PostProcesses/grainPostProcess";
  67992. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  67993. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67994. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  67995. export * from "babylonjs/PostProcesses/passPostProcess";
  67996. export * from "babylonjs/PostProcesses/postProcess";
  67997. export * from "babylonjs/PostProcesses/postProcessManager";
  67998. export * from "babylonjs/PostProcesses/refractionPostProcess";
  67999. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68000. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68001. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68002. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68003. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68004. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68005. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68006. }
  68007. declare module "babylonjs/Probes/index" {
  68008. export * from "babylonjs/Probes/reflectionProbe";
  68009. }
  68010. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68011. import { Scene } from "babylonjs/scene";
  68012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68013. import { SmartArray } from "babylonjs/Misc/smartArray";
  68014. import { ISceneComponent } from "babylonjs/sceneComponent";
  68015. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68016. import "babylonjs/Meshes/Builders/boxBuilder";
  68017. import "babylonjs/Shaders/color.fragment";
  68018. import "babylonjs/Shaders/color.vertex";
  68019. import { Color3 } from "babylonjs/Maths/math.color";
  68020. module "babylonjs/scene" {
  68021. interface Scene {
  68022. /** @hidden (Backing field) */
  68023. _boundingBoxRenderer: BoundingBoxRenderer;
  68024. /** @hidden (Backing field) */
  68025. _forceShowBoundingBoxes: boolean;
  68026. /**
  68027. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68028. */
  68029. forceShowBoundingBoxes: boolean;
  68030. /**
  68031. * Gets the bounding box renderer associated with the scene
  68032. * @returns a BoundingBoxRenderer
  68033. */
  68034. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68035. }
  68036. }
  68037. module "babylonjs/Meshes/abstractMesh" {
  68038. interface AbstractMesh {
  68039. /** @hidden (Backing field) */
  68040. _showBoundingBox: boolean;
  68041. /**
  68042. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68043. */
  68044. showBoundingBox: boolean;
  68045. }
  68046. }
  68047. /**
  68048. * Component responsible of rendering the bounding box of the meshes in a scene.
  68049. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68050. */
  68051. export class BoundingBoxRenderer implements ISceneComponent {
  68052. /**
  68053. * The component name helpfull to identify the component in the list of scene components.
  68054. */
  68055. readonly name: string;
  68056. /**
  68057. * The scene the component belongs to.
  68058. */
  68059. scene: Scene;
  68060. /**
  68061. * Color of the bounding box lines placed in front of an object
  68062. */
  68063. frontColor: Color3;
  68064. /**
  68065. * Color of the bounding box lines placed behind an object
  68066. */
  68067. backColor: Color3;
  68068. /**
  68069. * Defines if the renderer should show the back lines or not
  68070. */
  68071. showBackLines: boolean;
  68072. /**
  68073. * @hidden
  68074. */
  68075. renderList: SmartArray<BoundingBox>;
  68076. private _colorShader;
  68077. private _vertexBuffers;
  68078. private _indexBuffer;
  68079. private _fillIndexBuffer;
  68080. private _fillIndexData;
  68081. /**
  68082. * Instantiates a new bounding box renderer in a scene.
  68083. * @param scene the scene the renderer renders in
  68084. */
  68085. constructor(scene: Scene);
  68086. /**
  68087. * Registers the component in a given scene
  68088. */
  68089. register(): void;
  68090. private _evaluateSubMesh;
  68091. private _activeMesh;
  68092. private _prepareRessources;
  68093. private _createIndexBuffer;
  68094. /**
  68095. * Rebuilds the elements related to this component in case of
  68096. * context lost for instance.
  68097. */
  68098. rebuild(): void;
  68099. /**
  68100. * @hidden
  68101. */
  68102. reset(): void;
  68103. /**
  68104. * Render the bounding boxes of a specific rendering group
  68105. * @param renderingGroupId defines the rendering group to render
  68106. */
  68107. render(renderingGroupId: number): void;
  68108. /**
  68109. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68110. * @param mesh Define the mesh to render the occlusion bounding box for
  68111. */
  68112. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68113. /**
  68114. * Dispose and release the resources attached to this renderer.
  68115. */
  68116. dispose(): void;
  68117. }
  68118. }
  68119. declare module "babylonjs/Shaders/depth.fragment" {
  68120. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68121. /** @hidden */
  68122. export var depthPixelShader: {
  68123. name: string;
  68124. shader: string;
  68125. };
  68126. }
  68127. declare module "babylonjs/Rendering/depthRenderer" {
  68128. import { Nullable } from "babylonjs/types";
  68129. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68130. import { Scene } from "babylonjs/scene";
  68131. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68132. import { Camera } from "babylonjs/Cameras/camera";
  68133. import "babylonjs/Shaders/depth.fragment";
  68134. import "babylonjs/Shaders/depth.vertex";
  68135. /**
  68136. * This represents a depth renderer in Babylon.
  68137. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68138. */
  68139. export class DepthRenderer {
  68140. private _scene;
  68141. private _depthMap;
  68142. private _effect;
  68143. private readonly _storeNonLinearDepth;
  68144. private readonly _clearColor;
  68145. /** Get if the depth renderer is using packed depth or not */
  68146. readonly isPacked: boolean;
  68147. private _cachedDefines;
  68148. private _camera;
  68149. /**
  68150. * Specifiess that the depth renderer will only be used within
  68151. * the camera it is created for.
  68152. * This can help forcing its rendering during the camera processing.
  68153. */
  68154. useOnlyInActiveCamera: boolean;
  68155. /** @hidden */
  68156. static _SceneComponentInitialization: (scene: Scene) => void;
  68157. /**
  68158. * Instantiates a depth renderer
  68159. * @param scene The scene the renderer belongs to
  68160. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68161. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68162. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68163. */
  68164. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68165. /**
  68166. * Creates the depth rendering effect and checks if the effect is ready.
  68167. * @param subMesh The submesh to be used to render the depth map of
  68168. * @param useInstances If multiple world instances should be used
  68169. * @returns if the depth renderer is ready to render the depth map
  68170. */
  68171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68172. /**
  68173. * Gets the texture which the depth map will be written to.
  68174. * @returns The depth map texture
  68175. */
  68176. getDepthMap(): RenderTargetTexture;
  68177. /**
  68178. * Disposes of the depth renderer.
  68179. */
  68180. dispose(): void;
  68181. }
  68182. }
  68183. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68184. import { Nullable } from "babylonjs/types";
  68185. import { Scene } from "babylonjs/scene";
  68186. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68187. import { Camera } from "babylonjs/Cameras/camera";
  68188. import { ISceneComponent } from "babylonjs/sceneComponent";
  68189. module "babylonjs/scene" {
  68190. interface Scene {
  68191. /** @hidden (Backing field) */
  68192. _depthRenderer: {
  68193. [id: string]: DepthRenderer;
  68194. };
  68195. /**
  68196. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68197. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68198. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68199. * @returns the created depth renderer
  68200. */
  68201. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68202. /**
  68203. * Disables a depth renderer for a given camera
  68204. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68205. */
  68206. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68207. }
  68208. }
  68209. /**
  68210. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68211. * in several rendering techniques.
  68212. */
  68213. export class DepthRendererSceneComponent implements ISceneComponent {
  68214. /**
  68215. * The component name helpfull to identify the component in the list of scene components.
  68216. */
  68217. readonly name: string;
  68218. /**
  68219. * The scene the component belongs to.
  68220. */
  68221. scene: Scene;
  68222. /**
  68223. * Creates a new instance of the component for the given scene
  68224. * @param scene Defines the scene to register the component in
  68225. */
  68226. constructor(scene: Scene);
  68227. /**
  68228. * Registers the component in a given scene
  68229. */
  68230. register(): void;
  68231. /**
  68232. * Rebuilds the elements related to this component in case of
  68233. * context lost for instance.
  68234. */
  68235. rebuild(): void;
  68236. /**
  68237. * Disposes the component and the associated ressources
  68238. */
  68239. dispose(): void;
  68240. private _gatherRenderTargets;
  68241. private _gatherActiveCameraRenderTargets;
  68242. }
  68243. }
  68244. declare module "babylonjs/Shaders/outline.fragment" {
  68245. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68246. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68247. /** @hidden */
  68248. export var outlinePixelShader: {
  68249. name: string;
  68250. shader: string;
  68251. };
  68252. }
  68253. declare module "babylonjs/Shaders/outline.vertex" {
  68254. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68256. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68257. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68258. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68259. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68260. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68261. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68262. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68263. /** @hidden */
  68264. export var outlineVertexShader: {
  68265. name: string;
  68266. shader: string;
  68267. };
  68268. }
  68269. declare module "babylonjs/Rendering/outlineRenderer" {
  68270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68271. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68272. import { Scene } from "babylonjs/scene";
  68273. import { ISceneComponent } from "babylonjs/sceneComponent";
  68274. import "babylonjs/Shaders/outline.fragment";
  68275. import "babylonjs/Shaders/outline.vertex";
  68276. module "babylonjs/scene" {
  68277. interface Scene {
  68278. /** @hidden */
  68279. _outlineRenderer: OutlineRenderer;
  68280. /**
  68281. * Gets the outline renderer associated with the scene
  68282. * @returns a OutlineRenderer
  68283. */
  68284. getOutlineRenderer(): OutlineRenderer;
  68285. }
  68286. }
  68287. module "babylonjs/Meshes/abstractMesh" {
  68288. interface AbstractMesh {
  68289. /** @hidden (Backing field) */
  68290. _renderOutline: boolean;
  68291. /**
  68292. * Gets or sets a boolean indicating if the outline must be rendered as well
  68293. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68294. */
  68295. renderOutline: boolean;
  68296. /** @hidden (Backing field) */
  68297. _renderOverlay: boolean;
  68298. /**
  68299. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68300. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68301. */
  68302. renderOverlay: boolean;
  68303. }
  68304. }
  68305. /**
  68306. * This class is responsible to draw bothe outline/overlay of meshes.
  68307. * It should not be used directly but through the available method on mesh.
  68308. */
  68309. export class OutlineRenderer implements ISceneComponent {
  68310. /**
  68311. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68312. */
  68313. private static _StencilReference;
  68314. /**
  68315. * The name of the component. Each component must have a unique name.
  68316. */
  68317. name: string;
  68318. /**
  68319. * The scene the component belongs to.
  68320. */
  68321. scene: Scene;
  68322. /**
  68323. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68324. */
  68325. zOffset: number;
  68326. private _engine;
  68327. private _effect;
  68328. private _cachedDefines;
  68329. private _savedDepthWrite;
  68330. /**
  68331. * Instantiates a new outline renderer. (There could be only one per scene).
  68332. * @param scene Defines the scene it belongs to
  68333. */
  68334. constructor(scene: Scene);
  68335. /**
  68336. * Register the component to one instance of a scene.
  68337. */
  68338. register(): void;
  68339. /**
  68340. * Rebuilds the elements related to this component in case of
  68341. * context lost for instance.
  68342. */
  68343. rebuild(): void;
  68344. /**
  68345. * Disposes the component and the associated ressources.
  68346. */
  68347. dispose(): void;
  68348. /**
  68349. * Renders the outline in the canvas.
  68350. * @param subMesh Defines the sumesh to render
  68351. * @param batch Defines the batch of meshes in case of instances
  68352. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68353. */
  68354. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68355. /**
  68356. * Returns whether or not the outline renderer is ready for a given submesh.
  68357. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68358. * @param subMesh Defines the submesh to check readyness for
  68359. * @param useInstances Defines wheter wee are trying to render instances or not
  68360. * @returns true if ready otherwise false
  68361. */
  68362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68363. private _beforeRenderingMesh;
  68364. private _afterRenderingMesh;
  68365. }
  68366. }
  68367. declare module "babylonjs/Rendering/index" {
  68368. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68369. export * from "babylonjs/Rendering/depthRenderer";
  68370. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68371. export * from "babylonjs/Rendering/edgesRenderer";
  68372. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68373. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68374. export * from "babylonjs/Rendering/outlineRenderer";
  68375. export * from "babylonjs/Rendering/renderingGroup";
  68376. export * from "babylonjs/Rendering/renderingManager";
  68377. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68378. }
  68379. declare module "babylonjs/Sprites/ISprites" {
  68380. /**
  68381. * Defines the basic options interface of a Sprite Frame Source Size.
  68382. */
  68383. export interface ISpriteJSONSpriteSourceSize {
  68384. /**
  68385. * number of the original width of the Frame
  68386. */
  68387. w: number;
  68388. /**
  68389. * number of the original height of the Frame
  68390. */
  68391. h: number;
  68392. }
  68393. /**
  68394. * Defines the basic options interface of a Sprite Frame Data.
  68395. */
  68396. export interface ISpriteJSONSpriteFrameData {
  68397. /**
  68398. * number of the x offset of the Frame
  68399. */
  68400. x: number;
  68401. /**
  68402. * number of the y offset of the Frame
  68403. */
  68404. y: number;
  68405. /**
  68406. * number of the width of the Frame
  68407. */
  68408. w: number;
  68409. /**
  68410. * number of the height of the Frame
  68411. */
  68412. h: number;
  68413. }
  68414. /**
  68415. * Defines the basic options interface of a JSON Sprite.
  68416. */
  68417. export interface ISpriteJSONSprite {
  68418. /**
  68419. * string name of the Frame
  68420. */
  68421. filename: string;
  68422. /**
  68423. * ISpriteJSONSpriteFrame basic object of the frame data
  68424. */
  68425. frame: ISpriteJSONSpriteFrameData;
  68426. /**
  68427. * boolean to flag is the frame was rotated.
  68428. */
  68429. rotated: boolean;
  68430. /**
  68431. * boolean to flag is the frame was trimmed.
  68432. */
  68433. trimmed: boolean;
  68434. /**
  68435. * ISpriteJSONSpriteFrame basic object of the source data
  68436. */
  68437. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68438. /**
  68439. * ISpriteJSONSpriteFrame basic object of the source data
  68440. */
  68441. sourceSize: ISpriteJSONSpriteSourceSize;
  68442. }
  68443. /**
  68444. * Defines the basic options interface of a JSON atlas.
  68445. */
  68446. export interface ISpriteJSONAtlas {
  68447. /**
  68448. * Array of objects that contain the frame data.
  68449. */
  68450. frames: Array<ISpriteJSONSprite>;
  68451. /**
  68452. * object basic object containing the sprite meta data.
  68453. */
  68454. meta?: object;
  68455. }
  68456. }
  68457. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68458. /** @hidden */
  68459. export var spriteMapPixelShader: {
  68460. name: string;
  68461. shader: string;
  68462. };
  68463. }
  68464. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68465. /** @hidden */
  68466. export var spriteMapVertexShader: {
  68467. name: string;
  68468. shader: string;
  68469. };
  68470. }
  68471. declare module "babylonjs/Sprites/spriteMap" {
  68472. import { IDisposable, Scene } from "babylonjs/scene";
  68473. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68474. import { Texture } from "babylonjs/Materials/Textures/texture";
  68475. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68476. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68477. import "babylonjs/Meshes/Builders/planeBuilder";
  68478. import "babylonjs/Shaders/spriteMap.fragment";
  68479. import "babylonjs/Shaders/spriteMap.vertex";
  68480. /**
  68481. * Defines the basic options interface of a SpriteMap
  68482. */
  68483. export interface ISpriteMapOptions {
  68484. /**
  68485. * Vector2 of the number of cells in the grid.
  68486. */
  68487. stageSize?: Vector2;
  68488. /**
  68489. * Vector2 of the size of the output plane in World Units.
  68490. */
  68491. outputSize?: Vector2;
  68492. /**
  68493. * Vector3 of the position of the output plane in World Units.
  68494. */
  68495. outputPosition?: Vector3;
  68496. /**
  68497. * Vector3 of the rotation of the output plane.
  68498. */
  68499. outputRotation?: Vector3;
  68500. /**
  68501. * number of layers that the system will reserve in resources.
  68502. */
  68503. layerCount?: number;
  68504. /**
  68505. * number of max animation frames a single cell will reserve in resources.
  68506. */
  68507. maxAnimationFrames?: number;
  68508. /**
  68509. * number cell index of the base tile when the system compiles.
  68510. */
  68511. baseTile?: number;
  68512. /**
  68513. * boolean flip the sprite after its been repositioned by the framing data.
  68514. */
  68515. flipU?: boolean;
  68516. /**
  68517. * Vector3 scalar of the global RGB values of the SpriteMap.
  68518. */
  68519. colorMultiply?: Vector3;
  68520. }
  68521. /**
  68522. * Defines the IDisposable interface in order to be cleanable from resources.
  68523. */
  68524. export interface ISpriteMap extends IDisposable {
  68525. /**
  68526. * String name of the SpriteMap.
  68527. */
  68528. name: string;
  68529. /**
  68530. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68531. */
  68532. atlasJSON: ISpriteJSONAtlas;
  68533. /**
  68534. * Texture of the SpriteMap.
  68535. */
  68536. spriteSheet: Texture;
  68537. /**
  68538. * The parameters to initialize the SpriteMap with.
  68539. */
  68540. options: ISpriteMapOptions;
  68541. }
  68542. /**
  68543. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68544. */
  68545. export class SpriteMap implements ISpriteMap {
  68546. /** The Name of the spriteMap */
  68547. name: string;
  68548. /** The JSON file with the frame and meta data */
  68549. atlasJSON: ISpriteJSONAtlas;
  68550. /** The systems Sprite Sheet Texture */
  68551. spriteSheet: Texture;
  68552. /** Arguments passed with the Constructor */
  68553. options: ISpriteMapOptions;
  68554. /** Public Sprite Storage array, parsed from atlasJSON */
  68555. sprites: Array<ISpriteJSONSprite>;
  68556. /** Returns the Number of Sprites in the System */
  68557. get spriteCount(): number;
  68558. /** Returns the Position of Output Plane*/
  68559. get position(): Vector3;
  68560. /** Returns the Position of Output Plane*/
  68561. set position(v: Vector3);
  68562. /** Returns the Rotation of Output Plane*/
  68563. get rotation(): Vector3;
  68564. /** Returns the Rotation of Output Plane*/
  68565. set rotation(v: Vector3);
  68566. /** Sets the AnimationMap*/
  68567. get animationMap(): RawTexture;
  68568. /** Sets the AnimationMap*/
  68569. set animationMap(v: RawTexture);
  68570. /** Scene that the SpriteMap was created in */
  68571. private _scene;
  68572. /** Texture Buffer of Float32 that holds tile frame data*/
  68573. private _frameMap;
  68574. /** Texture Buffers of Float32 that holds tileMap data*/
  68575. private _tileMaps;
  68576. /** Texture Buffer of Float32 that holds Animation Data*/
  68577. private _animationMap;
  68578. /** Custom ShaderMaterial Central to the System*/
  68579. private _material;
  68580. /** Custom ShaderMaterial Central to the System*/
  68581. private _output;
  68582. /** Systems Time Ticker*/
  68583. private _time;
  68584. /**
  68585. * Creates a new SpriteMap
  68586. * @param name defines the SpriteMaps Name
  68587. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68588. * @param spriteSheet is the Texture that the Sprites are on.
  68589. * @param options a basic deployment configuration
  68590. * @param scene The Scene that the map is deployed on
  68591. */
  68592. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68593. /**
  68594. * Returns tileID location
  68595. * @returns Vector2 the cell position ID
  68596. */
  68597. getTileID(): Vector2;
  68598. /**
  68599. * Gets the UV location of the mouse over the SpriteMap.
  68600. * @returns Vector2 the UV position of the mouse interaction
  68601. */
  68602. getMousePosition(): Vector2;
  68603. /**
  68604. * Creates the "frame" texture Buffer
  68605. * -------------------------------------
  68606. * Structure of frames
  68607. * "filename": "Falling-Water-2.png",
  68608. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68609. * "rotated": true,
  68610. * "trimmed": true,
  68611. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68612. * "sourceSize": {"w":32,"h":32}
  68613. * @returns RawTexture of the frameMap
  68614. */
  68615. private _createFrameBuffer;
  68616. /**
  68617. * Creates the tileMap texture Buffer
  68618. * @param buffer normally and array of numbers, or a false to generate from scratch
  68619. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68620. * @returns RawTexture of the tileMap
  68621. */
  68622. private _createTileBuffer;
  68623. /**
  68624. * Modifies the data of the tileMaps
  68625. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68626. * @param pos is the iVector2 Coordinates of the Tile
  68627. * @param tile The SpriteIndex of the new Tile
  68628. */
  68629. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68630. /**
  68631. * Creates the animationMap texture Buffer
  68632. * @param buffer normally and array of numbers, or a false to generate from scratch
  68633. * @returns RawTexture of the animationMap
  68634. */
  68635. private _createTileAnimationBuffer;
  68636. /**
  68637. * Modifies the data of the animationMap
  68638. * @param cellID is the Index of the Sprite
  68639. * @param _frame is the target Animation frame
  68640. * @param toCell is the Target Index of the next frame of the animation
  68641. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68642. * @param speed is a global scalar of the time variable on the map.
  68643. */
  68644. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68645. /**
  68646. * Exports the .tilemaps file
  68647. */
  68648. saveTileMaps(): void;
  68649. /**
  68650. * Imports the .tilemaps file
  68651. * @param url of the .tilemaps file
  68652. */
  68653. loadTileMaps(url: string): void;
  68654. /**
  68655. * Release associated resources
  68656. */
  68657. dispose(): void;
  68658. }
  68659. }
  68660. declare module "babylonjs/Sprites/spritePackedManager" {
  68661. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68662. import { Scene } from "babylonjs/scene";
  68663. /**
  68664. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68665. * @see http://doc.babylonjs.com/babylon101/sprites
  68666. */
  68667. export class SpritePackedManager extends SpriteManager {
  68668. /** defines the packed manager's name */
  68669. name: string;
  68670. /**
  68671. * Creates a new sprite manager from a packed sprite sheet
  68672. * @param name defines the manager's name
  68673. * @param imgUrl defines the sprite sheet url
  68674. * @param capacity defines the maximum allowed number of sprites
  68675. * @param scene defines the hosting scene
  68676. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68677. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68678. * @param samplingMode defines the smapling mode to use with spritesheet
  68679. * @param fromPacked set to true; do not alter
  68680. */
  68681. constructor(
  68682. /** defines the packed manager's name */
  68683. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68684. }
  68685. }
  68686. declare module "babylonjs/Sprites/index" {
  68687. export * from "babylonjs/Sprites/sprite";
  68688. export * from "babylonjs/Sprites/ISprites";
  68689. export * from "babylonjs/Sprites/spriteManager";
  68690. export * from "babylonjs/Sprites/spriteMap";
  68691. export * from "babylonjs/Sprites/spritePackedManager";
  68692. export * from "babylonjs/Sprites/spriteSceneComponent";
  68693. }
  68694. declare module "babylonjs/States/index" {
  68695. export * from "babylonjs/States/alphaCullingState";
  68696. export * from "babylonjs/States/depthCullingState";
  68697. export * from "babylonjs/States/stencilState";
  68698. }
  68699. declare module "babylonjs/Misc/assetsManager" {
  68700. import { Scene } from "babylonjs/scene";
  68701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68703. import { Skeleton } from "babylonjs/Bones/skeleton";
  68704. import { Observable } from "babylonjs/Misc/observable";
  68705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68706. import { Texture } from "babylonjs/Materials/Textures/texture";
  68707. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68708. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68709. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68710. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68711. /**
  68712. * Defines the list of states available for a task inside a AssetsManager
  68713. */
  68714. export enum AssetTaskState {
  68715. /**
  68716. * Initialization
  68717. */
  68718. INIT = 0,
  68719. /**
  68720. * Running
  68721. */
  68722. RUNNING = 1,
  68723. /**
  68724. * Done
  68725. */
  68726. DONE = 2,
  68727. /**
  68728. * Error
  68729. */
  68730. ERROR = 3
  68731. }
  68732. /**
  68733. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68734. */
  68735. export abstract class AbstractAssetTask {
  68736. /**
  68737. * Task name
  68738. */ name: string;
  68739. /**
  68740. * Callback called when the task is successful
  68741. */
  68742. onSuccess: (task: any) => void;
  68743. /**
  68744. * Callback called when the task is not successful
  68745. */
  68746. onError: (task: any, message?: string, exception?: any) => void;
  68747. /**
  68748. * Creates a new AssetsManager
  68749. * @param name defines the name of the task
  68750. */
  68751. constructor(
  68752. /**
  68753. * Task name
  68754. */ name: string);
  68755. private _isCompleted;
  68756. private _taskState;
  68757. private _errorObject;
  68758. /**
  68759. * Get if the task is completed
  68760. */
  68761. get isCompleted(): boolean;
  68762. /**
  68763. * Gets the current state of the task
  68764. */
  68765. get taskState(): AssetTaskState;
  68766. /**
  68767. * Gets the current error object (if task is in error)
  68768. */
  68769. get errorObject(): {
  68770. message?: string;
  68771. exception?: any;
  68772. };
  68773. /**
  68774. * Internal only
  68775. * @hidden
  68776. */
  68777. _setErrorObject(message?: string, exception?: any): void;
  68778. /**
  68779. * Execute the current task
  68780. * @param scene defines the scene where you want your assets to be loaded
  68781. * @param onSuccess is a callback called when the task is successfully executed
  68782. * @param onError is a callback called if an error occurs
  68783. */
  68784. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68785. /**
  68786. * Execute the current task
  68787. * @param scene defines the scene where you want your assets to be loaded
  68788. * @param onSuccess is a callback called when the task is successfully executed
  68789. * @param onError is a callback called if an error occurs
  68790. */
  68791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68792. /**
  68793. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68794. * This can be used with failed tasks that have the reason for failure fixed.
  68795. */
  68796. reset(): void;
  68797. private onErrorCallback;
  68798. private onDoneCallback;
  68799. }
  68800. /**
  68801. * Define the interface used by progress events raised during assets loading
  68802. */
  68803. export interface IAssetsProgressEvent {
  68804. /**
  68805. * Defines the number of remaining tasks to process
  68806. */
  68807. remainingCount: number;
  68808. /**
  68809. * Defines the total number of tasks
  68810. */
  68811. totalCount: number;
  68812. /**
  68813. * Defines the task that was just processed
  68814. */
  68815. task: AbstractAssetTask;
  68816. }
  68817. /**
  68818. * Class used to share progress information about assets loading
  68819. */
  68820. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68821. /**
  68822. * Defines the number of remaining tasks to process
  68823. */
  68824. remainingCount: number;
  68825. /**
  68826. * Defines the total number of tasks
  68827. */
  68828. totalCount: number;
  68829. /**
  68830. * Defines the task that was just processed
  68831. */
  68832. task: AbstractAssetTask;
  68833. /**
  68834. * Creates a AssetsProgressEvent
  68835. * @param remainingCount defines the number of remaining tasks to process
  68836. * @param totalCount defines the total number of tasks
  68837. * @param task defines the task that was just processed
  68838. */
  68839. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68840. }
  68841. /**
  68842. * Define a task used by AssetsManager to load meshes
  68843. */
  68844. export class MeshAssetTask extends AbstractAssetTask {
  68845. /**
  68846. * Defines the name of the task
  68847. */
  68848. name: string;
  68849. /**
  68850. * Defines the list of mesh's names you want to load
  68851. */
  68852. meshesNames: any;
  68853. /**
  68854. * Defines the root url to use as a base to load your meshes and associated resources
  68855. */
  68856. rootUrl: string;
  68857. /**
  68858. * Defines the filename of the scene to load from
  68859. */
  68860. sceneFilename: string;
  68861. /**
  68862. * Gets the list of loaded meshes
  68863. */
  68864. loadedMeshes: Array<AbstractMesh>;
  68865. /**
  68866. * Gets the list of loaded particle systems
  68867. */
  68868. loadedParticleSystems: Array<IParticleSystem>;
  68869. /**
  68870. * Gets the list of loaded skeletons
  68871. */
  68872. loadedSkeletons: Array<Skeleton>;
  68873. /**
  68874. * Gets the list of loaded animation groups
  68875. */
  68876. loadedAnimationGroups: Array<AnimationGroup>;
  68877. /**
  68878. * Callback called when the task is successful
  68879. */
  68880. onSuccess: (task: MeshAssetTask) => void;
  68881. /**
  68882. * Callback called when the task is successful
  68883. */
  68884. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68885. /**
  68886. * Creates a new MeshAssetTask
  68887. * @param name defines the name of the task
  68888. * @param meshesNames defines the list of mesh's names you want to load
  68889. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68890. * @param sceneFilename defines the filename of the scene to load from
  68891. */
  68892. constructor(
  68893. /**
  68894. * Defines the name of the task
  68895. */
  68896. name: string,
  68897. /**
  68898. * Defines the list of mesh's names you want to load
  68899. */
  68900. meshesNames: any,
  68901. /**
  68902. * Defines the root url to use as a base to load your meshes and associated resources
  68903. */
  68904. rootUrl: string,
  68905. /**
  68906. * Defines the filename of the scene to load from
  68907. */
  68908. sceneFilename: string);
  68909. /**
  68910. * Execute the current task
  68911. * @param scene defines the scene where you want your assets to be loaded
  68912. * @param onSuccess is a callback called when the task is successfully executed
  68913. * @param onError is a callback called if an error occurs
  68914. */
  68915. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68916. }
  68917. /**
  68918. * Define a task used by AssetsManager to load text content
  68919. */
  68920. export class TextFileAssetTask extends AbstractAssetTask {
  68921. /**
  68922. * Defines the name of the task
  68923. */
  68924. name: string;
  68925. /**
  68926. * Defines the location of the file to load
  68927. */
  68928. url: string;
  68929. /**
  68930. * Gets the loaded text string
  68931. */
  68932. text: string;
  68933. /**
  68934. * Callback called when the task is successful
  68935. */
  68936. onSuccess: (task: TextFileAssetTask) => void;
  68937. /**
  68938. * Callback called when the task is successful
  68939. */
  68940. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68941. /**
  68942. * Creates a new TextFileAssetTask object
  68943. * @param name defines the name of the task
  68944. * @param url defines the location of the file to load
  68945. */
  68946. constructor(
  68947. /**
  68948. * Defines the name of the task
  68949. */
  68950. name: string,
  68951. /**
  68952. * Defines the location of the file to load
  68953. */
  68954. url: string);
  68955. /**
  68956. * Execute the current task
  68957. * @param scene defines the scene where you want your assets to be loaded
  68958. * @param onSuccess is a callback called when the task is successfully executed
  68959. * @param onError is a callback called if an error occurs
  68960. */
  68961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68962. }
  68963. /**
  68964. * Define a task used by AssetsManager to load binary data
  68965. */
  68966. export class BinaryFileAssetTask extends AbstractAssetTask {
  68967. /**
  68968. * Defines the name of the task
  68969. */
  68970. name: string;
  68971. /**
  68972. * Defines the location of the file to load
  68973. */
  68974. url: string;
  68975. /**
  68976. * Gets the lodaded data (as an array buffer)
  68977. */
  68978. data: ArrayBuffer;
  68979. /**
  68980. * Callback called when the task is successful
  68981. */
  68982. onSuccess: (task: BinaryFileAssetTask) => void;
  68983. /**
  68984. * Callback called when the task is successful
  68985. */
  68986. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68987. /**
  68988. * Creates a new BinaryFileAssetTask object
  68989. * @param name defines the name of the new task
  68990. * @param url defines the location of the file to load
  68991. */
  68992. constructor(
  68993. /**
  68994. * Defines the name of the task
  68995. */
  68996. name: string,
  68997. /**
  68998. * Defines the location of the file to load
  68999. */
  69000. url: string);
  69001. /**
  69002. * Execute the current task
  69003. * @param scene defines the scene where you want your assets to be loaded
  69004. * @param onSuccess is a callback called when the task is successfully executed
  69005. * @param onError is a callback called if an error occurs
  69006. */
  69007. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69008. }
  69009. /**
  69010. * Define a task used by AssetsManager to load images
  69011. */
  69012. export class ImageAssetTask extends AbstractAssetTask {
  69013. /**
  69014. * Defines the name of the task
  69015. */
  69016. name: string;
  69017. /**
  69018. * Defines the location of the image to load
  69019. */
  69020. url: string;
  69021. /**
  69022. * Gets the loaded images
  69023. */
  69024. image: HTMLImageElement;
  69025. /**
  69026. * Callback called when the task is successful
  69027. */
  69028. onSuccess: (task: ImageAssetTask) => void;
  69029. /**
  69030. * Callback called when the task is successful
  69031. */
  69032. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69033. /**
  69034. * Creates a new ImageAssetTask
  69035. * @param name defines the name of the task
  69036. * @param url defines the location of the image to load
  69037. */
  69038. constructor(
  69039. /**
  69040. * Defines the name of the task
  69041. */
  69042. name: string,
  69043. /**
  69044. * Defines the location of the image to load
  69045. */
  69046. url: string);
  69047. /**
  69048. * Execute the current task
  69049. * @param scene defines the scene where you want your assets to be loaded
  69050. * @param onSuccess is a callback called when the task is successfully executed
  69051. * @param onError is a callback called if an error occurs
  69052. */
  69053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69054. }
  69055. /**
  69056. * Defines the interface used by texture loading tasks
  69057. */
  69058. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69059. /**
  69060. * Gets the loaded texture
  69061. */
  69062. texture: TEX;
  69063. }
  69064. /**
  69065. * Define a task used by AssetsManager to load 2D textures
  69066. */
  69067. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69068. /**
  69069. * Defines the name of the task
  69070. */
  69071. name: string;
  69072. /**
  69073. * Defines the location of the file to load
  69074. */
  69075. url: string;
  69076. /**
  69077. * Defines if mipmap should not be generated (default is false)
  69078. */
  69079. noMipmap?: boolean | undefined;
  69080. /**
  69081. * Defines if texture must be inverted on Y axis (default is false)
  69082. */
  69083. invertY?: boolean | undefined;
  69084. /**
  69085. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69086. */
  69087. samplingMode: number;
  69088. /**
  69089. * Gets the loaded texture
  69090. */
  69091. texture: Texture;
  69092. /**
  69093. * Callback called when the task is successful
  69094. */
  69095. onSuccess: (task: TextureAssetTask) => void;
  69096. /**
  69097. * Callback called when the task is successful
  69098. */
  69099. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69100. /**
  69101. * Creates a new TextureAssetTask object
  69102. * @param name defines the name of the task
  69103. * @param url defines the location of the file to load
  69104. * @param noMipmap defines if mipmap should not be generated (default is false)
  69105. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69106. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69107. */
  69108. constructor(
  69109. /**
  69110. * Defines the name of the task
  69111. */
  69112. name: string,
  69113. /**
  69114. * Defines the location of the file to load
  69115. */
  69116. url: string,
  69117. /**
  69118. * Defines if mipmap should not be generated (default is false)
  69119. */
  69120. noMipmap?: boolean | undefined,
  69121. /**
  69122. * Defines if texture must be inverted on Y axis (default is false)
  69123. */
  69124. invertY?: boolean | undefined,
  69125. /**
  69126. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69127. */
  69128. samplingMode?: number);
  69129. /**
  69130. * Execute the current task
  69131. * @param scene defines the scene where you want your assets to be loaded
  69132. * @param onSuccess is a callback called when the task is successfully executed
  69133. * @param onError is a callback called if an error occurs
  69134. */
  69135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69136. }
  69137. /**
  69138. * Define a task used by AssetsManager to load cube textures
  69139. */
  69140. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69141. /**
  69142. * Defines the name of the task
  69143. */
  69144. name: string;
  69145. /**
  69146. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69147. */
  69148. url: string;
  69149. /**
  69150. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69151. */
  69152. extensions?: string[] | undefined;
  69153. /**
  69154. * Defines if mipmaps should not be generated (default is false)
  69155. */
  69156. noMipmap?: boolean | undefined;
  69157. /**
  69158. * Defines the explicit list of files (undefined by default)
  69159. */
  69160. files?: string[] | undefined;
  69161. /**
  69162. * Gets the loaded texture
  69163. */
  69164. texture: CubeTexture;
  69165. /**
  69166. * Callback called when the task is successful
  69167. */
  69168. onSuccess: (task: CubeTextureAssetTask) => void;
  69169. /**
  69170. * Callback called when the task is successful
  69171. */
  69172. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69173. /**
  69174. * Creates a new CubeTextureAssetTask
  69175. * @param name defines the name of the task
  69176. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69177. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69178. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69179. * @param files defines the explicit list of files (undefined by default)
  69180. */
  69181. constructor(
  69182. /**
  69183. * Defines the name of the task
  69184. */
  69185. name: string,
  69186. /**
  69187. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69188. */
  69189. url: string,
  69190. /**
  69191. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69192. */
  69193. extensions?: string[] | undefined,
  69194. /**
  69195. * Defines if mipmaps should not be generated (default is false)
  69196. */
  69197. noMipmap?: boolean | undefined,
  69198. /**
  69199. * Defines the explicit list of files (undefined by default)
  69200. */
  69201. files?: string[] | undefined);
  69202. /**
  69203. * Execute the current task
  69204. * @param scene defines the scene where you want your assets to be loaded
  69205. * @param onSuccess is a callback called when the task is successfully executed
  69206. * @param onError is a callback called if an error occurs
  69207. */
  69208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69209. }
  69210. /**
  69211. * Define a task used by AssetsManager to load HDR cube textures
  69212. */
  69213. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69214. /**
  69215. * Defines the name of the task
  69216. */
  69217. name: string;
  69218. /**
  69219. * Defines the location of the file to load
  69220. */
  69221. url: string;
  69222. /**
  69223. * Defines the desired size (the more it increases the longer the generation will be)
  69224. */
  69225. size: number;
  69226. /**
  69227. * Defines if mipmaps should not be generated (default is false)
  69228. */
  69229. noMipmap: boolean;
  69230. /**
  69231. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69232. */
  69233. generateHarmonics: boolean;
  69234. /**
  69235. * 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)
  69236. */
  69237. gammaSpace: boolean;
  69238. /**
  69239. * Internal Use Only
  69240. */
  69241. reserved: boolean;
  69242. /**
  69243. * Gets the loaded texture
  69244. */
  69245. texture: HDRCubeTexture;
  69246. /**
  69247. * Callback called when the task is successful
  69248. */
  69249. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69250. /**
  69251. * Callback called when the task is successful
  69252. */
  69253. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69254. /**
  69255. * Creates a new HDRCubeTextureAssetTask object
  69256. * @param name defines the name of the task
  69257. * @param url defines the location of the file to load
  69258. * @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.
  69259. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69260. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69261. * @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)
  69262. * @param reserved Internal use only
  69263. */
  69264. constructor(
  69265. /**
  69266. * Defines the name of the task
  69267. */
  69268. name: string,
  69269. /**
  69270. * Defines the location of the file to load
  69271. */
  69272. url: string,
  69273. /**
  69274. * Defines the desired size (the more it increases the longer the generation will be)
  69275. */
  69276. size: number,
  69277. /**
  69278. * Defines if mipmaps should not be generated (default is false)
  69279. */
  69280. noMipmap?: boolean,
  69281. /**
  69282. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69283. */
  69284. generateHarmonics?: boolean,
  69285. /**
  69286. * 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)
  69287. */
  69288. gammaSpace?: boolean,
  69289. /**
  69290. * Internal Use Only
  69291. */
  69292. reserved?: boolean);
  69293. /**
  69294. * Execute the current task
  69295. * @param scene defines the scene where you want your assets to be loaded
  69296. * @param onSuccess is a callback called when the task is successfully executed
  69297. * @param onError is a callback called if an error occurs
  69298. */
  69299. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69300. }
  69301. /**
  69302. * Define a task used by AssetsManager to load Equirectangular cube textures
  69303. */
  69304. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69305. /**
  69306. * Defines the name of the task
  69307. */
  69308. name: string;
  69309. /**
  69310. * Defines the location of the file to load
  69311. */
  69312. url: string;
  69313. /**
  69314. * Defines the desired size (the more it increases the longer the generation will be)
  69315. */
  69316. size: number;
  69317. /**
  69318. * Defines if mipmaps should not be generated (default is false)
  69319. */
  69320. noMipmap: boolean;
  69321. /**
  69322. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69323. * but the standard material would require them in Gamma space) (default is true)
  69324. */
  69325. gammaSpace: boolean;
  69326. /**
  69327. * Gets the loaded texture
  69328. */
  69329. texture: EquiRectangularCubeTexture;
  69330. /**
  69331. * Callback called when the task is successful
  69332. */
  69333. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69334. /**
  69335. * Callback called when the task is successful
  69336. */
  69337. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69338. /**
  69339. * Creates a new EquiRectangularCubeTextureAssetTask object
  69340. * @param name defines the name of the task
  69341. * @param url defines the location of the file to load
  69342. * @param size defines the desired size (the more it increases the longer the generation will be)
  69343. * If the size is omitted this implies you are using a preprocessed cubemap.
  69344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69345. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69346. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69347. * (default is true)
  69348. */
  69349. constructor(
  69350. /**
  69351. * Defines the name of the task
  69352. */
  69353. name: string,
  69354. /**
  69355. * Defines the location of the file to load
  69356. */
  69357. url: string,
  69358. /**
  69359. * Defines the desired size (the more it increases the longer the generation will be)
  69360. */
  69361. size: number,
  69362. /**
  69363. * Defines if mipmaps should not be generated (default is false)
  69364. */
  69365. noMipmap?: boolean,
  69366. /**
  69367. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69368. * but the standard material would require them in Gamma space) (default is true)
  69369. */
  69370. gammaSpace?: boolean);
  69371. /**
  69372. * Execute the current task
  69373. * @param scene defines the scene where you want your assets to be loaded
  69374. * @param onSuccess is a callback called when the task is successfully executed
  69375. * @param onError is a callback called if an error occurs
  69376. */
  69377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69378. }
  69379. /**
  69380. * This class can be used to easily import assets into a scene
  69381. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69382. */
  69383. export class AssetsManager {
  69384. private _scene;
  69385. private _isLoading;
  69386. protected _tasks: AbstractAssetTask[];
  69387. protected _waitingTasksCount: number;
  69388. protected _totalTasksCount: number;
  69389. /**
  69390. * Callback called when all tasks are processed
  69391. */
  69392. onFinish: (tasks: AbstractAssetTask[]) => void;
  69393. /**
  69394. * Callback called when a task is successful
  69395. */
  69396. onTaskSuccess: (task: AbstractAssetTask) => void;
  69397. /**
  69398. * Callback called when a task had an error
  69399. */
  69400. onTaskError: (task: AbstractAssetTask) => void;
  69401. /**
  69402. * Callback called when a task is done (whatever the result is)
  69403. */
  69404. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69405. /**
  69406. * Observable called when all tasks are processed
  69407. */
  69408. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69409. /**
  69410. * Observable called when a task had an error
  69411. */
  69412. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69413. /**
  69414. * Observable called when all tasks were executed
  69415. */
  69416. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69417. /**
  69418. * Observable called when a task is done (whatever the result is)
  69419. */
  69420. onProgressObservable: Observable<IAssetsProgressEvent>;
  69421. /**
  69422. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69423. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69424. */
  69425. useDefaultLoadingScreen: boolean;
  69426. /**
  69427. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69428. * when all assets have been downloaded.
  69429. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69430. */
  69431. autoHideLoadingUI: boolean;
  69432. /**
  69433. * Creates a new AssetsManager
  69434. * @param scene defines the scene to work on
  69435. */
  69436. constructor(scene: Scene);
  69437. /**
  69438. * Add a MeshAssetTask to the list of active tasks
  69439. * @param taskName defines the name of the new task
  69440. * @param meshesNames defines the name of meshes to load
  69441. * @param rootUrl defines the root url to use to locate files
  69442. * @param sceneFilename defines the filename of the scene file
  69443. * @returns a new MeshAssetTask object
  69444. */
  69445. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69446. /**
  69447. * Add a TextFileAssetTask to the list of active tasks
  69448. * @param taskName defines the name of the new task
  69449. * @param url defines the url of the file to load
  69450. * @returns a new TextFileAssetTask object
  69451. */
  69452. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69453. /**
  69454. * Add a BinaryFileAssetTask to the list of active tasks
  69455. * @param taskName defines the name of the new task
  69456. * @param url defines the url of the file to load
  69457. * @returns a new BinaryFileAssetTask object
  69458. */
  69459. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69460. /**
  69461. * Add a ImageAssetTask to the list of active tasks
  69462. * @param taskName defines the name of the new task
  69463. * @param url defines the url of the file to load
  69464. * @returns a new ImageAssetTask object
  69465. */
  69466. addImageTask(taskName: string, url: string): ImageAssetTask;
  69467. /**
  69468. * Add a TextureAssetTask to the list of active tasks
  69469. * @param taskName defines the name of the new task
  69470. * @param url defines the url of the file to load
  69471. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69472. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69473. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69474. * @returns a new TextureAssetTask object
  69475. */
  69476. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69477. /**
  69478. * Add a CubeTextureAssetTask to the list of active tasks
  69479. * @param taskName defines the name of the new task
  69480. * @param url defines the url of the file to load
  69481. * @param extensions defines the extension to use to load the cube map (can be null)
  69482. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69483. * @param files defines the list of files to load (can be null)
  69484. * @returns a new CubeTextureAssetTask object
  69485. */
  69486. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69487. /**
  69488. *
  69489. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69490. * @param taskName defines the name of the new task
  69491. * @param url defines the url of the file to load
  69492. * @param size defines the size you want for the cubemap (can be null)
  69493. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69494. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69495. * @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)
  69496. * @param reserved Internal use only
  69497. * @returns a new HDRCubeTextureAssetTask object
  69498. */
  69499. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69500. /**
  69501. *
  69502. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69503. * @param taskName defines the name of the new task
  69504. * @param url defines the url of the file to load
  69505. * @param size defines the size you want for the cubemap (can be null)
  69506. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69507. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69508. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69509. * @returns a new EquiRectangularCubeTextureAssetTask object
  69510. */
  69511. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69512. /**
  69513. * Remove a task from the assets manager.
  69514. * @param task the task to remove
  69515. */
  69516. removeTask(task: AbstractAssetTask): void;
  69517. private _decreaseWaitingTasksCount;
  69518. private _runTask;
  69519. /**
  69520. * Reset the AssetsManager and remove all tasks
  69521. * @return the current instance of the AssetsManager
  69522. */
  69523. reset(): AssetsManager;
  69524. /**
  69525. * Start the loading process
  69526. * @return the current instance of the AssetsManager
  69527. */
  69528. load(): AssetsManager;
  69529. /**
  69530. * Start the loading process as an async operation
  69531. * @return a promise returning the list of failed tasks
  69532. */
  69533. loadAsync(): Promise<void>;
  69534. }
  69535. }
  69536. declare module "babylonjs/Misc/deferred" {
  69537. /**
  69538. * Wrapper class for promise with external resolve and reject.
  69539. */
  69540. export class Deferred<T> {
  69541. /**
  69542. * The promise associated with this deferred object.
  69543. */
  69544. readonly promise: Promise<T>;
  69545. private _resolve;
  69546. private _reject;
  69547. /**
  69548. * The resolve method of the promise associated with this deferred object.
  69549. */
  69550. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69551. /**
  69552. * The reject method of the promise associated with this deferred object.
  69553. */
  69554. get reject(): (reason?: any) => void;
  69555. /**
  69556. * Constructor for this deferred object.
  69557. */
  69558. constructor();
  69559. }
  69560. }
  69561. declare module "babylonjs/Misc/meshExploder" {
  69562. import { Mesh } from "babylonjs/Meshes/mesh";
  69563. /**
  69564. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69565. */
  69566. export class MeshExploder {
  69567. private _centerMesh;
  69568. private _meshes;
  69569. private _meshesOrigins;
  69570. private _toCenterVectors;
  69571. private _scaledDirection;
  69572. private _newPosition;
  69573. private _centerPosition;
  69574. /**
  69575. * Explodes meshes from a center mesh.
  69576. * @param meshes The meshes to explode.
  69577. * @param centerMesh The mesh to be center of explosion.
  69578. */
  69579. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69580. private _setCenterMesh;
  69581. /**
  69582. * Get class name
  69583. * @returns "MeshExploder"
  69584. */
  69585. getClassName(): string;
  69586. /**
  69587. * "Exploded meshes"
  69588. * @returns Array of meshes with the centerMesh at index 0.
  69589. */
  69590. getMeshes(): Array<Mesh>;
  69591. /**
  69592. * Explodes meshes giving a specific direction
  69593. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69594. */
  69595. explode(direction?: number): void;
  69596. }
  69597. }
  69598. declare module "babylonjs/Misc/filesInput" {
  69599. import { Engine } from "babylonjs/Engines/engine";
  69600. import { Scene } from "babylonjs/scene";
  69601. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69602. /**
  69603. * Class used to help managing file picking and drag'n'drop
  69604. */
  69605. export class FilesInput {
  69606. /**
  69607. * List of files ready to be loaded
  69608. */
  69609. static get FilesToLoad(): {
  69610. [key: string]: File;
  69611. };
  69612. /**
  69613. * Callback called when a file is processed
  69614. */
  69615. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69616. private _engine;
  69617. private _currentScene;
  69618. private _sceneLoadedCallback;
  69619. private _progressCallback;
  69620. private _additionalRenderLoopLogicCallback;
  69621. private _textureLoadingCallback;
  69622. private _startingProcessingFilesCallback;
  69623. private _onReloadCallback;
  69624. private _errorCallback;
  69625. private _elementToMonitor;
  69626. private _sceneFileToLoad;
  69627. private _filesToLoad;
  69628. /**
  69629. * Creates a new FilesInput
  69630. * @param engine defines the rendering engine
  69631. * @param scene defines the hosting scene
  69632. * @param sceneLoadedCallback callback called when scene is loaded
  69633. * @param progressCallback callback called to track progress
  69634. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69635. * @param textureLoadingCallback callback called when a texture is loading
  69636. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69637. * @param onReloadCallback callback called when a reload is requested
  69638. * @param errorCallback callback call if an error occurs
  69639. */
  69640. 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);
  69641. private _dragEnterHandler;
  69642. private _dragOverHandler;
  69643. private _dropHandler;
  69644. /**
  69645. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69646. * @param elementToMonitor defines the DOM element to track
  69647. */
  69648. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69649. /**
  69650. * Release all associated resources
  69651. */
  69652. dispose(): void;
  69653. private renderFunction;
  69654. private drag;
  69655. private drop;
  69656. private _traverseFolder;
  69657. private _processFiles;
  69658. /**
  69659. * Load files from a drop event
  69660. * @param event defines the drop event to use as source
  69661. */
  69662. loadFiles(event: any): void;
  69663. private _processReload;
  69664. /**
  69665. * Reload the current scene from the loaded files
  69666. */
  69667. reload(): void;
  69668. }
  69669. }
  69670. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69671. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69672. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69673. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69674. }
  69675. declare module "babylonjs/Misc/sceneOptimizer" {
  69676. import { Scene, IDisposable } from "babylonjs/scene";
  69677. import { Observable } from "babylonjs/Misc/observable";
  69678. /**
  69679. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69680. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69681. */
  69682. export class SceneOptimization {
  69683. /**
  69684. * Defines the priority of this optimization (0 by default which means first in the list)
  69685. */
  69686. priority: number;
  69687. /**
  69688. * Gets a string describing the action executed by the current optimization
  69689. * @returns description string
  69690. */
  69691. getDescription(): string;
  69692. /**
  69693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69694. * @param scene defines the current scene where to apply this optimization
  69695. * @param optimizer defines the current optimizer
  69696. * @returns true if everything that can be done was applied
  69697. */
  69698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69699. /**
  69700. * Creates the SceneOptimization object
  69701. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69702. * @param desc defines the description associated with the optimization
  69703. */
  69704. constructor(
  69705. /**
  69706. * Defines the priority of this optimization (0 by default which means first in the list)
  69707. */
  69708. priority?: number);
  69709. }
  69710. /**
  69711. * Defines an optimization used to reduce the size of render target textures
  69712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69713. */
  69714. export class TextureOptimization extends SceneOptimization {
  69715. /**
  69716. * Defines the priority of this optimization (0 by default which means first in the list)
  69717. */
  69718. priority: number;
  69719. /**
  69720. * 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
  69721. */
  69722. maximumSize: number;
  69723. /**
  69724. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69725. */
  69726. step: number;
  69727. /**
  69728. * Gets a string describing the action executed by the current optimization
  69729. * @returns description string
  69730. */
  69731. getDescription(): string;
  69732. /**
  69733. * Creates the TextureOptimization object
  69734. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69735. * @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
  69736. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69737. */
  69738. constructor(
  69739. /**
  69740. * Defines the priority of this optimization (0 by default which means first in the list)
  69741. */
  69742. priority?: number,
  69743. /**
  69744. * 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
  69745. */
  69746. maximumSize?: number,
  69747. /**
  69748. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69749. */
  69750. step?: number);
  69751. /**
  69752. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69753. * @param scene defines the current scene where to apply this optimization
  69754. * @param optimizer defines the current optimizer
  69755. * @returns true if everything that can be done was applied
  69756. */
  69757. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69758. }
  69759. /**
  69760. * Defines an optimization used to increase or decrease the rendering resolution
  69761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69762. */
  69763. export class HardwareScalingOptimization extends SceneOptimization {
  69764. /**
  69765. * Defines the priority of this optimization (0 by default which means first in the list)
  69766. */
  69767. priority: number;
  69768. /**
  69769. * Defines the maximum scale to use (2 by default)
  69770. */
  69771. maximumScale: number;
  69772. /**
  69773. * Defines the step to use between two passes (0.5 by default)
  69774. */
  69775. step: number;
  69776. private _currentScale;
  69777. private _directionOffset;
  69778. /**
  69779. * Gets a string describing the action executed by the current optimization
  69780. * @return description string
  69781. */
  69782. getDescription(): string;
  69783. /**
  69784. * Creates the HardwareScalingOptimization object
  69785. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69786. * @param maximumScale defines the maximum scale to use (2 by default)
  69787. * @param step defines the step to use between two passes (0.5 by default)
  69788. */
  69789. constructor(
  69790. /**
  69791. * Defines the priority of this optimization (0 by default which means first in the list)
  69792. */
  69793. priority?: number,
  69794. /**
  69795. * Defines the maximum scale to use (2 by default)
  69796. */
  69797. maximumScale?: number,
  69798. /**
  69799. * Defines the step to use between two passes (0.5 by default)
  69800. */
  69801. step?: number);
  69802. /**
  69803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69804. * @param scene defines the current scene where to apply this optimization
  69805. * @param optimizer defines the current optimizer
  69806. * @returns true if everything that can be done was applied
  69807. */
  69808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69809. }
  69810. /**
  69811. * Defines an optimization used to remove shadows
  69812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69813. */
  69814. export class ShadowsOptimization extends SceneOptimization {
  69815. /**
  69816. * Gets a string describing the action executed by the current optimization
  69817. * @return description string
  69818. */
  69819. getDescription(): string;
  69820. /**
  69821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69822. * @param scene defines the current scene where to apply this optimization
  69823. * @param optimizer defines the current optimizer
  69824. * @returns true if everything that can be done was applied
  69825. */
  69826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69827. }
  69828. /**
  69829. * Defines an optimization used to turn post-processes off
  69830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69831. */
  69832. export class PostProcessesOptimization extends SceneOptimization {
  69833. /**
  69834. * Gets a string describing the action executed by the current optimization
  69835. * @return description string
  69836. */
  69837. getDescription(): string;
  69838. /**
  69839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69840. * @param scene defines the current scene where to apply this optimization
  69841. * @param optimizer defines the current optimizer
  69842. * @returns true if everything that can be done was applied
  69843. */
  69844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69845. }
  69846. /**
  69847. * Defines an optimization used to turn lens flares off
  69848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69849. */
  69850. export class LensFlaresOptimization extends SceneOptimization {
  69851. /**
  69852. * Gets a string describing the action executed by the current optimization
  69853. * @return description string
  69854. */
  69855. getDescription(): string;
  69856. /**
  69857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69858. * @param scene defines the current scene where to apply this optimization
  69859. * @param optimizer defines the current optimizer
  69860. * @returns true if everything that can be done was applied
  69861. */
  69862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69863. }
  69864. /**
  69865. * Defines an optimization based on user defined callback.
  69866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69867. */
  69868. export class CustomOptimization extends SceneOptimization {
  69869. /**
  69870. * Callback called to apply the custom optimization.
  69871. */
  69872. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69873. /**
  69874. * Callback called to get custom description
  69875. */
  69876. onGetDescription: () => string;
  69877. /**
  69878. * Gets a string describing the action executed by the current optimization
  69879. * @returns description string
  69880. */
  69881. getDescription(): string;
  69882. /**
  69883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69884. * @param scene defines the current scene where to apply this optimization
  69885. * @param optimizer defines the current optimizer
  69886. * @returns true if everything that can be done was applied
  69887. */
  69888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69889. }
  69890. /**
  69891. * Defines an optimization used to turn particles off
  69892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69893. */
  69894. export class ParticlesOptimization extends SceneOptimization {
  69895. /**
  69896. * Gets a string describing the action executed by the current optimization
  69897. * @return description string
  69898. */
  69899. getDescription(): string;
  69900. /**
  69901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69902. * @param scene defines the current scene where to apply this optimization
  69903. * @param optimizer defines the current optimizer
  69904. * @returns true if everything that can be done was applied
  69905. */
  69906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69907. }
  69908. /**
  69909. * Defines an optimization used to turn render targets off
  69910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69911. */
  69912. export class RenderTargetsOptimization extends SceneOptimization {
  69913. /**
  69914. * Gets a string describing the action executed by the current optimization
  69915. * @return description string
  69916. */
  69917. getDescription(): string;
  69918. /**
  69919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69920. * @param scene defines the current scene where to apply this optimization
  69921. * @param optimizer defines the current optimizer
  69922. * @returns true if everything that can be done was applied
  69923. */
  69924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69925. }
  69926. /**
  69927. * Defines an optimization used to merge meshes with compatible materials
  69928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69929. */
  69930. export class MergeMeshesOptimization extends SceneOptimization {
  69931. private static _UpdateSelectionTree;
  69932. /**
  69933. * Gets or sets a boolean which defines if optimization octree has to be updated
  69934. */
  69935. static get UpdateSelectionTree(): boolean;
  69936. /**
  69937. * Gets or sets a boolean which defines if optimization octree has to be updated
  69938. */
  69939. static set UpdateSelectionTree(value: boolean);
  69940. /**
  69941. * Gets a string describing the action executed by the current optimization
  69942. * @return description string
  69943. */
  69944. getDescription(): string;
  69945. private _canBeMerged;
  69946. /**
  69947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69948. * @param scene defines the current scene where to apply this optimization
  69949. * @param optimizer defines the current optimizer
  69950. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69951. * @returns true if everything that can be done was applied
  69952. */
  69953. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69954. }
  69955. /**
  69956. * Defines a list of options used by SceneOptimizer
  69957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69958. */
  69959. export class SceneOptimizerOptions {
  69960. /**
  69961. * Defines the target frame rate to reach (60 by default)
  69962. */
  69963. targetFrameRate: number;
  69964. /**
  69965. * Defines the interval between two checkes (2000ms by default)
  69966. */
  69967. trackerDuration: number;
  69968. /**
  69969. * Gets the list of optimizations to apply
  69970. */
  69971. optimizations: SceneOptimization[];
  69972. /**
  69973. * Creates a new list of options used by SceneOptimizer
  69974. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69975. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69976. */
  69977. constructor(
  69978. /**
  69979. * Defines the target frame rate to reach (60 by default)
  69980. */
  69981. targetFrameRate?: number,
  69982. /**
  69983. * Defines the interval between two checkes (2000ms by default)
  69984. */
  69985. trackerDuration?: number);
  69986. /**
  69987. * Add a new optimization
  69988. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69989. * @returns the current SceneOptimizerOptions
  69990. */
  69991. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69992. /**
  69993. * Add a new custom optimization
  69994. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69995. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69996. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69997. * @returns the current SceneOptimizerOptions
  69998. */
  69999. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70000. /**
  70001. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70002. * @param targetFrameRate defines the target frame rate (60 by default)
  70003. * @returns a SceneOptimizerOptions object
  70004. */
  70005. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70006. /**
  70007. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70008. * @param targetFrameRate defines the target frame rate (60 by default)
  70009. * @returns a SceneOptimizerOptions object
  70010. */
  70011. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70012. /**
  70013. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70014. * @param targetFrameRate defines the target frame rate (60 by default)
  70015. * @returns a SceneOptimizerOptions object
  70016. */
  70017. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70018. }
  70019. /**
  70020. * Class used to run optimizations in order to reach a target frame rate
  70021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70022. */
  70023. export class SceneOptimizer implements IDisposable {
  70024. private _isRunning;
  70025. private _options;
  70026. private _scene;
  70027. private _currentPriorityLevel;
  70028. private _targetFrameRate;
  70029. private _trackerDuration;
  70030. private _currentFrameRate;
  70031. private _sceneDisposeObserver;
  70032. private _improvementMode;
  70033. /**
  70034. * Defines an observable called when the optimizer reaches the target frame rate
  70035. */
  70036. onSuccessObservable: Observable<SceneOptimizer>;
  70037. /**
  70038. * Defines an observable called when the optimizer enables an optimization
  70039. */
  70040. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70041. /**
  70042. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70043. */
  70044. onFailureObservable: Observable<SceneOptimizer>;
  70045. /**
  70046. * Gets a boolean indicating if the optimizer is in improvement mode
  70047. */
  70048. get isInImprovementMode(): boolean;
  70049. /**
  70050. * Gets the current priority level (0 at start)
  70051. */
  70052. get currentPriorityLevel(): number;
  70053. /**
  70054. * Gets the current frame rate checked by the SceneOptimizer
  70055. */
  70056. get currentFrameRate(): number;
  70057. /**
  70058. * Gets or sets the current target frame rate (60 by default)
  70059. */
  70060. get targetFrameRate(): number;
  70061. /**
  70062. * Gets or sets the current target frame rate (60 by default)
  70063. */
  70064. set targetFrameRate(value: number);
  70065. /**
  70066. * Gets or sets the current interval between two checks (every 2000ms by default)
  70067. */
  70068. get trackerDuration(): number;
  70069. /**
  70070. * Gets or sets the current interval between two checks (every 2000ms by default)
  70071. */
  70072. set trackerDuration(value: number);
  70073. /**
  70074. * Gets the list of active optimizations
  70075. */
  70076. get optimizations(): SceneOptimization[];
  70077. /**
  70078. * Creates a new SceneOptimizer
  70079. * @param scene defines the scene to work on
  70080. * @param options defines the options to use with the SceneOptimizer
  70081. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70082. * @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)
  70083. */
  70084. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70085. /**
  70086. * Stops the current optimizer
  70087. */
  70088. stop(): void;
  70089. /**
  70090. * Reset the optimizer to initial step (current priority level = 0)
  70091. */
  70092. reset(): void;
  70093. /**
  70094. * Start the optimizer. By default it will try to reach a specific framerate
  70095. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70096. */
  70097. start(): void;
  70098. private _checkCurrentState;
  70099. /**
  70100. * Release all resources
  70101. */
  70102. dispose(): void;
  70103. /**
  70104. * Helper function to create a SceneOptimizer with one single line of code
  70105. * @param scene defines the scene to work on
  70106. * @param options defines the options to use with the SceneOptimizer
  70107. * @param onSuccess defines a callback to call on success
  70108. * @param onFailure defines a callback to call on failure
  70109. * @returns the new SceneOptimizer object
  70110. */
  70111. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70112. }
  70113. }
  70114. declare module "babylonjs/Misc/sceneSerializer" {
  70115. import { Scene } from "babylonjs/scene";
  70116. /**
  70117. * Class used to serialize a scene into a string
  70118. */
  70119. export class SceneSerializer {
  70120. /**
  70121. * Clear cache used by a previous serialization
  70122. */
  70123. static ClearCache(): void;
  70124. /**
  70125. * Serialize a scene into a JSON compatible object
  70126. * @param scene defines the scene to serialize
  70127. * @returns a JSON compatible object
  70128. */
  70129. static Serialize(scene: Scene): any;
  70130. /**
  70131. * Serialize a mesh into a JSON compatible object
  70132. * @param toSerialize defines the mesh to serialize
  70133. * @param withParents defines if parents must be serialized as well
  70134. * @param withChildren defines if children must be serialized as well
  70135. * @returns a JSON compatible object
  70136. */
  70137. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70138. }
  70139. }
  70140. declare module "babylonjs/Misc/textureTools" {
  70141. import { Texture } from "babylonjs/Materials/Textures/texture";
  70142. /**
  70143. * Class used to host texture specific utilities
  70144. */
  70145. export class TextureTools {
  70146. /**
  70147. * Uses the GPU to create a copy texture rescaled at a given size
  70148. * @param texture Texture to copy from
  70149. * @param width defines the desired width
  70150. * @param height defines the desired height
  70151. * @param useBilinearMode defines if bilinear mode has to be used
  70152. * @return the generated texture
  70153. */
  70154. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70155. }
  70156. }
  70157. declare module "babylonjs/Misc/videoRecorder" {
  70158. import { Nullable } from "babylonjs/types";
  70159. import { Engine } from "babylonjs/Engines/engine";
  70160. /**
  70161. * This represents the different options available for the video capture.
  70162. */
  70163. export interface VideoRecorderOptions {
  70164. /** Defines the mime type of the video. */
  70165. mimeType: string;
  70166. /** Defines the FPS the video should be recorded at. */
  70167. fps: number;
  70168. /** Defines the chunk size for the recording data. */
  70169. recordChunckSize: number;
  70170. /** The audio tracks to attach to the recording. */
  70171. audioTracks?: MediaStreamTrack[];
  70172. }
  70173. /**
  70174. * This can help with recording videos from BabylonJS.
  70175. * This is based on the available WebRTC functionalities of the browser.
  70176. *
  70177. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70178. */
  70179. export class VideoRecorder {
  70180. private static readonly _defaultOptions;
  70181. /**
  70182. * Returns whether or not the VideoRecorder is available in your browser.
  70183. * @param engine Defines the Babylon Engine.
  70184. * @returns true if supported otherwise false.
  70185. */
  70186. static IsSupported(engine: Engine): boolean;
  70187. private readonly _options;
  70188. private _canvas;
  70189. private _mediaRecorder;
  70190. private _recordedChunks;
  70191. private _fileName;
  70192. private _resolve;
  70193. private _reject;
  70194. /**
  70195. * True when a recording is already in progress.
  70196. */
  70197. get isRecording(): boolean;
  70198. /**
  70199. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70200. * @param engine Defines the BabylonJS Engine you wish to record.
  70201. * @param options Defines options that can be used to customize the capture.
  70202. */
  70203. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70204. /**
  70205. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70206. */
  70207. stopRecording(): void;
  70208. /**
  70209. * Starts recording the canvas for a max duration specified in parameters.
  70210. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70211. * If null no automatic download will start and you can rely on the promise to get the data back.
  70212. * @param maxDuration Defines the maximum recording time in seconds.
  70213. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70214. * @return A promise callback at the end of the recording with the video data in Blob.
  70215. */
  70216. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70217. /**
  70218. * Releases internal resources used during the recording.
  70219. */
  70220. dispose(): void;
  70221. private _handleDataAvailable;
  70222. private _handleError;
  70223. private _handleStop;
  70224. }
  70225. }
  70226. declare module "babylonjs/Misc/screenshotTools" {
  70227. import { Camera } from "babylonjs/Cameras/camera";
  70228. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70229. import { Engine } from "babylonjs/Engines/engine";
  70230. /**
  70231. * Class containing a set of static utilities functions for screenshots
  70232. */
  70233. export class ScreenshotTools {
  70234. /**
  70235. * Captures a screenshot of the current rendering
  70236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70237. * @param engine defines the rendering engine
  70238. * @param camera defines the source camera
  70239. * @param size This parameter can be set to a single number or to an object with the
  70240. * following (optional) properties: precision, width, height. If a single number is passed,
  70241. * it will be used for both width and height. If an object is passed, the screenshot size
  70242. * will be derived from the parameters. The precision property is a multiplier allowing
  70243. * rendering at a higher or lower resolution
  70244. * @param successCallback defines the callback receives a single parameter which contains the
  70245. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70246. * src parameter of an <img> to display it
  70247. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70248. * Check your browser for supported MIME types
  70249. */
  70250. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70251. /**
  70252. * Captures a screenshot of the current rendering
  70253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70254. * @param engine defines the rendering engine
  70255. * @param camera defines the source camera
  70256. * @param size This parameter can be set to a single number or to an object with the
  70257. * following (optional) properties: precision, width, height. If a single number is passed,
  70258. * it will be used for both width and height. If an object is passed, the screenshot size
  70259. * will be derived from the parameters. The precision property is a multiplier allowing
  70260. * rendering at a higher or lower resolution
  70261. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70262. * Check your browser for supported MIME types
  70263. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70264. * to the src parameter of an <img> to display it
  70265. */
  70266. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70267. /**
  70268. * Generates an image screenshot from the specified camera.
  70269. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70270. * @param engine The engine to use for rendering
  70271. * @param camera The camera to use for rendering
  70272. * @param size This parameter can be set to a single number or to an object with the
  70273. * following (optional) properties: precision, width, height. If a single number is passed,
  70274. * it will be used for both width and height. If an object is passed, the screenshot size
  70275. * will be derived from the parameters. The precision property is a multiplier allowing
  70276. * rendering at a higher or lower resolution
  70277. * @param successCallback The callback receives a single parameter which contains the
  70278. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70279. * src parameter of an <img> to display it
  70280. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70281. * Check your browser for supported MIME types
  70282. * @param samples Texture samples (default: 1)
  70283. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70284. * @param fileName A name for for the downloaded file.
  70285. */
  70286. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70287. /**
  70288. * Generates an image screenshot from the specified camera.
  70289. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70290. * @param engine The engine to use for rendering
  70291. * @param camera The camera to use for rendering
  70292. * @param size This parameter can be set to a single number or to an object with the
  70293. * following (optional) properties: precision, width, height. If a single number is passed,
  70294. * it will be used for both width and height. If an object is passed, the screenshot size
  70295. * will be derived from the parameters. The precision property is a multiplier allowing
  70296. * rendering at a higher or lower resolution
  70297. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70298. * Check your browser for supported MIME types
  70299. * @param samples Texture samples (default: 1)
  70300. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70301. * @param fileName A name for for the downloaded file.
  70302. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70303. * to the src parameter of an <img> to display it
  70304. */
  70305. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70306. /**
  70307. * Gets height and width for screenshot size
  70308. * @private
  70309. */
  70310. private static _getScreenshotSize;
  70311. }
  70312. }
  70313. declare module "babylonjs/Misc/dataReader" {
  70314. /**
  70315. * Interface for a data buffer
  70316. */
  70317. export interface IDataBuffer {
  70318. /**
  70319. * Reads bytes from the data buffer.
  70320. * @param byteOffset The byte offset to read
  70321. * @param byteLength The byte length to read
  70322. * @returns A promise that resolves when the bytes are read
  70323. */
  70324. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70325. /**
  70326. * The byte length of the buffer.
  70327. */
  70328. readonly byteLength: number;
  70329. }
  70330. /**
  70331. * Utility class for reading from a data buffer
  70332. */
  70333. export class DataReader {
  70334. /**
  70335. * The data buffer associated with this data reader.
  70336. */
  70337. readonly buffer: IDataBuffer;
  70338. /**
  70339. * The current byte offset from the beginning of the data buffer.
  70340. */
  70341. byteOffset: number;
  70342. private _dataView;
  70343. private _dataByteOffset;
  70344. /**
  70345. * Constructor
  70346. * @param buffer The buffer to read
  70347. */
  70348. constructor(buffer: IDataBuffer);
  70349. /**
  70350. * Loads the given byte length.
  70351. * @param byteLength The byte length to load
  70352. * @returns A promise that resolves when the load is complete
  70353. */
  70354. loadAsync(byteLength: number): Promise<void>;
  70355. /**
  70356. * Read a unsigned 32-bit integer from the currently loaded data range.
  70357. * @returns The 32-bit integer read
  70358. */
  70359. readUint32(): number;
  70360. /**
  70361. * Read a byte array from the currently loaded data range.
  70362. * @param byteLength The byte length to read
  70363. * @returns The byte array read
  70364. */
  70365. readUint8Array(byteLength: number): Uint8Array;
  70366. /**
  70367. * Read a string from the currently loaded data range.
  70368. * @param byteLength The byte length to read
  70369. * @returns The string read
  70370. */
  70371. readString(byteLength: number): string;
  70372. /**
  70373. * Skips the given byte length the currently loaded data range.
  70374. * @param byteLength The byte length to skip
  70375. */
  70376. skipBytes(byteLength: number): void;
  70377. }
  70378. }
  70379. declare module "babylonjs/Misc/index" {
  70380. export * from "babylonjs/Misc/andOrNotEvaluator";
  70381. export * from "babylonjs/Misc/assetsManager";
  70382. export * from "babylonjs/Misc/basis";
  70383. export * from "babylonjs/Misc/dds";
  70384. export * from "babylonjs/Misc/decorators";
  70385. export * from "babylonjs/Misc/deferred";
  70386. export * from "babylonjs/Misc/environmentTextureTools";
  70387. export * from "babylonjs/Misc/meshExploder";
  70388. export * from "babylonjs/Misc/filesInput";
  70389. export * from "babylonjs/Misc/HighDynamicRange/index";
  70390. export * from "babylonjs/Misc/khronosTextureContainer";
  70391. export * from "babylonjs/Misc/observable";
  70392. export * from "babylonjs/Misc/performanceMonitor";
  70393. export * from "babylonjs/Misc/promise";
  70394. export * from "babylonjs/Misc/sceneOptimizer";
  70395. export * from "babylonjs/Misc/sceneSerializer";
  70396. export * from "babylonjs/Misc/smartArray";
  70397. export * from "babylonjs/Misc/stringDictionary";
  70398. export * from "babylonjs/Misc/tags";
  70399. export * from "babylonjs/Misc/textureTools";
  70400. export * from "babylonjs/Misc/tga";
  70401. export * from "babylonjs/Misc/tools";
  70402. export * from "babylonjs/Misc/videoRecorder";
  70403. export * from "babylonjs/Misc/virtualJoystick";
  70404. export * from "babylonjs/Misc/workerPool";
  70405. export * from "babylonjs/Misc/logger";
  70406. export * from "babylonjs/Misc/typeStore";
  70407. export * from "babylonjs/Misc/filesInputStore";
  70408. export * from "babylonjs/Misc/deepCopier";
  70409. export * from "babylonjs/Misc/pivotTools";
  70410. export * from "babylonjs/Misc/precisionDate";
  70411. export * from "babylonjs/Misc/screenshotTools";
  70412. export * from "babylonjs/Misc/typeStore";
  70413. export * from "babylonjs/Misc/webRequest";
  70414. export * from "babylonjs/Misc/iInspectable";
  70415. export * from "babylonjs/Misc/brdfTextureTools";
  70416. export * from "babylonjs/Misc/rgbdTextureTools";
  70417. export * from "babylonjs/Misc/gradients";
  70418. export * from "babylonjs/Misc/perfCounter";
  70419. export * from "babylonjs/Misc/fileRequest";
  70420. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70421. export * from "babylonjs/Misc/retryStrategy";
  70422. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70423. export * from "babylonjs/Misc/canvasGenerator";
  70424. export * from "babylonjs/Misc/fileTools";
  70425. export * from "babylonjs/Misc/stringTools";
  70426. export * from "babylonjs/Misc/dataReader";
  70427. }
  70428. declare module "babylonjs/index" {
  70429. export * from "babylonjs/abstractScene";
  70430. export * from "babylonjs/Actions/index";
  70431. export * from "babylonjs/Animations/index";
  70432. export * from "babylonjs/assetContainer";
  70433. export * from "babylonjs/Audio/index";
  70434. export * from "babylonjs/Behaviors/index";
  70435. export * from "babylonjs/Bones/index";
  70436. export * from "babylonjs/Cameras/index";
  70437. export * from "babylonjs/Collisions/index";
  70438. export * from "babylonjs/Culling/index";
  70439. export * from "babylonjs/Debug/index";
  70440. export * from "babylonjs/Engines/index";
  70441. export * from "babylonjs/Events/index";
  70442. export * from "babylonjs/Gamepads/index";
  70443. export * from "babylonjs/Gizmos/index";
  70444. export * from "babylonjs/Helpers/index";
  70445. export * from "babylonjs/Instrumentation/index";
  70446. export * from "babylonjs/Layers/index";
  70447. export * from "babylonjs/LensFlares/index";
  70448. export * from "babylonjs/Lights/index";
  70449. export * from "babylonjs/Loading/index";
  70450. export * from "babylonjs/Materials/index";
  70451. export * from "babylonjs/Maths/index";
  70452. export * from "babylonjs/Meshes/index";
  70453. export * from "babylonjs/Morph/index";
  70454. export * from "babylonjs/Navigation/index";
  70455. export * from "babylonjs/node";
  70456. export * from "babylonjs/Offline/index";
  70457. export * from "babylonjs/Particles/index";
  70458. export * from "babylonjs/Physics/index";
  70459. export * from "babylonjs/PostProcesses/index";
  70460. export * from "babylonjs/Probes/index";
  70461. export * from "babylonjs/Rendering/index";
  70462. export * from "babylonjs/scene";
  70463. export * from "babylonjs/sceneComponent";
  70464. export * from "babylonjs/Sprites/index";
  70465. export * from "babylonjs/States/index";
  70466. export * from "babylonjs/Misc/index";
  70467. export * from "babylonjs/types";
  70468. }
  70469. declare module "babylonjs/Animations/pathCursor" {
  70470. import { Vector3 } from "babylonjs/Maths/math.vector";
  70471. import { Path2 } from "babylonjs/Maths/math.path";
  70472. /**
  70473. * A cursor which tracks a point on a path
  70474. */
  70475. export class PathCursor {
  70476. private path;
  70477. /**
  70478. * Stores path cursor callbacks for when an onchange event is triggered
  70479. */
  70480. private _onchange;
  70481. /**
  70482. * The value of the path cursor
  70483. */
  70484. value: number;
  70485. /**
  70486. * The animation array of the path cursor
  70487. */
  70488. animations: Animation[];
  70489. /**
  70490. * Initializes the path cursor
  70491. * @param path The path to track
  70492. */
  70493. constructor(path: Path2);
  70494. /**
  70495. * Gets the cursor point on the path
  70496. * @returns A point on the path cursor at the cursor location
  70497. */
  70498. getPoint(): Vector3;
  70499. /**
  70500. * Moves the cursor ahead by the step amount
  70501. * @param step The amount to move the cursor forward
  70502. * @returns This path cursor
  70503. */
  70504. moveAhead(step?: number): PathCursor;
  70505. /**
  70506. * Moves the cursor behind by the step amount
  70507. * @param step The amount to move the cursor back
  70508. * @returns This path cursor
  70509. */
  70510. moveBack(step?: number): PathCursor;
  70511. /**
  70512. * Moves the cursor by the step amount
  70513. * If the step amount is greater than one, an exception is thrown
  70514. * @param step The amount to move the cursor
  70515. * @returns This path cursor
  70516. */
  70517. move(step: number): PathCursor;
  70518. /**
  70519. * Ensures that the value is limited between zero and one
  70520. * @returns This path cursor
  70521. */
  70522. private ensureLimits;
  70523. /**
  70524. * Runs onchange callbacks on change (used by the animation engine)
  70525. * @returns This path cursor
  70526. */
  70527. private raiseOnChange;
  70528. /**
  70529. * Executes a function on change
  70530. * @param f A path cursor onchange callback
  70531. * @returns This path cursor
  70532. */
  70533. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70534. }
  70535. }
  70536. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70537. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70538. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70539. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70540. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70541. }
  70542. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70543. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70544. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70545. }
  70546. declare module "babylonjs/Engines/Processors/index" {
  70547. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70548. export * from "babylonjs/Engines/Processors/Expressions/index";
  70549. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70550. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70551. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70552. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70553. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70554. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70555. }
  70556. declare module "babylonjs/Legacy/legacy" {
  70557. import * as Babylon from "babylonjs/index";
  70558. export * from "babylonjs/index";
  70559. }
  70560. declare module "babylonjs/Shaders/blur.fragment" {
  70561. /** @hidden */
  70562. export var blurPixelShader: {
  70563. name: string;
  70564. shader: string;
  70565. };
  70566. }
  70567. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70568. /** @hidden */
  70569. export var pointCloudVertexDeclaration: {
  70570. name: string;
  70571. shader: string;
  70572. };
  70573. }
  70574. declare module "babylonjs" {
  70575. export * from "babylonjs/Legacy/legacy";
  70576. }
  70577. declare module BABYLON {
  70578. /** Alias type for value that can be null */
  70579. export type Nullable<T> = T | null;
  70580. /**
  70581. * Alias type for number that are floats
  70582. * @ignorenaming
  70583. */
  70584. export type float = number;
  70585. /**
  70586. * Alias type for number that are doubles.
  70587. * @ignorenaming
  70588. */
  70589. export type double = number;
  70590. /**
  70591. * Alias type for number that are integer
  70592. * @ignorenaming
  70593. */
  70594. export type int = number;
  70595. /** Alias type for number array or Float32Array */
  70596. export type FloatArray = number[] | Float32Array;
  70597. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70598. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70599. /**
  70600. * Alias for types that can be used by a Buffer or VertexBuffer.
  70601. */
  70602. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70603. /**
  70604. * Alias type for primitive types
  70605. * @ignorenaming
  70606. */
  70607. type Primitive = undefined | null | boolean | string | number | Function;
  70608. /**
  70609. * Type modifier to make all the properties of an object Readonly
  70610. */
  70611. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70612. /**
  70613. * Type modifier to make all the properties of an object Readonly recursively
  70614. */
  70615. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70616. /**
  70617. * Type modifier to make object properties readonly.
  70618. */
  70619. export type DeepImmutableObject<T> = {
  70620. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70621. };
  70622. /** @hidden */
  70623. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70624. }
  70625. }
  70626. declare module BABYLON {
  70627. /**
  70628. * A class serves as a medium between the observable and its observers
  70629. */
  70630. export class EventState {
  70631. /**
  70632. * Create a new EventState
  70633. * @param mask defines the mask associated with this state
  70634. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70635. * @param target defines the original target of the state
  70636. * @param currentTarget defines the current target of the state
  70637. */
  70638. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70639. /**
  70640. * Initialize the current event state
  70641. * @param mask defines the mask associated with this state
  70642. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70643. * @param target defines the original target of the state
  70644. * @param currentTarget defines the current target of the state
  70645. * @returns the current event state
  70646. */
  70647. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70648. /**
  70649. * An Observer can set this property to true to prevent subsequent observers of being notified
  70650. */
  70651. skipNextObservers: boolean;
  70652. /**
  70653. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70654. */
  70655. mask: number;
  70656. /**
  70657. * The object that originally notified the event
  70658. */
  70659. target?: any;
  70660. /**
  70661. * The current object in the bubbling phase
  70662. */
  70663. currentTarget?: any;
  70664. /**
  70665. * This will be populated with the return value of the last function that was executed.
  70666. * If it is the first function in the callback chain it will be the event data.
  70667. */
  70668. lastReturnValue?: any;
  70669. }
  70670. /**
  70671. * Represent an Observer registered to a given Observable object.
  70672. */
  70673. export class Observer<T> {
  70674. /**
  70675. * Defines the callback to call when the observer is notified
  70676. */
  70677. callback: (eventData: T, eventState: EventState) => void;
  70678. /**
  70679. * Defines the mask of the observer (used to filter notifications)
  70680. */
  70681. mask: number;
  70682. /**
  70683. * Defines the current scope used to restore the JS context
  70684. */
  70685. scope: any;
  70686. /** @hidden */
  70687. _willBeUnregistered: boolean;
  70688. /**
  70689. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70690. */
  70691. unregisterOnNextCall: boolean;
  70692. /**
  70693. * Creates a new observer
  70694. * @param callback defines the callback to call when the observer is notified
  70695. * @param mask defines the mask of the observer (used to filter notifications)
  70696. * @param scope defines the current scope used to restore the JS context
  70697. */
  70698. constructor(
  70699. /**
  70700. * Defines the callback to call when the observer is notified
  70701. */
  70702. callback: (eventData: T, eventState: EventState) => void,
  70703. /**
  70704. * Defines the mask of the observer (used to filter notifications)
  70705. */
  70706. mask: number,
  70707. /**
  70708. * Defines the current scope used to restore the JS context
  70709. */
  70710. scope?: any);
  70711. }
  70712. /**
  70713. * Represent a list of observers registered to multiple Observables object.
  70714. */
  70715. export class MultiObserver<T> {
  70716. private _observers;
  70717. private _observables;
  70718. /**
  70719. * Release associated resources
  70720. */
  70721. dispose(): void;
  70722. /**
  70723. * Raise a callback when one of the observable will notify
  70724. * @param observables defines a list of observables to watch
  70725. * @param callback defines the callback to call on notification
  70726. * @param mask defines the mask used to filter notifications
  70727. * @param scope defines the current scope used to restore the JS context
  70728. * @returns the new MultiObserver
  70729. */
  70730. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70731. }
  70732. /**
  70733. * The Observable class is a simple implementation of the Observable pattern.
  70734. *
  70735. * 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.
  70736. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70737. * 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).
  70738. * 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.
  70739. */
  70740. export class Observable<T> {
  70741. private _observers;
  70742. private _eventState;
  70743. private _onObserverAdded;
  70744. /**
  70745. * Gets the list of observers
  70746. */
  70747. get observers(): Array<Observer<T>>;
  70748. /**
  70749. * Creates a new observable
  70750. * @param onObserverAdded defines a callback to call when a new observer is added
  70751. */
  70752. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70753. /**
  70754. * Create a new Observer with the specified callback
  70755. * @param callback the callback that will be executed for that Observer
  70756. * @param mask the mask used to filter observers
  70757. * @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.
  70758. * @param scope optional scope for the callback to be called from
  70759. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70760. * @returns the new observer created for the callback
  70761. */
  70762. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70763. /**
  70764. * Create a new Observer with the specified callback and unregisters after the next notification
  70765. * @param callback the callback that will be executed for that Observer
  70766. * @returns the new observer created for the callback
  70767. */
  70768. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70769. /**
  70770. * Remove an Observer from the Observable object
  70771. * @param observer the instance of the Observer to remove
  70772. * @returns false if it doesn't belong to this Observable
  70773. */
  70774. remove(observer: Nullable<Observer<T>>): boolean;
  70775. /**
  70776. * Remove a callback from the Observable object
  70777. * @param callback the callback to remove
  70778. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70779. * @returns false if it doesn't belong to this Observable
  70780. */
  70781. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70782. private _deferUnregister;
  70783. private _remove;
  70784. /**
  70785. * Moves the observable to the top of the observer list making it get called first when notified
  70786. * @param observer the observer to move
  70787. */
  70788. makeObserverTopPriority(observer: Observer<T>): void;
  70789. /**
  70790. * Moves the observable to the bottom of the observer list making it get called last when notified
  70791. * @param observer the observer to move
  70792. */
  70793. makeObserverBottomPriority(observer: Observer<T>): void;
  70794. /**
  70795. * Notify all Observers by calling their respective callback with the given data
  70796. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70797. * @param eventData defines the data to send to all observers
  70798. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70799. * @param target defines the original target of the state
  70800. * @param currentTarget defines the current target of the state
  70801. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70802. */
  70803. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70804. /**
  70805. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70806. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70807. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70808. * and it is crucial that all callbacks will be executed.
  70809. * The order of the callbacks is kept, callbacks are not executed parallel.
  70810. *
  70811. * @param eventData The data to be sent to each callback
  70812. * @param mask is used to filter observers defaults to -1
  70813. * @param target defines the callback target (see EventState)
  70814. * @param currentTarget defines he current object in the bubbling phase
  70815. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70816. */
  70817. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70818. /**
  70819. * Notify a specific observer
  70820. * @param observer defines the observer to notify
  70821. * @param eventData defines the data to be sent to each callback
  70822. * @param mask is used to filter observers defaults to -1
  70823. */
  70824. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70825. /**
  70826. * Gets a boolean indicating if the observable has at least one observer
  70827. * @returns true is the Observable has at least one Observer registered
  70828. */
  70829. hasObservers(): boolean;
  70830. /**
  70831. * Clear the list of observers
  70832. */
  70833. clear(): void;
  70834. /**
  70835. * Clone the current observable
  70836. * @returns a new observable
  70837. */
  70838. clone(): Observable<T>;
  70839. /**
  70840. * Does this observable handles observer registered with a given mask
  70841. * @param mask defines the mask to be tested
  70842. * @return whether or not one observer registered with the given mask is handeled
  70843. **/
  70844. hasSpecificMask(mask?: number): boolean;
  70845. }
  70846. }
  70847. declare module BABYLON {
  70848. /**
  70849. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70850. * Babylon.js
  70851. */
  70852. export class DomManagement {
  70853. /**
  70854. * Checks if the window object exists
  70855. * @returns true if the window object exists
  70856. */
  70857. static IsWindowObjectExist(): boolean;
  70858. /**
  70859. * Checks if the navigator object exists
  70860. * @returns true if the navigator object exists
  70861. */
  70862. static IsNavigatorAvailable(): boolean;
  70863. /**
  70864. * Extracts text content from a DOM element hierarchy
  70865. * @param element defines the root element
  70866. * @returns a string
  70867. */
  70868. static GetDOMTextContent(element: HTMLElement): string;
  70869. }
  70870. }
  70871. declare module BABYLON {
  70872. /**
  70873. * Logger used througouht the application to allow configuration of
  70874. * the log level required for the messages.
  70875. */
  70876. export class Logger {
  70877. /**
  70878. * No log
  70879. */
  70880. static readonly NoneLogLevel: number;
  70881. /**
  70882. * Only message logs
  70883. */
  70884. static readonly MessageLogLevel: number;
  70885. /**
  70886. * Only warning logs
  70887. */
  70888. static readonly WarningLogLevel: number;
  70889. /**
  70890. * Only error logs
  70891. */
  70892. static readonly ErrorLogLevel: number;
  70893. /**
  70894. * All logs
  70895. */
  70896. static readonly AllLogLevel: number;
  70897. private static _LogCache;
  70898. /**
  70899. * Gets a value indicating the number of loading errors
  70900. * @ignorenaming
  70901. */
  70902. static errorsCount: number;
  70903. /**
  70904. * Callback called when a new log is added
  70905. */
  70906. static OnNewCacheEntry: (entry: string) => void;
  70907. private static _AddLogEntry;
  70908. private static _FormatMessage;
  70909. private static _LogDisabled;
  70910. private static _LogEnabled;
  70911. private static _WarnDisabled;
  70912. private static _WarnEnabled;
  70913. private static _ErrorDisabled;
  70914. private static _ErrorEnabled;
  70915. /**
  70916. * Log a message to the console
  70917. */
  70918. static Log: (message: string) => void;
  70919. /**
  70920. * Write a warning message to the console
  70921. */
  70922. static Warn: (message: string) => void;
  70923. /**
  70924. * Write an error message to the console
  70925. */
  70926. static Error: (message: string) => void;
  70927. /**
  70928. * Gets current log cache (list of logs)
  70929. */
  70930. static get LogCache(): string;
  70931. /**
  70932. * Clears the log cache
  70933. */
  70934. static ClearLogCache(): void;
  70935. /**
  70936. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  70937. */
  70938. static set LogLevels(level: number);
  70939. }
  70940. }
  70941. declare module BABYLON {
  70942. /** @hidden */
  70943. export class _TypeStore {
  70944. /** @hidden */
  70945. static RegisteredTypes: {
  70946. [key: string]: Object;
  70947. };
  70948. /** @hidden */
  70949. static GetClass(fqdn: string): any;
  70950. }
  70951. }
  70952. declare module BABYLON {
  70953. /**
  70954. * Helper to manipulate strings
  70955. */
  70956. export class StringTools {
  70957. /**
  70958. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70959. * @param str Source string
  70960. * @param suffix Suffix to search for in the source string
  70961. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70962. */
  70963. static EndsWith(str: string, suffix: string): boolean;
  70964. /**
  70965. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70966. * @param str Source string
  70967. * @param suffix Suffix to search for in the source string
  70968. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70969. */
  70970. static StartsWith(str: string, suffix: string): boolean;
  70971. /**
  70972. * Decodes a buffer into a string
  70973. * @param buffer The buffer to decode
  70974. * @returns The decoded string
  70975. */
  70976. static Decode(buffer: Uint8Array | Uint16Array): string;
  70977. /**
  70978. * Encode a buffer to a base64 string
  70979. * @param buffer defines the buffer to encode
  70980. * @returns the encoded string
  70981. */
  70982. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  70983. }
  70984. }
  70985. declare module BABYLON {
  70986. /**
  70987. * Class containing a set of static utilities functions for deep copy.
  70988. */
  70989. export class DeepCopier {
  70990. /**
  70991. * Tries to copy an object by duplicating every property
  70992. * @param source defines the source object
  70993. * @param destination defines the target object
  70994. * @param doNotCopyList defines a list of properties to avoid
  70995. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  70996. */
  70997. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  70998. }
  70999. }
  71000. declare module BABYLON {
  71001. /**
  71002. * Class containing a set of static utilities functions for precision date
  71003. */
  71004. export class PrecisionDate {
  71005. /**
  71006. * Gets either window.performance.now() if supported or Date.now() else
  71007. */
  71008. static get Now(): number;
  71009. }
  71010. }
  71011. declare module BABYLON {
  71012. /** @hidden */
  71013. export class _DevTools {
  71014. static WarnImport(name: string): string;
  71015. }
  71016. }
  71017. declare module BABYLON {
  71018. /**
  71019. * Interface used to define the mechanism to get data from the network
  71020. */
  71021. export interface IWebRequest {
  71022. /**
  71023. * Returns client's response url
  71024. */
  71025. responseURL: string;
  71026. /**
  71027. * Returns client's status
  71028. */
  71029. status: number;
  71030. /**
  71031. * Returns client's status as a text
  71032. */
  71033. statusText: string;
  71034. }
  71035. }
  71036. declare module BABYLON {
  71037. /**
  71038. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71039. */
  71040. export class WebRequest implements IWebRequest {
  71041. private _xhr;
  71042. /**
  71043. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71044. * i.e. when loading files, where the server/service expects an Authorization header
  71045. */
  71046. static CustomRequestHeaders: {
  71047. [key: string]: string;
  71048. };
  71049. /**
  71050. * Add callback functions in this array to update all the requests before they get sent to the network
  71051. */
  71052. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71053. private _injectCustomRequestHeaders;
  71054. /**
  71055. * Gets or sets a function to be called when loading progress changes
  71056. */
  71057. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71058. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71059. /**
  71060. * Returns client's state
  71061. */
  71062. get readyState(): number;
  71063. /**
  71064. * Returns client's status
  71065. */
  71066. get status(): number;
  71067. /**
  71068. * Returns client's status as a text
  71069. */
  71070. get statusText(): string;
  71071. /**
  71072. * Returns client's response
  71073. */
  71074. get response(): any;
  71075. /**
  71076. * Returns client's response url
  71077. */
  71078. get responseURL(): string;
  71079. /**
  71080. * Returns client's response as text
  71081. */
  71082. get responseText(): string;
  71083. /**
  71084. * Gets or sets the expected response type
  71085. */
  71086. get responseType(): XMLHttpRequestResponseType;
  71087. set responseType(value: XMLHttpRequestResponseType);
  71088. /** @hidden */
  71089. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71090. /** @hidden */
  71091. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71092. /**
  71093. * Cancels any network activity
  71094. */
  71095. abort(): void;
  71096. /**
  71097. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71098. * @param body defines an optional request body
  71099. */
  71100. send(body?: Document | BodyInit | null): void;
  71101. /**
  71102. * Sets the request method, request URL
  71103. * @param method defines the method to use (GET, POST, etc..)
  71104. * @param url defines the url to connect with
  71105. */
  71106. open(method: string, url: string): void;
  71107. /**
  71108. * Sets the value of a request header.
  71109. * @param name The name of the header whose value is to be set
  71110. * @param value The value to set as the body of the header
  71111. */
  71112. setRequestHeader(name: string, value: string): void;
  71113. /**
  71114. * Get the string containing the text of a particular header's value.
  71115. * @param name The name of the header
  71116. * @returns The string containing the text of the given header name
  71117. */
  71118. getResponseHeader(name: string): Nullable<string>;
  71119. }
  71120. }
  71121. declare module BABYLON {
  71122. /**
  71123. * File request interface
  71124. */
  71125. export interface IFileRequest {
  71126. /**
  71127. * Raised when the request is complete (success or error).
  71128. */
  71129. onCompleteObservable: Observable<IFileRequest>;
  71130. /**
  71131. * Aborts the request for a file.
  71132. */
  71133. abort: () => void;
  71134. }
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * Define options used to create a render target texture
  71139. */
  71140. export class RenderTargetCreationOptions {
  71141. /**
  71142. * Specifies is mipmaps must be generated
  71143. */
  71144. generateMipMaps?: boolean;
  71145. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71146. generateDepthBuffer?: boolean;
  71147. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71148. generateStencilBuffer?: boolean;
  71149. /** Defines texture type (int by default) */
  71150. type?: number;
  71151. /** Defines sampling mode (trilinear by default) */
  71152. samplingMode?: number;
  71153. /** Defines format (RGBA by default) */
  71154. format?: number;
  71155. }
  71156. }
  71157. declare module BABYLON {
  71158. /**
  71159. * @hidden
  71160. **/
  71161. export class _TimeToken {
  71162. _startTimeQuery: Nullable<WebGLQuery>;
  71163. _endTimeQuery: Nullable<WebGLQuery>;
  71164. _timeElapsedQuery: Nullable<WebGLQuery>;
  71165. _timeElapsedQueryEnded: boolean;
  71166. }
  71167. }
  71168. declare module BABYLON {
  71169. /** Defines the cross module used constants to avoid circular dependncies */
  71170. export class Constants {
  71171. /** Defines that alpha blending is disabled */
  71172. static readonly ALPHA_DISABLE: number;
  71173. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71174. static readonly ALPHA_ADD: number;
  71175. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71176. static readonly ALPHA_COMBINE: number;
  71177. /** Defines that alpha blending is DEST - SRC * DEST */
  71178. static readonly ALPHA_SUBTRACT: number;
  71179. /** Defines that alpha blending is SRC * DEST */
  71180. static readonly ALPHA_MULTIPLY: number;
  71181. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71182. static readonly ALPHA_MAXIMIZED: number;
  71183. /** Defines that alpha blending is SRC + DEST */
  71184. static readonly ALPHA_ONEONE: number;
  71185. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71186. static readonly ALPHA_PREMULTIPLIED: number;
  71187. /**
  71188. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71189. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71190. */
  71191. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71192. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71193. static readonly ALPHA_INTERPOLATE: number;
  71194. /**
  71195. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71196. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71197. */
  71198. static readonly ALPHA_SCREENMODE: number;
  71199. /**
  71200. * Defines that alpha blending is SRC + DST
  71201. * Alpha will be set to SRC ALPHA + DST ALPHA
  71202. */
  71203. static readonly ALPHA_ONEONE_ONEONE: number;
  71204. /**
  71205. * Defines that alpha blending is SRC * DST ALPHA + DST
  71206. * Alpha will be set to 0
  71207. */
  71208. static readonly ALPHA_ALPHATOCOLOR: number;
  71209. /**
  71210. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71211. */
  71212. static readonly ALPHA_REVERSEONEMINUS: number;
  71213. /**
  71214. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71215. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71216. */
  71217. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71218. /**
  71219. * Defines that alpha blending is SRC + DST
  71220. * Alpha will be set to SRC ALPHA
  71221. */
  71222. static readonly ALPHA_ONEONE_ONEZERO: number;
  71223. /**
  71224. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71225. * Alpha will be set to DST ALPHA
  71226. */
  71227. static readonly ALPHA_EXCLUSION: number;
  71228. /** Defines that alpha blending equation a SUM */
  71229. static readonly ALPHA_EQUATION_ADD: number;
  71230. /** Defines that alpha blending equation a SUBSTRACTION */
  71231. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71232. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71233. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71234. /** Defines that alpha blending equation a MAX operation */
  71235. static readonly ALPHA_EQUATION_MAX: number;
  71236. /** Defines that alpha blending equation a MIN operation */
  71237. static readonly ALPHA_EQUATION_MIN: number;
  71238. /**
  71239. * Defines that alpha blending equation a DARKEN operation:
  71240. * It takes the min of the src and sums the alpha channels.
  71241. */
  71242. static readonly ALPHA_EQUATION_DARKEN: number;
  71243. /** Defines that the ressource is not delayed*/
  71244. static readonly DELAYLOADSTATE_NONE: number;
  71245. /** Defines that the ressource was successfully delay loaded */
  71246. static readonly DELAYLOADSTATE_LOADED: number;
  71247. /** Defines that the ressource is currently delay loading */
  71248. static readonly DELAYLOADSTATE_LOADING: number;
  71249. /** Defines that the ressource is delayed and has not started loading */
  71250. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71251. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71252. static readonly NEVER: number;
  71253. /** 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 */
  71254. static readonly ALWAYS: number;
  71255. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71256. static readonly LESS: number;
  71257. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71258. static readonly EQUAL: number;
  71259. /** 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 */
  71260. static readonly LEQUAL: number;
  71261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71262. static readonly GREATER: number;
  71263. /** 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 */
  71264. static readonly GEQUAL: number;
  71265. /** 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 */
  71266. static readonly NOTEQUAL: number;
  71267. /** Passed to stencilOperation to specify that stencil value must be kept */
  71268. static readonly KEEP: number;
  71269. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71270. static readonly REPLACE: number;
  71271. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71272. static readonly INCR: number;
  71273. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71274. static readonly DECR: number;
  71275. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71276. static readonly INVERT: number;
  71277. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71278. static readonly INCR_WRAP: number;
  71279. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71280. static readonly DECR_WRAP: number;
  71281. /** Texture is not repeating outside of 0..1 UVs */
  71282. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71283. /** Texture is repeating outside of 0..1 UVs */
  71284. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71285. /** Texture is repeating and mirrored */
  71286. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71287. /** ALPHA */
  71288. static readonly TEXTUREFORMAT_ALPHA: number;
  71289. /** LUMINANCE */
  71290. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71291. /** LUMINANCE_ALPHA */
  71292. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71293. /** RGB */
  71294. static readonly TEXTUREFORMAT_RGB: number;
  71295. /** RGBA */
  71296. static readonly TEXTUREFORMAT_RGBA: number;
  71297. /** RED */
  71298. static readonly TEXTUREFORMAT_RED: number;
  71299. /** RED (2nd reference) */
  71300. static readonly TEXTUREFORMAT_R: number;
  71301. /** RG */
  71302. static readonly TEXTUREFORMAT_RG: number;
  71303. /** RED_INTEGER */
  71304. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71305. /** RED_INTEGER (2nd reference) */
  71306. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71307. /** RG_INTEGER */
  71308. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71309. /** RGB_INTEGER */
  71310. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71311. /** RGBA_INTEGER */
  71312. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71313. /** UNSIGNED_BYTE */
  71314. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71315. /** UNSIGNED_BYTE (2nd reference) */
  71316. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71317. /** FLOAT */
  71318. static readonly TEXTURETYPE_FLOAT: number;
  71319. /** HALF_FLOAT */
  71320. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71321. /** BYTE */
  71322. static readonly TEXTURETYPE_BYTE: number;
  71323. /** SHORT */
  71324. static readonly TEXTURETYPE_SHORT: number;
  71325. /** UNSIGNED_SHORT */
  71326. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71327. /** INT */
  71328. static readonly TEXTURETYPE_INT: number;
  71329. /** UNSIGNED_INT */
  71330. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71331. /** UNSIGNED_SHORT_4_4_4_4 */
  71332. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71333. /** UNSIGNED_SHORT_5_5_5_1 */
  71334. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71335. /** UNSIGNED_SHORT_5_6_5 */
  71336. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71337. /** UNSIGNED_INT_2_10_10_10_REV */
  71338. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71339. /** UNSIGNED_INT_24_8 */
  71340. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71341. /** UNSIGNED_INT_10F_11F_11F_REV */
  71342. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71343. /** UNSIGNED_INT_5_9_9_9_REV */
  71344. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71345. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71346. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71347. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71348. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71349. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71350. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71351. /** Trilinear is mag = linear and min = linear and mip = linear */
  71352. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71353. /** nearest is mag = nearest and min = nearest and mip = linear */
  71354. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71356. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71357. /** Trilinear is mag = linear and min = linear and mip = linear */
  71358. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71359. /** mag = nearest and min = nearest and mip = nearest */
  71360. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71361. /** mag = nearest and min = linear and mip = nearest */
  71362. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71363. /** mag = nearest and min = linear and mip = linear */
  71364. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71365. /** mag = nearest and min = linear and mip = none */
  71366. static readonly TEXTURE_NEAREST_LINEAR: number;
  71367. /** mag = nearest and min = nearest and mip = none */
  71368. static readonly TEXTURE_NEAREST_NEAREST: number;
  71369. /** mag = linear and min = nearest and mip = nearest */
  71370. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71371. /** mag = linear and min = nearest and mip = linear */
  71372. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71373. /** mag = linear and min = linear and mip = none */
  71374. static readonly TEXTURE_LINEAR_LINEAR: number;
  71375. /** mag = linear and min = nearest and mip = none */
  71376. static readonly TEXTURE_LINEAR_NEAREST: number;
  71377. /** Explicit coordinates mode */
  71378. static readonly TEXTURE_EXPLICIT_MODE: number;
  71379. /** Spherical coordinates mode */
  71380. static readonly TEXTURE_SPHERICAL_MODE: number;
  71381. /** Planar coordinates mode */
  71382. static readonly TEXTURE_PLANAR_MODE: number;
  71383. /** Cubic coordinates mode */
  71384. static readonly TEXTURE_CUBIC_MODE: number;
  71385. /** Projection coordinates mode */
  71386. static readonly TEXTURE_PROJECTION_MODE: number;
  71387. /** Skybox coordinates mode */
  71388. static readonly TEXTURE_SKYBOX_MODE: number;
  71389. /** Inverse Cubic coordinates mode */
  71390. static readonly TEXTURE_INVCUBIC_MODE: number;
  71391. /** Equirectangular coordinates mode */
  71392. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71393. /** Equirectangular Fixed coordinates mode */
  71394. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71395. /** Equirectangular Fixed Mirrored coordinates mode */
  71396. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71397. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71398. static readonly SCALEMODE_FLOOR: number;
  71399. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71400. static readonly SCALEMODE_NEAREST: number;
  71401. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71402. static readonly SCALEMODE_CEILING: number;
  71403. /**
  71404. * The dirty texture flag value
  71405. */
  71406. static readonly MATERIAL_TextureDirtyFlag: number;
  71407. /**
  71408. * The dirty light flag value
  71409. */
  71410. static readonly MATERIAL_LightDirtyFlag: number;
  71411. /**
  71412. * The dirty fresnel flag value
  71413. */
  71414. static readonly MATERIAL_FresnelDirtyFlag: number;
  71415. /**
  71416. * The dirty attribute flag value
  71417. */
  71418. static readonly MATERIAL_AttributesDirtyFlag: number;
  71419. /**
  71420. * The dirty misc flag value
  71421. */
  71422. static readonly MATERIAL_MiscDirtyFlag: number;
  71423. /**
  71424. * The all dirty flag value
  71425. */
  71426. static readonly MATERIAL_AllDirtyFlag: number;
  71427. /**
  71428. * Returns the triangle fill mode
  71429. */
  71430. static readonly MATERIAL_TriangleFillMode: number;
  71431. /**
  71432. * Returns the wireframe mode
  71433. */
  71434. static readonly MATERIAL_WireFrameFillMode: number;
  71435. /**
  71436. * Returns the point fill mode
  71437. */
  71438. static readonly MATERIAL_PointFillMode: number;
  71439. /**
  71440. * Returns the point list draw mode
  71441. */
  71442. static readonly MATERIAL_PointListDrawMode: number;
  71443. /**
  71444. * Returns the line list draw mode
  71445. */
  71446. static readonly MATERIAL_LineListDrawMode: number;
  71447. /**
  71448. * Returns the line loop draw mode
  71449. */
  71450. static readonly MATERIAL_LineLoopDrawMode: number;
  71451. /**
  71452. * Returns the line strip draw mode
  71453. */
  71454. static readonly MATERIAL_LineStripDrawMode: number;
  71455. /**
  71456. * Returns the triangle strip draw mode
  71457. */
  71458. static readonly MATERIAL_TriangleStripDrawMode: number;
  71459. /**
  71460. * Returns the triangle fan draw mode
  71461. */
  71462. static readonly MATERIAL_TriangleFanDrawMode: number;
  71463. /**
  71464. * Stores the clock-wise side orientation
  71465. */
  71466. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71467. /**
  71468. * Stores the counter clock-wise side orientation
  71469. */
  71470. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71471. /**
  71472. * Nothing
  71473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71474. */
  71475. static readonly ACTION_NothingTrigger: number;
  71476. /**
  71477. * On pick
  71478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71479. */
  71480. static readonly ACTION_OnPickTrigger: number;
  71481. /**
  71482. * On left pick
  71483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71484. */
  71485. static readonly ACTION_OnLeftPickTrigger: number;
  71486. /**
  71487. * On right pick
  71488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71489. */
  71490. static readonly ACTION_OnRightPickTrigger: number;
  71491. /**
  71492. * On center pick
  71493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71494. */
  71495. static readonly ACTION_OnCenterPickTrigger: number;
  71496. /**
  71497. * On pick down
  71498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71499. */
  71500. static readonly ACTION_OnPickDownTrigger: number;
  71501. /**
  71502. * On double pick
  71503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71504. */
  71505. static readonly ACTION_OnDoublePickTrigger: number;
  71506. /**
  71507. * On pick up
  71508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71509. */
  71510. static readonly ACTION_OnPickUpTrigger: number;
  71511. /**
  71512. * On pick out.
  71513. * This trigger will only be raised if you also declared a OnPickDown
  71514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71515. */
  71516. static readonly ACTION_OnPickOutTrigger: number;
  71517. /**
  71518. * On long press
  71519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71520. */
  71521. static readonly ACTION_OnLongPressTrigger: number;
  71522. /**
  71523. * On pointer over
  71524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71525. */
  71526. static readonly ACTION_OnPointerOverTrigger: number;
  71527. /**
  71528. * On pointer out
  71529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71530. */
  71531. static readonly ACTION_OnPointerOutTrigger: number;
  71532. /**
  71533. * On every frame
  71534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71535. */
  71536. static readonly ACTION_OnEveryFrameTrigger: number;
  71537. /**
  71538. * On intersection enter
  71539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71540. */
  71541. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71542. /**
  71543. * On intersection exit
  71544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71545. */
  71546. static readonly ACTION_OnIntersectionExitTrigger: number;
  71547. /**
  71548. * On key down
  71549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71550. */
  71551. static readonly ACTION_OnKeyDownTrigger: number;
  71552. /**
  71553. * On key up
  71554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71555. */
  71556. static readonly ACTION_OnKeyUpTrigger: number;
  71557. /**
  71558. * Billboard mode will only apply to Y axis
  71559. */
  71560. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71561. /**
  71562. * Billboard mode will apply to all axes
  71563. */
  71564. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71565. /**
  71566. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71567. */
  71568. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71569. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71570. * Test order :
  71571. * Is the bounding sphere outside the frustum ?
  71572. * If not, are the bounding box vertices outside the frustum ?
  71573. * It not, then the cullable object is in the frustum.
  71574. */
  71575. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71576. /** Culling strategy : Bounding Sphere Only.
  71577. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71578. * It's also less accurate than the standard because some not visible objects can still be selected.
  71579. * Test : is the bounding sphere outside the frustum ?
  71580. * If not, then the cullable object is in the frustum.
  71581. */
  71582. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71583. /** Culling strategy : Optimistic Inclusion.
  71584. * This in an inclusion test first, then the standard exclusion test.
  71585. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71586. * 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.
  71587. * Anyway, it's as accurate as the standard strategy.
  71588. * Test :
  71589. * Is the cullable object bounding sphere center in the frustum ?
  71590. * If not, apply the default culling strategy.
  71591. */
  71592. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71593. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71594. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71595. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71596. * 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.
  71597. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71598. * Test :
  71599. * Is the cullable object bounding sphere center in the frustum ?
  71600. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71601. */
  71602. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71603. /**
  71604. * No logging while loading
  71605. */
  71606. static readonly SCENELOADER_NO_LOGGING: number;
  71607. /**
  71608. * Minimal logging while loading
  71609. */
  71610. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71611. /**
  71612. * Summary logging while loading
  71613. */
  71614. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71615. /**
  71616. * Detailled logging while loading
  71617. */
  71618. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /**
  71623. * This represents the required contract to create a new type of texture loader.
  71624. */
  71625. export interface IInternalTextureLoader {
  71626. /**
  71627. * Defines wether the loader supports cascade loading the different faces.
  71628. */
  71629. supportCascades: boolean;
  71630. /**
  71631. * This returns if the loader support the current file information.
  71632. * @param extension defines the file extension of the file being loaded
  71633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71634. * @param fallback defines the fallback internal texture if any
  71635. * @param isBase64 defines whether the texture is encoded as a base64
  71636. * @param isBuffer defines whether the texture data are stored as a buffer
  71637. * @returns true if the loader can load the specified file
  71638. */
  71639. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71640. /**
  71641. * Transform the url before loading if required.
  71642. * @param rootUrl the url of the texture
  71643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71644. * @returns the transformed texture
  71645. */
  71646. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71647. /**
  71648. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71649. * @param rootUrl the url of the texture
  71650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71651. * @returns the fallback texture
  71652. */
  71653. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71654. /**
  71655. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71656. * @param data contains the texture data
  71657. * @param texture defines the BabylonJS internal texture
  71658. * @param createPolynomials will be true if polynomials have been requested
  71659. * @param onLoad defines the callback to trigger once the texture is ready
  71660. * @param onError defines the callback to trigger in case of error
  71661. */
  71662. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71663. /**
  71664. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71665. * @param data contains the texture data
  71666. * @param texture defines the BabylonJS internal texture
  71667. * @param callback defines the method to call once ready to upload
  71668. */
  71669. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71670. }
  71671. }
  71672. declare module BABYLON {
  71673. /**
  71674. * Class used to store and describe the pipeline context associated with an effect
  71675. */
  71676. export interface IPipelineContext {
  71677. /**
  71678. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71679. */
  71680. isAsync: boolean;
  71681. /**
  71682. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71683. */
  71684. isReady: boolean;
  71685. /** @hidden */
  71686. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71687. }
  71688. }
  71689. declare module BABYLON {
  71690. /**
  71691. * Class used to store gfx data (like WebGLBuffer)
  71692. */
  71693. export class DataBuffer {
  71694. /**
  71695. * Gets or sets the number of objects referencing this buffer
  71696. */
  71697. references: number;
  71698. /** Gets or sets the size of the underlying buffer */
  71699. capacity: number;
  71700. /**
  71701. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71702. */
  71703. is32Bits: boolean;
  71704. /**
  71705. * Gets the underlying buffer
  71706. */
  71707. get underlyingResource(): any;
  71708. }
  71709. }
  71710. declare module BABYLON {
  71711. /** @hidden */
  71712. export interface IShaderProcessor {
  71713. attributeProcessor?: (attribute: string) => string;
  71714. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71715. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71716. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71717. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71718. lineProcessor?: (line: string, isFragment: boolean) => string;
  71719. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71720. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71721. }
  71722. }
  71723. declare module BABYLON {
  71724. /** @hidden */
  71725. export interface ProcessingOptions {
  71726. defines: string[];
  71727. indexParameters: any;
  71728. isFragment: boolean;
  71729. shouldUseHighPrecisionShader: boolean;
  71730. supportsUniformBuffers: boolean;
  71731. shadersRepository: string;
  71732. includesShadersStore: {
  71733. [key: string]: string;
  71734. };
  71735. processor?: IShaderProcessor;
  71736. version: string;
  71737. platformName: string;
  71738. lookForClosingBracketForUniformBuffer?: boolean;
  71739. }
  71740. }
  71741. declare module BABYLON {
  71742. /** @hidden */
  71743. export class ShaderCodeNode {
  71744. line: string;
  71745. children: ShaderCodeNode[];
  71746. additionalDefineKey?: string;
  71747. additionalDefineValue?: string;
  71748. isValid(preprocessors: {
  71749. [key: string]: string;
  71750. }): boolean;
  71751. process(preprocessors: {
  71752. [key: string]: string;
  71753. }, options: ProcessingOptions): string;
  71754. }
  71755. }
  71756. declare module BABYLON {
  71757. /** @hidden */
  71758. export class ShaderCodeCursor {
  71759. private _lines;
  71760. lineIndex: number;
  71761. get currentLine(): string;
  71762. get canRead(): boolean;
  71763. set lines(value: string[]);
  71764. }
  71765. }
  71766. declare module BABYLON {
  71767. /** @hidden */
  71768. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71769. process(preprocessors: {
  71770. [key: string]: string;
  71771. }, options: ProcessingOptions): string;
  71772. }
  71773. }
  71774. declare module BABYLON {
  71775. /** @hidden */
  71776. export class ShaderDefineExpression {
  71777. isTrue(preprocessors: {
  71778. [key: string]: string;
  71779. }): boolean;
  71780. }
  71781. }
  71782. declare module BABYLON {
  71783. /** @hidden */
  71784. export class ShaderCodeTestNode extends ShaderCodeNode {
  71785. testExpression: ShaderDefineExpression;
  71786. isValid(preprocessors: {
  71787. [key: string]: string;
  71788. }): boolean;
  71789. }
  71790. }
  71791. declare module BABYLON {
  71792. /** @hidden */
  71793. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71794. define: string;
  71795. not: boolean;
  71796. constructor(define: string, not?: boolean);
  71797. isTrue(preprocessors: {
  71798. [key: string]: string;
  71799. }): boolean;
  71800. }
  71801. }
  71802. declare module BABYLON {
  71803. /** @hidden */
  71804. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71805. leftOperand: ShaderDefineExpression;
  71806. rightOperand: ShaderDefineExpression;
  71807. isTrue(preprocessors: {
  71808. [key: string]: string;
  71809. }): boolean;
  71810. }
  71811. }
  71812. declare module BABYLON {
  71813. /** @hidden */
  71814. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71815. leftOperand: ShaderDefineExpression;
  71816. rightOperand: ShaderDefineExpression;
  71817. isTrue(preprocessors: {
  71818. [key: string]: string;
  71819. }): boolean;
  71820. }
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71825. define: string;
  71826. operand: string;
  71827. testValue: string;
  71828. constructor(define: string, operand: string, testValue: string);
  71829. isTrue(preprocessors: {
  71830. [key: string]: string;
  71831. }): boolean;
  71832. }
  71833. }
  71834. declare module BABYLON {
  71835. /**
  71836. * Class used to enable access to offline support
  71837. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71838. */
  71839. export interface IOfflineProvider {
  71840. /**
  71841. * Gets a boolean indicating if scene must be saved in the database
  71842. */
  71843. enableSceneOffline: boolean;
  71844. /**
  71845. * Gets a boolean indicating if textures must be saved in the database
  71846. */
  71847. enableTexturesOffline: boolean;
  71848. /**
  71849. * Open the offline support and make it available
  71850. * @param successCallback defines the callback to call on success
  71851. * @param errorCallback defines the callback to call on error
  71852. */
  71853. open(successCallback: () => void, errorCallback: () => void): void;
  71854. /**
  71855. * Loads an image from the offline support
  71856. * @param url defines the url to load from
  71857. * @param image defines the target DOM image
  71858. */
  71859. loadImage(url: string, image: HTMLImageElement): void;
  71860. /**
  71861. * Loads a file from offline support
  71862. * @param url defines the URL to load from
  71863. * @param sceneLoaded defines a callback to call on success
  71864. * @param progressCallBack defines a callback to call when progress changed
  71865. * @param errorCallback defines a callback to call on error
  71866. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71867. */
  71868. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71869. }
  71870. }
  71871. declare module BABYLON {
  71872. /**
  71873. * Class used to help managing file picking and drag'n'drop
  71874. * File Storage
  71875. */
  71876. export class FilesInputStore {
  71877. /**
  71878. * List of files ready to be loaded
  71879. */
  71880. static FilesToLoad: {
  71881. [key: string]: File;
  71882. };
  71883. }
  71884. }
  71885. declare module BABYLON {
  71886. /**
  71887. * Class used to define a retry strategy when error happens while loading assets
  71888. */
  71889. export class RetryStrategy {
  71890. /**
  71891. * Function used to defines an exponential back off strategy
  71892. * @param maxRetries defines the maximum number of retries (3 by default)
  71893. * @param baseInterval defines the interval between retries
  71894. * @returns the strategy function to use
  71895. */
  71896. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71897. }
  71898. }
  71899. declare module BABYLON {
  71900. /**
  71901. * @ignore
  71902. * Application error to support additional information when loading a file
  71903. */
  71904. export abstract class BaseError extends Error {
  71905. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71906. }
  71907. }
  71908. declare module BABYLON {
  71909. /** @ignore */
  71910. export class LoadFileError extends BaseError {
  71911. request?: WebRequest;
  71912. file?: File;
  71913. /**
  71914. * Creates a new LoadFileError
  71915. * @param message defines the message of the error
  71916. * @param request defines the optional web request
  71917. * @param file defines the optional file
  71918. */
  71919. constructor(message: string, object?: WebRequest | File);
  71920. }
  71921. /** @ignore */
  71922. export class RequestFileError extends BaseError {
  71923. request: WebRequest;
  71924. /**
  71925. * Creates a new LoadFileError
  71926. * @param message defines the message of the error
  71927. * @param request defines the optional web request
  71928. */
  71929. constructor(message: string, request: WebRequest);
  71930. }
  71931. /** @ignore */
  71932. export class ReadFileError extends BaseError {
  71933. file: File;
  71934. /**
  71935. * Creates a new ReadFileError
  71936. * @param message defines the message of the error
  71937. * @param file defines the optional file
  71938. */
  71939. constructor(message: string, file: File);
  71940. }
  71941. /**
  71942. * @hidden
  71943. */
  71944. export class FileTools {
  71945. /**
  71946. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71947. */
  71948. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71949. /**
  71950. * Gets or sets the base URL to use to load assets
  71951. */
  71952. static BaseUrl: string;
  71953. /**
  71954. * Default behaviour for cors in the application.
  71955. * It can be a string if the expected behavior is identical in the entire app.
  71956. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71957. */
  71958. static CorsBehavior: string | ((url: string | string[]) => string);
  71959. /**
  71960. * Gets or sets a function used to pre-process url before using them to load assets
  71961. */
  71962. static PreprocessUrl: (url: string) => string;
  71963. /**
  71964. * Removes unwanted characters from an url
  71965. * @param url defines the url to clean
  71966. * @returns the cleaned url
  71967. */
  71968. private static _CleanUrl;
  71969. /**
  71970. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71971. * @param url define the url we are trying
  71972. * @param element define the dom element where to configure the cors policy
  71973. */
  71974. static SetCorsBehavior(url: string | string[], element: {
  71975. crossOrigin: string | null;
  71976. }): void;
  71977. /**
  71978. * Loads an image as an HTMLImageElement.
  71979. * @param input url string, ArrayBuffer, or Blob to load
  71980. * @param onLoad callback called when the image successfully loads
  71981. * @param onError callback called when the image fails to load
  71982. * @param offlineProvider offline provider for caching
  71983. * @param mimeType optional mime type
  71984. * @returns the HTMLImageElement of the loaded image
  71985. */
  71986. 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>;
  71987. /**
  71988. * Reads a file from a File object
  71989. * @param file defines the file to load
  71990. * @param onSuccess defines the callback to call when data is loaded
  71991. * @param onProgress defines the callback to call during loading process
  71992. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71993. * @param onError defines the callback to call when an error occurs
  71994. * @returns a file request object
  71995. */
  71996. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  71997. /**
  71998. * Loads a file from a url
  71999. * @param url url to load
  72000. * @param onSuccess callback called when the file successfully loads
  72001. * @param onProgress callback called while file is loading (if the server supports this mode)
  72002. * @param offlineProvider defines the offline provider for caching
  72003. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72004. * @param onError callback called when the file fails to load
  72005. * @returns a file request object
  72006. */
  72007. 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;
  72008. /**
  72009. * Loads a file
  72010. * @param url url to load
  72011. * @param onSuccess callback called when the file successfully loads
  72012. * @param onProgress callback called while file is loading (if the server supports this mode)
  72013. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72014. * @param onError callback called when the file fails to load
  72015. * @param onOpened callback called when the web request is opened
  72016. * @returns a file request object
  72017. */
  72018. 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;
  72019. /**
  72020. * Checks if the loaded document was accessed via `file:`-Protocol.
  72021. * @returns boolean
  72022. */
  72023. static IsFileURL(): boolean;
  72024. }
  72025. }
  72026. declare module BABYLON {
  72027. /** @hidden */
  72028. export class ShaderProcessor {
  72029. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72030. private static _ProcessPrecision;
  72031. private static _ExtractOperation;
  72032. private static _BuildSubExpression;
  72033. private static _BuildExpression;
  72034. private static _MoveCursorWithinIf;
  72035. private static _MoveCursor;
  72036. private static _EvaluatePreProcessors;
  72037. private static _PreparePreProcessors;
  72038. private static _ProcessShaderConversion;
  72039. private static _ProcessIncludes;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. /**
  72044. * @hidden
  72045. */
  72046. export interface IColor4Like {
  72047. r: float;
  72048. g: float;
  72049. b: float;
  72050. a: float;
  72051. }
  72052. /**
  72053. * @hidden
  72054. */
  72055. export interface IColor3Like {
  72056. r: float;
  72057. g: float;
  72058. b: float;
  72059. }
  72060. /**
  72061. * @hidden
  72062. */
  72063. export interface IVector4Like {
  72064. x: float;
  72065. y: float;
  72066. z: float;
  72067. w: float;
  72068. }
  72069. /**
  72070. * @hidden
  72071. */
  72072. export interface IVector3Like {
  72073. x: float;
  72074. y: float;
  72075. z: float;
  72076. }
  72077. /**
  72078. * @hidden
  72079. */
  72080. export interface IVector2Like {
  72081. x: float;
  72082. y: float;
  72083. }
  72084. /**
  72085. * @hidden
  72086. */
  72087. export interface IMatrixLike {
  72088. toArray(): DeepImmutable<Float32Array>;
  72089. updateFlag: int;
  72090. }
  72091. /**
  72092. * @hidden
  72093. */
  72094. export interface IViewportLike {
  72095. x: float;
  72096. y: float;
  72097. width: float;
  72098. height: float;
  72099. }
  72100. /**
  72101. * @hidden
  72102. */
  72103. export interface IPlaneLike {
  72104. normal: IVector3Like;
  72105. d: float;
  72106. normalize(): void;
  72107. }
  72108. }
  72109. declare module BABYLON {
  72110. /**
  72111. * Interface used to define common properties for effect fallbacks
  72112. */
  72113. export interface IEffectFallbacks {
  72114. /**
  72115. * Removes the defines that should be removed when falling back.
  72116. * @param currentDefines defines the current define statements for the shader.
  72117. * @param effect defines the current effect we try to compile
  72118. * @returns The resulting defines with defines of the current rank removed.
  72119. */
  72120. reduce(currentDefines: string, effect: Effect): string;
  72121. /**
  72122. * Removes the fallback from the bound mesh.
  72123. */
  72124. unBindMesh(): void;
  72125. /**
  72126. * Checks to see if more fallbacks are still availible.
  72127. */
  72128. hasMoreFallbacks: boolean;
  72129. }
  72130. }
  72131. declare module BABYLON {
  72132. /**
  72133. * Class used to evalaute queries containing `and` and `or` operators
  72134. */
  72135. export class AndOrNotEvaluator {
  72136. /**
  72137. * Evaluate a query
  72138. * @param query defines the query to evaluate
  72139. * @param evaluateCallback defines the callback used to filter result
  72140. * @returns true if the query matches
  72141. */
  72142. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72143. private static _HandleParenthesisContent;
  72144. private static _SimplifyNegation;
  72145. }
  72146. }
  72147. declare module BABYLON {
  72148. /**
  72149. * Class used to store custom tags
  72150. */
  72151. export class Tags {
  72152. /**
  72153. * Adds support for tags on the given object
  72154. * @param obj defines the object to use
  72155. */
  72156. static EnableFor(obj: any): void;
  72157. /**
  72158. * Removes tags support
  72159. * @param obj defines the object to use
  72160. */
  72161. static DisableFor(obj: any): void;
  72162. /**
  72163. * Gets a boolean indicating if the given object has tags
  72164. * @param obj defines the object to use
  72165. * @returns a boolean
  72166. */
  72167. static HasTags(obj: any): boolean;
  72168. /**
  72169. * Gets the tags available on a given object
  72170. * @param obj defines the object to use
  72171. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72172. * @returns the tags
  72173. */
  72174. static GetTags(obj: any, asString?: boolean): any;
  72175. /**
  72176. * Adds tags to an object
  72177. * @param obj defines the object to use
  72178. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72179. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72180. */
  72181. static AddTagsTo(obj: any, tagsString: string): void;
  72182. /**
  72183. * @hidden
  72184. */
  72185. static _AddTagTo(obj: any, tag: string): void;
  72186. /**
  72187. * Removes specific tags from a specific object
  72188. * @param obj defines the object to use
  72189. * @param tagsString defines the tags to remove
  72190. */
  72191. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72192. /**
  72193. * @hidden
  72194. */
  72195. static _RemoveTagFrom(obj: any, tag: string): void;
  72196. /**
  72197. * Defines if tags hosted on an object match a given query
  72198. * @param obj defines the object to use
  72199. * @param tagsQuery defines the tag query
  72200. * @returns a boolean
  72201. */
  72202. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /**
  72207. * Scalar computation library
  72208. */
  72209. export class Scalar {
  72210. /**
  72211. * Two pi constants convenient for computation.
  72212. */
  72213. static TwoPi: number;
  72214. /**
  72215. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72216. * @param a number
  72217. * @param b number
  72218. * @param epsilon (default = 1.401298E-45)
  72219. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72220. */
  72221. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72222. /**
  72223. * Returns a string : the upper case translation of the number i to hexadecimal.
  72224. * @param i number
  72225. * @returns the upper case translation of the number i to hexadecimal.
  72226. */
  72227. static ToHex(i: number): string;
  72228. /**
  72229. * Returns -1 if value is negative and +1 is value is positive.
  72230. * @param value the value
  72231. * @returns the value itself if it's equal to zero.
  72232. */
  72233. static Sign(value: number): number;
  72234. /**
  72235. * Returns the value itself if it's between min and max.
  72236. * Returns min if the value is lower than min.
  72237. * Returns max if the value is greater than max.
  72238. * @param value the value to clmap
  72239. * @param min the min value to clamp to (default: 0)
  72240. * @param max the max value to clamp to (default: 1)
  72241. * @returns the clamped value
  72242. */
  72243. static Clamp(value: number, min?: number, max?: number): number;
  72244. /**
  72245. * the log2 of value.
  72246. * @param value the value to compute log2 of
  72247. * @returns the log2 of value.
  72248. */
  72249. static Log2(value: number): number;
  72250. /**
  72251. * Loops the value, so that it is never larger than length and never smaller than 0.
  72252. *
  72253. * This is similar to the modulo operator but it works with floating point numbers.
  72254. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72255. * With t = 5 and length = 2.5, the result would be 0.0.
  72256. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72257. * @param value the value
  72258. * @param length the length
  72259. * @returns the looped value
  72260. */
  72261. static Repeat(value: number, length: number): number;
  72262. /**
  72263. * Normalize the value between 0.0 and 1.0 using min and max values
  72264. * @param value value to normalize
  72265. * @param min max to normalize between
  72266. * @param max min to normalize between
  72267. * @returns the normalized value
  72268. */
  72269. static Normalize(value: number, min: number, max: number): number;
  72270. /**
  72271. * Denormalize the value from 0.0 and 1.0 using min and max values
  72272. * @param normalized value to denormalize
  72273. * @param min max to denormalize between
  72274. * @param max min to denormalize between
  72275. * @returns the denormalized value
  72276. */
  72277. static Denormalize(normalized: number, min: number, max: number): number;
  72278. /**
  72279. * Calculates the shortest difference between two given angles given in degrees.
  72280. * @param current current angle in degrees
  72281. * @param target target angle in degrees
  72282. * @returns the delta
  72283. */
  72284. static DeltaAngle(current: number, target: number): number;
  72285. /**
  72286. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72287. * @param tx value
  72288. * @param length length
  72289. * @returns The returned value will move back and forth between 0 and length
  72290. */
  72291. static PingPong(tx: number, length: number): number;
  72292. /**
  72293. * Interpolates between min and max with smoothing at the limits.
  72294. *
  72295. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72296. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72297. * @param from from
  72298. * @param to to
  72299. * @param tx value
  72300. * @returns the smooth stepped value
  72301. */
  72302. static SmoothStep(from: number, to: number, tx: number): number;
  72303. /**
  72304. * Moves a value current towards target.
  72305. *
  72306. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72307. * Negative values of maxDelta pushes the value away from target.
  72308. * @param current current value
  72309. * @param target target value
  72310. * @param maxDelta max distance to move
  72311. * @returns resulting value
  72312. */
  72313. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72314. /**
  72315. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72316. *
  72317. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72318. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72319. * @param current current value
  72320. * @param target target value
  72321. * @param maxDelta max distance to move
  72322. * @returns resulting angle
  72323. */
  72324. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72325. /**
  72326. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72327. * @param start start value
  72328. * @param end target value
  72329. * @param amount amount to lerp between
  72330. * @returns the lerped value
  72331. */
  72332. static Lerp(start: number, end: number, amount: number): number;
  72333. /**
  72334. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72335. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72336. * @param start start value
  72337. * @param end target value
  72338. * @param amount amount to lerp between
  72339. * @returns the lerped value
  72340. */
  72341. static LerpAngle(start: number, end: number, amount: number): number;
  72342. /**
  72343. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72344. * @param a start value
  72345. * @param b target value
  72346. * @param value value between a and b
  72347. * @returns the inverseLerp value
  72348. */
  72349. static InverseLerp(a: number, b: number, value: number): number;
  72350. /**
  72351. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72352. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72353. * @param value1 spline value
  72354. * @param tangent1 spline value
  72355. * @param value2 spline value
  72356. * @param tangent2 spline value
  72357. * @param amount input value
  72358. * @returns hermite result
  72359. */
  72360. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72361. /**
  72362. * Returns a random float number between and min and max values
  72363. * @param min min value of random
  72364. * @param max max value of random
  72365. * @returns random value
  72366. */
  72367. static RandomRange(min: number, max: number): number;
  72368. /**
  72369. * This function returns percentage of a number in a given range.
  72370. *
  72371. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72372. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72373. * @param number to convert to percentage
  72374. * @param min min range
  72375. * @param max max range
  72376. * @returns the percentage
  72377. */
  72378. static RangeToPercent(number: number, min: number, max: number): number;
  72379. /**
  72380. * This function returns number that corresponds to the percentage in a given range.
  72381. *
  72382. * PercentToRange(0.34,0,100) will return 34.
  72383. * @param percent to convert to number
  72384. * @param min min range
  72385. * @param max max range
  72386. * @returns the number
  72387. */
  72388. static PercentToRange(percent: number, min: number, max: number): number;
  72389. /**
  72390. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72391. * @param angle The angle to normalize in radian.
  72392. * @return The converted angle.
  72393. */
  72394. static NormalizeRadians(angle: number): number;
  72395. }
  72396. }
  72397. declare module BABYLON {
  72398. /**
  72399. * Constant used to convert a value to gamma space
  72400. * @ignorenaming
  72401. */
  72402. export const ToGammaSpace: number;
  72403. /**
  72404. * Constant used to convert a value to linear space
  72405. * @ignorenaming
  72406. */
  72407. export const ToLinearSpace = 2.2;
  72408. /**
  72409. * Constant used to define the minimal number value in Babylon.js
  72410. * @ignorenaming
  72411. */
  72412. let Epsilon: number;
  72413. }
  72414. declare module BABYLON {
  72415. /**
  72416. * Class used to represent a viewport on screen
  72417. */
  72418. export class Viewport {
  72419. /** viewport left coordinate */
  72420. x: number;
  72421. /** viewport top coordinate */
  72422. y: number;
  72423. /**viewport width */
  72424. width: number;
  72425. /** viewport height */
  72426. height: number;
  72427. /**
  72428. * Creates a Viewport object located at (x, y) and sized (width, height)
  72429. * @param x defines viewport left coordinate
  72430. * @param y defines viewport top coordinate
  72431. * @param width defines the viewport width
  72432. * @param height defines the viewport height
  72433. */
  72434. constructor(
  72435. /** viewport left coordinate */
  72436. x: number,
  72437. /** viewport top coordinate */
  72438. y: number,
  72439. /**viewport width */
  72440. width: number,
  72441. /** viewport height */
  72442. height: number);
  72443. /**
  72444. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72445. * @param renderWidth defines the rendering width
  72446. * @param renderHeight defines the rendering height
  72447. * @returns a new Viewport
  72448. */
  72449. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72450. /**
  72451. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72452. * @param renderWidth defines the rendering width
  72453. * @param renderHeight defines the rendering height
  72454. * @param ref defines the target viewport
  72455. * @returns the current viewport
  72456. */
  72457. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72458. /**
  72459. * Returns a new Viewport copied from the current one
  72460. * @returns a new Viewport
  72461. */
  72462. clone(): Viewport;
  72463. }
  72464. }
  72465. declare module BABYLON {
  72466. /**
  72467. * Class containing a set of static utilities functions for arrays.
  72468. */
  72469. export class ArrayTools {
  72470. /**
  72471. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72472. * @param size the number of element to construct and put in the array
  72473. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72474. * @returns a new array filled with new objects
  72475. */
  72476. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72477. }
  72478. }
  72479. declare module BABYLON {
  72480. /**
  72481. * Class representing a vector containing 2 coordinates
  72482. */
  72483. export class Vector2 {
  72484. /** defines the first coordinate */
  72485. x: number;
  72486. /** defines the second coordinate */
  72487. y: number;
  72488. /**
  72489. * Creates a new Vector2 from the given x and y coordinates
  72490. * @param x defines the first coordinate
  72491. * @param y defines the second coordinate
  72492. */
  72493. constructor(
  72494. /** defines the first coordinate */
  72495. x?: number,
  72496. /** defines the second coordinate */
  72497. y?: number);
  72498. /**
  72499. * Gets a string with the Vector2 coordinates
  72500. * @returns a string with the Vector2 coordinates
  72501. */
  72502. toString(): string;
  72503. /**
  72504. * Gets class name
  72505. * @returns the string "Vector2"
  72506. */
  72507. getClassName(): string;
  72508. /**
  72509. * Gets current vector hash code
  72510. * @returns the Vector2 hash code as a number
  72511. */
  72512. getHashCode(): number;
  72513. /**
  72514. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72515. * @param array defines the source array
  72516. * @param index defines the offset in source array
  72517. * @returns the current Vector2
  72518. */
  72519. toArray(array: FloatArray, index?: number): Vector2;
  72520. /**
  72521. * Copy the current vector to an array
  72522. * @returns a new array with 2 elements: the Vector2 coordinates.
  72523. */
  72524. asArray(): number[];
  72525. /**
  72526. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72527. * @param source defines the source Vector2
  72528. * @returns the current updated Vector2
  72529. */
  72530. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72531. /**
  72532. * Sets the Vector2 coordinates with the given floats
  72533. * @param x defines the first coordinate
  72534. * @param y defines the second coordinate
  72535. * @returns the current updated Vector2
  72536. */
  72537. copyFromFloats(x: number, y: number): Vector2;
  72538. /**
  72539. * Sets the Vector2 coordinates with the given floats
  72540. * @param x defines the first coordinate
  72541. * @param y defines the second coordinate
  72542. * @returns the current updated Vector2
  72543. */
  72544. set(x: number, y: number): Vector2;
  72545. /**
  72546. * Add another vector with the current one
  72547. * @param otherVector defines the other vector
  72548. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72549. */
  72550. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72551. /**
  72552. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72553. * @param otherVector defines the other vector
  72554. * @param result defines the target vector
  72555. * @returns the unmodified current Vector2
  72556. */
  72557. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72558. /**
  72559. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72560. * @param otherVector defines the other vector
  72561. * @returns the current updated Vector2
  72562. */
  72563. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72564. /**
  72565. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72566. * @param otherVector defines the other vector
  72567. * @returns a new Vector2
  72568. */
  72569. addVector3(otherVector: Vector3): Vector2;
  72570. /**
  72571. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72572. * @param otherVector defines the other vector
  72573. * @returns a new Vector2
  72574. */
  72575. subtract(otherVector: Vector2): Vector2;
  72576. /**
  72577. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72578. * @param otherVector defines the other vector
  72579. * @param result defines the target vector
  72580. * @returns the unmodified current Vector2
  72581. */
  72582. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72583. /**
  72584. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72585. * @param otherVector defines the other vector
  72586. * @returns the current updated Vector2
  72587. */
  72588. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72589. /**
  72590. * Multiplies in place the current Vector2 coordinates by the given ones
  72591. * @param otherVector defines the other vector
  72592. * @returns the current updated Vector2
  72593. */
  72594. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72595. /**
  72596. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72597. * @param otherVector defines the other vector
  72598. * @returns a new Vector2
  72599. */
  72600. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72601. /**
  72602. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72603. * @param otherVector defines the other vector
  72604. * @param result defines the target vector
  72605. * @returns the unmodified current Vector2
  72606. */
  72607. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72608. /**
  72609. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72610. * @param x defines the first coordinate
  72611. * @param y defines the second coordinate
  72612. * @returns a new Vector2
  72613. */
  72614. multiplyByFloats(x: number, y: number): Vector2;
  72615. /**
  72616. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72617. * @param otherVector defines the other vector
  72618. * @returns a new Vector2
  72619. */
  72620. divide(otherVector: Vector2): Vector2;
  72621. /**
  72622. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72623. * @param otherVector defines the other vector
  72624. * @param result defines the target vector
  72625. * @returns the unmodified current Vector2
  72626. */
  72627. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72628. /**
  72629. * Divides the current Vector2 coordinates by the given ones
  72630. * @param otherVector defines the other vector
  72631. * @returns the current updated Vector2
  72632. */
  72633. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72634. /**
  72635. * Gets a new Vector2 with current Vector2 negated coordinates
  72636. * @returns a new Vector2
  72637. */
  72638. negate(): Vector2;
  72639. /**
  72640. * Multiply the Vector2 coordinates by scale
  72641. * @param scale defines the scaling factor
  72642. * @returns the current updated Vector2
  72643. */
  72644. scaleInPlace(scale: number): Vector2;
  72645. /**
  72646. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72647. * @param scale defines the scaling factor
  72648. * @returns a new Vector2
  72649. */
  72650. scale(scale: number): Vector2;
  72651. /**
  72652. * Scale the current Vector2 values by a factor to a given Vector2
  72653. * @param scale defines the scale factor
  72654. * @param result defines the Vector2 object where to store the result
  72655. * @returns the unmodified current Vector2
  72656. */
  72657. scaleToRef(scale: number, result: Vector2): Vector2;
  72658. /**
  72659. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72660. * @param scale defines the scale factor
  72661. * @param result defines the Vector2 object where to store the result
  72662. * @returns the unmodified current Vector2
  72663. */
  72664. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72665. /**
  72666. * Gets a boolean if two vectors are equals
  72667. * @param otherVector defines the other vector
  72668. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72669. */
  72670. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72671. /**
  72672. * Gets a boolean if two vectors are equals (using an epsilon value)
  72673. * @param otherVector defines the other vector
  72674. * @param epsilon defines the minimal distance to consider equality
  72675. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72676. */
  72677. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72678. /**
  72679. * Gets a new Vector2 from current Vector2 floored values
  72680. * @returns a new Vector2
  72681. */
  72682. floor(): Vector2;
  72683. /**
  72684. * Gets a new Vector2 from current Vector2 floored values
  72685. * @returns a new Vector2
  72686. */
  72687. fract(): Vector2;
  72688. /**
  72689. * Gets the length of the vector
  72690. * @returns the vector length (float)
  72691. */
  72692. length(): number;
  72693. /**
  72694. * Gets the vector squared length
  72695. * @returns the vector squared length (float)
  72696. */
  72697. lengthSquared(): number;
  72698. /**
  72699. * Normalize the vector
  72700. * @returns the current updated Vector2
  72701. */
  72702. normalize(): Vector2;
  72703. /**
  72704. * Gets a new Vector2 copied from the Vector2
  72705. * @returns a new Vector2
  72706. */
  72707. clone(): Vector2;
  72708. /**
  72709. * Gets a new Vector2(0, 0)
  72710. * @returns a new Vector2
  72711. */
  72712. static Zero(): Vector2;
  72713. /**
  72714. * Gets a new Vector2(1, 1)
  72715. * @returns a new Vector2
  72716. */
  72717. static One(): Vector2;
  72718. /**
  72719. * Gets a new Vector2 set from the given index element of the given array
  72720. * @param array defines the data source
  72721. * @param offset defines the offset in the data source
  72722. * @returns a new Vector2
  72723. */
  72724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72725. /**
  72726. * Sets "result" from the given index element of the given array
  72727. * @param array defines the data source
  72728. * @param offset defines the offset in the data source
  72729. * @param result defines the target vector
  72730. */
  72731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72732. /**
  72733. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72734. * @param value1 defines 1st point of control
  72735. * @param value2 defines 2nd point of control
  72736. * @param value3 defines 3rd point of control
  72737. * @param value4 defines 4th point of control
  72738. * @param amount defines the interpolation factor
  72739. * @returns a new Vector2
  72740. */
  72741. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72742. /**
  72743. * 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".
  72744. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72745. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72746. * @param value defines the value to clamp
  72747. * @param min defines the lower limit
  72748. * @param max defines the upper limit
  72749. * @returns a new Vector2
  72750. */
  72751. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72752. /**
  72753. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72754. * @param value1 defines the 1st control point
  72755. * @param tangent1 defines the outgoing tangent
  72756. * @param value2 defines the 2nd control point
  72757. * @param tangent2 defines the incoming tangent
  72758. * @param amount defines the interpolation factor
  72759. * @returns a new Vector2
  72760. */
  72761. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72762. /**
  72763. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72764. * @param start defines the start vector
  72765. * @param end defines the end vector
  72766. * @param amount defines the interpolation factor
  72767. * @returns a new Vector2
  72768. */
  72769. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72770. /**
  72771. * Gets the dot product of the vector "left" and the vector "right"
  72772. * @param left defines first vector
  72773. * @param right defines second vector
  72774. * @returns the dot product (float)
  72775. */
  72776. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72777. /**
  72778. * Returns a new Vector2 equal to the normalized given vector
  72779. * @param vector defines the vector to normalize
  72780. * @returns a new Vector2
  72781. */
  72782. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72783. /**
  72784. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72785. * @param left defines 1st vector
  72786. * @param right defines 2nd vector
  72787. * @returns a new Vector2
  72788. */
  72789. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72790. /**
  72791. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72792. * @param left defines 1st vector
  72793. * @param right defines 2nd vector
  72794. * @returns a new Vector2
  72795. */
  72796. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72797. /**
  72798. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72799. * @param vector defines the vector to transform
  72800. * @param transformation defines the matrix to apply
  72801. * @returns a new Vector2
  72802. */
  72803. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72804. /**
  72805. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72806. * @param vector defines the vector to transform
  72807. * @param transformation defines the matrix to apply
  72808. * @param result defines the target vector
  72809. */
  72810. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72811. /**
  72812. * Determines if a given vector is included in a triangle
  72813. * @param p defines the vector to test
  72814. * @param p0 defines 1st triangle point
  72815. * @param p1 defines 2nd triangle point
  72816. * @param p2 defines 3rd triangle point
  72817. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72818. */
  72819. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72820. /**
  72821. * Gets the distance between the vectors "value1" and "value2"
  72822. * @param value1 defines first vector
  72823. * @param value2 defines second vector
  72824. * @returns the distance between vectors
  72825. */
  72826. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72827. /**
  72828. * Returns the squared distance between the vectors "value1" and "value2"
  72829. * @param value1 defines first vector
  72830. * @param value2 defines second vector
  72831. * @returns the squared distance between vectors
  72832. */
  72833. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72834. /**
  72835. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72836. * @param value1 defines first vector
  72837. * @param value2 defines second vector
  72838. * @returns a new Vector2
  72839. */
  72840. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72841. /**
  72842. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72843. * @param p defines the middle point
  72844. * @param segA defines one point of the segment
  72845. * @param segB defines the other point of the segment
  72846. * @returns the shortest distance
  72847. */
  72848. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72849. }
  72850. /**
  72851. * Class used to store (x,y,z) vector representation
  72852. * A Vector3 is the main object used in 3D geometry
  72853. * It can represent etiher the coordinates of a point the space, either a direction
  72854. * Reminder: js uses a left handed forward facing system
  72855. */
  72856. export class Vector3 {
  72857. /**
  72858. * Defines the first coordinates (on X axis)
  72859. */
  72860. x: number;
  72861. /**
  72862. * Defines the second coordinates (on Y axis)
  72863. */
  72864. y: number;
  72865. /**
  72866. * Defines the third coordinates (on Z axis)
  72867. */
  72868. z: number;
  72869. private static _UpReadOnly;
  72870. private static _ZeroReadOnly;
  72871. /**
  72872. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72873. * @param x defines the first coordinates (on X axis)
  72874. * @param y defines the second coordinates (on Y axis)
  72875. * @param z defines the third coordinates (on Z axis)
  72876. */
  72877. constructor(
  72878. /**
  72879. * Defines the first coordinates (on X axis)
  72880. */
  72881. x?: number,
  72882. /**
  72883. * Defines the second coordinates (on Y axis)
  72884. */
  72885. y?: number,
  72886. /**
  72887. * Defines the third coordinates (on Z axis)
  72888. */
  72889. z?: number);
  72890. /**
  72891. * Creates a string representation of the Vector3
  72892. * @returns a string with the Vector3 coordinates.
  72893. */
  72894. toString(): string;
  72895. /**
  72896. * Gets the class name
  72897. * @returns the string "Vector3"
  72898. */
  72899. getClassName(): string;
  72900. /**
  72901. * Creates the Vector3 hash code
  72902. * @returns a number which tends to be unique between Vector3 instances
  72903. */
  72904. getHashCode(): number;
  72905. /**
  72906. * Creates an array containing three elements : the coordinates of the Vector3
  72907. * @returns a new array of numbers
  72908. */
  72909. asArray(): number[];
  72910. /**
  72911. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72912. * @param array defines the destination array
  72913. * @param index defines the offset in the destination array
  72914. * @returns the current Vector3
  72915. */
  72916. toArray(array: FloatArray, index?: number): Vector3;
  72917. /**
  72918. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72919. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72920. */
  72921. toQuaternion(): Quaternion;
  72922. /**
  72923. * Adds the given vector to the current Vector3
  72924. * @param otherVector defines the second operand
  72925. * @returns the current updated Vector3
  72926. */
  72927. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72928. /**
  72929. * Adds the given coordinates to the current Vector3
  72930. * @param x defines the x coordinate of the operand
  72931. * @param y defines the y coordinate of the operand
  72932. * @param z defines the z coordinate of the operand
  72933. * @returns the current updated Vector3
  72934. */
  72935. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72936. /**
  72937. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72938. * @param otherVector defines the second operand
  72939. * @returns the resulting Vector3
  72940. */
  72941. add(otherVector: DeepImmutable<Vector3>): Vector3;
  72942. /**
  72943. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72944. * @param otherVector defines the second operand
  72945. * @param result defines the Vector3 object where to store the result
  72946. * @returns the current Vector3
  72947. */
  72948. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72949. /**
  72950. * Subtract the given vector from the current Vector3
  72951. * @param otherVector defines the second operand
  72952. * @returns the current updated Vector3
  72953. */
  72954. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72955. /**
  72956. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72957. * @param otherVector defines the second operand
  72958. * @returns the resulting Vector3
  72959. */
  72960. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  72961. /**
  72962. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72963. * @param otherVector defines the second operand
  72964. * @param result defines the Vector3 object where to store the result
  72965. * @returns the current Vector3
  72966. */
  72967. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72968. /**
  72969. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72970. * @param x defines the x coordinate of the operand
  72971. * @param y defines the y coordinate of the operand
  72972. * @param z defines the z coordinate of the operand
  72973. * @returns the resulting Vector3
  72974. */
  72975. subtractFromFloats(x: number, y: number, z: number): Vector3;
  72976. /**
  72977. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72978. * @param x defines the x coordinate of the operand
  72979. * @param y defines the y coordinate of the operand
  72980. * @param z defines the z coordinate of the operand
  72981. * @param result defines the Vector3 object where to store the result
  72982. * @returns the current Vector3
  72983. */
  72984. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  72985. /**
  72986. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72987. * @returns a new Vector3
  72988. */
  72989. negate(): Vector3;
  72990. /**
  72991. * Multiplies the Vector3 coordinates by the float "scale"
  72992. * @param scale defines the multiplier factor
  72993. * @returns the current updated Vector3
  72994. */
  72995. scaleInPlace(scale: number): Vector3;
  72996. /**
  72997. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72998. * @param scale defines the multiplier factor
  72999. * @returns a new Vector3
  73000. */
  73001. scale(scale: number): Vector3;
  73002. /**
  73003. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73004. * @param scale defines the multiplier factor
  73005. * @param result defines the Vector3 object where to store the result
  73006. * @returns the current Vector3
  73007. */
  73008. scaleToRef(scale: number, result: Vector3): Vector3;
  73009. /**
  73010. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73011. * @param scale defines the scale factor
  73012. * @param result defines the Vector3 object where to store the result
  73013. * @returns the unmodified current Vector3
  73014. */
  73015. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73016. /**
  73017. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73018. * @param otherVector defines the second operand
  73019. * @returns true if both vectors are equals
  73020. */
  73021. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73022. /**
  73023. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73024. * @param otherVector defines the second operand
  73025. * @param epsilon defines the minimal distance to define values as equals
  73026. * @returns true if both vectors are distant less than epsilon
  73027. */
  73028. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73029. /**
  73030. * Returns true if the current Vector3 coordinates equals the given floats
  73031. * @param x defines the x coordinate of the operand
  73032. * @param y defines the y coordinate of the operand
  73033. * @param z defines the z coordinate of the operand
  73034. * @returns true if both vectors are equals
  73035. */
  73036. equalsToFloats(x: number, y: number, z: number): boolean;
  73037. /**
  73038. * Multiplies the current Vector3 coordinates by the given ones
  73039. * @param otherVector defines the second operand
  73040. * @returns the current updated Vector3
  73041. */
  73042. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73043. /**
  73044. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73045. * @param otherVector defines the second operand
  73046. * @returns the new Vector3
  73047. */
  73048. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73049. /**
  73050. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73051. * @param otherVector defines the second operand
  73052. * @param result defines the Vector3 object where to store the result
  73053. * @returns the current Vector3
  73054. */
  73055. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73056. /**
  73057. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73058. * @param x defines the x coordinate of the operand
  73059. * @param y defines the y coordinate of the operand
  73060. * @param z defines the z coordinate of the operand
  73061. * @returns the new Vector3
  73062. */
  73063. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73064. /**
  73065. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73066. * @param otherVector defines the second operand
  73067. * @returns the new Vector3
  73068. */
  73069. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73070. /**
  73071. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73072. * @param otherVector defines the second operand
  73073. * @param result defines the Vector3 object where to store the result
  73074. * @returns the current Vector3
  73075. */
  73076. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73077. /**
  73078. * Divides the current Vector3 coordinates by the given ones.
  73079. * @param otherVector defines the second operand
  73080. * @returns the current updated Vector3
  73081. */
  73082. divideInPlace(otherVector: Vector3): Vector3;
  73083. /**
  73084. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73085. * @param other defines the second operand
  73086. * @returns the current updated Vector3
  73087. */
  73088. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73089. /**
  73090. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73091. * @param other defines the second operand
  73092. * @returns the current updated Vector3
  73093. */
  73094. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73095. /**
  73096. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73097. * @param x defines the x coordinate of the operand
  73098. * @param y defines the y coordinate of the operand
  73099. * @param z defines the z coordinate of the operand
  73100. * @returns the current updated Vector3
  73101. */
  73102. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73103. /**
  73104. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73105. * @param x defines the x coordinate of the operand
  73106. * @param y defines the y coordinate of the operand
  73107. * @param z defines the z coordinate of the operand
  73108. * @returns the current updated Vector3
  73109. */
  73110. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73111. /**
  73112. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73113. * Check if is non uniform within a certain amount of decimal places to account for this
  73114. * @param epsilon the amount the values can differ
  73115. * @returns if the the vector is non uniform to a certain number of decimal places
  73116. */
  73117. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73118. /**
  73119. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73120. */
  73121. get isNonUniform(): boolean;
  73122. /**
  73123. * Gets a new Vector3 from current Vector3 floored values
  73124. * @returns a new Vector3
  73125. */
  73126. floor(): Vector3;
  73127. /**
  73128. * Gets a new Vector3 from current Vector3 floored values
  73129. * @returns a new Vector3
  73130. */
  73131. fract(): Vector3;
  73132. /**
  73133. * Gets the length of the Vector3
  73134. * @returns the length of the Vector3
  73135. */
  73136. length(): number;
  73137. /**
  73138. * Gets the squared length of the Vector3
  73139. * @returns squared length of the Vector3
  73140. */
  73141. lengthSquared(): number;
  73142. /**
  73143. * Normalize the current Vector3.
  73144. * Please note that this is an in place operation.
  73145. * @returns the current updated Vector3
  73146. */
  73147. normalize(): Vector3;
  73148. /**
  73149. * Reorders the x y z properties of the vector in place
  73150. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73151. * @returns the current updated vector
  73152. */
  73153. reorderInPlace(order: string): this;
  73154. /**
  73155. * Rotates the vector around 0,0,0 by a quaternion
  73156. * @param quaternion the rotation quaternion
  73157. * @param result vector to store the result
  73158. * @returns the resulting vector
  73159. */
  73160. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73161. /**
  73162. * Rotates a vector around a given point
  73163. * @param quaternion the rotation quaternion
  73164. * @param point the point to rotate around
  73165. * @param result vector to store the result
  73166. * @returns the resulting vector
  73167. */
  73168. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73169. /**
  73170. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73171. * The cross product is then orthogonal to both current and "other"
  73172. * @param other defines the right operand
  73173. * @returns the cross product
  73174. */
  73175. cross(other: Vector3): Vector3;
  73176. /**
  73177. * Normalize the current Vector3 with the given input length.
  73178. * Please note that this is an in place operation.
  73179. * @param len the length of the vector
  73180. * @returns the current updated Vector3
  73181. */
  73182. normalizeFromLength(len: number): Vector3;
  73183. /**
  73184. * Normalize the current Vector3 to a new vector
  73185. * @returns the new Vector3
  73186. */
  73187. normalizeToNew(): Vector3;
  73188. /**
  73189. * Normalize the current Vector3 to the reference
  73190. * @param reference define the Vector3 to update
  73191. * @returns the updated Vector3
  73192. */
  73193. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73194. /**
  73195. * Creates a new Vector3 copied from the current Vector3
  73196. * @returns the new Vector3
  73197. */
  73198. clone(): Vector3;
  73199. /**
  73200. * Copies the given vector coordinates to the current Vector3 ones
  73201. * @param source defines the source Vector3
  73202. * @returns the current updated Vector3
  73203. */
  73204. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73205. /**
  73206. * Copies the given floats to the current Vector3 coordinates
  73207. * @param x defines the x coordinate of the operand
  73208. * @param y defines the y coordinate of the operand
  73209. * @param z defines the z coordinate of the operand
  73210. * @returns the current updated Vector3
  73211. */
  73212. copyFromFloats(x: number, y: number, z: number): Vector3;
  73213. /**
  73214. * Copies the given floats to the current Vector3 coordinates
  73215. * @param x defines the x coordinate of the operand
  73216. * @param y defines the y coordinate of the operand
  73217. * @param z defines the z coordinate of the operand
  73218. * @returns the current updated Vector3
  73219. */
  73220. set(x: number, y: number, z: number): Vector3;
  73221. /**
  73222. * Copies the given float to the current Vector3 coordinates
  73223. * @param v defines the x, y and z coordinates of the operand
  73224. * @returns the current updated Vector3
  73225. */
  73226. setAll(v: number): Vector3;
  73227. /**
  73228. * Get the clip factor between two vectors
  73229. * @param vector0 defines the first operand
  73230. * @param vector1 defines the second operand
  73231. * @param axis defines the axis to use
  73232. * @param size defines the size along the axis
  73233. * @returns the clip factor
  73234. */
  73235. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73236. /**
  73237. * Get angle between two vectors
  73238. * @param vector0 angle between vector0 and vector1
  73239. * @param vector1 angle between vector0 and vector1
  73240. * @param normal direction of the normal
  73241. * @return the angle between vector0 and vector1
  73242. */
  73243. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73244. /**
  73245. * Returns a new Vector3 set from the index "offset" of the given array
  73246. * @param array defines the source array
  73247. * @param offset defines the offset in the source array
  73248. * @returns the new Vector3
  73249. */
  73250. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73251. /**
  73252. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73253. * @param array defines the source array
  73254. * @param offset defines the offset in the source array
  73255. * @returns the new Vector3
  73256. * @deprecated Please use FromArray instead.
  73257. */
  73258. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73259. /**
  73260. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73261. * @param array defines the source array
  73262. * @param offset defines the offset in the source array
  73263. * @param result defines the Vector3 where to store the result
  73264. */
  73265. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73266. /**
  73267. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73268. * @param array defines the source array
  73269. * @param offset defines the offset in the source array
  73270. * @param result defines the Vector3 where to store the result
  73271. * @deprecated Please use FromArrayToRef instead.
  73272. */
  73273. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73274. /**
  73275. * Sets the given vector "result" with the given floats.
  73276. * @param x defines the x coordinate of the source
  73277. * @param y defines the y coordinate of the source
  73278. * @param z defines the z coordinate of the source
  73279. * @param result defines the Vector3 where to store the result
  73280. */
  73281. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73282. /**
  73283. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73284. * @returns a new empty Vector3
  73285. */
  73286. static Zero(): Vector3;
  73287. /**
  73288. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73289. * @returns a new unit Vector3
  73290. */
  73291. static One(): Vector3;
  73292. /**
  73293. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73294. * @returns a new up Vector3
  73295. */
  73296. static Up(): Vector3;
  73297. /**
  73298. * Gets a up Vector3 that must not be updated
  73299. */
  73300. static get UpReadOnly(): DeepImmutable<Vector3>;
  73301. /**
  73302. * Gets a zero Vector3 that must not be updated
  73303. */
  73304. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73305. /**
  73306. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73307. * @returns a new down Vector3
  73308. */
  73309. static Down(): Vector3;
  73310. /**
  73311. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73312. * @returns a new forward Vector3
  73313. */
  73314. static Forward(): Vector3;
  73315. /**
  73316. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73317. * @returns a new forward Vector3
  73318. */
  73319. static Backward(): Vector3;
  73320. /**
  73321. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73322. * @returns a new right Vector3
  73323. */
  73324. static Right(): Vector3;
  73325. /**
  73326. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73327. * @returns a new left Vector3
  73328. */
  73329. static Left(): Vector3;
  73330. /**
  73331. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73332. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73333. * @param vector defines the Vector3 to transform
  73334. * @param transformation defines the transformation matrix
  73335. * @returns the transformed Vector3
  73336. */
  73337. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73338. /**
  73339. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73340. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73341. * @param vector defines the Vector3 to transform
  73342. * @param transformation defines the transformation matrix
  73343. * @param result defines the Vector3 where to store the result
  73344. */
  73345. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73346. /**
  73347. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73348. * This method computes tranformed coordinates only, not transformed direction vectors
  73349. * @param x define the x coordinate of the source vector
  73350. * @param y define the y coordinate of the source vector
  73351. * @param z define the z coordinate of the source vector
  73352. * @param transformation defines the transformation matrix
  73353. * @param result defines the Vector3 where to store the result
  73354. */
  73355. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73356. /**
  73357. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73358. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73359. * @param vector defines the Vector3 to transform
  73360. * @param transformation defines the transformation matrix
  73361. * @returns the new Vector3
  73362. */
  73363. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73364. /**
  73365. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73366. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73367. * @param vector defines the Vector3 to transform
  73368. * @param transformation defines the transformation matrix
  73369. * @param result defines the Vector3 where to store the result
  73370. */
  73371. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73372. /**
  73373. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73374. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73375. * @param x define the x coordinate of the source vector
  73376. * @param y define the y coordinate of the source vector
  73377. * @param z define the z coordinate of the source vector
  73378. * @param transformation defines the transformation matrix
  73379. * @param result defines the Vector3 where to store the result
  73380. */
  73381. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73382. /**
  73383. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73384. * @param value1 defines the first control point
  73385. * @param value2 defines the second control point
  73386. * @param value3 defines the third control point
  73387. * @param value4 defines the fourth control point
  73388. * @param amount defines the amount on the spline to use
  73389. * @returns the new Vector3
  73390. */
  73391. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73392. /**
  73393. * 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"
  73394. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73395. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73396. * @param value defines the current value
  73397. * @param min defines the lower range value
  73398. * @param max defines the upper range value
  73399. * @returns the new Vector3
  73400. */
  73401. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73402. /**
  73403. * 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"
  73404. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73405. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73406. * @param value defines the current value
  73407. * @param min defines the lower range value
  73408. * @param max defines the upper range value
  73409. * @param result defines the Vector3 where to store the result
  73410. */
  73411. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73412. /**
  73413. * Checks if a given vector is inside a specific range
  73414. * @param v defines the vector to test
  73415. * @param min defines the minimum range
  73416. * @param max defines the maximum range
  73417. */
  73418. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73419. /**
  73420. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73421. * @param value1 defines the first control point
  73422. * @param tangent1 defines the first tangent vector
  73423. * @param value2 defines the second control point
  73424. * @param tangent2 defines the second tangent vector
  73425. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73426. * @returns the new Vector3
  73427. */
  73428. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73429. /**
  73430. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73431. * @param start defines the start value
  73432. * @param end defines the end value
  73433. * @param amount max defines amount between both (between 0 and 1)
  73434. * @returns the new Vector3
  73435. */
  73436. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73437. /**
  73438. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73439. * @param start defines the start value
  73440. * @param end defines the end value
  73441. * @param amount max defines amount between both (between 0 and 1)
  73442. * @param result defines the Vector3 where to store the result
  73443. */
  73444. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73445. /**
  73446. * Returns the dot product (float) between the vectors "left" and "right"
  73447. * @param left defines the left operand
  73448. * @param right defines the right operand
  73449. * @returns the dot product
  73450. */
  73451. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73452. /**
  73453. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73454. * The cross product is then orthogonal to both "left" and "right"
  73455. * @param left defines the left operand
  73456. * @param right defines the right operand
  73457. * @returns the cross product
  73458. */
  73459. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73460. /**
  73461. * Sets the given vector "result" with the cross product of "left" and "right"
  73462. * The cross product is then orthogonal to both "left" and "right"
  73463. * @param left defines the left operand
  73464. * @param right defines the right operand
  73465. * @param result defines the Vector3 where to store the result
  73466. */
  73467. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73468. /**
  73469. * Returns a new Vector3 as the normalization of the given vector
  73470. * @param vector defines the Vector3 to normalize
  73471. * @returns the new Vector3
  73472. */
  73473. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73474. /**
  73475. * Sets the given vector "result" with the normalization of the given first vector
  73476. * @param vector defines the Vector3 to normalize
  73477. * @param result defines the Vector3 where to store the result
  73478. */
  73479. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73480. /**
  73481. * Project a Vector3 onto screen space
  73482. * @param vector defines the Vector3 to project
  73483. * @param world defines the world matrix to use
  73484. * @param transform defines the transform (view x projection) matrix to use
  73485. * @param viewport defines the screen viewport to use
  73486. * @returns the new Vector3
  73487. */
  73488. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73489. /** @hidden */
  73490. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73491. /**
  73492. * Unproject from screen space to object space
  73493. * @param source defines the screen space Vector3 to use
  73494. * @param viewportWidth defines the current width of the viewport
  73495. * @param viewportHeight defines the current height of the viewport
  73496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73497. * @param transform defines the transform (view x projection) matrix to use
  73498. * @returns the new Vector3
  73499. */
  73500. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73501. /**
  73502. * Unproject from screen space to object space
  73503. * @param source defines the screen space Vector3 to use
  73504. * @param viewportWidth defines the current width of the viewport
  73505. * @param viewportHeight defines the current height of the viewport
  73506. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73507. * @param view defines the view matrix to use
  73508. * @param projection defines the projection matrix to use
  73509. * @returns the new Vector3
  73510. */
  73511. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73512. /**
  73513. * Unproject from screen space to object space
  73514. * @param source defines the screen space Vector3 to use
  73515. * @param viewportWidth defines the current width of the viewport
  73516. * @param viewportHeight defines the current height of the viewport
  73517. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73518. * @param view defines the view matrix to use
  73519. * @param projection defines the projection matrix to use
  73520. * @param result defines the Vector3 where to store the result
  73521. */
  73522. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73523. /**
  73524. * Unproject from screen space to object space
  73525. * @param sourceX defines the screen space x coordinate to use
  73526. * @param sourceY defines the screen space y coordinate to use
  73527. * @param sourceZ defines the screen space z coordinate to use
  73528. * @param viewportWidth defines the current width of the viewport
  73529. * @param viewportHeight defines the current height of the viewport
  73530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73531. * @param view defines the view matrix to use
  73532. * @param projection defines the projection matrix to use
  73533. * @param result defines the Vector3 where to store the result
  73534. */
  73535. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73536. /**
  73537. * Gets the minimal coordinate values between two Vector3
  73538. * @param left defines the first operand
  73539. * @param right defines the second operand
  73540. * @returns the new Vector3
  73541. */
  73542. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73543. /**
  73544. * Gets the maximal coordinate values between two Vector3
  73545. * @param left defines the first operand
  73546. * @param right defines the second operand
  73547. * @returns the new Vector3
  73548. */
  73549. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73550. /**
  73551. * Returns the distance between the vectors "value1" and "value2"
  73552. * @param value1 defines the first operand
  73553. * @param value2 defines the second operand
  73554. * @returns the distance
  73555. */
  73556. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73557. /**
  73558. * Returns the squared distance between the vectors "value1" and "value2"
  73559. * @param value1 defines the first operand
  73560. * @param value2 defines the second operand
  73561. * @returns the squared distance
  73562. */
  73563. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73564. /**
  73565. * Returns a new Vector3 located at the center between "value1" and "value2"
  73566. * @param value1 defines the first operand
  73567. * @param value2 defines the second operand
  73568. * @returns the new Vector3
  73569. */
  73570. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73571. /**
  73572. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73573. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73574. * to something in order to rotate it from its local system to the given target system
  73575. * Note: axis1, axis2 and axis3 are normalized during this operation
  73576. * @param axis1 defines the first axis
  73577. * @param axis2 defines the second axis
  73578. * @param axis3 defines the third axis
  73579. * @returns a new Vector3
  73580. */
  73581. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73582. /**
  73583. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73584. * @param axis1 defines the first axis
  73585. * @param axis2 defines the second axis
  73586. * @param axis3 defines the third axis
  73587. * @param ref defines the Vector3 where to store the result
  73588. */
  73589. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73590. }
  73591. /**
  73592. * Vector4 class created for EulerAngle class conversion to Quaternion
  73593. */
  73594. export class Vector4 {
  73595. /** x value of the vector */
  73596. x: number;
  73597. /** y value of the vector */
  73598. y: number;
  73599. /** z value of the vector */
  73600. z: number;
  73601. /** w value of the vector */
  73602. w: number;
  73603. /**
  73604. * Creates a Vector4 object from the given floats.
  73605. * @param x x value of the vector
  73606. * @param y y value of the vector
  73607. * @param z z value of the vector
  73608. * @param w w value of the vector
  73609. */
  73610. constructor(
  73611. /** x value of the vector */
  73612. x: number,
  73613. /** y value of the vector */
  73614. y: number,
  73615. /** z value of the vector */
  73616. z: number,
  73617. /** w value of the vector */
  73618. w: number);
  73619. /**
  73620. * Returns the string with the Vector4 coordinates.
  73621. * @returns a string containing all the vector values
  73622. */
  73623. toString(): string;
  73624. /**
  73625. * Returns the string "Vector4".
  73626. * @returns "Vector4"
  73627. */
  73628. getClassName(): string;
  73629. /**
  73630. * Returns the Vector4 hash code.
  73631. * @returns a unique hash code
  73632. */
  73633. getHashCode(): number;
  73634. /**
  73635. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73636. * @returns the resulting array
  73637. */
  73638. asArray(): number[];
  73639. /**
  73640. * Populates the given array from the given index with the Vector4 coordinates.
  73641. * @param array array to populate
  73642. * @param index index of the array to start at (default: 0)
  73643. * @returns the Vector4.
  73644. */
  73645. toArray(array: FloatArray, index?: number): Vector4;
  73646. /**
  73647. * Adds the given vector to the current Vector4.
  73648. * @param otherVector the vector to add
  73649. * @returns the updated Vector4.
  73650. */
  73651. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73652. /**
  73653. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73654. * @param otherVector the vector to add
  73655. * @returns the resulting vector
  73656. */
  73657. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73658. /**
  73659. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73660. * @param otherVector the vector to add
  73661. * @param result the vector to store the result
  73662. * @returns the current Vector4.
  73663. */
  73664. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73665. /**
  73666. * Subtract in place the given vector from the current Vector4.
  73667. * @param otherVector the vector to subtract
  73668. * @returns the updated Vector4.
  73669. */
  73670. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73671. /**
  73672. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73673. * @param otherVector the vector to add
  73674. * @returns the new vector with the result
  73675. */
  73676. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73677. /**
  73678. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73679. * @param otherVector the vector to subtract
  73680. * @param result the vector to store the result
  73681. * @returns the current Vector4.
  73682. */
  73683. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73684. /**
  73685. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73686. */
  73687. /**
  73688. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73689. * @param x value to subtract
  73690. * @param y value to subtract
  73691. * @param z value to subtract
  73692. * @param w value to subtract
  73693. * @returns new vector containing the result
  73694. */
  73695. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73696. /**
  73697. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73698. * @param x value to subtract
  73699. * @param y value to subtract
  73700. * @param z value to subtract
  73701. * @param w value to subtract
  73702. * @param result the vector to store the result in
  73703. * @returns the current Vector4.
  73704. */
  73705. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73706. /**
  73707. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73708. * @returns a new vector with the negated values
  73709. */
  73710. negate(): Vector4;
  73711. /**
  73712. * Multiplies the current Vector4 coordinates by scale (float).
  73713. * @param scale the number to scale with
  73714. * @returns the updated Vector4.
  73715. */
  73716. scaleInPlace(scale: number): Vector4;
  73717. /**
  73718. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73719. * @param scale the number to scale with
  73720. * @returns a new vector with the result
  73721. */
  73722. scale(scale: number): Vector4;
  73723. /**
  73724. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73725. * @param scale the number to scale with
  73726. * @param result a vector to store the result in
  73727. * @returns the current Vector4.
  73728. */
  73729. scaleToRef(scale: number, result: Vector4): Vector4;
  73730. /**
  73731. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73732. * @param scale defines the scale factor
  73733. * @param result defines the Vector4 object where to store the result
  73734. * @returns the unmodified current Vector4
  73735. */
  73736. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73737. /**
  73738. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73739. * @param otherVector the vector to compare against
  73740. * @returns true if they are equal
  73741. */
  73742. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73743. /**
  73744. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73745. * @param otherVector vector to compare against
  73746. * @param epsilon (Default: very small number)
  73747. * @returns true if they are equal
  73748. */
  73749. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73750. /**
  73751. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73752. * @param x x value to compare against
  73753. * @param y y value to compare against
  73754. * @param z z value to compare against
  73755. * @param w w value to compare against
  73756. * @returns true if equal
  73757. */
  73758. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73759. /**
  73760. * Multiplies in place the current Vector4 by the given one.
  73761. * @param otherVector vector to multiple with
  73762. * @returns the updated Vector4.
  73763. */
  73764. multiplyInPlace(otherVector: Vector4): Vector4;
  73765. /**
  73766. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73767. * @param otherVector vector to multiple with
  73768. * @returns resulting new vector
  73769. */
  73770. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73771. /**
  73772. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73773. * @param otherVector vector to multiple with
  73774. * @param result vector to store the result
  73775. * @returns the current Vector4.
  73776. */
  73777. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73778. /**
  73779. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73780. * @param x x value multiply with
  73781. * @param y y value multiply with
  73782. * @param z z value multiply with
  73783. * @param w w value multiply with
  73784. * @returns resulting new vector
  73785. */
  73786. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73787. /**
  73788. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73789. * @param otherVector vector to devide with
  73790. * @returns resulting new vector
  73791. */
  73792. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73793. /**
  73794. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73795. * @param otherVector vector to devide with
  73796. * @param result vector to store the result
  73797. * @returns the current Vector4.
  73798. */
  73799. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73800. /**
  73801. * Divides the current Vector3 coordinates by the given ones.
  73802. * @param otherVector vector to devide with
  73803. * @returns the updated Vector3.
  73804. */
  73805. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73806. /**
  73807. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73808. * @param other defines the second operand
  73809. * @returns the current updated Vector4
  73810. */
  73811. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73812. /**
  73813. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73814. * @param other defines the second operand
  73815. * @returns the current updated Vector4
  73816. */
  73817. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73818. /**
  73819. * Gets a new Vector4 from current Vector4 floored values
  73820. * @returns a new Vector4
  73821. */
  73822. floor(): Vector4;
  73823. /**
  73824. * Gets a new Vector4 from current Vector3 floored values
  73825. * @returns a new Vector4
  73826. */
  73827. fract(): Vector4;
  73828. /**
  73829. * Returns the Vector4 length (float).
  73830. * @returns the length
  73831. */
  73832. length(): number;
  73833. /**
  73834. * Returns the Vector4 squared length (float).
  73835. * @returns the length squared
  73836. */
  73837. lengthSquared(): number;
  73838. /**
  73839. * Normalizes in place the Vector4.
  73840. * @returns the updated Vector4.
  73841. */
  73842. normalize(): Vector4;
  73843. /**
  73844. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73845. * @returns this converted to a new vector3
  73846. */
  73847. toVector3(): Vector3;
  73848. /**
  73849. * Returns a new Vector4 copied from the current one.
  73850. * @returns the new cloned vector
  73851. */
  73852. clone(): Vector4;
  73853. /**
  73854. * Updates the current Vector4 with the given one coordinates.
  73855. * @param source the source vector to copy from
  73856. * @returns the updated Vector4.
  73857. */
  73858. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73859. /**
  73860. * Updates the current Vector4 coordinates with the given floats.
  73861. * @param x float to copy from
  73862. * @param y float to copy from
  73863. * @param z float to copy from
  73864. * @param w float to copy from
  73865. * @returns the updated Vector4.
  73866. */
  73867. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73868. /**
  73869. * Updates the current Vector4 coordinates with the given floats.
  73870. * @param x float to set from
  73871. * @param y float to set from
  73872. * @param z float to set from
  73873. * @param w float to set from
  73874. * @returns the updated Vector4.
  73875. */
  73876. set(x: number, y: number, z: number, w: number): Vector4;
  73877. /**
  73878. * Copies the given float to the current Vector3 coordinates
  73879. * @param v defines the x, y, z and w coordinates of the operand
  73880. * @returns the current updated Vector3
  73881. */
  73882. setAll(v: number): Vector4;
  73883. /**
  73884. * Returns a new Vector4 set from the starting index of the given array.
  73885. * @param array the array to pull values from
  73886. * @param offset the offset into the array to start at
  73887. * @returns the new vector
  73888. */
  73889. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73890. /**
  73891. * Updates the given vector "result" from the starting index of the given array.
  73892. * @param array the array to pull values from
  73893. * @param offset the offset into the array to start at
  73894. * @param result the vector to store the result in
  73895. */
  73896. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73897. /**
  73898. * Updates the given vector "result" from the starting index of the given Float32Array.
  73899. * @param array the array to pull values from
  73900. * @param offset the offset into the array to start at
  73901. * @param result the vector to store the result in
  73902. */
  73903. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73904. /**
  73905. * Updates the given vector "result" coordinates from the given floats.
  73906. * @param x float to set from
  73907. * @param y float to set from
  73908. * @param z float to set from
  73909. * @param w float to set from
  73910. * @param result the vector to the floats in
  73911. */
  73912. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  73913. /**
  73914. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73915. * @returns the new vector
  73916. */
  73917. static Zero(): Vector4;
  73918. /**
  73919. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73920. * @returns the new vector
  73921. */
  73922. static One(): Vector4;
  73923. /**
  73924. * Returns a new normalized Vector4 from the given one.
  73925. * @param vector the vector to normalize
  73926. * @returns the vector
  73927. */
  73928. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  73929. /**
  73930. * Updates the given vector "result" from the normalization of the given one.
  73931. * @param vector the vector to normalize
  73932. * @param result the vector to store the result in
  73933. */
  73934. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  73935. /**
  73936. * Returns a vector with the minimum values from the left and right vectors
  73937. * @param left left vector to minimize
  73938. * @param right right vector to minimize
  73939. * @returns a new vector with the minimum of the left and right vector values
  73940. */
  73941. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73942. /**
  73943. * Returns a vector with the maximum values from the left and right vectors
  73944. * @param left left vector to maximize
  73945. * @param right right vector to maximize
  73946. * @returns a new vector with the maximum of the left and right vector values
  73947. */
  73948. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73949. /**
  73950. * Returns the distance (float) between the vectors "value1" and "value2".
  73951. * @param value1 value to calulate the distance between
  73952. * @param value2 value to calulate the distance between
  73953. * @return the distance between the two vectors
  73954. */
  73955. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73956. /**
  73957. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73958. * @param value1 value to calulate the distance between
  73959. * @param value2 value to calulate the distance between
  73960. * @return the distance between the two vectors squared
  73961. */
  73962. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73963. /**
  73964. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73965. * @param value1 value to calulate the center between
  73966. * @param value2 value to calulate the center between
  73967. * @return the center between the two vectors
  73968. */
  73969. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  73970. /**
  73971. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73972. * This methods computes transformed normalized direction vectors only.
  73973. * @param vector the vector to transform
  73974. * @param transformation the transformation matrix to apply
  73975. * @returns the new vector
  73976. */
  73977. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  73978. /**
  73979. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73980. * This methods computes transformed normalized direction vectors only.
  73981. * @param vector the vector to transform
  73982. * @param transformation the transformation matrix to apply
  73983. * @param result the vector to store the result in
  73984. */
  73985. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73986. /**
  73987. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  73988. * This methods computes transformed normalized direction vectors only.
  73989. * @param x value to transform
  73990. * @param y value to transform
  73991. * @param z value to transform
  73992. * @param w value to transform
  73993. * @param transformation the transformation matrix to apply
  73994. * @param result the vector to store the results in
  73995. */
  73996. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73997. /**
  73998. * Creates a new Vector4 from a Vector3
  73999. * @param source defines the source data
  74000. * @param w defines the 4th component (default is 0)
  74001. * @returns a new Vector4
  74002. */
  74003. static FromVector3(source: Vector3, w?: number): Vector4;
  74004. }
  74005. /**
  74006. * Class used to store quaternion data
  74007. * @see https://en.wikipedia.org/wiki/Quaternion
  74008. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74009. */
  74010. export class Quaternion {
  74011. /** defines the first component (0 by default) */
  74012. x: number;
  74013. /** defines the second component (0 by default) */
  74014. y: number;
  74015. /** defines the third component (0 by default) */
  74016. z: number;
  74017. /** defines the fourth component (1.0 by default) */
  74018. w: number;
  74019. /**
  74020. * Creates a new Quaternion from the given floats
  74021. * @param x defines the first component (0 by default)
  74022. * @param y defines the second component (0 by default)
  74023. * @param z defines the third component (0 by default)
  74024. * @param w defines the fourth component (1.0 by default)
  74025. */
  74026. constructor(
  74027. /** defines the first component (0 by default) */
  74028. x?: number,
  74029. /** defines the second component (0 by default) */
  74030. y?: number,
  74031. /** defines the third component (0 by default) */
  74032. z?: number,
  74033. /** defines the fourth component (1.0 by default) */
  74034. w?: number);
  74035. /**
  74036. * Gets a string representation for the current quaternion
  74037. * @returns a string with the Quaternion coordinates
  74038. */
  74039. toString(): string;
  74040. /**
  74041. * Gets the class name of the quaternion
  74042. * @returns the string "Quaternion"
  74043. */
  74044. getClassName(): string;
  74045. /**
  74046. * Gets a hash code for this quaternion
  74047. * @returns the quaternion hash code
  74048. */
  74049. getHashCode(): number;
  74050. /**
  74051. * Copy the quaternion to an array
  74052. * @returns a new array populated with 4 elements from the quaternion coordinates
  74053. */
  74054. asArray(): number[];
  74055. /**
  74056. * Check if two quaternions are equals
  74057. * @param otherQuaternion defines the second operand
  74058. * @return true if the current quaternion and the given one coordinates are strictly equals
  74059. */
  74060. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74061. /**
  74062. * Clone the current quaternion
  74063. * @returns a new quaternion copied from the current one
  74064. */
  74065. clone(): Quaternion;
  74066. /**
  74067. * Copy a quaternion to the current one
  74068. * @param other defines the other quaternion
  74069. * @returns the updated current quaternion
  74070. */
  74071. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74072. /**
  74073. * Updates the current quaternion with the given float coordinates
  74074. * @param x defines the x coordinate
  74075. * @param y defines the y coordinate
  74076. * @param z defines the z coordinate
  74077. * @param w defines the w coordinate
  74078. * @returns the updated current quaternion
  74079. */
  74080. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74081. /**
  74082. * Updates the current quaternion from the given float coordinates
  74083. * @param x defines the x coordinate
  74084. * @param y defines the y coordinate
  74085. * @param z defines the z coordinate
  74086. * @param w defines the w coordinate
  74087. * @returns the updated current quaternion
  74088. */
  74089. set(x: number, y: number, z: number, w: number): Quaternion;
  74090. /**
  74091. * Adds two quaternions
  74092. * @param other defines the second operand
  74093. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74094. */
  74095. add(other: DeepImmutable<Quaternion>): Quaternion;
  74096. /**
  74097. * Add a quaternion to the current one
  74098. * @param other defines the quaternion to add
  74099. * @returns the current quaternion
  74100. */
  74101. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74102. /**
  74103. * Subtract two quaternions
  74104. * @param other defines the second operand
  74105. * @returns a new quaternion as the subtraction result of the given one from the current one
  74106. */
  74107. subtract(other: Quaternion): Quaternion;
  74108. /**
  74109. * Multiplies the current quaternion by a scale factor
  74110. * @param value defines the scale factor
  74111. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74112. */
  74113. scale(value: number): Quaternion;
  74114. /**
  74115. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74116. * @param scale defines the scale factor
  74117. * @param result defines the Quaternion object where to store the result
  74118. * @returns the unmodified current quaternion
  74119. */
  74120. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74121. /**
  74122. * Multiplies in place the current quaternion by a scale factor
  74123. * @param value defines the scale factor
  74124. * @returns the current modified quaternion
  74125. */
  74126. scaleInPlace(value: number): Quaternion;
  74127. /**
  74128. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74129. * @param scale defines the scale factor
  74130. * @param result defines the Quaternion object where to store the result
  74131. * @returns the unmodified current quaternion
  74132. */
  74133. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74134. /**
  74135. * Multiplies two quaternions
  74136. * @param q1 defines the second operand
  74137. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74138. */
  74139. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74140. /**
  74141. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74142. * @param q1 defines the second operand
  74143. * @param result defines the target quaternion
  74144. * @returns the current quaternion
  74145. */
  74146. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74147. /**
  74148. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74149. * @param q1 defines the second operand
  74150. * @returns the currentupdated quaternion
  74151. */
  74152. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74153. /**
  74154. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74155. * @param ref defines the target quaternion
  74156. * @returns the current quaternion
  74157. */
  74158. conjugateToRef(ref: Quaternion): Quaternion;
  74159. /**
  74160. * Conjugates in place (1-q) the current quaternion
  74161. * @returns the current updated quaternion
  74162. */
  74163. conjugateInPlace(): Quaternion;
  74164. /**
  74165. * Conjugates in place (1-q) the current quaternion
  74166. * @returns a new quaternion
  74167. */
  74168. conjugate(): Quaternion;
  74169. /**
  74170. * Gets length of current quaternion
  74171. * @returns the quaternion length (float)
  74172. */
  74173. length(): number;
  74174. /**
  74175. * Normalize in place the current quaternion
  74176. * @returns the current updated quaternion
  74177. */
  74178. normalize(): Quaternion;
  74179. /**
  74180. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74181. * @param order is a reserved parameter and is ignore for now
  74182. * @returns a new Vector3 containing the Euler angles
  74183. */
  74184. toEulerAngles(order?: string): Vector3;
  74185. /**
  74186. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74187. * @param result defines the vector which will be filled with the Euler angles
  74188. * @param order is a reserved parameter and is ignore for now
  74189. * @returns the current unchanged quaternion
  74190. */
  74191. toEulerAnglesToRef(result: Vector3): Quaternion;
  74192. /**
  74193. * Updates the given rotation matrix with the current quaternion values
  74194. * @param result defines the target matrix
  74195. * @returns the current unchanged quaternion
  74196. */
  74197. toRotationMatrix(result: Matrix): Quaternion;
  74198. /**
  74199. * Updates the current quaternion from the given rotation matrix values
  74200. * @param matrix defines the source matrix
  74201. * @returns the current updated quaternion
  74202. */
  74203. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74204. /**
  74205. * Creates a new quaternion from a rotation matrix
  74206. * @param matrix defines the source matrix
  74207. * @returns a new quaternion created from the given rotation matrix values
  74208. */
  74209. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74210. /**
  74211. * Updates the given quaternion with the given rotation matrix values
  74212. * @param matrix defines the source matrix
  74213. * @param result defines the target quaternion
  74214. */
  74215. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74216. /**
  74217. * Returns the dot product (float) between the quaternions "left" and "right"
  74218. * @param left defines the left operand
  74219. * @param right defines the right operand
  74220. * @returns the dot product
  74221. */
  74222. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74223. /**
  74224. * Checks if the two quaternions are close to each other
  74225. * @param quat0 defines the first quaternion to check
  74226. * @param quat1 defines the second quaternion to check
  74227. * @returns true if the two quaternions are close to each other
  74228. */
  74229. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74230. /**
  74231. * Creates an empty quaternion
  74232. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74233. */
  74234. static Zero(): Quaternion;
  74235. /**
  74236. * Inverse a given quaternion
  74237. * @param q defines the source quaternion
  74238. * @returns a new quaternion as the inverted current quaternion
  74239. */
  74240. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74241. /**
  74242. * Inverse a given quaternion
  74243. * @param q defines the source quaternion
  74244. * @param result the quaternion the result will be stored in
  74245. * @returns the result quaternion
  74246. */
  74247. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74248. /**
  74249. * Creates an identity quaternion
  74250. * @returns the identity quaternion
  74251. */
  74252. static Identity(): Quaternion;
  74253. /**
  74254. * Gets a boolean indicating if the given quaternion is identity
  74255. * @param quaternion defines the quaternion to check
  74256. * @returns true if the quaternion is identity
  74257. */
  74258. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74259. /**
  74260. * Creates a quaternion from a rotation around an axis
  74261. * @param axis defines the axis to use
  74262. * @param angle defines the angle to use
  74263. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74264. */
  74265. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74266. /**
  74267. * Creates a rotation around an axis and stores it into the given quaternion
  74268. * @param axis defines the axis to use
  74269. * @param angle defines the angle to use
  74270. * @param result defines the target quaternion
  74271. * @returns the target quaternion
  74272. */
  74273. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74274. /**
  74275. * Creates a new quaternion from data stored into an array
  74276. * @param array defines the data source
  74277. * @param offset defines the offset in the source array where the data starts
  74278. * @returns a new quaternion
  74279. */
  74280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74281. /**
  74282. * Create a quaternion from Euler rotation angles
  74283. * @param x Pitch
  74284. * @param y Yaw
  74285. * @param z Roll
  74286. * @returns the new Quaternion
  74287. */
  74288. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74289. /**
  74290. * Updates a quaternion from Euler rotation angles
  74291. * @param x Pitch
  74292. * @param y Yaw
  74293. * @param z Roll
  74294. * @param result the quaternion to store the result
  74295. * @returns the updated quaternion
  74296. */
  74297. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74298. /**
  74299. * Create a quaternion from Euler rotation vector
  74300. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74301. * @returns the new Quaternion
  74302. */
  74303. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74304. /**
  74305. * Updates a quaternion from Euler rotation vector
  74306. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74307. * @param result the quaternion to store the result
  74308. * @returns the updated quaternion
  74309. */
  74310. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74311. /**
  74312. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74313. * @param yaw defines the rotation around Y axis
  74314. * @param pitch defines the rotation around X axis
  74315. * @param roll defines the rotation around Z axis
  74316. * @returns the new quaternion
  74317. */
  74318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74319. /**
  74320. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74321. * @param yaw defines the rotation around Y axis
  74322. * @param pitch defines the rotation around X axis
  74323. * @param roll defines the rotation around Z axis
  74324. * @param result defines the target quaternion
  74325. */
  74326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74327. /**
  74328. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74329. * @param alpha defines the rotation around first axis
  74330. * @param beta defines the rotation around second axis
  74331. * @param gamma defines the rotation around third axis
  74332. * @returns the new quaternion
  74333. */
  74334. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74335. /**
  74336. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74337. * @param alpha defines the rotation around first axis
  74338. * @param beta defines the rotation around second axis
  74339. * @param gamma defines the rotation around third axis
  74340. * @param result defines the target quaternion
  74341. */
  74342. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74343. /**
  74344. * 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)
  74345. * @param axis1 defines the first axis
  74346. * @param axis2 defines the second axis
  74347. * @param axis3 defines the third axis
  74348. * @returns the new quaternion
  74349. */
  74350. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74351. /**
  74352. * 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
  74353. * @param axis1 defines the first axis
  74354. * @param axis2 defines the second axis
  74355. * @param axis3 defines the third axis
  74356. * @param ref defines the target quaternion
  74357. */
  74358. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74359. /**
  74360. * Interpolates between two quaternions
  74361. * @param left defines first quaternion
  74362. * @param right defines second quaternion
  74363. * @param amount defines the gradient to use
  74364. * @returns the new interpolated quaternion
  74365. */
  74366. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74367. /**
  74368. * Interpolates between two quaternions and stores it into a target quaternion
  74369. * @param left defines first quaternion
  74370. * @param right defines second quaternion
  74371. * @param amount defines the gradient to use
  74372. * @param result defines the target quaternion
  74373. */
  74374. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74375. /**
  74376. * Interpolate between two quaternions using Hermite interpolation
  74377. * @param value1 defines first quaternion
  74378. * @param tangent1 defines the incoming tangent
  74379. * @param value2 defines second quaternion
  74380. * @param tangent2 defines the outgoing tangent
  74381. * @param amount defines the target quaternion
  74382. * @returns the new interpolated quaternion
  74383. */
  74384. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74385. }
  74386. /**
  74387. * Class used to store matrix data (4x4)
  74388. */
  74389. export class Matrix {
  74390. private static _updateFlagSeed;
  74391. private static _identityReadOnly;
  74392. private _isIdentity;
  74393. private _isIdentityDirty;
  74394. private _isIdentity3x2;
  74395. private _isIdentity3x2Dirty;
  74396. /**
  74397. * Gets the update flag of the matrix which is an unique number for the matrix.
  74398. * It will be incremented every time the matrix data change.
  74399. * You can use it to speed the comparison between two versions of the same matrix.
  74400. */
  74401. updateFlag: number;
  74402. private readonly _m;
  74403. /**
  74404. * Gets the internal data of the matrix
  74405. */
  74406. get m(): DeepImmutable<Float32Array>;
  74407. /** @hidden */
  74408. _markAsUpdated(): void;
  74409. /** @hidden */
  74410. private _updateIdentityStatus;
  74411. /**
  74412. * Creates an empty matrix (filled with zeros)
  74413. */
  74414. constructor();
  74415. /**
  74416. * Check if the current matrix is identity
  74417. * @returns true is the matrix is the identity matrix
  74418. */
  74419. isIdentity(): boolean;
  74420. /**
  74421. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74422. * @returns true is the matrix is the identity matrix
  74423. */
  74424. isIdentityAs3x2(): boolean;
  74425. /**
  74426. * Gets the determinant of the matrix
  74427. * @returns the matrix determinant
  74428. */
  74429. determinant(): number;
  74430. /**
  74431. * Returns the matrix as a Float32Array
  74432. * @returns the matrix underlying array
  74433. */
  74434. toArray(): DeepImmutable<Float32Array>;
  74435. /**
  74436. * Returns the matrix as a Float32Array
  74437. * @returns the matrix underlying array.
  74438. */
  74439. asArray(): DeepImmutable<Float32Array>;
  74440. /**
  74441. * Inverts the current matrix in place
  74442. * @returns the current inverted matrix
  74443. */
  74444. invert(): Matrix;
  74445. /**
  74446. * Sets all the matrix elements to zero
  74447. * @returns the current matrix
  74448. */
  74449. reset(): Matrix;
  74450. /**
  74451. * Adds the current matrix with a second one
  74452. * @param other defines the matrix to add
  74453. * @returns a new matrix as the addition of the current matrix and the given one
  74454. */
  74455. add(other: DeepImmutable<Matrix>): Matrix;
  74456. /**
  74457. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74458. * @param other defines the matrix to add
  74459. * @param result defines the target matrix
  74460. * @returns the current matrix
  74461. */
  74462. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74463. /**
  74464. * Adds in place the given matrix to the current matrix
  74465. * @param other defines the second operand
  74466. * @returns the current updated matrix
  74467. */
  74468. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74469. /**
  74470. * Sets the given matrix to the current inverted Matrix
  74471. * @param other defines the target matrix
  74472. * @returns the unmodified current matrix
  74473. */
  74474. invertToRef(other: Matrix): Matrix;
  74475. /**
  74476. * add a value at the specified position in the current Matrix
  74477. * @param index the index of the value within the matrix. between 0 and 15.
  74478. * @param value the value to be added
  74479. * @returns the current updated matrix
  74480. */
  74481. addAtIndex(index: number, value: number): Matrix;
  74482. /**
  74483. * mutiply the specified position in the current Matrix by a value
  74484. * @param index the index of the value within the matrix. between 0 and 15.
  74485. * @param value the value to be added
  74486. * @returns the current updated matrix
  74487. */
  74488. multiplyAtIndex(index: number, value: number): Matrix;
  74489. /**
  74490. * Inserts the translation vector (using 3 floats) in the current matrix
  74491. * @param x defines the 1st component of the translation
  74492. * @param y defines the 2nd component of the translation
  74493. * @param z defines the 3rd component of the translation
  74494. * @returns the current updated matrix
  74495. */
  74496. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74497. /**
  74498. * Adds the translation vector (using 3 floats) in the current matrix
  74499. * @param x defines the 1st component of the translation
  74500. * @param y defines the 2nd component of the translation
  74501. * @param z defines the 3rd component of the translation
  74502. * @returns the current updated matrix
  74503. */
  74504. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74505. /**
  74506. * Inserts the translation vector in the current matrix
  74507. * @param vector3 defines the translation to insert
  74508. * @returns the current updated matrix
  74509. */
  74510. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74511. /**
  74512. * Gets the translation value of the current matrix
  74513. * @returns a new Vector3 as the extracted translation from the matrix
  74514. */
  74515. getTranslation(): Vector3;
  74516. /**
  74517. * Fill a Vector3 with the extracted translation from the matrix
  74518. * @param result defines the Vector3 where to store the translation
  74519. * @returns the current matrix
  74520. */
  74521. getTranslationToRef(result: Vector3): Matrix;
  74522. /**
  74523. * Remove rotation and scaling part from the matrix
  74524. * @returns the updated matrix
  74525. */
  74526. removeRotationAndScaling(): Matrix;
  74527. /**
  74528. * Multiply two matrices
  74529. * @param other defines the second operand
  74530. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74531. */
  74532. multiply(other: DeepImmutable<Matrix>): Matrix;
  74533. /**
  74534. * Copy the current matrix from the given one
  74535. * @param other defines the source matrix
  74536. * @returns the current updated matrix
  74537. */
  74538. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74539. /**
  74540. * Populates the given array from the starting index with the current matrix values
  74541. * @param array defines the target array
  74542. * @param offset defines the offset in the target array where to start storing values
  74543. * @returns the current matrix
  74544. */
  74545. copyToArray(array: Float32Array, offset?: number): Matrix;
  74546. /**
  74547. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74548. * @param other defines the second operand
  74549. * @param result defines the matrix where to store the multiplication
  74550. * @returns the current matrix
  74551. */
  74552. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74553. /**
  74554. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74555. * @param other defines the second operand
  74556. * @param result defines the array where to store the multiplication
  74557. * @param offset defines the offset in the target array where to start storing values
  74558. * @returns the current matrix
  74559. */
  74560. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74561. /**
  74562. * Check equality between this matrix and a second one
  74563. * @param value defines the second matrix to compare
  74564. * @returns true is the current matrix and the given one values are strictly equal
  74565. */
  74566. equals(value: DeepImmutable<Matrix>): boolean;
  74567. /**
  74568. * Clone the current matrix
  74569. * @returns a new matrix from the current matrix
  74570. */
  74571. clone(): Matrix;
  74572. /**
  74573. * Returns the name of the current matrix class
  74574. * @returns the string "Matrix"
  74575. */
  74576. getClassName(): string;
  74577. /**
  74578. * Gets the hash code of the current matrix
  74579. * @returns the hash code
  74580. */
  74581. getHashCode(): number;
  74582. /**
  74583. * Decomposes the current Matrix into a translation, rotation and scaling components
  74584. * @param scale defines the scale vector3 given as a reference to update
  74585. * @param rotation defines the rotation quaternion given as a reference to update
  74586. * @param translation defines the translation vector3 given as a reference to update
  74587. * @returns true if operation was successful
  74588. */
  74589. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74590. /**
  74591. * Gets specific row of the matrix
  74592. * @param index defines the number of the row to get
  74593. * @returns the index-th row of the current matrix as a new Vector4
  74594. */
  74595. getRow(index: number): Nullable<Vector4>;
  74596. /**
  74597. * Sets the index-th row of the current matrix to the vector4 values
  74598. * @param index defines the number of the row to set
  74599. * @param row defines the target vector4
  74600. * @returns the updated current matrix
  74601. */
  74602. setRow(index: number, row: Vector4): Matrix;
  74603. /**
  74604. * Compute the transpose of the matrix
  74605. * @returns the new transposed matrix
  74606. */
  74607. transpose(): Matrix;
  74608. /**
  74609. * Compute the transpose of the matrix and store it in a given matrix
  74610. * @param result defines the target matrix
  74611. * @returns the current matrix
  74612. */
  74613. transposeToRef(result: Matrix): Matrix;
  74614. /**
  74615. * Sets the index-th row of the current matrix with the given 4 x float values
  74616. * @param index defines the row index
  74617. * @param x defines the x component to set
  74618. * @param y defines the y component to set
  74619. * @param z defines the z component to set
  74620. * @param w defines the w component to set
  74621. * @returns the updated current matrix
  74622. */
  74623. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74624. /**
  74625. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74626. * @param scale defines the scale factor
  74627. * @returns a new matrix
  74628. */
  74629. scale(scale: number): Matrix;
  74630. /**
  74631. * Scale the current matrix values by a factor to a given result matrix
  74632. * @param scale defines the scale factor
  74633. * @param result defines the matrix to store the result
  74634. * @returns the current matrix
  74635. */
  74636. scaleToRef(scale: number, result: Matrix): Matrix;
  74637. /**
  74638. * Scale the current matrix values by a factor and add the result to a given matrix
  74639. * @param scale defines the scale factor
  74640. * @param result defines the Matrix to store the result
  74641. * @returns the current matrix
  74642. */
  74643. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74644. /**
  74645. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74646. * @param ref matrix to store the result
  74647. */
  74648. toNormalMatrix(ref: Matrix): void;
  74649. /**
  74650. * Gets only rotation part of the current matrix
  74651. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74652. */
  74653. getRotationMatrix(): Matrix;
  74654. /**
  74655. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74656. * @param result defines the target matrix to store data to
  74657. * @returns the current matrix
  74658. */
  74659. getRotationMatrixToRef(result: Matrix): Matrix;
  74660. /**
  74661. * Toggles model matrix from being right handed to left handed in place and vice versa
  74662. */
  74663. toggleModelMatrixHandInPlace(): void;
  74664. /**
  74665. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74666. */
  74667. toggleProjectionMatrixHandInPlace(): void;
  74668. /**
  74669. * Creates a matrix from an array
  74670. * @param array defines the source array
  74671. * @param offset defines an offset in the source array
  74672. * @returns a new Matrix set from the starting index of the given array
  74673. */
  74674. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74675. /**
  74676. * Copy the content of an array into a given matrix
  74677. * @param array defines the source array
  74678. * @param offset defines an offset in the source array
  74679. * @param result defines the target matrix
  74680. */
  74681. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74682. /**
  74683. * Stores an array into a matrix after having multiplied each component by a given factor
  74684. * @param array defines the source array
  74685. * @param offset defines the offset in the source array
  74686. * @param scale defines the scaling factor
  74687. * @param result defines the target matrix
  74688. */
  74689. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74690. /**
  74691. * Gets an identity matrix that must not be updated
  74692. */
  74693. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74694. /**
  74695. * Stores a list of values (16) inside a given matrix
  74696. * @param initialM11 defines 1st value of 1st row
  74697. * @param initialM12 defines 2nd value of 1st row
  74698. * @param initialM13 defines 3rd value of 1st row
  74699. * @param initialM14 defines 4th value of 1st row
  74700. * @param initialM21 defines 1st value of 2nd row
  74701. * @param initialM22 defines 2nd value of 2nd row
  74702. * @param initialM23 defines 3rd value of 2nd row
  74703. * @param initialM24 defines 4th value of 2nd row
  74704. * @param initialM31 defines 1st value of 3rd row
  74705. * @param initialM32 defines 2nd value of 3rd row
  74706. * @param initialM33 defines 3rd value of 3rd row
  74707. * @param initialM34 defines 4th value of 3rd row
  74708. * @param initialM41 defines 1st value of 4th row
  74709. * @param initialM42 defines 2nd value of 4th row
  74710. * @param initialM43 defines 3rd value of 4th row
  74711. * @param initialM44 defines 4th value of 4th row
  74712. * @param result defines the target matrix
  74713. */
  74714. 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;
  74715. /**
  74716. * Creates new matrix from a list of values (16)
  74717. * @param initialM11 defines 1st value of 1st row
  74718. * @param initialM12 defines 2nd value of 1st row
  74719. * @param initialM13 defines 3rd value of 1st row
  74720. * @param initialM14 defines 4th value of 1st row
  74721. * @param initialM21 defines 1st value of 2nd row
  74722. * @param initialM22 defines 2nd value of 2nd row
  74723. * @param initialM23 defines 3rd value of 2nd row
  74724. * @param initialM24 defines 4th value of 2nd row
  74725. * @param initialM31 defines 1st value of 3rd row
  74726. * @param initialM32 defines 2nd value of 3rd row
  74727. * @param initialM33 defines 3rd value of 3rd row
  74728. * @param initialM34 defines 4th value of 3rd row
  74729. * @param initialM41 defines 1st value of 4th row
  74730. * @param initialM42 defines 2nd value of 4th row
  74731. * @param initialM43 defines 3rd value of 4th row
  74732. * @param initialM44 defines 4th value of 4th row
  74733. * @returns the new matrix
  74734. */
  74735. 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;
  74736. /**
  74737. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74738. * @param scale defines the scale vector3
  74739. * @param rotation defines the rotation quaternion
  74740. * @param translation defines the translation vector3
  74741. * @returns a new matrix
  74742. */
  74743. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74744. /**
  74745. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74746. * @param scale defines the scale vector3
  74747. * @param rotation defines the rotation quaternion
  74748. * @param translation defines the translation vector3
  74749. * @param result defines the target matrix
  74750. */
  74751. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74752. /**
  74753. * Creates a new identity matrix
  74754. * @returns a new identity matrix
  74755. */
  74756. static Identity(): Matrix;
  74757. /**
  74758. * Creates a new identity matrix and stores the result in a given matrix
  74759. * @param result defines the target matrix
  74760. */
  74761. static IdentityToRef(result: Matrix): void;
  74762. /**
  74763. * Creates a new zero matrix
  74764. * @returns a new zero matrix
  74765. */
  74766. static Zero(): Matrix;
  74767. /**
  74768. * Creates a new rotation matrix for "angle" radians around the X axis
  74769. * @param angle defines the angle (in radians) to use
  74770. * @return the new matrix
  74771. */
  74772. static RotationX(angle: number): Matrix;
  74773. /**
  74774. * Creates a new matrix as the invert of a given matrix
  74775. * @param source defines the source matrix
  74776. * @returns the new matrix
  74777. */
  74778. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74779. /**
  74780. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74781. * @param angle defines the angle (in radians) to use
  74782. * @param result defines the target matrix
  74783. */
  74784. static RotationXToRef(angle: number, result: Matrix): void;
  74785. /**
  74786. * Creates a new rotation matrix for "angle" radians around the Y axis
  74787. * @param angle defines the angle (in radians) to use
  74788. * @return the new matrix
  74789. */
  74790. static RotationY(angle: number): Matrix;
  74791. /**
  74792. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74793. * @param angle defines the angle (in radians) to use
  74794. * @param result defines the target matrix
  74795. */
  74796. static RotationYToRef(angle: number, result: Matrix): void;
  74797. /**
  74798. * Creates a new rotation matrix for "angle" radians around the Z axis
  74799. * @param angle defines the angle (in radians) to use
  74800. * @return the new matrix
  74801. */
  74802. static RotationZ(angle: number): Matrix;
  74803. /**
  74804. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74805. * @param angle defines the angle (in radians) to use
  74806. * @param result defines the target matrix
  74807. */
  74808. static RotationZToRef(angle: number, result: Matrix): void;
  74809. /**
  74810. * Creates a new rotation matrix for "angle" radians around the given axis
  74811. * @param axis defines the axis to use
  74812. * @param angle defines the angle (in radians) to use
  74813. * @return the new matrix
  74814. */
  74815. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74816. /**
  74817. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74818. * @param axis defines the axis to use
  74819. * @param angle defines the angle (in radians) to use
  74820. * @param result defines the target matrix
  74821. */
  74822. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74823. /**
  74824. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74825. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74826. * @param from defines the vector to align
  74827. * @param to defines the vector to align to
  74828. * @param result defines the target matrix
  74829. */
  74830. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74831. /**
  74832. * Creates a rotation matrix
  74833. * @param yaw defines the yaw angle in radians (Y axis)
  74834. * @param pitch defines the pitch angle in radians (X axis)
  74835. * @param roll defines the roll angle in radians (X axis)
  74836. * @returns the new rotation matrix
  74837. */
  74838. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74839. /**
  74840. * Creates a rotation matrix and stores it in a given matrix
  74841. * @param yaw defines the yaw angle in radians (Y axis)
  74842. * @param pitch defines the pitch angle in radians (X axis)
  74843. * @param roll defines the roll angle in radians (X axis)
  74844. * @param result defines the target matrix
  74845. */
  74846. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74847. /**
  74848. * Creates a scaling matrix
  74849. * @param x defines the scale factor on X axis
  74850. * @param y defines the scale factor on Y axis
  74851. * @param z defines the scale factor on Z axis
  74852. * @returns the new matrix
  74853. */
  74854. static Scaling(x: number, y: number, z: number): Matrix;
  74855. /**
  74856. * Creates a scaling matrix and stores it in a given matrix
  74857. * @param x defines the scale factor on X axis
  74858. * @param y defines the scale factor on Y axis
  74859. * @param z defines the scale factor on Z axis
  74860. * @param result defines the target matrix
  74861. */
  74862. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74863. /**
  74864. * Creates a translation matrix
  74865. * @param x defines the translation on X axis
  74866. * @param y defines the translation on Y axis
  74867. * @param z defines the translationon Z axis
  74868. * @returns the new matrix
  74869. */
  74870. static Translation(x: number, y: number, z: number): Matrix;
  74871. /**
  74872. * Creates a translation matrix and stores it in a given matrix
  74873. * @param x defines the translation on X axis
  74874. * @param y defines the translation on Y axis
  74875. * @param z defines the translationon Z axis
  74876. * @param result defines the target matrix
  74877. */
  74878. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74879. /**
  74880. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74881. * @param startValue defines the start value
  74882. * @param endValue defines the end value
  74883. * @param gradient defines the gradient factor
  74884. * @returns the new matrix
  74885. */
  74886. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74887. /**
  74888. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74889. * @param startValue defines the start value
  74890. * @param endValue defines the end value
  74891. * @param gradient defines the gradient factor
  74892. * @param result defines the Matrix object where to store data
  74893. */
  74894. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74895. /**
  74896. * Builds a new matrix whose values are computed by:
  74897. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74898. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74899. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74900. * @param startValue defines the first matrix
  74901. * @param endValue defines the second matrix
  74902. * @param gradient defines the gradient between the two matrices
  74903. * @returns the new matrix
  74904. */
  74905. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74906. /**
  74907. * Update a matrix to values which are computed by:
  74908. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74909. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74910. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74911. * @param startValue defines the first matrix
  74912. * @param endValue defines the second matrix
  74913. * @param gradient defines the gradient between the two matrices
  74914. * @param result defines the target matrix
  74915. */
  74916. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74917. /**
  74918. * 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"
  74919. * This function works in left handed mode
  74920. * @param eye defines the final position of the entity
  74921. * @param target defines where the entity should look at
  74922. * @param up defines the up vector for the entity
  74923. * @returns the new matrix
  74924. */
  74925. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74926. /**
  74927. * 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".
  74928. * This function works in left handed mode
  74929. * @param eye defines the final position of the entity
  74930. * @param target defines where the entity should look at
  74931. * @param up defines the up vector for the entity
  74932. * @param result defines the target matrix
  74933. */
  74934. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74935. /**
  74936. * 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"
  74937. * This function works in right handed mode
  74938. * @param eye defines the final position of the entity
  74939. * @param target defines where the entity should look at
  74940. * @param up defines the up vector for the entity
  74941. * @returns the new matrix
  74942. */
  74943. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74944. /**
  74945. * 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".
  74946. * This function works in right handed mode
  74947. * @param eye defines the final position of the entity
  74948. * @param target defines where the entity should look at
  74949. * @param up defines the up vector for the entity
  74950. * @param result defines the target matrix
  74951. */
  74952. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74953. /**
  74954. * Create a left-handed orthographic projection matrix
  74955. * @param width defines the viewport width
  74956. * @param height defines the viewport height
  74957. * @param znear defines the near clip plane
  74958. * @param zfar defines the far clip plane
  74959. * @returns a new matrix as a left-handed orthographic projection matrix
  74960. */
  74961. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74962. /**
  74963. * Store a left-handed orthographic projection to a given matrix
  74964. * @param width defines the viewport width
  74965. * @param height defines the viewport height
  74966. * @param znear defines the near clip plane
  74967. * @param zfar defines the far clip plane
  74968. * @param result defines the target matrix
  74969. */
  74970. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  74971. /**
  74972. * Create a left-handed orthographic projection matrix
  74973. * @param left defines the viewport left coordinate
  74974. * @param right defines the viewport right coordinate
  74975. * @param bottom defines the viewport bottom coordinate
  74976. * @param top defines the viewport top coordinate
  74977. * @param znear defines the near clip plane
  74978. * @param zfar defines the far clip plane
  74979. * @returns a new matrix as a left-handed orthographic projection matrix
  74980. */
  74981. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  74982. /**
  74983. * Stores a left-handed orthographic projection into a given matrix
  74984. * @param left defines the viewport left coordinate
  74985. * @param right defines the viewport right coordinate
  74986. * @param bottom defines the viewport bottom coordinate
  74987. * @param top defines the viewport top coordinate
  74988. * @param znear defines the near clip plane
  74989. * @param zfar defines the far clip plane
  74990. * @param result defines the target matrix
  74991. */
  74992. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  74993. /**
  74994. * Creates a right-handed orthographic projection matrix
  74995. * @param left defines the viewport left coordinate
  74996. * @param right defines the viewport right coordinate
  74997. * @param bottom defines the viewport bottom coordinate
  74998. * @param top defines the viewport top coordinate
  74999. * @param znear defines the near clip plane
  75000. * @param zfar defines the far clip plane
  75001. * @returns a new matrix as a right-handed orthographic projection matrix
  75002. */
  75003. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75004. /**
  75005. * Stores a right-handed orthographic projection into a given matrix
  75006. * @param left defines the viewport left coordinate
  75007. * @param right defines the viewport right coordinate
  75008. * @param bottom defines the viewport bottom coordinate
  75009. * @param top defines the viewport top coordinate
  75010. * @param znear defines the near clip plane
  75011. * @param zfar defines the far clip plane
  75012. * @param result defines the target matrix
  75013. */
  75014. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75015. /**
  75016. * Creates a left-handed perspective projection matrix
  75017. * @param width defines the viewport width
  75018. * @param height defines the viewport height
  75019. * @param znear defines the near clip plane
  75020. * @param zfar defines the far clip plane
  75021. * @returns a new matrix as a left-handed perspective projection matrix
  75022. */
  75023. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75024. /**
  75025. * Creates a left-handed perspective projection matrix
  75026. * @param fov defines the horizontal field of view
  75027. * @param aspect defines the aspect ratio
  75028. * @param znear defines the near clip plane
  75029. * @param zfar defines the far clip plane
  75030. * @returns a new matrix as a left-handed perspective projection matrix
  75031. */
  75032. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75033. /**
  75034. * Stores a left-handed perspective projection into a given matrix
  75035. * @param fov defines the horizontal field of view
  75036. * @param aspect defines the aspect ratio
  75037. * @param znear defines the near clip plane
  75038. * @param zfar defines the far clip plane
  75039. * @param result defines the target matrix
  75040. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75041. */
  75042. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75043. /**
  75044. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75045. * @param fov defines the horizontal field of view
  75046. * @param aspect defines the aspect ratio
  75047. * @param znear defines the near clip plane
  75048. * @param zfar not used as infinity is used as far clip
  75049. * @param result defines the target matrix
  75050. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75051. */
  75052. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75053. /**
  75054. * Creates a right-handed perspective projection matrix
  75055. * @param fov defines the horizontal field of view
  75056. * @param aspect defines the aspect ratio
  75057. * @param znear defines the near clip plane
  75058. * @param zfar defines the far clip plane
  75059. * @returns a new matrix as a right-handed perspective projection matrix
  75060. */
  75061. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75062. /**
  75063. * Stores a right-handed perspective projection into a given matrix
  75064. * @param fov defines the horizontal field of view
  75065. * @param aspect defines the aspect ratio
  75066. * @param znear defines the near clip plane
  75067. * @param zfar defines the far clip plane
  75068. * @param result defines the target matrix
  75069. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75070. */
  75071. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75072. /**
  75073. * Stores a right-handed perspective projection into a given matrix
  75074. * @param fov defines the horizontal field of view
  75075. * @param aspect defines the aspect ratio
  75076. * @param znear defines the near clip plane
  75077. * @param zfar not used as infinity is used as far clip
  75078. * @param result defines the target matrix
  75079. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75080. */
  75081. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75082. /**
  75083. * Stores a perspective projection for WebVR info a given matrix
  75084. * @param fov defines the field of view
  75085. * @param znear defines the near clip plane
  75086. * @param zfar defines the far clip plane
  75087. * @param result defines the target matrix
  75088. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75089. */
  75090. static PerspectiveFovWebVRToRef(fov: {
  75091. upDegrees: number;
  75092. downDegrees: number;
  75093. leftDegrees: number;
  75094. rightDegrees: number;
  75095. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75096. /**
  75097. * Computes a complete transformation matrix
  75098. * @param viewport defines the viewport to use
  75099. * @param world defines the world matrix
  75100. * @param view defines the view matrix
  75101. * @param projection defines the projection matrix
  75102. * @param zmin defines the near clip plane
  75103. * @param zmax defines the far clip plane
  75104. * @returns the transformation matrix
  75105. */
  75106. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75107. /**
  75108. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75109. * @param matrix defines the matrix to use
  75110. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75111. */
  75112. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75113. /**
  75114. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75115. * @param matrix defines the matrix to use
  75116. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75117. */
  75118. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75119. /**
  75120. * Compute the transpose of a given matrix
  75121. * @param matrix defines the matrix to transpose
  75122. * @returns the new matrix
  75123. */
  75124. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75125. /**
  75126. * Compute the transpose of a matrix and store it in a target matrix
  75127. * @param matrix defines the matrix to transpose
  75128. * @param result defines the target matrix
  75129. */
  75130. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75131. /**
  75132. * Computes a reflection matrix from a plane
  75133. * @param plane defines the reflection plane
  75134. * @returns a new matrix
  75135. */
  75136. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75137. /**
  75138. * Computes a reflection matrix from a plane
  75139. * @param plane defines the reflection plane
  75140. * @param result defines the target matrix
  75141. */
  75142. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75143. /**
  75144. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75145. * @param xaxis defines the value of the 1st axis
  75146. * @param yaxis defines the value of the 2nd axis
  75147. * @param zaxis defines the value of the 3rd axis
  75148. * @param result defines the target matrix
  75149. */
  75150. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75151. /**
  75152. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75153. * @param quat defines the quaternion to use
  75154. * @param result defines the target matrix
  75155. */
  75156. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75157. }
  75158. /**
  75159. * @hidden
  75160. */
  75161. export class TmpVectors {
  75162. static Vector2: Vector2[];
  75163. static Vector3: Vector3[];
  75164. static Vector4: Vector4[];
  75165. static Quaternion: Quaternion[];
  75166. static Matrix: Matrix[];
  75167. }
  75168. }
  75169. declare module BABYLON {
  75170. /**
  75171. * Defines potential orientation for back face culling
  75172. */
  75173. export enum Orientation {
  75174. /**
  75175. * Clockwise
  75176. */
  75177. CW = 0,
  75178. /** Counter clockwise */
  75179. CCW = 1
  75180. }
  75181. /** Class used to represent a Bezier curve */
  75182. export class BezierCurve {
  75183. /**
  75184. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75185. * @param t defines the time
  75186. * @param x1 defines the left coordinate on X axis
  75187. * @param y1 defines the left coordinate on Y axis
  75188. * @param x2 defines the right coordinate on X axis
  75189. * @param y2 defines the right coordinate on Y axis
  75190. * @returns the interpolated value
  75191. */
  75192. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75193. }
  75194. /**
  75195. * Defines angle representation
  75196. */
  75197. export class Angle {
  75198. private _radians;
  75199. /**
  75200. * Creates an Angle object of "radians" radians (float).
  75201. * @param radians the angle in radians
  75202. */
  75203. constructor(radians: number);
  75204. /**
  75205. * Get value in degrees
  75206. * @returns the Angle value in degrees (float)
  75207. */
  75208. degrees(): number;
  75209. /**
  75210. * Get value in radians
  75211. * @returns the Angle value in radians (float)
  75212. */
  75213. radians(): number;
  75214. /**
  75215. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75216. * @param a defines first vector
  75217. * @param b defines second vector
  75218. * @returns a new Angle
  75219. */
  75220. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75221. /**
  75222. * Gets a new Angle object from the given float in radians
  75223. * @param radians defines the angle value in radians
  75224. * @returns a new Angle
  75225. */
  75226. static FromRadians(radians: number): Angle;
  75227. /**
  75228. * Gets a new Angle object from the given float in degrees
  75229. * @param degrees defines the angle value in degrees
  75230. * @returns a new Angle
  75231. */
  75232. static FromDegrees(degrees: number): Angle;
  75233. }
  75234. /**
  75235. * This represents an arc in a 2d space.
  75236. */
  75237. export class Arc2 {
  75238. /** Defines the start point of the arc */
  75239. startPoint: Vector2;
  75240. /** Defines the mid point of the arc */
  75241. midPoint: Vector2;
  75242. /** Defines the end point of the arc */
  75243. endPoint: Vector2;
  75244. /**
  75245. * Defines the center point of the arc.
  75246. */
  75247. centerPoint: Vector2;
  75248. /**
  75249. * Defines the radius of the arc.
  75250. */
  75251. radius: number;
  75252. /**
  75253. * Defines the angle of the arc (from mid point to end point).
  75254. */
  75255. angle: Angle;
  75256. /**
  75257. * Defines the start angle of the arc (from start point to middle point).
  75258. */
  75259. startAngle: Angle;
  75260. /**
  75261. * Defines the orientation of the arc (clock wise/counter clock wise).
  75262. */
  75263. orientation: Orientation;
  75264. /**
  75265. * Creates an Arc object from the three given points : start, middle and end.
  75266. * @param startPoint Defines the start point of the arc
  75267. * @param midPoint Defines the midlle point of the arc
  75268. * @param endPoint Defines the end point of the arc
  75269. */
  75270. constructor(
  75271. /** Defines the start point of the arc */
  75272. startPoint: Vector2,
  75273. /** Defines the mid point of the arc */
  75274. midPoint: Vector2,
  75275. /** Defines the end point of the arc */
  75276. endPoint: Vector2);
  75277. }
  75278. /**
  75279. * Represents a 2D path made up of multiple 2D points
  75280. */
  75281. export class Path2 {
  75282. private _points;
  75283. private _length;
  75284. /**
  75285. * If the path start and end point are the same
  75286. */
  75287. closed: boolean;
  75288. /**
  75289. * Creates a Path2 object from the starting 2D coordinates x and y.
  75290. * @param x the starting points x value
  75291. * @param y the starting points y value
  75292. */
  75293. constructor(x: number, y: number);
  75294. /**
  75295. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75296. * @param x the added points x value
  75297. * @param y the added points y value
  75298. * @returns the updated Path2.
  75299. */
  75300. addLineTo(x: number, y: number): Path2;
  75301. /**
  75302. * 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.
  75303. * @param midX middle point x value
  75304. * @param midY middle point y value
  75305. * @param endX end point x value
  75306. * @param endY end point y value
  75307. * @param numberOfSegments (default: 36)
  75308. * @returns the updated Path2.
  75309. */
  75310. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75311. /**
  75312. * Closes the Path2.
  75313. * @returns the Path2.
  75314. */
  75315. close(): Path2;
  75316. /**
  75317. * Gets the sum of the distance between each sequential point in the path
  75318. * @returns the Path2 total length (float).
  75319. */
  75320. length(): number;
  75321. /**
  75322. * Gets the points which construct the path
  75323. * @returns the Path2 internal array of points.
  75324. */
  75325. getPoints(): Vector2[];
  75326. /**
  75327. * Retreives the point at the distance aways from the starting point
  75328. * @param normalizedLengthPosition the length along the path to retreive the point from
  75329. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75330. */
  75331. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75332. /**
  75333. * Creates a new path starting from an x and y position
  75334. * @param x starting x value
  75335. * @param y starting y value
  75336. * @returns a new Path2 starting at the coordinates (x, y).
  75337. */
  75338. static StartingAt(x: number, y: number): Path2;
  75339. }
  75340. /**
  75341. * Represents a 3D path made up of multiple 3D points
  75342. */
  75343. export class Path3D {
  75344. /**
  75345. * an array of Vector3, the curve axis of the Path3D
  75346. */
  75347. path: Vector3[];
  75348. private _curve;
  75349. private _distances;
  75350. private _tangents;
  75351. private _normals;
  75352. private _binormals;
  75353. private _raw;
  75354. private _alignTangentsWithPath;
  75355. private readonly _pointAtData;
  75356. /**
  75357. * new Path3D(path, normal, raw)
  75358. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75359. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75360. * @param path an array of Vector3, the curve axis of the Path3D
  75361. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75362. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75363. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75364. */
  75365. constructor(
  75366. /**
  75367. * an array of Vector3, the curve axis of the Path3D
  75368. */
  75369. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75370. /**
  75371. * Returns the Path3D array of successive Vector3 designing its curve.
  75372. * @returns the Path3D array of successive Vector3 designing its curve.
  75373. */
  75374. getCurve(): Vector3[];
  75375. /**
  75376. * Returns the Path3D array of successive Vector3 designing its curve.
  75377. * @returns the Path3D array of successive Vector3 designing its curve.
  75378. */
  75379. getPoints(): Vector3[];
  75380. /**
  75381. * @returns the computed length (float) of the path.
  75382. */
  75383. length(): number;
  75384. /**
  75385. * Returns an array populated with tangent vectors on each Path3D curve point.
  75386. * @returns an array populated with tangent vectors on each Path3D curve point.
  75387. */
  75388. getTangents(): Vector3[];
  75389. /**
  75390. * Returns an array populated with normal vectors on each Path3D curve point.
  75391. * @returns an array populated with normal vectors on each Path3D curve point.
  75392. */
  75393. getNormals(): Vector3[];
  75394. /**
  75395. * Returns an array populated with binormal vectors on each Path3D curve point.
  75396. * @returns an array populated with binormal vectors on each Path3D curve point.
  75397. */
  75398. getBinormals(): Vector3[];
  75399. /**
  75400. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75401. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75402. */
  75403. getDistances(): number[];
  75404. /**
  75405. * Returns an interpolated point along this path
  75406. * @param position the position of the point along this path, from 0.0 to 1.0
  75407. * @returns a new Vector3 as the point
  75408. */
  75409. getPointAt(position: number): Vector3;
  75410. /**
  75411. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75412. * @param position the position of the point along this path, from 0.0 to 1.0
  75413. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75414. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75415. */
  75416. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75417. /**
  75418. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75419. * @param position the position of the point along this path, from 0.0 to 1.0
  75420. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75421. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75422. */
  75423. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75424. /**
  75425. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75426. * @param position the position of the point along this path, from 0.0 to 1.0
  75427. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75428. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75429. */
  75430. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75431. /**
  75432. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75433. * @param position the position of the point along this path, from 0.0 to 1.0
  75434. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75435. */
  75436. getDistanceAt(position: number): number;
  75437. /**
  75438. * Returns the array index of the previous point of an interpolated point along this path
  75439. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75440. * @returns the array index
  75441. */
  75442. getPreviousPointIndexAt(position: number): number;
  75443. /**
  75444. * 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)
  75445. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75446. * @returns the sub position
  75447. */
  75448. getSubPositionAt(position: number): number;
  75449. /**
  75450. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75451. * @param target the vector of which to get the closest position to
  75452. * @returns the position of the closest virtual point on this path to the target vector
  75453. */
  75454. getClosestPositionTo(target: Vector3): number;
  75455. /**
  75456. * Returns a sub path (slice) of this path
  75457. * @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
  75458. * @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
  75459. * @returns a sub path (slice) of this path
  75460. */
  75461. slice(start?: number, end?: number): Path3D;
  75462. /**
  75463. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75464. * @param path path which all values are copied into the curves points
  75465. * @param firstNormal which should be projected onto the curve
  75466. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75467. * @returns the same object updated.
  75468. */
  75469. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75470. private _compute;
  75471. private _getFirstNonNullVector;
  75472. private _getLastNonNullVector;
  75473. private _normalVector;
  75474. /**
  75475. * Updates the point at data for an interpolated point along this curve
  75476. * @param position the position of the point along this curve, from 0.0 to 1.0
  75477. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75478. * @returns the (updated) point at data
  75479. */
  75480. private _updatePointAtData;
  75481. /**
  75482. * Updates the point at data from the specified parameters
  75483. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75484. * @param point the interpolated point
  75485. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75486. */
  75487. private _setPointAtData;
  75488. /**
  75489. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75490. */
  75491. private _updateInterpolationMatrix;
  75492. }
  75493. /**
  75494. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75495. * A Curve3 is designed from a series of successive Vector3.
  75496. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75497. */
  75498. export class Curve3 {
  75499. private _points;
  75500. private _length;
  75501. /**
  75502. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75503. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75504. * @param v1 (Vector3) the control point
  75505. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75506. * @param nbPoints (integer) the wanted number of points in the curve
  75507. * @returns the created Curve3
  75508. */
  75509. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75510. /**
  75511. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75512. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75513. * @param v1 (Vector3) the first control point
  75514. * @param v2 (Vector3) the second control point
  75515. * @param v3 (Vector3) the end point of the Cubic Bezier
  75516. * @param nbPoints (integer) the wanted number of points in the curve
  75517. * @returns the created Curve3
  75518. */
  75519. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75520. /**
  75521. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75522. * @param p1 (Vector3) the origin point of the Hermite Spline
  75523. * @param t1 (Vector3) the tangent vector at the origin point
  75524. * @param p2 (Vector3) the end point of the Hermite Spline
  75525. * @param t2 (Vector3) the tangent vector at the end point
  75526. * @param nbPoints (integer) the wanted number of points in the curve
  75527. * @returns the created Curve3
  75528. */
  75529. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75530. /**
  75531. * Returns a Curve3 object along a CatmullRom Spline curve :
  75532. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75533. * @param nbPoints (integer) the wanted number of points between each curve control points
  75534. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75535. * @returns the created Curve3
  75536. */
  75537. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75538. /**
  75539. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75540. * A Curve3 is designed from a series of successive Vector3.
  75541. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75542. * @param points points which make up the curve
  75543. */
  75544. constructor(points: Vector3[]);
  75545. /**
  75546. * @returns the Curve3 stored array of successive Vector3
  75547. */
  75548. getPoints(): Vector3[];
  75549. /**
  75550. * @returns the computed length (float) of the curve.
  75551. */
  75552. length(): number;
  75553. /**
  75554. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75555. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75556. * curveA and curveB keep unchanged.
  75557. * @param curve the curve to continue from this curve
  75558. * @returns the newly constructed curve
  75559. */
  75560. continue(curve: DeepImmutable<Curve3>): Curve3;
  75561. private _computeLength;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /**
  75566. * This represents the main contract an easing function should follow.
  75567. * Easing functions are used throughout the animation system.
  75568. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75569. */
  75570. export interface IEasingFunction {
  75571. /**
  75572. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75573. * of the easing function.
  75574. * The link below provides some of the most common examples of easing functions.
  75575. * @see https://easings.net/
  75576. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75577. * @returns the corresponding value on the curve defined by the easing function
  75578. */
  75579. ease(gradient: number): number;
  75580. }
  75581. /**
  75582. * Base class used for every default easing function.
  75583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75584. */
  75585. export class EasingFunction implements IEasingFunction {
  75586. /**
  75587. * Interpolation follows the mathematical formula associated with the easing function.
  75588. */
  75589. static readonly EASINGMODE_EASEIN: number;
  75590. /**
  75591. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75592. */
  75593. static readonly EASINGMODE_EASEOUT: number;
  75594. /**
  75595. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75596. */
  75597. static readonly EASINGMODE_EASEINOUT: number;
  75598. private _easingMode;
  75599. /**
  75600. * Sets the easing mode of the current function.
  75601. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75602. */
  75603. setEasingMode(easingMode: number): void;
  75604. /**
  75605. * Gets the current easing mode.
  75606. * @returns the easing mode
  75607. */
  75608. getEasingMode(): number;
  75609. /**
  75610. * @hidden
  75611. */
  75612. easeInCore(gradient: number): number;
  75613. /**
  75614. * Given an input gradient between 0 and 1, this returns the corresponding value
  75615. * of the easing function.
  75616. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75617. * @returns the corresponding value on the curve defined by the easing function
  75618. */
  75619. ease(gradient: number): number;
  75620. }
  75621. /**
  75622. * Easing function with a circle shape (see link below).
  75623. * @see https://easings.net/#easeInCirc
  75624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75625. */
  75626. export class CircleEase extends EasingFunction implements IEasingFunction {
  75627. /** @hidden */
  75628. easeInCore(gradient: number): number;
  75629. }
  75630. /**
  75631. * Easing function with a ease back shape (see link below).
  75632. * @see https://easings.net/#easeInBack
  75633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75634. */
  75635. export class BackEase extends EasingFunction implements IEasingFunction {
  75636. /** Defines the amplitude of the function */
  75637. amplitude: number;
  75638. /**
  75639. * Instantiates a back ease easing
  75640. * @see https://easings.net/#easeInBack
  75641. * @param amplitude Defines the amplitude of the function
  75642. */
  75643. constructor(
  75644. /** Defines the amplitude of the function */
  75645. amplitude?: number);
  75646. /** @hidden */
  75647. easeInCore(gradient: number): number;
  75648. }
  75649. /**
  75650. * Easing function with a bouncing shape (see link below).
  75651. * @see https://easings.net/#easeInBounce
  75652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75653. */
  75654. export class BounceEase extends EasingFunction implements IEasingFunction {
  75655. /** Defines the number of bounces */
  75656. bounces: number;
  75657. /** Defines the amplitude of the bounce */
  75658. bounciness: number;
  75659. /**
  75660. * Instantiates a bounce easing
  75661. * @see https://easings.net/#easeInBounce
  75662. * @param bounces Defines the number of bounces
  75663. * @param bounciness Defines the amplitude of the bounce
  75664. */
  75665. constructor(
  75666. /** Defines the number of bounces */
  75667. bounces?: number,
  75668. /** Defines the amplitude of the bounce */
  75669. bounciness?: number);
  75670. /** @hidden */
  75671. easeInCore(gradient: number): number;
  75672. }
  75673. /**
  75674. * Easing function with a power of 3 shape (see link below).
  75675. * @see https://easings.net/#easeInCubic
  75676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75677. */
  75678. export class CubicEase extends EasingFunction implements IEasingFunction {
  75679. /** @hidden */
  75680. easeInCore(gradient: number): number;
  75681. }
  75682. /**
  75683. * Easing function with an elastic shape (see link below).
  75684. * @see https://easings.net/#easeInElastic
  75685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75686. */
  75687. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75688. /** Defines the number of oscillations*/
  75689. oscillations: number;
  75690. /** Defines the amplitude of the oscillations*/
  75691. springiness: number;
  75692. /**
  75693. * Instantiates an elastic easing function
  75694. * @see https://easings.net/#easeInElastic
  75695. * @param oscillations Defines the number of oscillations
  75696. * @param springiness Defines the amplitude of the oscillations
  75697. */
  75698. constructor(
  75699. /** Defines the number of oscillations*/
  75700. oscillations?: number,
  75701. /** Defines the amplitude of the oscillations*/
  75702. springiness?: number);
  75703. /** @hidden */
  75704. easeInCore(gradient: number): number;
  75705. }
  75706. /**
  75707. * Easing function with an exponential shape (see link below).
  75708. * @see https://easings.net/#easeInExpo
  75709. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75710. */
  75711. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75712. /** Defines the exponent of the function */
  75713. exponent: number;
  75714. /**
  75715. * Instantiates an exponential easing function
  75716. * @see https://easings.net/#easeInExpo
  75717. * @param exponent Defines the exponent of the function
  75718. */
  75719. constructor(
  75720. /** Defines the exponent of the function */
  75721. exponent?: number);
  75722. /** @hidden */
  75723. easeInCore(gradient: number): number;
  75724. }
  75725. /**
  75726. * Easing function with a power shape (see link below).
  75727. * @see https://easings.net/#easeInQuad
  75728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75729. */
  75730. export class PowerEase extends EasingFunction implements IEasingFunction {
  75731. /** Defines the power of the function */
  75732. power: number;
  75733. /**
  75734. * Instantiates an power base easing function
  75735. * @see https://easings.net/#easeInQuad
  75736. * @param power Defines the power of the function
  75737. */
  75738. constructor(
  75739. /** Defines the power of the function */
  75740. power?: number);
  75741. /** @hidden */
  75742. easeInCore(gradient: number): number;
  75743. }
  75744. /**
  75745. * Easing function with a power of 2 shape (see link below).
  75746. * @see https://easings.net/#easeInQuad
  75747. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75748. */
  75749. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75750. /** @hidden */
  75751. easeInCore(gradient: number): number;
  75752. }
  75753. /**
  75754. * Easing function with a power of 4 shape (see link below).
  75755. * @see https://easings.net/#easeInQuart
  75756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75757. */
  75758. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75759. /** @hidden */
  75760. easeInCore(gradient: number): number;
  75761. }
  75762. /**
  75763. * Easing function with a power of 5 shape (see link below).
  75764. * @see https://easings.net/#easeInQuint
  75765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75766. */
  75767. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75768. /** @hidden */
  75769. easeInCore(gradient: number): number;
  75770. }
  75771. /**
  75772. * Easing function with a sin shape (see link below).
  75773. * @see https://easings.net/#easeInSine
  75774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75775. */
  75776. export class SineEase extends EasingFunction implements IEasingFunction {
  75777. /** @hidden */
  75778. easeInCore(gradient: number): number;
  75779. }
  75780. /**
  75781. * Easing function with a bezier shape (see link below).
  75782. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75784. */
  75785. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75786. /** Defines the x component of the start tangent in the bezier curve */
  75787. x1: number;
  75788. /** Defines the y component of the start tangent in the bezier curve */
  75789. y1: number;
  75790. /** Defines the x component of the end tangent in the bezier curve */
  75791. x2: number;
  75792. /** Defines the y component of the end tangent in the bezier curve */
  75793. y2: number;
  75794. /**
  75795. * Instantiates a bezier function
  75796. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75797. * @param x1 Defines the x component of the start tangent in the bezier curve
  75798. * @param y1 Defines the y component of the start tangent in the bezier curve
  75799. * @param x2 Defines the x component of the end tangent in the bezier curve
  75800. * @param y2 Defines the y component of the end tangent in the bezier curve
  75801. */
  75802. constructor(
  75803. /** Defines the x component of the start tangent in the bezier curve */
  75804. x1?: number,
  75805. /** Defines the y component of the start tangent in the bezier curve */
  75806. y1?: number,
  75807. /** Defines the x component of the end tangent in the bezier curve */
  75808. x2?: number,
  75809. /** Defines the y component of the end tangent in the bezier curve */
  75810. y2?: number);
  75811. /** @hidden */
  75812. easeInCore(gradient: number): number;
  75813. }
  75814. }
  75815. declare module BABYLON {
  75816. /**
  75817. * Class used to hold a RBG color
  75818. */
  75819. export class Color3 {
  75820. /**
  75821. * Defines the red component (between 0 and 1, default is 0)
  75822. */
  75823. r: number;
  75824. /**
  75825. * Defines the green component (between 0 and 1, default is 0)
  75826. */
  75827. g: number;
  75828. /**
  75829. * Defines the blue component (between 0 and 1, default is 0)
  75830. */
  75831. b: number;
  75832. /**
  75833. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75834. * @param r defines the red component (between 0 and 1, default is 0)
  75835. * @param g defines the green component (between 0 and 1, default is 0)
  75836. * @param b defines the blue component (between 0 and 1, default is 0)
  75837. */
  75838. constructor(
  75839. /**
  75840. * Defines the red component (between 0 and 1, default is 0)
  75841. */
  75842. r?: number,
  75843. /**
  75844. * Defines the green component (between 0 and 1, default is 0)
  75845. */
  75846. g?: number,
  75847. /**
  75848. * Defines the blue component (between 0 and 1, default is 0)
  75849. */
  75850. b?: number);
  75851. /**
  75852. * Creates a string with the Color3 current values
  75853. * @returns the string representation of the Color3 object
  75854. */
  75855. toString(): string;
  75856. /**
  75857. * Returns the string "Color3"
  75858. * @returns "Color3"
  75859. */
  75860. getClassName(): string;
  75861. /**
  75862. * Compute the Color3 hash code
  75863. * @returns an unique number that can be used to hash Color3 objects
  75864. */
  75865. getHashCode(): number;
  75866. /**
  75867. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75868. * @param array defines the array where to store the r,g,b components
  75869. * @param index defines an optional index in the target array to define where to start storing values
  75870. * @returns the current Color3 object
  75871. */
  75872. toArray(array: FloatArray, index?: number): Color3;
  75873. /**
  75874. * Returns a new Color4 object from the current Color3 and the given alpha
  75875. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75876. * @returns a new Color4 object
  75877. */
  75878. toColor4(alpha?: number): Color4;
  75879. /**
  75880. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75881. * @returns the new array
  75882. */
  75883. asArray(): number[];
  75884. /**
  75885. * Returns the luminance value
  75886. * @returns a float value
  75887. */
  75888. toLuminance(): number;
  75889. /**
  75890. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75891. * @param otherColor defines the second operand
  75892. * @returns the new Color3 object
  75893. */
  75894. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75895. /**
  75896. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75897. * @param otherColor defines the second operand
  75898. * @param result defines the Color3 object where to store the result
  75899. * @returns the current Color3
  75900. */
  75901. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75902. /**
  75903. * Determines equality between Color3 objects
  75904. * @param otherColor defines the second operand
  75905. * @returns true if the rgb values are equal to the given ones
  75906. */
  75907. equals(otherColor: DeepImmutable<Color3>): boolean;
  75908. /**
  75909. * Determines equality between the current Color3 object and a set of r,b,g values
  75910. * @param r defines the red component to check
  75911. * @param g defines the green component to check
  75912. * @param b defines the blue component to check
  75913. * @returns true if the rgb values are equal to the given ones
  75914. */
  75915. equalsFloats(r: number, g: number, b: number): boolean;
  75916. /**
  75917. * Multiplies in place each rgb value by scale
  75918. * @param scale defines the scaling factor
  75919. * @returns the updated Color3
  75920. */
  75921. scale(scale: number): Color3;
  75922. /**
  75923. * Multiplies the rgb values by scale and stores the result into "result"
  75924. * @param scale defines the scaling factor
  75925. * @param result defines the Color3 object where to store the result
  75926. * @returns the unmodified current Color3
  75927. */
  75928. scaleToRef(scale: number, result: Color3): Color3;
  75929. /**
  75930. * Scale the current Color3 values by a factor and add the result to a given Color3
  75931. * @param scale defines the scale factor
  75932. * @param result defines color to store the result into
  75933. * @returns the unmodified current Color3
  75934. */
  75935. scaleAndAddToRef(scale: number, result: Color3): Color3;
  75936. /**
  75937. * Clamps the rgb values by the min and max values and stores the result into "result"
  75938. * @param min defines minimum clamping value (default is 0)
  75939. * @param max defines maximum clamping value (default is 1)
  75940. * @param result defines color to store the result into
  75941. * @returns the original Color3
  75942. */
  75943. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  75944. /**
  75945. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  75946. * @param otherColor defines the second operand
  75947. * @returns the new Color3
  75948. */
  75949. add(otherColor: DeepImmutable<Color3>): Color3;
  75950. /**
  75951. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  75952. * @param otherColor defines the second operand
  75953. * @param result defines Color3 object to store the result into
  75954. * @returns the unmodified current Color3
  75955. */
  75956. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75957. /**
  75958. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  75959. * @param otherColor defines the second operand
  75960. * @returns the new Color3
  75961. */
  75962. subtract(otherColor: DeepImmutable<Color3>): Color3;
  75963. /**
  75964. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  75965. * @param otherColor defines the second operand
  75966. * @param result defines Color3 object to store the result into
  75967. * @returns the unmodified current Color3
  75968. */
  75969. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75970. /**
  75971. * Copy the current object
  75972. * @returns a new Color3 copied the current one
  75973. */
  75974. clone(): Color3;
  75975. /**
  75976. * Copies the rgb values from the source in the current Color3
  75977. * @param source defines the source Color3 object
  75978. * @returns the updated Color3 object
  75979. */
  75980. copyFrom(source: DeepImmutable<Color3>): Color3;
  75981. /**
  75982. * Updates the Color3 rgb values from the given floats
  75983. * @param r defines the red component to read from
  75984. * @param g defines the green component to read from
  75985. * @param b defines the blue component to read from
  75986. * @returns the current Color3 object
  75987. */
  75988. copyFromFloats(r: number, g: number, b: number): Color3;
  75989. /**
  75990. * Updates the Color3 rgb values from the given floats
  75991. * @param r defines the red component to read from
  75992. * @param g defines the green component to read from
  75993. * @param b defines the blue component to read from
  75994. * @returns the current Color3 object
  75995. */
  75996. set(r: number, g: number, b: number): Color3;
  75997. /**
  75998. * Compute the Color3 hexadecimal code as a string
  75999. * @returns a string containing the hexadecimal representation of the Color3 object
  76000. */
  76001. toHexString(): string;
  76002. /**
  76003. * Computes a new Color3 converted from the current one to linear space
  76004. * @returns a new Color3 object
  76005. */
  76006. toLinearSpace(): Color3;
  76007. /**
  76008. * Converts current color in rgb space to HSV values
  76009. * @returns a new color3 representing the HSV values
  76010. */
  76011. toHSV(): Color3;
  76012. /**
  76013. * Converts current color in rgb space to HSV values
  76014. * @param result defines the Color3 where to store the HSV values
  76015. */
  76016. toHSVToRef(result: Color3): void;
  76017. /**
  76018. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76019. * @param convertedColor defines the Color3 object where to store the linear space version
  76020. * @returns the unmodified Color3
  76021. */
  76022. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76023. /**
  76024. * Computes a new Color3 converted from the current one to gamma space
  76025. * @returns a new Color3 object
  76026. */
  76027. toGammaSpace(): Color3;
  76028. /**
  76029. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76030. * @param convertedColor defines the Color3 object where to store the gamma space version
  76031. * @returns the unmodified Color3
  76032. */
  76033. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76034. private static _BlackReadOnly;
  76035. /**
  76036. * Convert Hue, saturation and value to a Color3 (RGB)
  76037. * @param hue defines the hue
  76038. * @param saturation defines the saturation
  76039. * @param value defines the value
  76040. * @param result defines the Color3 where to store the RGB values
  76041. */
  76042. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76043. /**
  76044. * Creates a new Color3 from the string containing valid hexadecimal values
  76045. * @param hex defines a string containing valid hexadecimal values
  76046. * @returns a new Color3 object
  76047. */
  76048. static FromHexString(hex: string): Color3;
  76049. /**
  76050. * Creates a new Color3 from the starting index of the given array
  76051. * @param array defines the source array
  76052. * @param offset defines an offset in the source array
  76053. * @returns a new Color3 object
  76054. */
  76055. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76056. /**
  76057. * Creates a new Color3 from integer values (< 256)
  76058. * @param r defines the red component to read from (value between 0 and 255)
  76059. * @param g defines the green component to read from (value between 0 and 255)
  76060. * @param b defines the blue component to read from (value between 0 and 255)
  76061. * @returns a new Color3 object
  76062. */
  76063. static FromInts(r: number, g: number, b: number): Color3;
  76064. /**
  76065. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76066. * @param start defines the start Color3 value
  76067. * @param end defines the end Color3 value
  76068. * @param amount defines the gradient value between start and end
  76069. * @returns a new Color3 object
  76070. */
  76071. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76072. /**
  76073. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76074. * @param left defines the start value
  76075. * @param right defines the end value
  76076. * @param amount defines the gradient factor
  76077. * @param result defines the Color3 object where to store the result
  76078. */
  76079. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76080. /**
  76081. * Returns a Color3 value containing a red color
  76082. * @returns a new Color3 object
  76083. */
  76084. static Red(): Color3;
  76085. /**
  76086. * Returns a Color3 value containing a green color
  76087. * @returns a new Color3 object
  76088. */
  76089. static Green(): Color3;
  76090. /**
  76091. * Returns a Color3 value containing a blue color
  76092. * @returns a new Color3 object
  76093. */
  76094. static Blue(): Color3;
  76095. /**
  76096. * Returns a Color3 value containing a black color
  76097. * @returns a new Color3 object
  76098. */
  76099. static Black(): Color3;
  76100. /**
  76101. * Gets a Color3 value containing a black color that must not be updated
  76102. */
  76103. static get BlackReadOnly(): DeepImmutable<Color3>;
  76104. /**
  76105. * Returns a Color3 value containing a white color
  76106. * @returns a new Color3 object
  76107. */
  76108. static White(): Color3;
  76109. /**
  76110. * Returns a Color3 value containing a purple color
  76111. * @returns a new Color3 object
  76112. */
  76113. static Purple(): Color3;
  76114. /**
  76115. * Returns a Color3 value containing a magenta color
  76116. * @returns a new Color3 object
  76117. */
  76118. static Magenta(): Color3;
  76119. /**
  76120. * Returns a Color3 value containing a yellow color
  76121. * @returns a new Color3 object
  76122. */
  76123. static Yellow(): Color3;
  76124. /**
  76125. * Returns a Color3 value containing a gray color
  76126. * @returns a new Color3 object
  76127. */
  76128. static Gray(): Color3;
  76129. /**
  76130. * Returns a Color3 value containing a teal color
  76131. * @returns a new Color3 object
  76132. */
  76133. static Teal(): Color3;
  76134. /**
  76135. * Returns a Color3 value containing a random color
  76136. * @returns a new Color3 object
  76137. */
  76138. static Random(): Color3;
  76139. }
  76140. /**
  76141. * Class used to hold a RBGA color
  76142. */
  76143. export class Color4 {
  76144. /**
  76145. * Defines the red component (between 0 and 1, default is 0)
  76146. */
  76147. r: number;
  76148. /**
  76149. * Defines the green component (between 0 and 1, default is 0)
  76150. */
  76151. g: number;
  76152. /**
  76153. * Defines the blue component (between 0 and 1, default is 0)
  76154. */
  76155. b: number;
  76156. /**
  76157. * Defines the alpha component (between 0 and 1, default is 1)
  76158. */
  76159. a: number;
  76160. /**
  76161. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76162. * @param r defines the red component (between 0 and 1, default is 0)
  76163. * @param g defines the green component (between 0 and 1, default is 0)
  76164. * @param b defines the blue component (between 0 and 1, default is 0)
  76165. * @param a defines the alpha component (between 0 and 1, default is 1)
  76166. */
  76167. constructor(
  76168. /**
  76169. * Defines the red component (between 0 and 1, default is 0)
  76170. */
  76171. r?: number,
  76172. /**
  76173. * Defines the green component (between 0 and 1, default is 0)
  76174. */
  76175. g?: number,
  76176. /**
  76177. * Defines the blue component (between 0 and 1, default is 0)
  76178. */
  76179. b?: number,
  76180. /**
  76181. * Defines the alpha component (between 0 and 1, default is 1)
  76182. */
  76183. a?: number);
  76184. /**
  76185. * Adds in place the given Color4 values to the current Color4 object
  76186. * @param right defines the second operand
  76187. * @returns the current updated Color4 object
  76188. */
  76189. addInPlace(right: DeepImmutable<Color4>): Color4;
  76190. /**
  76191. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76192. * @returns the new array
  76193. */
  76194. asArray(): number[];
  76195. /**
  76196. * Stores from the starting index in the given array the Color4 successive values
  76197. * @param array defines the array where to store the r,g,b components
  76198. * @param index defines an optional index in the target array to define where to start storing values
  76199. * @returns the current Color4 object
  76200. */
  76201. toArray(array: number[], index?: number): Color4;
  76202. /**
  76203. * Determines equality between Color4 objects
  76204. * @param otherColor defines the second operand
  76205. * @returns true if the rgba values are equal to the given ones
  76206. */
  76207. equals(otherColor: DeepImmutable<Color4>): boolean;
  76208. /**
  76209. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76210. * @param right defines the second operand
  76211. * @returns a new Color4 object
  76212. */
  76213. add(right: DeepImmutable<Color4>): Color4;
  76214. /**
  76215. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76216. * @param right defines the second operand
  76217. * @returns a new Color4 object
  76218. */
  76219. subtract(right: DeepImmutable<Color4>): Color4;
  76220. /**
  76221. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76222. * @param right defines the second operand
  76223. * @param result defines the Color4 object where to store the result
  76224. * @returns the current Color4 object
  76225. */
  76226. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76227. /**
  76228. * Creates a new Color4 with the current Color4 values multiplied by scale
  76229. * @param scale defines the scaling factor to apply
  76230. * @returns a new Color4 object
  76231. */
  76232. scale(scale: number): Color4;
  76233. /**
  76234. * Multiplies the current Color4 values by scale and stores the result in "result"
  76235. * @param scale defines the scaling factor to apply
  76236. * @param result defines the Color4 object where to store the result
  76237. * @returns the current unmodified Color4
  76238. */
  76239. scaleToRef(scale: number, result: Color4): Color4;
  76240. /**
  76241. * Scale the current Color4 values by a factor and add the result to a given Color4
  76242. * @param scale defines the scale factor
  76243. * @param result defines the Color4 object where to store the result
  76244. * @returns the unmodified current Color4
  76245. */
  76246. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76247. /**
  76248. * Clamps the rgb values by the min and max values and stores the result into "result"
  76249. * @param min defines minimum clamping value (default is 0)
  76250. * @param max defines maximum clamping value (default is 1)
  76251. * @param result defines color to store the result into.
  76252. * @returns the cuurent Color4
  76253. */
  76254. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76255. /**
  76256. * Multipy an Color4 value by another and return a new Color4 object
  76257. * @param color defines the Color4 value to multiply by
  76258. * @returns a new Color4 object
  76259. */
  76260. multiply(color: Color4): Color4;
  76261. /**
  76262. * Multipy a Color4 value by another and push the result in a reference value
  76263. * @param color defines the Color4 value to multiply by
  76264. * @param result defines the Color4 to fill the result in
  76265. * @returns the result Color4
  76266. */
  76267. multiplyToRef(color: Color4, result: Color4): Color4;
  76268. /**
  76269. * Creates a string with the Color4 current values
  76270. * @returns the string representation of the Color4 object
  76271. */
  76272. toString(): string;
  76273. /**
  76274. * Returns the string "Color4"
  76275. * @returns "Color4"
  76276. */
  76277. getClassName(): string;
  76278. /**
  76279. * Compute the Color4 hash code
  76280. * @returns an unique number that can be used to hash Color4 objects
  76281. */
  76282. getHashCode(): number;
  76283. /**
  76284. * Creates a new Color4 copied from the current one
  76285. * @returns a new Color4 object
  76286. */
  76287. clone(): Color4;
  76288. /**
  76289. * Copies the given Color4 values into the current one
  76290. * @param source defines the source Color4 object
  76291. * @returns the current updated Color4 object
  76292. */
  76293. copyFrom(source: Color4): Color4;
  76294. /**
  76295. * Copies the given float values into the current one
  76296. * @param r defines the red component to read from
  76297. * @param g defines the green component to read from
  76298. * @param b defines the blue component to read from
  76299. * @param a defines the alpha component to read from
  76300. * @returns the current updated Color4 object
  76301. */
  76302. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76303. /**
  76304. * Copies the given float values into the current one
  76305. * @param r defines the red component to read from
  76306. * @param g defines the green component to read from
  76307. * @param b defines the blue component to read from
  76308. * @param a defines the alpha component to read from
  76309. * @returns the current updated Color4 object
  76310. */
  76311. set(r: number, g: number, b: number, a: number): Color4;
  76312. /**
  76313. * Compute the Color4 hexadecimal code as a string
  76314. * @returns a string containing the hexadecimal representation of the Color4 object
  76315. */
  76316. toHexString(): string;
  76317. /**
  76318. * Computes a new Color4 converted from the current one to linear space
  76319. * @returns a new Color4 object
  76320. */
  76321. toLinearSpace(): Color4;
  76322. /**
  76323. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76324. * @param convertedColor defines the Color4 object where to store the linear space version
  76325. * @returns the unmodified Color4
  76326. */
  76327. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76328. /**
  76329. * Computes a new Color4 converted from the current one to gamma space
  76330. * @returns a new Color4 object
  76331. */
  76332. toGammaSpace(): Color4;
  76333. /**
  76334. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76335. * @param convertedColor defines the Color4 object where to store the gamma space version
  76336. * @returns the unmodified Color4
  76337. */
  76338. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76339. /**
  76340. * Creates a new Color4 from the string containing valid hexadecimal values
  76341. * @param hex defines a string containing valid hexadecimal values
  76342. * @returns a new Color4 object
  76343. */
  76344. static FromHexString(hex: string): Color4;
  76345. /**
  76346. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76347. * @param left defines the start value
  76348. * @param right defines the end value
  76349. * @param amount defines the gradient factor
  76350. * @returns a new Color4 object
  76351. */
  76352. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76353. /**
  76354. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76355. * @param left defines the start value
  76356. * @param right defines the end value
  76357. * @param amount defines the gradient factor
  76358. * @param result defines the Color4 object where to store data
  76359. */
  76360. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76361. /**
  76362. * Creates a new Color4 from a Color3 and an alpha value
  76363. * @param color3 defines the source Color3 to read from
  76364. * @param alpha defines the alpha component (1.0 by default)
  76365. * @returns a new Color4 object
  76366. */
  76367. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76368. /**
  76369. * Creates a new Color4 from the starting index element of the given array
  76370. * @param array defines the source array to read from
  76371. * @param offset defines the offset in the source array
  76372. * @returns a new Color4 object
  76373. */
  76374. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76375. /**
  76376. * Creates a new Color3 from integer values (< 256)
  76377. * @param r defines the red component to read from (value between 0 and 255)
  76378. * @param g defines the green component to read from (value between 0 and 255)
  76379. * @param b defines the blue component to read from (value between 0 and 255)
  76380. * @param a defines the alpha component to read from (value between 0 and 255)
  76381. * @returns a new Color3 object
  76382. */
  76383. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76384. /**
  76385. * Check the content of a given array and convert it to an array containing RGBA data
  76386. * If the original array was already containing count * 4 values then it is returned directly
  76387. * @param colors defines the array to check
  76388. * @param count defines the number of RGBA data to expect
  76389. * @returns an array containing count * 4 values (RGBA)
  76390. */
  76391. static CheckColors4(colors: number[], count: number): number[];
  76392. }
  76393. /**
  76394. * @hidden
  76395. */
  76396. export class TmpColors {
  76397. static Color3: Color3[];
  76398. static Color4: Color4[];
  76399. }
  76400. }
  76401. declare module BABYLON {
  76402. /**
  76403. * Defines an interface which represents an animation key frame
  76404. */
  76405. export interface IAnimationKey {
  76406. /**
  76407. * Frame of the key frame
  76408. */
  76409. frame: number;
  76410. /**
  76411. * Value at the specifies key frame
  76412. */
  76413. value: any;
  76414. /**
  76415. * The input tangent for the cubic hermite spline
  76416. */
  76417. inTangent?: any;
  76418. /**
  76419. * The output tangent for the cubic hermite spline
  76420. */
  76421. outTangent?: any;
  76422. /**
  76423. * The animation interpolation type
  76424. */
  76425. interpolation?: AnimationKeyInterpolation;
  76426. }
  76427. /**
  76428. * Enum for the animation key frame interpolation type
  76429. */
  76430. export enum AnimationKeyInterpolation {
  76431. /**
  76432. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76433. */
  76434. STEP = 1
  76435. }
  76436. }
  76437. declare module BABYLON {
  76438. /**
  76439. * Represents the range of an animation
  76440. */
  76441. export class AnimationRange {
  76442. /**The name of the animation range**/
  76443. name: string;
  76444. /**The starting frame of the animation */
  76445. from: number;
  76446. /**The ending frame of the animation*/
  76447. to: number;
  76448. /**
  76449. * Initializes the range of an animation
  76450. * @param name The name of the animation range
  76451. * @param from The starting frame of the animation
  76452. * @param to The ending frame of the animation
  76453. */
  76454. constructor(
  76455. /**The name of the animation range**/
  76456. name: string,
  76457. /**The starting frame of the animation */
  76458. from: number,
  76459. /**The ending frame of the animation*/
  76460. to: number);
  76461. /**
  76462. * Makes a copy of the animation range
  76463. * @returns A copy of the animation range
  76464. */
  76465. clone(): AnimationRange;
  76466. }
  76467. }
  76468. declare module BABYLON {
  76469. /**
  76470. * Composed of a frame, and an action function
  76471. */
  76472. export class AnimationEvent {
  76473. /** The frame for which the event is triggered **/
  76474. frame: number;
  76475. /** The event to perform when triggered **/
  76476. action: (currentFrame: number) => void;
  76477. /** Specifies if the event should be triggered only once**/
  76478. onlyOnce?: boolean | undefined;
  76479. /**
  76480. * Specifies if the animation event is done
  76481. */
  76482. isDone: boolean;
  76483. /**
  76484. * Initializes the animation event
  76485. * @param frame The frame for which the event is triggered
  76486. * @param action The event to perform when triggered
  76487. * @param onlyOnce Specifies if the event should be triggered only once
  76488. */
  76489. constructor(
  76490. /** The frame for which the event is triggered **/
  76491. frame: number,
  76492. /** The event to perform when triggered **/
  76493. action: (currentFrame: number) => void,
  76494. /** Specifies if the event should be triggered only once**/
  76495. onlyOnce?: boolean | undefined);
  76496. /** @hidden */
  76497. _clone(): AnimationEvent;
  76498. }
  76499. }
  76500. declare module BABYLON {
  76501. /**
  76502. * Interface used to define a behavior
  76503. */
  76504. export interface Behavior<T> {
  76505. /** gets or sets behavior's name */
  76506. name: string;
  76507. /**
  76508. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76509. */
  76510. init(): void;
  76511. /**
  76512. * Called when the behavior is attached to a target
  76513. * @param target defines the target where the behavior is attached to
  76514. */
  76515. attach(target: T): void;
  76516. /**
  76517. * Called when the behavior is detached from its target
  76518. */
  76519. detach(): void;
  76520. }
  76521. /**
  76522. * Interface implemented by classes supporting behaviors
  76523. */
  76524. export interface IBehaviorAware<T> {
  76525. /**
  76526. * Attach a behavior
  76527. * @param behavior defines the behavior to attach
  76528. * @returns the current host
  76529. */
  76530. addBehavior(behavior: Behavior<T>): T;
  76531. /**
  76532. * Remove a behavior from the current object
  76533. * @param behavior defines the behavior to detach
  76534. * @returns the current host
  76535. */
  76536. removeBehavior(behavior: Behavior<T>): T;
  76537. /**
  76538. * Gets a behavior using its name to search
  76539. * @param name defines the name to search
  76540. * @returns the behavior or null if not found
  76541. */
  76542. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76543. }
  76544. }
  76545. declare module BABYLON {
  76546. /**
  76547. * Defines an array and its length.
  76548. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76549. */
  76550. export interface ISmartArrayLike<T> {
  76551. /**
  76552. * The data of the array.
  76553. */
  76554. data: Array<T>;
  76555. /**
  76556. * The active length of the array.
  76557. */
  76558. length: number;
  76559. }
  76560. /**
  76561. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76562. */
  76563. export class SmartArray<T> implements ISmartArrayLike<T> {
  76564. /**
  76565. * The full set of data from the array.
  76566. */
  76567. data: Array<T>;
  76568. /**
  76569. * The active length of the array.
  76570. */
  76571. length: number;
  76572. protected _id: number;
  76573. /**
  76574. * Instantiates a Smart Array.
  76575. * @param capacity defines the default capacity of the array.
  76576. */
  76577. constructor(capacity: number);
  76578. /**
  76579. * Pushes a value at the end of the active data.
  76580. * @param value defines the object to push in the array.
  76581. */
  76582. push(value: T): void;
  76583. /**
  76584. * Iterates over the active data and apply the lambda to them.
  76585. * @param func defines the action to apply on each value.
  76586. */
  76587. forEach(func: (content: T) => void): void;
  76588. /**
  76589. * Sorts the full sets of data.
  76590. * @param compareFn defines the comparison function to apply.
  76591. */
  76592. sort(compareFn: (a: T, b: T) => number): void;
  76593. /**
  76594. * Resets the active data to an empty array.
  76595. */
  76596. reset(): void;
  76597. /**
  76598. * Releases all the data from the array as well as the array.
  76599. */
  76600. dispose(): void;
  76601. /**
  76602. * Concats the active data with a given array.
  76603. * @param array defines the data to concatenate with.
  76604. */
  76605. concat(array: any): void;
  76606. /**
  76607. * Returns the position of a value in the active data.
  76608. * @param value defines the value to find the index for
  76609. * @returns the index if found in the active data otherwise -1
  76610. */
  76611. indexOf(value: T): number;
  76612. /**
  76613. * Returns whether an element is part of the active data.
  76614. * @param value defines the value to look for
  76615. * @returns true if found in the active data otherwise false
  76616. */
  76617. contains(value: T): boolean;
  76618. private static _GlobalId;
  76619. }
  76620. /**
  76621. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76622. * The data in this array can only be present once
  76623. */
  76624. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76625. private _duplicateId;
  76626. /**
  76627. * Pushes a value at the end of the active data.
  76628. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76629. * @param value defines the object to push in the array.
  76630. */
  76631. push(value: T): void;
  76632. /**
  76633. * Pushes a value at the end of the active data.
  76634. * If the data is already present, it won t be added again
  76635. * @param value defines the object to push in the array.
  76636. * @returns true if added false if it was already present
  76637. */
  76638. pushNoDuplicate(value: T): boolean;
  76639. /**
  76640. * Resets the active data to an empty array.
  76641. */
  76642. reset(): void;
  76643. /**
  76644. * Concats the active data with a given array.
  76645. * This ensures no dupplicate will be present in the result.
  76646. * @param array defines the data to concatenate with.
  76647. */
  76648. concatWithNoDuplicate(array: any): void;
  76649. }
  76650. }
  76651. declare module BABYLON {
  76652. /**
  76653. * @ignore
  76654. * This is a list of all the different input types that are available in the application.
  76655. * Fo instance: ArcRotateCameraGamepadInput...
  76656. */
  76657. export var CameraInputTypes: {};
  76658. /**
  76659. * This is the contract to implement in order to create a new input class.
  76660. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76661. */
  76662. export interface ICameraInput<TCamera extends Camera> {
  76663. /**
  76664. * Defines the camera the input is attached to.
  76665. */
  76666. camera: Nullable<TCamera>;
  76667. /**
  76668. * Gets the class name of the current intput.
  76669. * @returns the class name
  76670. */
  76671. getClassName(): string;
  76672. /**
  76673. * Get the friendly name associated with the input class.
  76674. * @returns the input friendly name
  76675. */
  76676. getSimpleName(): string;
  76677. /**
  76678. * Attach the input controls to a specific dom element to get the input from.
  76679. * @param element Defines the element the controls should be listened from
  76680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76681. */
  76682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76683. /**
  76684. * Detach the current controls from the specified dom element.
  76685. * @param element Defines the element to stop listening the inputs from
  76686. */
  76687. detachControl(element: Nullable<HTMLElement>): void;
  76688. /**
  76689. * Update the current camera state depending on the inputs that have been used this frame.
  76690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76691. */
  76692. checkInputs?: () => void;
  76693. }
  76694. /**
  76695. * Represents a map of input types to input instance or input index to input instance.
  76696. */
  76697. export interface CameraInputsMap<TCamera extends Camera> {
  76698. /**
  76699. * Accessor to the input by input type.
  76700. */
  76701. [name: string]: ICameraInput<TCamera>;
  76702. /**
  76703. * Accessor to the input by input index.
  76704. */
  76705. [idx: number]: ICameraInput<TCamera>;
  76706. }
  76707. /**
  76708. * This represents the input manager used within a camera.
  76709. * It helps dealing with all the different kind of input attached to a camera.
  76710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76711. */
  76712. export class CameraInputsManager<TCamera extends Camera> {
  76713. /**
  76714. * Defines the list of inputs attahed to the camera.
  76715. */
  76716. attached: CameraInputsMap<TCamera>;
  76717. /**
  76718. * Defines the dom element the camera is collecting inputs from.
  76719. * This is null if the controls have not been attached.
  76720. */
  76721. attachedElement: Nullable<HTMLElement>;
  76722. /**
  76723. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76724. */
  76725. noPreventDefault: boolean;
  76726. /**
  76727. * Defined the camera the input manager belongs to.
  76728. */
  76729. camera: TCamera;
  76730. /**
  76731. * Update the current camera state depending on the inputs that have been used this frame.
  76732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76733. */
  76734. checkInputs: () => void;
  76735. /**
  76736. * Instantiate a new Camera Input Manager.
  76737. * @param camera Defines the camera the input manager blongs to
  76738. */
  76739. constructor(camera: TCamera);
  76740. /**
  76741. * Add an input method to a camera
  76742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76743. * @param input camera input method
  76744. */
  76745. add(input: ICameraInput<TCamera>): void;
  76746. /**
  76747. * Remove a specific input method from a camera
  76748. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76749. * @param inputToRemove camera input method
  76750. */
  76751. remove(inputToRemove: ICameraInput<TCamera>): void;
  76752. /**
  76753. * Remove a specific input type from a camera
  76754. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76755. * @param inputType the type of the input to remove
  76756. */
  76757. removeByType(inputType: string): void;
  76758. private _addCheckInputs;
  76759. /**
  76760. * Attach the input controls to the currently attached dom element to listen the events from.
  76761. * @param input Defines the input to attach
  76762. */
  76763. attachInput(input: ICameraInput<TCamera>): void;
  76764. /**
  76765. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76766. * @param element Defines the dom element to collect the events from
  76767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76768. */
  76769. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76770. /**
  76771. * Detach the current manager inputs controls from a specific dom element.
  76772. * @param element Defines the dom element to collect the events from
  76773. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76774. */
  76775. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76776. /**
  76777. * Rebuild the dynamic inputCheck function from the current list of
  76778. * defined inputs in the manager.
  76779. */
  76780. rebuildInputCheck(): void;
  76781. /**
  76782. * Remove all attached input methods from a camera
  76783. */
  76784. clear(): void;
  76785. /**
  76786. * Serialize the current input manager attached to a camera.
  76787. * This ensures than once parsed,
  76788. * the input associated to the camera will be identical to the current ones
  76789. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76790. */
  76791. serialize(serializedCamera: any): void;
  76792. /**
  76793. * Parses an input manager serialized JSON to restore the previous list of inputs
  76794. * and states associated to a camera.
  76795. * @param parsedCamera Defines the JSON to parse
  76796. */
  76797. parse(parsedCamera: any): void;
  76798. }
  76799. }
  76800. declare module BABYLON {
  76801. /**
  76802. * Class used to store data that will be store in GPU memory
  76803. */
  76804. export class Buffer {
  76805. private _engine;
  76806. private _buffer;
  76807. /** @hidden */
  76808. _data: Nullable<DataArray>;
  76809. private _updatable;
  76810. private _instanced;
  76811. private _divisor;
  76812. /**
  76813. * Gets the byte stride.
  76814. */
  76815. readonly byteStride: number;
  76816. /**
  76817. * Constructor
  76818. * @param engine the engine
  76819. * @param data the data to use for this buffer
  76820. * @param updatable whether the data is updatable
  76821. * @param stride the stride (optional)
  76822. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76823. * @param instanced whether the buffer is instanced (optional)
  76824. * @param useBytes set to true if the stride in in bytes (optional)
  76825. * @param divisor sets an optional divisor for instances (1 by default)
  76826. */
  76827. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76828. /**
  76829. * Create a new VertexBuffer based on the current buffer
  76830. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76831. * @param offset defines offset in the buffer (0 by default)
  76832. * @param size defines the size in floats of attributes (position is 3 for instance)
  76833. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76834. * @param instanced defines if the vertex buffer contains indexed data
  76835. * @param useBytes defines if the offset and stride are in bytes *
  76836. * @param divisor sets an optional divisor for instances (1 by default)
  76837. * @returns the new vertex buffer
  76838. */
  76839. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76840. /**
  76841. * Gets a boolean indicating if the Buffer is updatable?
  76842. * @returns true if the buffer is updatable
  76843. */
  76844. isUpdatable(): boolean;
  76845. /**
  76846. * Gets current buffer's data
  76847. * @returns a DataArray or null
  76848. */
  76849. getData(): Nullable<DataArray>;
  76850. /**
  76851. * Gets underlying native buffer
  76852. * @returns underlying native buffer
  76853. */
  76854. getBuffer(): Nullable<DataBuffer>;
  76855. /**
  76856. * Gets the stride in float32 units (i.e. byte stride / 4).
  76857. * May not be an integer if the byte stride is not divisible by 4.
  76858. * @returns the stride in float32 units
  76859. * @deprecated Please use byteStride instead.
  76860. */
  76861. getStrideSize(): number;
  76862. /**
  76863. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76864. * @param data defines the data to store
  76865. */
  76866. create(data?: Nullable<DataArray>): void;
  76867. /** @hidden */
  76868. _rebuild(): void;
  76869. /**
  76870. * Update current buffer data
  76871. * @param data defines the data to store
  76872. */
  76873. update(data: DataArray): void;
  76874. /**
  76875. * Updates the data directly.
  76876. * @param data the new data
  76877. * @param offset the new offset
  76878. * @param vertexCount the vertex count (optional)
  76879. * @param useBytes set to true if the offset is in bytes
  76880. */
  76881. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76882. /**
  76883. * Release all resources
  76884. */
  76885. dispose(): void;
  76886. }
  76887. /**
  76888. * Specialized buffer used to store vertex data
  76889. */
  76890. export class VertexBuffer {
  76891. /** @hidden */
  76892. _buffer: Buffer;
  76893. private _kind;
  76894. private _size;
  76895. private _ownsBuffer;
  76896. private _instanced;
  76897. private _instanceDivisor;
  76898. /**
  76899. * The byte type.
  76900. */
  76901. static readonly BYTE: number;
  76902. /**
  76903. * The unsigned byte type.
  76904. */
  76905. static readonly UNSIGNED_BYTE: number;
  76906. /**
  76907. * The short type.
  76908. */
  76909. static readonly SHORT: number;
  76910. /**
  76911. * The unsigned short type.
  76912. */
  76913. static readonly UNSIGNED_SHORT: number;
  76914. /**
  76915. * The integer type.
  76916. */
  76917. static readonly INT: number;
  76918. /**
  76919. * The unsigned integer type.
  76920. */
  76921. static readonly UNSIGNED_INT: number;
  76922. /**
  76923. * The float type.
  76924. */
  76925. static readonly FLOAT: number;
  76926. /**
  76927. * Gets or sets the instance divisor when in instanced mode
  76928. */
  76929. get instanceDivisor(): number;
  76930. set instanceDivisor(value: number);
  76931. /**
  76932. * Gets the byte stride.
  76933. */
  76934. readonly byteStride: number;
  76935. /**
  76936. * Gets the byte offset.
  76937. */
  76938. readonly byteOffset: number;
  76939. /**
  76940. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  76941. */
  76942. readonly normalized: boolean;
  76943. /**
  76944. * Gets the data type of each component in the array.
  76945. */
  76946. readonly type: number;
  76947. /**
  76948. * Constructor
  76949. * @param engine the engine
  76950. * @param data the data to use for this vertex buffer
  76951. * @param kind the vertex buffer kind
  76952. * @param updatable whether the data is updatable
  76953. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76954. * @param stride the stride (optional)
  76955. * @param instanced whether the buffer is instanced (optional)
  76956. * @param offset the offset of the data (optional)
  76957. * @param size the number of components (optional)
  76958. * @param type the type of the component (optional)
  76959. * @param normalized whether the data contains normalized data (optional)
  76960. * @param useBytes set to true if stride and offset are in bytes (optional)
  76961. * @param divisor defines the instance divisor to use (1 by default)
  76962. */
  76963. 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);
  76964. /** @hidden */
  76965. _rebuild(): void;
  76966. /**
  76967. * Returns the kind of the VertexBuffer (string)
  76968. * @returns a string
  76969. */
  76970. getKind(): string;
  76971. /**
  76972. * Gets a boolean indicating if the VertexBuffer is updatable?
  76973. * @returns true if the buffer is updatable
  76974. */
  76975. isUpdatable(): boolean;
  76976. /**
  76977. * Gets current buffer's data
  76978. * @returns a DataArray or null
  76979. */
  76980. getData(): Nullable<DataArray>;
  76981. /**
  76982. * Gets underlying native buffer
  76983. * @returns underlying native buffer
  76984. */
  76985. getBuffer(): Nullable<DataBuffer>;
  76986. /**
  76987. * Gets the stride in float32 units (i.e. byte stride / 4).
  76988. * May not be an integer if the byte stride is not divisible by 4.
  76989. * @returns the stride in float32 units
  76990. * @deprecated Please use byteStride instead.
  76991. */
  76992. getStrideSize(): number;
  76993. /**
  76994. * Returns the offset as a multiple of the type byte length.
  76995. * @returns the offset in bytes
  76996. * @deprecated Please use byteOffset instead.
  76997. */
  76998. getOffset(): number;
  76999. /**
  77000. * Returns the number of components per vertex attribute (integer)
  77001. * @returns the size in float
  77002. */
  77003. getSize(): number;
  77004. /**
  77005. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77006. * @returns true if this buffer is instanced
  77007. */
  77008. getIsInstanced(): boolean;
  77009. /**
  77010. * Returns the instancing divisor, zero for non-instanced (integer).
  77011. * @returns a number
  77012. */
  77013. getInstanceDivisor(): number;
  77014. /**
  77015. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77016. * @param data defines the data to store
  77017. */
  77018. create(data?: DataArray): void;
  77019. /**
  77020. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77021. * This function will create a new buffer if the current one is not updatable
  77022. * @param data defines the data to store
  77023. */
  77024. update(data: DataArray): void;
  77025. /**
  77026. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77027. * Returns the directly updated WebGLBuffer.
  77028. * @param data the new data
  77029. * @param offset the new offset
  77030. * @param useBytes set to true if the offset is in bytes
  77031. */
  77032. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77033. /**
  77034. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77035. */
  77036. dispose(): void;
  77037. /**
  77038. * Enumerates each value of this vertex buffer as numbers.
  77039. * @param count the number of values to enumerate
  77040. * @param callback the callback function called for each value
  77041. */
  77042. forEach(count: number, callback: (value: number, index: number) => void): void;
  77043. /**
  77044. * Positions
  77045. */
  77046. static readonly PositionKind: string;
  77047. /**
  77048. * Normals
  77049. */
  77050. static readonly NormalKind: string;
  77051. /**
  77052. * Tangents
  77053. */
  77054. static readonly TangentKind: string;
  77055. /**
  77056. * Texture coordinates
  77057. */
  77058. static readonly UVKind: string;
  77059. /**
  77060. * Texture coordinates 2
  77061. */
  77062. static readonly UV2Kind: string;
  77063. /**
  77064. * Texture coordinates 3
  77065. */
  77066. static readonly UV3Kind: string;
  77067. /**
  77068. * Texture coordinates 4
  77069. */
  77070. static readonly UV4Kind: string;
  77071. /**
  77072. * Texture coordinates 5
  77073. */
  77074. static readonly UV5Kind: string;
  77075. /**
  77076. * Texture coordinates 6
  77077. */
  77078. static readonly UV6Kind: string;
  77079. /**
  77080. * Colors
  77081. */
  77082. static readonly ColorKind: string;
  77083. /**
  77084. * Matrix indices (for bones)
  77085. */
  77086. static readonly MatricesIndicesKind: string;
  77087. /**
  77088. * Matrix weights (for bones)
  77089. */
  77090. static readonly MatricesWeightsKind: string;
  77091. /**
  77092. * Additional matrix indices (for bones)
  77093. */
  77094. static readonly MatricesIndicesExtraKind: string;
  77095. /**
  77096. * Additional matrix weights (for bones)
  77097. */
  77098. static readonly MatricesWeightsExtraKind: string;
  77099. /**
  77100. * Deduces the stride given a kind.
  77101. * @param kind The kind string to deduce
  77102. * @returns The deduced stride
  77103. */
  77104. static DeduceStride(kind: string): number;
  77105. /**
  77106. * Gets the byte length of the given type.
  77107. * @param type the type
  77108. * @returns the number of bytes
  77109. */
  77110. static GetTypeByteLength(type: number): number;
  77111. /**
  77112. * Enumerates each value of the given parameters as numbers.
  77113. * @param data the data to enumerate
  77114. * @param byteOffset the byte offset of the data
  77115. * @param byteStride the byte stride of the data
  77116. * @param componentCount the number of components per element
  77117. * @param componentType the type of the component
  77118. * @param count the number of values to enumerate
  77119. * @param normalized whether the data is normalized
  77120. * @param callback the callback function called for each value
  77121. */
  77122. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77123. private static _GetFloatValue;
  77124. }
  77125. }
  77126. declare module BABYLON {
  77127. /**
  77128. * @hidden
  77129. */
  77130. export class IntersectionInfo {
  77131. bu: Nullable<number>;
  77132. bv: Nullable<number>;
  77133. distance: number;
  77134. faceId: number;
  77135. subMeshId: number;
  77136. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77137. }
  77138. }
  77139. declare module BABYLON {
  77140. /**
  77141. * Represens a plane by the equation ax + by + cz + d = 0
  77142. */
  77143. export class Plane {
  77144. private static _TmpMatrix;
  77145. /**
  77146. * Normal of the plane (a,b,c)
  77147. */
  77148. normal: Vector3;
  77149. /**
  77150. * d component of the plane
  77151. */
  77152. d: number;
  77153. /**
  77154. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77155. * @param a a component of the plane
  77156. * @param b b component of the plane
  77157. * @param c c component of the plane
  77158. * @param d d component of the plane
  77159. */
  77160. constructor(a: number, b: number, c: number, d: number);
  77161. /**
  77162. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77163. */
  77164. asArray(): number[];
  77165. /**
  77166. * @returns a new plane copied from the current Plane.
  77167. */
  77168. clone(): Plane;
  77169. /**
  77170. * @returns the string "Plane".
  77171. */
  77172. getClassName(): string;
  77173. /**
  77174. * @returns the Plane hash code.
  77175. */
  77176. getHashCode(): number;
  77177. /**
  77178. * Normalize the current Plane in place.
  77179. * @returns the updated Plane.
  77180. */
  77181. normalize(): Plane;
  77182. /**
  77183. * Applies a transformation the plane and returns the result
  77184. * @param transformation the transformation matrix to be applied to the plane
  77185. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77186. */
  77187. transform(transformation: DeepImmutable<Matrix>): Plane;
  77188. /**
  77189. * Calcualtte the dot product between the point and the plane normal
  77190. * @param point point to calculate the dot product with
  77191. * @returns the dot product (float) of the point coordinates and the plane normal.
  77192. */
  77193. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77194. /**
  77195. * Updates the current Plane from the plane defined by the three given points.
  77196. * @param point1 one of the points used to contruct the plane
  77197. * @param point2 one of the points used to contruct the plane
  77198. * @param point3 one of the points used to contruct the plane
  77199. * @returns the updated Plane.
  77200. */
  77201. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77202. /**
  77203. * Checks if the plane is facing a given direction
  77204. * @param direction the direction to check if the plane is facing
  77205. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77206. * @returns True is the vector "direction" is the same side than the plane normal.
  77207. */
  77208. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77209. /**
  77210. * Calculates the distance to a point
  77211. * @param point point to calculate distance to
  77212. * @returns the signed distance (float) from the given point to the Plane.
  77213. */
  77214. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77215. /**
  77216. * Creates a plane from an array
  77217. * @param array the array to create a plane from
  77218. * @returns a new Plane from the given array.
  77219. */
  77220. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77221. /**
  77222. * Creates a plane from three points
  77223. * @param point1 point used to create the plane
  77224. * @param point2 point used to create the plane
  77225. * @param point3 point used to create the plane
  77226. * @returns a new Plane defined by the three given points.
  77227. */
  77228. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77229. /**
  77230. * Creates a plane from an origin point and a normal
  77231. * @param origin origin of the plane to be constructed
  77232. * @param normal normal of the plane to be constructed
  77233. * @returns a new Plane the normal vector to this plane at the given origin point.
  77234. * Note : the vector "normal" is updated because normalized.
  77235. */
  77236. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77237. /**
  77238. * Calculates the distance from a plane and a point
  77239. * @param origin origin of the plane to be constructed
  77240. * @param normal normal of the plane to be constructed
  77241. * @param point point to calculate distance to
  77242. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77243. */
  77244. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77245. }
  77246. }
  77247. declare module BABYLON {
  77248. /**
  77249. * Class used to store bounding sphere information
  77250. */
  77251. export class BoundingSphere {
  77252. /**
  77253. * Gets the center of the bounding sphere in local space
  77254. */
  77255. readonly center: Vector3;
  77256. /**
  77257. * Radius of the bounding sphere in local space
  77258. */
  77259. radius: number;
  77260. /**
  77261. * Gets the center of the bounding sphere in world space
  77262. */
  77263. readonly centerWorld: Vector3;
  77264. /**
  77265. * Radius of the bounding sphere in world space
  77266. */
  77267. radiusWorld: number;
  77268. /**
  77269. * Gets the minimum vector in local space
  77270. */
  77271. readonly minimum: Vector3;
  77272. /**
  77273. * Gets the maximum vector in local space
  77274. */
  77275. readonly maximum: Vector3;
  77276. private _worldMatrix;
  77277. private static readonly TmpVector3;
  77278. /**
  77279. * Creates a new bounding sphere
  77280. * @param min defines the minimum vector (in local space)
  77281. * @param max defines the maximum vector (in local space)
  77282. * @param worldMatrix defines the new world matrix
  77283. */
  77284. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77285. /**
  77286. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77287. * @param min defines the new minimum vector (in local space)
  77288. * @param max defines the new maximum vector (in local space)
  77289. * @param worldMatrix defines the new world matrix
  77290. */
  77291. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77292. /**
  77293. * Scale the current bounding sphere by applying a scale factor
  77294. * @param factor defines the scale factor to apply
  77295. * @returns the current bounding box
  77296. */
  77297. scale(factor: number): BoundingSphere;
  77298. /**
  77299. * Gets the world matrix of the bounding box
  77300. * @returns a matrix
  77301. */
  77302. getWorldMatrix(): DeepImmutable<Matrix>;
  77303. /** @hidden */
  77304. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77305. /**
  77306. * Tests if the bounding sphere is intersecting the frustum planes
  77307. * @param frustumPlanes defines the frustum planes to test
  77308. * @returns true if there is an intersection
  77309. */
  77310. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77311. /**
  77312. * Tests if the bounding sphere center is in between the frustum planes.
  77313. * Used for optimistic fast inclusion.
  77314. * @param frustumPlanes defines the frustum planes to test
  77315. * @returns true if the sphere center is in between the frustum planes
  77316. */
  77317. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77318. /**
  77319. * Tests if a point is inside the bounding sphere
  77320. * @param point defines the point to test
  77321. * @returns true if the point is inside the bounding sphere
  77322. */
  77323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77324. /**
  77325. * Checks if two sphere intersct
  77326. * @param sphere0 sphere 0
  77327. * @param sphere1 sphere 1
  77328. * @returns true if the speres intersect
  77329. */
  77330. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77331. }
  77332. }
  77333. declare module BABYLON {
  77334. /**
  77335. * Class used to store bounding box information
  77336. */
  77337. export class BoundingBox implements ICullable {
  77338. /**
  77339. * Gets the 8 vectors representing the bounding box in local space
  77340. */
  77341. readonly vectors: Vector3[];
  77342. /**
  77343. * Gets the center of the bounding box in local space
  77344. */
  77345. readonly center: Vector3;
  77346. /**
  77347. * Gets the center of the bounding box in world space
  77348. */
  77349. readonly centerWorld: Vector3;
  77350. /**
  77351. * Gets the extend size in local space
  77352. */
  77353. readonly extendSize: Vector3;
  77354. /**
  77355. * Gets the extend size in world space
  77356. */
  77357. readonly extendSizeWorld: Vector3;
  77358. /**
  77359. * Gets the OBB (object bounding box) directions
  77360. */
  77361. readonly directions: Vector3[];
  77362. /**
  77363. * Gets the 8 vectors representing the bounding box in world space
  77364. */
  77365. readonly vectorsWorld: Vector3[];
  77366. /**
  77367. * Gets the minimum vector in world space
  77368. */
  77369. readonly minimumWorld: Vector3;
  77370. /**
  77371. * Gets the maximum vector in world space
  77372. */
  77373. readonly maximumWorld: Vector3;
  77374. /**
  77375. * Gets the minimum vector in local space
  77376. */
  77377. readonly minimum: Vector3;
  77378. /**
  77379. * Gets the maximum vector in local space
  77380. */
  77381. readonly maximum: Vector3;
  77382. private _worldMatrix;
  77383. private static readonly TmpVector3;
  77384. /**
  77385. * @hidden
  77386. */
  77387. _tag: number;
  77388. /**
  77389. * Creates a new bounding box
  77390. * @param min defines the minimum vector (in local space)
  77391. * @param max defines the maximum vector (in local space)
  77392. * @param worldMatrix defines the new world matrix
  77393. */
  77394. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77395. /**
  77396. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77397. * @param min defines the new minimum vector (in local space)
  77398. * @param max defines the new maximum vector (in local space)
  77399. * @param worldMatrix defines the new world matrix
  77400. */
  77401. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77402. /**
  77403. * Scale the current bounding box by applying a scale factor
  77404. * @param factor defines the scale factor to apply
  77405. * @returns the current bounding box
  77406. */
  77407. scale(factor: number): BoundingBox;
  77408. /**
  77409. * Gets the world matrix of the bounding box
  77410. * @returns a matrix
  77411. */
  77412. getWorldMatrix(): DeepImmutable<Matrix>;
  77413. /** @hidden */
  77414. _update(world: DeepImmutable<Matrix>): void;
  77415. /**
  77416. * Tests if the bounding box is intersecting the frustum planes
  77417. * @param frustumPlanes defines the frustum planes to test
  77418. * @returns true if there is an intersection
  77419. */
  77420. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77421. /**
  77422. * Tests if the bounding box is entirely inside the frustum planes
  77423. * @param frustumPlanes defines the frustum planes to test
  77424. * @returns true if there is an inclusion
  77425. */
  77426. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77427. /**
  77428. * Tests if a point is inside the bounding box
  77429. * @param point defines the point to test
  77430. * @returns true if the point is inside the bounding box
  77431. */
  77432. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77433. /**
  77434. * Tests if the bounding box intersects with a bounding sphere
  77435. * @param sphere defines the sphere to test
  77436. * @returns true if there is an intersection
  77437. */
  77438. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77439. /**
  77440. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77441. * @param min defines the min vector to use
  77442. * @param max defines the max vector to use
  77443. * @returns true if there is an intersection
  77444. */
  77445. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77446. /**
  77447. * Tests if two bounding boxes are intersections
  77448. * @param box0 defines the first box to test
  77449. * @param box1 defines the second box to test
  77450. * @returns true if there is an intersection
  77451. */
  77452. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77453. /**
  77454. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77455. * @param minPoint defines the minimum vector of the bounding box
  77456. * @param maxPoint defines the maximum vector of the bounding box
  77457. * @param sphereCenter defines the sphere center
  77458. * @param sphereRadius defines the sphere radius
  77459. * @returns true if there is an intersection
  77460. */
  77461. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77462. /**
  77463. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77464. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77465. * @param frustumPlanes defines the frustum planes to test
  77466. * @return true if there is an inclusion
  77467. */
  77468. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77469. /**
  77470. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77471. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77472. * @param frustumPlanes defines the frustum planes to test
  77473. * @return true if there is an intersection
  77474. */
  77475. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77476. }
  77477. }
  77478. declare module BABYLON {
  77479. /** @hidden */
  77480. export class Collider {
  77481. /** Define if a collision was found */
  77482. collisionFound: boolean;
  77483. /**
  77484. * Define last intersection point in local space
  77485. */
  77486. intersectionPoint: Vector3;
  77487. /**
  77488. * Define last collided mesh
  77489. */
  77490. collidedMesh: Nullable<AbstractMesh>;
  77491. private _collisionPoint;
  77492. private _planeIntersectionPoint;
  77493. private _tempVector;
  77494. private _tempVector2;
  77495. private _tempVector3;
  77496. private _tempVector4;
  77497. private _edge;
  77498. private _baseToVertex;
  77499. private _destinationPoint;
  77500. private _slidePlaneNormal;
  77501. private _displacementVector;
  77502. /** @hidden */
  77503. _radius: Vector3;
  77504. /** @hidden */
  77505. _retry: number;
  77506. private _velocity;
  77507. private _basePoint;
  77508. private _epsilon;
  77509. /** @hidden */
  77510. _velocityWorldLength: number;
  77511. /** @hidden */
  77512. _basePointWorld: Vector3;
  77513. private _velocityWorld;
  77514. private _normalizedVelocity;
  77515. /** @hidden */
  77516. _initialVelocity: Vector3;
  77517. /** @hidden */
  77518. _initialPosition: Vector3;
  77519. private _nearestDistance;
  77520. private _collisionMask;
  77521. get collisionMask(): number;
  77522. set collisionMask(mask: number);
  77523. /**
  77524. * Gets the plane normal used to compute the sliding response (in local space)
  77525. */
  77526. get slidePlaneNormal(): Vector3;
  77527. /** @hidden */
  77528. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77529. /** @hidden */
  77530. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77531. /** @hidden */
  77532. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77533. /** @hidden */
  77534. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77535. /** @hidden */
  77536. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77537. /** @hidden */
  77538. _getResponse(pos: Vector3, vel: Vector3): void;
  77539. }
  77540. }
  77541. declare module BABYLON {
  77542. /**
  77543. * Interface for cullable objects
  77544. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77545. */
  77546. export interface ICullable {
  77547. /**
  77548. * Checks if the object or part of the object is in the frustum
  77549. * @param frustumPlanes Camera near/planes
  77550. * @returns true if the object is in frustum otherwise false
  77551. */
  77552. isInFrustum(frustumPlanes: Plane[]): boolean;
  77553. /**
  77554. * Checks if a cullable object (mesh...) is in the camera frustum
  77555. * Unlike isInFrustum this cheks the full bounding box
  77556. * @param frustumPlanes Camera near/planes
  77557. * @returns true if the object is in frustum otherwise false
  77558. */
  77559. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77560. }
  77561. /**
  77562. * Info for a bounding data of a mesh
  77563. */
  77564. export class BoundingInfo implements ICullable {
  77565. /**
  77566. * Bounding box for the mesh
  77567. */
  77568. readonly boundingBox: BoundingBox;
  77569. /**
  77570. * Bounding sphere for the mesh
  77571. */
  77572. readonly boundingSphere: BoundingSphere;
  77573. private _isLocked;
  77574. private static readonly TmpVector3;
  77575. /**
  77576. * Constructs bounding info
  77577. * @param minimum min vector of the bounding box/sphere
  77578. * @param maximum max vector of the bounding box/sphere
  77579. * @param worldMatrix defines the new world matrix
  77580. */
  77581. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77582. /**
  77583. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77584. * @param min defines the new minimum vector (in local space)
  77585. * @param max defines the new maximum vector (in local space)
  77586. * @param worldMatrix defines the new world matrix
  77587. */
  77588. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77589. /**
  77590. * min vector of the bounding box/sphere
  77591. */
  77592. get minimum(): Vector3;
  77593. /**
  77594. * max vector of the bounding box/sphere
  77595. */
  77596. get maximum(): Vector3;
  77597. /**
  77598. * If the info is locked and won't be updated to avoid perf overhead
  77599. */
  77600. get isLocked(): boolean;
  77601. set isLocked(value: boolean);
  77602. /**
  77603. * Updates the bounding sphere and box
  77604. * @param world world matrix to be used to update
  77605. */
  77606. update(world: DeepImmutable<Matrix>): void;
  77607. /**
  77608. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77609. * @param center New center of the bounding info
  77610. * @param extend New extend of the bounding info
  77611. * @returns the current bounding info
  77612. */
  77613. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77614. /**
  77615. * Scale the current bounding info by applying a scale factor
  77616. * @param factor defines the scale factor to apply
  77617. * @returns the current bounding info
  77618. */
  77619. scale(factor: number): BoundingInfo;
  77620. /**
  77621. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77622. * @param frustumPlanes defines the frustum to test
  77623. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77624. * @returns true if the bounding info is in the frustum planes
  77625. */
  77626. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77627. /**
  77628. * Gets the world distance between the min and max points of the bounding box
  77629. */
  77630. get diagonalLength(): number;
  77631. /**
  77632. * Checks if a cullable object (mesh...) is in the camera frustum
  77633. * Unlike isInFrustum this cheks the full bounding box
  77634. * @param frustumPlanes Camera near/planes
  77635. * @returns true if the object is in frustum otherwise false
  77636. */
  77637. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77638. /** @hidden */
  77639. _checkCollision(collider: Collider): boolean;
  77640. /**
  77641. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77642. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77643. * @param point the point to check intersection with
  77644. * @returns if the point intersects
  77645. */
  77646. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77647. /**
  77648. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77649. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77650. * @param boundingInfo the bounding info to check intersection with
  77651. * @param precise if the intersection should be done using OBB
  77652. * @returns if the bounding info intersects
  77653. */
  77654. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77655. }
  77656. }
  77657. declare module BABYLON {
  77658. /**
  77659. * Extracts minimum and maximum values from a list of indexed positions
  77660. * @param positions defines the positions to use
  77661. * @param indices defines the indices to the positions
  77662. * @param indexStart defines the start index
  77663. * @param indexCount defines the end index
  77664. * @param bias defines bias value to add to the result
  77665. * @return minimum and maximum values
  77666. */
  77667. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77668. minimum: Vector3;
  77669. maximum: Vector3;
  77670. };
  77671. /**
  77672. * Extracts minimum and maximum values from a list of positions
  77673. * @param positions defines the positions to use
  77674. * @param start defines the start index in the positions array
  77675. * @param count defines the number of positions to handle
  77676. * @param bias defines bias value to add to the result
  77677. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77678. * @return minimum and maximum values
  77679. */
  77680. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77681. minimum: Vector3;
  77682. maximum: Vector3;
  77683. };
  77684. }
  77685. declare module BABYLON {
  77686. /** @hidden */
  77687. export class WebGLDataBuffer extends DataBuffer {
  77688. private _buffer;
  77689. constructor(resource: WebGLBuffer);
  77690. get underlyingResource(): any;
  77691. }
  77692. }
  77693. declare module BABYLON {
  77694. /** @hidden */
  77695. export class WebGLPipelineContext implements IPipelineContext {
  77696. engine: ThinEngine;
  77697. program: Nullable<WebGLProgram>;
  77698. context?: WebGLRenderingContext;
  77699. vertexShader?: WebGLShader;
  77700. fragmentShader?: WebGLShader;
  77701. isParallelCompiled: boolean;
  77702. onCompiled?: () => void;
  77703. transformFeedback?: WebGLTransformFeedback | null;
  77704. vertexCompilationError: Nullable<string>;
  77705. fragmentCompilationError: Nullable<string>;
  77706. programLinkError: Nullable<string>;
  77707. programValidationError: Nullable<string>;
  77708. get isAsync(): boolean;
  77709. get isReady(): boolean;
  77710. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77711. }
  77712. }
  77713. declare module BABYLON {
  77714. interface ThinEngine {
  77715. /**
  77716. * Create an uniform buffer
  77717. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77718. * @param elements defines the content of the uniform buffer
  77719. * @returns the webGL uniform buffer
  77720. */
  77721. createUniformBuffer(elements: FloatArray): DataBuffer;
  77722. /**
  77723. * Create a dynamic uniform buffer
  77724. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77725. * @param elements defines the content of the uniform buffer
  77726. * @returns the webGL uniform buffer
  77727. */
  77728. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77729. /**
  77730. * Update an existing uniform buffer
  77731. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77732. * @param uniformBuffer defines the target uniform buffer
  77733. * @param elements defines the content to update
  77734. * @param offset defines the offset in the uniform buffer where update should start
  77735. * @param count defines the size of the data to update
  77736. */
  77737. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77738. /**
  77739. * Bind an uniform buffer to the current webGL context
  77740. * @param buffer defines the buffer to bind
  77741. */
  77742. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77743. /**
  77744. * Bind a buffer to the current webGL context at a given location
  77745. * @param buffer defines the buffer to bind
  77746. * @param location defines the index where to bind the buffer
  77747. */
  77748. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77749. /**
  77750. * Bind a specific block at a given index in a specific shader program
  77751. * @param pipelineContext defines the pipeline context to use
  77752. * @param blockName defines the block name
  77753. * @param index defines the index where to bind the block
  77754. */
  77755. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77756. }
  77757. }
  77758. declare module BABYLON {
  77759. /**
  77760. * Uniform buffer objects.
  77761. *
  77762. * Handles blocks of uniform on the GPU.
  77763. *
  77764. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77765. *
  77766. * For more information, please refer to :
  77767. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77768. */
  77769. export class UniformBuffer {
  77770. private _engine;
  77771. private _buffer;
  77772. private _data;
  77773. private _bufferData;
  77774. private _dynamic?;
  77775. private _uniformLocations;
  77776. private _uniformSizes;
  77777. private _uniformLocationPointer;
  77778. private _needSync;
  77779. private _noUBO;
  77780. private _currentEffect;
  77781. /** @hidden */
  77782. _alreadyBound: boolean;
  77783. private static _MAX_UNIFORM_SIZE;
  77784. private static _tempBuffer;
  77785. /**
  77786. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77787. * This is dynamic to allow compat with webgl 1 and 2.
  77788. * You will need to pass the name of the uniform as well as the value.
  77789. */
  77790. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77791. /**
  77792. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77793. * This is dynamic to allow compat with webgl 1 and 2.
  77794. * You will need to pass the name of the uniform as well as the value.
  77795. */
  77796. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77797. /**
  77798. * Lambda to Update a single float in a uniform buffer.
  77799. * This is dynamic to allow compat with webgl 1 and 2.
  77800. * You will need to pass the name of the uniform as well as the value.
  77801. */
  77802. updateFloat: (name: string, x: number) => void;
  77803. /**
  77804. * Lambda to Update a vec2 of float in a uniform buffer.
  77805. * This is dynamic to allow compat with webgl 1 and 2.
  77806. * You will need to pass the name of the uniform as well as the value.
  77807. */
  77808. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77809. /**
  77810. * Lambda to Update a vec3 of float in a uniform buffer.
  77811. * This is dynamic to allow compat with webgl 1 and 2.
  77812. * You will need to pass the name of the uniform as well as the value.
  77813. */
  77814. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77815. /**
  77816. * Lambda to Update a vec4 of float in a uniform buffer.
  77817. * This is dynamic to allow compat with webgl 1 and 2.
  77818. * You will need to pass the name of the uniform as well as the value.
  77819. */
  77820. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77821. /**
  77822. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77823. * This is dynamic to allow compat with webgl 1 and 2.
  77824. * You will need to pass the name of the uniform as well as the value.
  77825. */
  77826. updateMatrix: (name: string, mat: Matrix) => void;
  77827. /**
  77828. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77829. * This is dynamic to allow compat with webgl 1 and 2.
  77830. * You will need to pass the name of the uniform as well as the value.
  77831. */
  77832. updateVector3: (name: string, vector: Vector3) => void;
  77833. /**
  77834. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77835. * This is dynamic to allow compat with webgl 1 and 2.
  77836. * You will need to pass the name of the uniform as well as the value.
  77837. */
  77838. updateVector4: (name: string, vector: Vector4) => void;
  77839. /**
  77840. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77841. * This is dynamic to allow compat with webgl 1 and 2.
  77842. * You will need to pass the name of the uniform as well as the value.
  77843. */
  77844. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77845. /**
  77846. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77847. * This is dynamic to allow compat with webgl 1 and 2.
  77848. * You will need to pass the name of the uniform as well as the value.
  77849. */
  77850. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77851. /**
  77852. * Instantiates a new Uniform buffer objects.
  77853. *
  77854. * Handles blocks of uniform on the GPU.
  77855. *
  77856. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77857. *
  77858. * For more information, please refer to :
  77859. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77860. * @param engine Define the engine the buffer is associated with
  77861. * @param data Define the data contained in the buffer
  77862. * @param dynamic Define if the buffer is updatable
  77863. */
  77864. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77865. /**
  77866. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77867. * or just falling back on setUniformXXX calls.
  77868. */
  77869. get useUbo(): boolean;
  77870. /**
  77871. * Indicates if the WebGL underlying uniform buffer is in sync
  77872. * with the javascript cache data.
  77873. */
  77874. get isSync(): boolean;
  77875. /**
  77876. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77877. * Also, a dynamic UniformBuffer will disable cache verification and always
  77878. * update the underlying WebGL uniform buffer to the GPU.
  77879. * @returns if Dynamic, otherwise false
  77880. */
  77881. isDynamic(): boolean;
  77882. /**
  77883. * The data cache on JS side.
  77884. * @returns the underlying data as a float array
  77885. */
  77886. getData(): Float32Array;
  77887. /**
  77888. * The underlying WebGL Uniform buffer.
  77889. * @returns the webgl buffer
  77890. */
  77891. getBuffer(): Nullable<DataBuffer>;
  77892. /**
  77893. * std140 layout specifies how to align data within an UBO structure.
  77894. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77895. * for specs.
  77896. */
  77897. private _fillAlignment;
  77898. /**
  77899. * Adds an uniform in the buffer.
  77900. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77901. * for the layout to be correct !
  77902. * @param name Name of the uniform, as used in the uniform block in the shader.
  77903. * @param size Data size, or data directly.
  77904. */
  77905. addUniform(name: string, size: number | number[]): void;
  77906. /**
  77907. * Adds a Matrix 4x4 to the uniform buffer.
  77908. * @param name Name of the uniform, as used in the uniform block in the shader.
  77909. * @param mat A 4x4 matrix.
  77910. */
  77911. addMatrix(name: string, mat: Matrix): void;
  77912. /**
  77913. * Adds a vec2 to the uniform buffer.
  77914. * @param name Name of the uniform, as used in the uniform block in the shader.
  77915. * @param x Define the x component value of the vec2
  77916. * @param y Define the y component value of the vec2
  77917. */
  77918. addFloat2(name: string, x: number, y: number): void;
  77919. /**
  77920. * Adds a vec3 to the uniform buffer.
  77921. * @param name Name of the uniform, as used in the uniform block in the shader.
  77922. * @param x Define the x component value of the vec3
  77923. * @param y Define the y component value of the vec3
  77924. * @param z Define the z component value of the vec3
  77925. */
  77926. addFloat3(name: string, x: number, y: number, z: number): void;
  77927. /**
  77928. * Adds a vec3 to the uniform buffer.
  77929. * @param name Name of the uniform, as used in the uniform block in the shader.
  77930. * @param color Define the vec3 from a Color
  77931. */
  77932. addColor3(name: string, color: Color3): void;
  77933. /**
  77934. * Adds a vec4 to the uniform buffer.
  77935. * @param name Name of the uniform, as used in the uniform block in the shader.
  77936. * @param color Define the rgb components from a Color
  77937. * @param alpha Define the a component of the vec4
  77938. */
  77939. addColor4(name: string, color: Color3, alpha: number): void;
  77940. /**
  77941. * Adds a vec3 to the uniform buffer.
  77942. * @param name Name of the uniform, as used in the uniform block in the shader.
  77943. * @param vector Define the vec3 components from a Vector
  77944. */
  77945. addVector3(name: string, vector: Vector3): void;
  77946. /**
  77947. * Adds a Matrix 3x3 to the uniform buffer.
  77948. * @param name Name of the uniform, as used in the uniform block in the shader.
  77949. */
  77950. addMatrix3x3(name: string): void;
  77951. /**
  77952. * Adds a Matrix 2x2 to the uniform buffer.
  77953. * @param name Name of the uniform, as used in the uniform block in the shader.
  77954. */
  77955. addMatrix2x2(name: string): void;
  77956. /**
  77957. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  77958. */
  77959. create(): void;
  77960. /** @hidden */
  77961. _rebuild(): void;
  77962. /**
  77963. * Updates the WebGL Uniform Buffer on the GPU.
  77964. * If the `dynamic` flag is set to true, no cache comparison is done.
  77965. * Otherwise, the buffer will be updated only if the cache differs.
  77966. */
  77967. update(): void;
  77968. /**
  77969. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  77970. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77971. * @param data Define the flattened data
  77972. * @param size Define the size of the data.
  77973. */
  77974. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  77975. private _valueCache;
  77976. private _cacheMatrix;
  77977. private _updateMatrix3x3ForUniform;
  77978. private _updateMatrix3x3ForEffect;
  77979. private _updateMatrix2x2ForEffect;
  77980. private _updateMatrix2x2ForUniform;
  77981. private _updateFloatForEffect;
  77982. private _updateFloatForUniform;
  77983. private _updateFloat2ForEffect;
  77984. private _updateFloat2ForUniform;
  77985. private _updateFloat3ForEffect;
  77986. private _updateFloat3ForUniform;
  77987. private _updateFloat4ForEffect;
  77988. private _updateFloat4ForUniform;
  77989. private _updateMatrixForEffect;
  77990. private _updateMatrixForUniform;
  77991. private _updateVector3ForEffect;
  77992. private _updateVector3ForUniform;
  77993. private _updateVector4ForEffect;
  77994. private _updateVector4ForUniform;
  77995. private _updateColor3ForEffect;
  77996. private _updateColor3ForUniform;
  77997. private _updateColor4ForEffect;
  77998. private _updateColor4ForUniform;
  77999. /**
  78000. * Sets a sampler uniform on the effect.
  78001. * @param name Define the name of the sampler.
  78002. * @param texture Define the texture to set in the sampler
  78003. */
  78004. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78005. /**
  78006. * Directly updates the value of the uniform in the cache AND on the GPU.
  78007. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78008. * @param data Define the flattened data
  78009. */
  78010. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78011. /**
  78012. * Binds this uniform buffer to an effect.
  78013. * @param effect Define the effect to bind the buffer to
  78014. * @param name Name of the uniform block in the shader.
  78015. */
  78016. bindToEffect(effect: Effect, name: string): void;
  78017. /**
  78018. * Disposes the uniform buffer.
  78019. */
  78020. dispose(): void;
  78021. }
  78022. }
  78023. declare module BABYLON {
  78024. /**
  78025. * Enum that determines the text-wrapping mode to use.
  78026. */
  78027. export enum InspectableType {
  78028. /**
  78029. * Checkbox for booleans
  78030. */
  78031. Checkbox = 0,
  78032. /**
  78033. * Sliders for numbers
  78034. */
  78035. Slider = 1,
  78036. /**
  78037. * Vector3
  78038. */
  78039. Vector3 = 2,
  78040. /**
  78041. * Quaternions
  78042. */
  78043. Quaternion = 3,
  78044. /**
  78045. * Color3
  78046. */
  78047. Color3 = 4,
  78048. /**
  78049. * String
  78050. */
  78051. String = 5
  78052. }
  78053. /**
  78054. * Interface used to define custom inspectable properties.
  78055. * This interface is used by the inspector to display custom property grids
  78056. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78057. */
  78058. export interface IInspectable {
  78059. /**
  78060. * Gets the label to display
  78061. */
  78062. label: string;
  78063. /**
  78064. * Gets the name of the property to edit
  78065. */
  78066. propertyName: string;
  78067. /**
  78068. * Gets the type of the editor to use
  78069. */
  78070. type: InspectableType;
  78071. /**
  78072. * Gets the minimum value of the property when using in "slider" mode
  78073. */
  78074. min?: number;
  78075. /**
  78076. * Gets the maximum value of the property when using in "slider" mode
  78077. */
  78078. max?: number;
  78079. /**
  78080. * Gets the setp to use when using in "slider" mode
  78081. */
  78082. step?: number;
  78083. }
  78084. }
  78085. declare module BABYLON {
  78086. /**
  78087. * Class used to provide helper for timing
  78088. */
  78089. export class TimingTools {
  78090. /**
  78091. * Polyfill for setImmediate
  78092. * @param action defines the action to execute after the current execution block
  78093. */
  78094. static SetImmediate(action: () => void): void;
  78095. }
  78096. }
  78097. declare module BABYLON {
  78098. /**
  78099. * Class used to enable instatition of objects by class name
  78100. */
  78101. export class InstantiationTools {
  78102. /**
  78103. * Use this object to register external classes like custom textures or material
  78104. * to allow the laoders to instantiate them
  78105. */
  78106. static RegisteredExternalClasses: {
  78107. [key: string]: Object;
  78108. };
  78109. /**
  78110. * Tries to instantiate a new object from a given class name
  78111. * @param className defines the class name to instantiate
  78112. * @returns the new object or null if the system was not able to do the instantiation
  78113. */
  78114. static Instantiate(className: string): any;
  78115. }
  78116. }
  78117. declare module BABYLON {
  78118. /**
  78119. * Define options used to create a depth texture
  78120. */
  78121. export class DepthTextureCreationOptions {
  78122. /** Specifies whether or not a stencil should be allocated in the texture */
  78123. generateStencil?: boolean;
  78124. /** Specifies whether or not bilinear filtering is enable on the texture */
  78125. bilinearFiltering?: boolean;
  78126. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78127. comparisonFunction?: number;
  78128. /** Specifies if the created texture is a cube texture */
  78129. isCube?: boolean;
  78130. }
  78131. }
  78132. declare module BABYLON {
  78133. interface ThinEngine {
  78134. /**
  78135. * Creates a depth stencil cube texture.
  78136. * This is only available in WebGL 2.
  78137. * @param size The size of face edge in the cube texture.
  78138. * @param options The options defining the cube texture.
  78139. * @returns The cube texture
  78140. */
  78141. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78142. /**
  78143. * Creates a cube texture
  78144. * @param rootUrl defines the url where the files to load is located
  78145. * @param scene defines the current scene
  78146. * @param files defines the list of files to load (1 per face)
  78147. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78148. * @param onLoad defines an optional callback raised when the texture is loaded
  78149. * @param onError defines an optional callback raised if there is an issue to load the texture
  78150. * @param format defines the format of the data
  78151. * @param forcedExtension defines the extension to use to pick the right loader
  78152. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78153. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78154. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78155. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78156. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78157. * @returns the cube texture as an InternalTexture
  78158. */
  78159. 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;
  78160. /**
  78161. * Creates a cube texture
  78162. * @param rootUrl defines the url where the files to load is located
  78163. * @param scene defines the current scene
  78164. * @param files defines the list of files to load (1 per face)
  78165. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78166. * @param onLoad defines an optional callback raised when the texture is loaded
  78167. * @param onError defines an optional callback raised if there is an issue to load the texture
  78168. * @param format defines the format of the data
  78169. * @param forcedExtension defines the extension to use to pick the right loader
  78170. * @returns the cube texture as an InternalTexture
  78171. */
  78172. 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;
  78173. /**
  78174. * Creates a cube texture
  78175. * @param rootUrl defines the url where the files to load is located
  78176. * @param scene defines the current scene
  78177. * @param files defines the list of files to load (1 per face)
  78178. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78179. * @param onLoad defines an optional callback raised when the texture is loaded
  78180. * @param onError defines an optional callback raised if there is an issue to load the texture
  78181. * @param format defines the format of the data
  78182. * @param forcedExtension defines the extension to use to pick the right loader
  78183. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78184. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78185. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78186. * @returns the cube texture as an InternalTexture
  78187. */
  78188. 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;
  78189. /** @hidden */
  78190. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78191. /** @hidden */
  78192. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78193. /** @hidden */
  78194. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78195. /** @hidden */
  78196. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78197. /**
  78198. * @hidden
  78199. */
  78200. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78201. }
  78202. }
  78203. declare module BABYLON {
  78204. /**
  78205. * Class for creating a cube texture
  78206. */
  78207. export class CubeTexture extends BaseTexture {
  78208. private _delayedOnLoad;
  78209. /**
  78210. * The url of the texture
  78211. */
  78212. url: string;
  78213. /**
  78214. * Gets or sets the center of the bounding box associated with the cube texture.
  78215. * It must define where the camera used to render the texture was set
  78216. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78217. */
  78218. boundingBoxPosition: Vector3;
  78219. private _boundingBoxSize;
  78220. /**
  78221. * Gets or sets the size of the bounding box associated with the cube texture
  78222. * When defined, the cubemap will switch to local mode
  78223. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78224. * @example https://www.babylonjs-playground.com/#RNASML
  78225. */
  78226. set boundingBoxSize(value: Vector3);
  78227. /**
  78228. * Returns the bounding box size
  78229. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78230. */
  78231. get boundingBoxSize(): Vector3;
  78232. protected _rotationY: number;
  78233. /**
  78234. * Sets texture matrix rotation angle around Y axis in radians.
  78235. */
  78236. set rotationY(value: number);
  78237. /**
  78238. * Gets texture matrix rotation angle around Y axis radians.
  78239. */
  78240. get rotationY(): number;
  78241. /**
  78242. * Are mip maps generated for this texture or not.
  78243. */
  78244. get noMipmap(): boolean;
  78245. private _noMipmap;
  78246. private _files;
  78247. protected _forcedExtension: Nullable<string>;
  78248. private _extensions;
  78249. private _textureMatrix;
  78250. private _format;
  78251. private _createPolynomials;
  78252. /** @hidden */
  78253. _prefiltered: boolean;
  78254. /**
  78255. * Creates a cube texture from an array of image urls
  78256. * @param files defines an array of image urls
  78257. * @param scene defines the hosting scene
  78258. * @param noMipmap specifies if mip maps are not used
  78259. * @returns a cube texture
  78260. */
  78261. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78262. /**
  78263. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78264. * @param url defines the url of the prefiltered texture
  78265. * @param scene defines the scene the texture is attached to
  78266. * @param forcedExtension defines the extension of the file if different from the url
  78267. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78268. * @return the prefiltered texture
  78269. */
  78270. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78271. /**
  78272. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78273. * as prefiltered data.
  78274. * @param rootUrl defines the url of the texture or the root name of the six images
  78275. * @param scene defines the scene the texture is attached to
  78276. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78277. * @param noMipmap defines if mipmaps should be created or not
  78278. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78279. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78280. * @param onError defines a callback triggered in case of error during load
  78281. * @param format defines the internal format to use for the texture once loaded
  78282. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78283. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78284. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78285. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78286. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78287. * @return the cube texture
  78288. */
  78289. 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);
  78290. /**
  78291. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78292. */
  78293. get isPrefiltered(): boolean;
  78294. /**
  78295. * Get the current class name of the texture useful for serialization or dynamic coding.
  78296. * @returns "CubeTexture"
  78297. */
  78298. getClassName(): string;
  78299. /**
  78300. * Update the url (and optional buffer) of this texture if url was null during construction.
  78301. * @param url the url of the texture
  78302. * @param forcedExtension defines the extension to use
  78303. * @param onLoad callback called when the texture is loaded (defaults to null)
  78304. */
  78305. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  78306. /**
  78307. * Delays loading of the cube texture
  78308. * @param forcedExtension defines the extension to use
  78309. */
  78310. delayLoad(forcedExtension?: string): void;
  78311. /**
  78312. * Returns the reflection texture matrix
  78313. * @returns the reflection texture matrix
  78314. */
  78315. getReflectionTextureMatrix(): Matrix;
  78316. /**
  78317. * Sets the reflection texture matrix
  78318. * @param value Reflection texture matrix
  78319. */
  78320. setReflectionTextureMatrix(value: Matrix): void;
  78321. /**
  78322. * Parses text to create a cube texture
  78323. * @param parsedTexture define the serialized text to read from
  78324. * @param scene defines the hosting scene
  78325. * @param rootUrl defines the root url of the cube texture
  78326. * @returns a cube texture
  78327. */
  78328. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78329. /**
  78330. * Makes a clone, or deep copy, of the cube texture
  78331. * @returns a new cube texture
  78332. */
  78333. clone(): CubeTexture;
  78334. }
  78335. }
  78336. declare module BABYLON {
  78337. /**
  78338. * Manages the defines for the Material
  78339. */
  78340. export class MaterialDefines {
  78341. /** @hidden */
  78342. protected _keys: string[];
  78343. private _isDirty;
  78344. /** @hidden */
  78345. _renderId: number;
  78346. /** @hidden */
  78347. _areLightsDirty: boolean;
  78348. /** @hidden */
  78349. _areLightsDisposed: boolean;
  78350. /** @hidden */
  78351. _areAttributesDirty: boolean;
  78352. /** @hidden */
  78353. _areTexturesDirty: boolean;
  78354. /** @hidden */
  78355. _areFresnelDirty: boolean;
  78356. /** @hidden */
  78357. _areMiscDirty: boolean;
  78358. /** @hidden */
  78359. _areImageProcessingDirty: boolean;
  78360. /** @hidden */
  78361. _normals: boolean;
  78362. /** @hidden */
  78363. _uvs: boolean;
  78364. /** @hidden */
  78365. _needNormals: boolean;
  78366. /** @hidden */
  78367. _needUVs: boolean;
  78368. [id: string]: any;
  78369. /**
  78370. * Specifies if the material needs to be re-calculated
  78371. */
  78372. get isDirty(): boolean;
  78373. /**
  78374. * Marks the material to indicate that it has been re-calculated
  78375. */
  78376. markAsProcessed(): void;
  78377. /**
  78378. * Marks the material to indicate that it needs to be re-calculated
  78379. */
  78380. markAsUnprocessed(): void;
  78381. /**
  78382. * Marks the material to indicate all of its defines need to be re-calculated
  78383. */
  78384. markAllAsDirty(): void;
  78385. /**
  78386. * Marks the material to indicate that image processing needs to be re-calculated
  78387. */
  78388. markAsImageProcessingDirty(): void;
  78389. /**
  78390. * Marks the material to indicate the lights need to be re-calculated
  78391. * @param disposed Defines whether the light is dirty due to dispose or not
  78392. */
  78393. markAsLightDirty(disposed?: boolean): void;
  78394. /**
  78395. * Marks the attribute state as changed
  78396. */
  78397. markAsAttributesDirty(): void;
  78398. /**
  78399. * Marks the texture state as changed
  78400. */
  78401. markAsTexturesDirty(): void;
  78402. /**
  78403. * Marks the fresnel state as changed
  78404. */
  78405. markAsFresnelDirty(): void;
  78406. /**
  78407. * Marks the misc state as changed
  78408. */
  78409. markAsMiscDirty(): void;
  78410. /**
  78411. * Rebuilds the material defines
  78412. */
  78413. rebuild(): void;
  78414. /**
  78415. * Specifies if two material defines are equal
  78416. * @param other - A material define instance to compare to
  78417. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78418. */
  78419. isEqual(other: MaterialDefines): boolean;
  78420. /**
  78421. * Clones this instance's defines to another instance
  78422. * @param other - material defines to clone values to
  78423. */
  78424. cloneTo(other: MaterialDefines): void;
  78425. /**
  78426. * Resets the material define values
  78427. */
  78428. reset(): void;
  78429. /**
  78430. * Converts the material define values to a string
  78431. * @returns - String of material define information
  78432. */
  78433. toString(): string;
  78434. }
  78435. }
  78436. declare module BABYLON {
  78437. /**
  78438. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78439. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78440. * 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;
  78441. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78442. */
  78443. export class ColorCurves {
  78444. private _dirty;
  78445. private _tempColor;
  78446. private _globalCurve;
  78447. private _highlightsCurve;
  78448. private _midtonesCurve;
  78449. private _shadowsCurve;
  78450. private _positiveCurve;
  78451. private _negativeCurve;
  78452. private _globalHue;
  78453. private _globalDensity;
  78454. private _globalSaturation;
  78455. private _globalExposure;
  78456. /**
  78457. * Gets the global Hue value.
  78458. * 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).
  78459. */
  78460. get globalHue(): number;
  78461. /**
  78462. * Sets the global Hue value.
  78463. * 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).
  78464. */
  78465. set globalHue(value: number);
  78466. /**
  78467. * Gets the global Density value.
  78468. * 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.
  78469. * Values less than zero provide a filter of opposite hue.
  78470. */
  78471. get globalDensity(): number;
  78472. /**
  78473. * Sets the global Density value.
  78474. * 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.
  78475. * Values less than zero provide a filter of opposite hue.
  78476. */
  78477. set globalDensity(value: number);
  78478. /**
  78479. * Gets the global Saturation value.
  78480. * 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.
  78481. */
  78482. get globalSaturation(): number;
  78483. /**
  78484. * Sets the global Saturation value.
  78485. * 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.
  78486. */
  78487. set globalSaturation(value: number);
  78488. /**
  78489. * Gets the global Exposure value.
  78490. * 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.
  78491. */
  78492. get globalExposure(): number;
  78493. /**
  78494. * Sets the global Exposure value.
  78495. * 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.
  78496. */
  78497. set globalExposure(value: number);
  78498. private _highlightsHue;
  78499. private _highlightsDensity;
  78500. private _highlightsSaturation;
  78501. private _highlightsExposure;
  78502. /**
  78503. * Gets the highlights Hue value.
  78504. * 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).
  78505. */
  78506. get highlightsHue(): number;
  78507. /**
  78508. * Sets the highlights Hue value.
  78509. * 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).
  78510. */
  78511. set highlightsHue(value: number);
  78512. /**
  78513. * Gets the highlights Density value.
  78514. * 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.
  78515. * Values less than zero provide a filter of opposite hue.
  78516. */
  78517. get highlightsDensity(): number;
  78518. /**
  78519. * Sets the highlights Density value.
  78520. * 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.
  78521. * Values less than zero provide a filter of opposite hue.
  78522. */
  78523. set highlightsDensity(value: number);
  78524. /**
  78525. * Gets the highlights Saturation value.
  78526. * 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.
  78527. */
  78528. get highlightsSaturation(): number;
  78529. /**
  78530. * Sets the highlights Saturation value.
  78531. * 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.
  78532. */
  78533. set highlightsSaturation(value: number);
  78534. /**
  78535. * Gets the highlights Exposure value.
  78536. * 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.
  78537. */
  78538. get highlightsExposure(): number;
  78539. /**
  78540. * Sets the highlights Exposure value.
  78541. * 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.
  78542. */
  78543. set highlightsExposure(value: number);
  78544. private _midtonesHue;
  78545. private _midtonesDensity;
  78546. private _midtonesSaturation;
  78547. private _midtonesExposure;
  78548. /**
  78549. * Gets the midtones Hue value.
  78550. * 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).
  78551. */
  78552. get midtonesHue(): number;
  78553. /**
  78554. * Sets the midtones Hue value.
  78555. * 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).
  78556. */
  78557. set midtonesHue(value: number);
  78558. /**
  78559. * Gets the midtones Density value.
  78560. * 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.
  78561. * Values less than zero provide a filter of opposite hue.
  78562. */
  78563. get midtonesDensity(): number;
  78564. /**
  78565. * Sets the midtones Density value.
  78566. * 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.
  78567. * Values less than zero provide a filter of opposite hue.
  78568. */
  78569. set midtonesDensity(value: number);
  78570. /**
  78571. * Gets the midtones Saturation value.
  78572. * 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.
  78573. */
  78574. get midtonesSaturation(): number;
  78575. /**
  78576. * Sets the midtones Saturation value.
  78577. * 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.
  78578. */
  78579. set midtonesSaturation(value: number);
  78580. /**
  78581. * Gets the midtones Exposure value.
  78582. * 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.
  78583. */
  78584. get midtonesExposure(): number;
  78585. /**
  78586. * Sets the midtones Exposure value.
  78587. * 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.
  78588. */
  78589. set midtonesExposure(value: number);
  78590. private _shadowsHue;
  78591. private _shadowsDensity;
  78592. private _shadowsSaturation;
  78593. private _shadowsExposure;
  78594. /**
  78595. * Gets the shadows Hue value.
  78596. * 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).
  78597. */
  78598. get shadowsHue(): number;
  78599. /**
  78600. * Sets the shadows Hue value.
  78601. * 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).
  78602. */
  78603. set shadowsHue(value: number);
  78604. /**
  78605. * Gets the shadows Density value.
  78606. * 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.
  78607. * Values less than zero provide a filter of opposite hue.
  78608. */
  78609. get shadowsDensity(): number;
  78610. /**
  78611. * Sets the shadows Density value.
  78612. * 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.
  78613. * Values less than zero provide a filter of opposite hue.
  78614. */
  78615. set shadowsDensity(value: number);
  78616. /**
  78617. * Gets the shadows Saturation value.
  78618. * 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.
  78619. */
  78620. get shadowsSaturation(): number;
  78621. /**
  78622. * Sets the shadows Saturation value.
  78623. * 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.
  78624. */
  78625. set shadowsSaturation(value: number);
  78626. /**
  78627. * Gets the shadows Exposure value.
  78628. * 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.
  78629. */
  78630. get shadowsExposure(): number;
  78631. /**
  78632. * Sets the shadows Exposure value.
  78633. * 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.
  78634. */
  78635. set shadowsExposure(value: number);
  78636. /**
  78637. * Returns the class name
  78638. * @returns The class name
  78639. */
  78640. getClassName(): string;
  78641. /**
  78642. * Binds the color curves to the shader.
  78643. * @param colorCurves The color curve to bind
  78644. * @param effect The effect to bind to
  78645. * @param positiveUniform The positive uniform shader parameter
  78646. * @param neutralUniform The neutral uniform shader parameter
  78647. * @param negativeUniform The negative uniform shader parameter
  78648. */
  78649. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78650. /**
  78651. * Prepare the list of uniforms associated with the ColorCurves effects.
  78652. * @param uniformsList The list of uniforms used in the effect
  78653. */
  78654. static PrepareUniforms(uniformsList: string[]): void;
  78655. /**
  78656. * Returns color grading data based on a hue, density, saturation and exposure value.
  78657. * @param filterHue The hue of the color filter.
  78658. * @param filterDensity The density of the color filter.
  78659. * @param saturation The saturation.
  78660. * @param exposure The exposure.
  78661. * @param result The result data container.
  78662. */
  78663. private getColorGradingDataToRef;
  78664. /**
  78665. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78666. * @param value The input slider value in range [-100,100].
  78667. * @returns Adjusted value.
  78668. */
  78669. private static applyColorGradingSliderNonlinear;
  78670. /**
  78671. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78672. * @param hue The hue (H) input.
  78673. * @param saturation The saturation (S) input.
  78674. * @param brightness The brightness (B) input.
  78675. * @result An RGBA color represented as Vector4.
  78676. */
  78677. private static fromHSBToRef;
  78678. /**
  78679. * Returns a value clamped between min and max
  78680. * @param value The value to clamp
  78681. * @param min The minimum of value
  78682. * @param max The maximum of value
  78683. * @returns The clamped value.
  78684. */
  78685. private static clamp;
  78686. /**
  78687. * Clones the current color curve instance.
  78688. * @return The cloned curves
  78689. */
  78690. clone(): ColorCurves;
  78691. /**
  78692. * Serializes the current color curve instance to a json representation.
  78693. * @return a JSON representation
  78694. */
  78695. serialize(): any;
  78696. /**
  78697. * Parses the color curve from a json representation.
  78698. * @param source the JSON source to parse
  78699. * @return The parsed curves
  78700. */
  78701. static Parse(source: any): ColorCurves;
  78702. }
  78703. }
  78704. declare module BABYLON {
  78705. /**
  78706. * Interface to follow in your material defines to integrate easily the
  78707. * Image proccessing functions.
  78708. * @hidden
  78709. */
  78710. export interface IImageProcessingConfigurationDefines {
  78711. IMAGEPROCESSING: boolean;
  78712. VIGNETTE: boolean;
  78713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78714. VIGNETTEBLENDMODEOPAQUE: boolean;
  78715. TONEMAPPING: boolean;
  78716. TONEMAPPING_ACES: boolean;
  78717. CONTRAST: boolean;
  78718. EXPOSURE: boolean;
  78719. COLORCURVES: boolean;
  78720. COLORGRADING: boolean;
  78721. COLORGRADING3D: boolean;
  78722. SAMPLER3DGREENDEPTH: boolean;
  78723. SAMPLER3DBGRMAP: boolean;
  78724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78725. }
  78726. /**
  78727. * @hidden
  78728. */
  78729. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78730. IMAGEPROCESSING: boolean;
  78731. VIGNETTE: boolean;
  78732. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78733. VIGNETTEBLENDMODEOPAQUE: boolean;
  78734. TONEMAPPING: boolean;
  78735. TONEMAPPING_ACES: boolean;
  78736. CONTRAST: boolean;
  78737. COLORCURVES: boolean;
  78738. COLORGRADING: boolean;
  78739. COLORGRADING3D: boolean;
  78740. SAMPLER3DGREENDEPTH: boolean;
  78741. SAMPLER3DBGRMAP: boolean;
  78742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78743. EXPOSURE: boolean;
  78744. constructor();
  78745. }
  78746. /**
  78747. * This groups together the common properties used for image processing either in direct forward pass
  78748. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78749. * or not.
  78750. */
  78751. export class ImageProcessingConfiguration {
  78752. /**
  78753. * Default tone mapping applied in BabylonJS.
  78754. */
  78755. static readonly TONEMAPPING_STANDARD: number;
  78756. /**
  78757. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78758. * to other engines rendering to increase portability.
  78759. */
  78760. static readonly TONEMAPPING_ACES: number;
  78761. /**
  78762. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78763. */
  78764. colorCurves: Nullable<ColorCurves>;
  78765. private _colorCurvesEnabled;
  78766. /**
  78767. * Gets wether the color curves effect is enabled.
  78768. */
  78769. get colorCurvesEnabled(): boolean;
  78770. /**
  78771. * Sets wether the color curves effect is enabled.
  78772. */
  78773. set colorCurvesEnabled(value: boolean);
  78774. private _colorGradingTexture;
  78775. /**
  78776. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78777. */
  78778. get colorGradingTexture(): Nullable<BaseTexture>;
  78779. /**
  78780. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78781. */
  78782. set colorGradingTexture(value: Nullable<BaseTexture>);
  78783. private _colorGradingEnabled;
  78784. /**
  78785. * Gets wether the color grading effect is enabled.
  78786. */
  78787. get colorGradingEnabled(): boolean;
  78788. /**
  78789. * Sets wether the color grading effect is enabled.
  78790. */
  78791. set colorGradingEnabled(value: boolean);
  78792. private _colorGradingWithGreenDepth;
  78793. /**
  78794. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78795. */
  78796. get colorGradingWithGreenDepth(): boolean;
  78797. /**
  78798. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78799. */
  78800. set colorGradingWithGreenDepth(value: boolean);
  78801. private _colorGradingBGR;
  78802. /**
  78803. * Gets wether the color grading texture contains BGR values.
  78804. */
  78805. get colorGradingBGR(): boolean;
  78806. /**
  78807. * Sets wether the color grading texture contains BGR values.
  78808. */
  78809. set colorGradingBGR(value: boolean);
  78810. /** @hidden */
  78811. _exposure: number;
  78812. /**
  78813. * Gets the Exposure used in the effect.
  78814. */
  78815. get exposure(): number;
  78816. /**
  78817. * Sets the Exposure used in the effect.
  78818. */
  78819. set exposure(value: number);
  78820. private _toneMappingEnabled;
  78821. /**
  78822. * Gets wether the tone mapping effect is enabled.
  78823. */
  78824. get toneMappingEnabled(): boolean;
  78825. /**
  78826. * Sets wether the tone mapping effect is enabled.
  78827. */
  78828. set toneMappingEnabled(value: boolean);
  78829. private _toneMappingType;
  78830. /**
  78831. * Gets the type of tone mapping effect.
  78832. */
  78833. get toneMappingType(): number;
  78834. /**
  78835. * Sets the type of tone mapping effect used in BabylonJS.
  78836. */
  78837. set toneMappingType(value: number);
  78838. protected _contrast: number;
  78839. /**
  78840. * Gets the contrast used in the effect.
  78841. */
  78842. get contrast(): number;
  78843. /**
  78844. * Sets the contrast used in the effect.
  78845. */
  78846. set contrast(value: number);
  78847. /**
  78848. * Vignette stretch size.
  78849. */
  78850. vignetteStretch: number;
  78851. /**
  78852. * Vignette centre X Offset.
  78853. */
  78854. vignetteCentreX: number;
  78855. /**
  78856. * Vignette centre Y Offset.
  78857. */
  78858. vignetteCentreY: number;
  78859. /**
  78860. * Vignette weight or intensity of the vignette effect.
  78861. */
  78862. vignetteWeight: number;
  78863. /**
  78864. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78865. * if vignetteEnabled is set to true.
  78866. */
  78867. vignetteColor: Color4;
  78868. /**
  78869. * Camera field of view used by the Vignette effect.
  78870. */
  78871. vignetteCameraFov: number;
  78872. private _vignetteBlendMode;
  78873. /**
  78874. * Gets the vignette blend mode allowing different kind of effect.
  78875. */
  78876. get vignetteBlendMode(): number;
  78877. /**
  78878. * Sets the vignette blend mode allowing different kind of effect.
  78879. */
  78880. set vignetteBlendMode(value: number);
  78881. private _vignetteEnabled;
  78882. /**
  78883. * Gets wether the vignette effect is enabled.
  78884. */
  78885. get vignetteEnabled(): boolean;
  78886. /**
  78887. * Sets wether the vignette effect is enabled.
  78888. */
  78889. set vignetteEnabled(value: boolean);
  78890. private _applyByPostProcess;
  78891. /**
  78892. * Gets wether the image processing is applied through a post process or not.
  78893. */
  78894. get applyByPostProcess(): boolean;
  78895. /**
  78896. * Sets wether the image processing is applied through a post process or not.
  78897. */
  78898. set applyByPostProcess(value: boolean);
  78899. private _isEnabled;
  78900. /**
  78901. * Gets wether the image processing is enabled or not.
  78902. */
  78903. get isEnabled(): boolean;
  78904. /**
  78905. * Sets wether the image processing is enabled or not.
  78906. */
  78907. set isEnabled(value: boolean);
  78908. /**
  78909. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  78910. */
  78911. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  78912. /**
  78913. * Method called each time the image processing information changes requires to recompile the effect.
  78914. */
  78915. protected _updateParameters(): void;
  78916. /**
  78917. * Gets the current class name.
  78918. * @return "ImageProcessingConfiguration"
  78919. */
  78920. getClassName(): string;
  78921. /**
  78922. * Prepare the list of uniforms associated with the Image Processing effects.
  78923. * @param uniforms The list of uniforms used in the effect
  78924. * @param defines the list of defines currently in use
  78925. */
  78926. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  78927. /**
  78928. * Prepare the list of samplers associated with the Image Processing effects.
  78929. * @param samplersList The list of uniforms used in the effect
  78930. * @param defines the list of defines currently in use
  78931. */
  78932. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  78933. /**
  78934. * Prepare the list of defines associated to the shader.
  78935. * @param defines the list of defines to complete
  78936. * @param forPostProcess Define if we are currently in post process mode or not
  78937. */
  78938. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  78939. /**
  78940. * Returns true if all the image processing information are ready.
  78941. * @returns True if ready, otherwise, false
  78942. */
  78943. isReady(): boolean;
  78944. /**
  78945. * Binds the image processing to the shader.
  78946. * @param effect The effect to bind to
  78947. * @param overrideAspectRatio Override the aspect ratio of the effect
  78948. */
  78949. bind(effect: Effect, overrideAspectRatio?: number): void;
  78950. /**
  78951. * Clones the current image processing instance.
  78952. * @return The cloned image processing
  78953. */
  78954. clone(): ImageProcessingConfiguration;
  78955. /**
  78956. * Serializes the current image processing instance to a json representation.
  78957. * @return a JSON representation
  78958. */
  78959. serialize(): any;
  78960. /**
  78961. * Parses the image processing from a json representation.
  78962. * @param source the JSON source to parse
  78963. * @return The parsed image processing
  78964. */
  78965. static Parse(source: any): ImageProcessingConfiguration;
  78966. private static _VIGNETTEMODE_MULTIPLY;
  78967. private static _VIGNETTEMODE_OPAQUE;
  78968. /**
  78969. * Used to apply the vignette as a mix with the pixel color.
  78970. */
  78971. static get VIGNETTEMODE_MULTIPLY(): number;
  78972. /**
  78973. * Used to apply the vignette as a replacement of the pixel color.
  78974. */
  78975. static get VIGNETTEMODE_OPAQUE(): number;
  78976. }
  78977. }
  78978. declare module BABYLON {
  78979. /** @hidden */
  78980. export var postprocessVertexShader: {
  78981. name: string;
  78982. shader: string;
  78983. };
  78984. }
  78985. declare module BABYLON {
  78986. interface ThinEngine {
  78987. /**
  78988. * Creates a new render target texture
  78989. * @param size defines the size of the texture
  78990. * @param options defines the options used to create the texture
  78991. * @returns a new render target texture stored in an InternalTexture
  78992. */
  78993. createRenderTargetTexture(size: number | {
  78994. width: number;
  78995. height: number;
  78996. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  78997. /**
  78998. * Creates a depth stencil texture.
  78999. * This is only available in WebGL 2 or with the depth texture extension available.
  79000. * @param size The size of face edge in the texture.
  79001. * @param options The options defining the texture.
  79002. * @returns The texture
  79003. */
  79004. createDepthStencilTexture(size: number | {
  79005. width: number;
  79006. height: number;
  79007. }, options: DepthTextureCreationOptions): InternalTexture;
  79008. /** @hidden */
  79009. _createDepthStencilTexture(size: number | {
  79010. width: number;
  79011. height: number;
  79012. }, options: DepthTextureCreationOptions): InternalTexture;
  79013. }
  79014. }
  79015. declare module BABYLON {
  79016. /** Defines supported spaces */
  79017. export enum Space {
  79018. /** Local (object) space */
  79019. LOCAL = 0,
  79020. /** World space */
  79021. WORLD = 1,
  79022. /** Bone space */
  79023. BONE = 2
  79024. }
  79025. /** Defines the 3 main axes */
  79026. export class Axis {
  79027. /** X axis */
  79028. static X: Vector3;
  79029. /** Y axis */
  79030. static Y: Vector3;
  79031. /** Z axis */
  79032. static Z: Vector3;
  79033. }
  79034. }
  79035. declare module BABYLON {
  79036. /**
  79037. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79038. * This is the base of the follow, arc rotate cameras and Free camera
  79039. * @see http://doc.babylonjs.com/features/cameras
  79040. */
  79041. export class TargetCamera extends Camera {
  79042. private static _RigCamTransformMatrix;
  79043. private static _TargetTransformMatrix;
  79044. private static _TargetFocalPoint;
  79045. /**
  79046. * Define the current direction the camera is moving to
  79047. */
  79048. cameraDirection: Vector3;
  79049. /**
  79050. * Define the current rotation the camera is rotating to
  79051. */
  79052. cameraRotation: Vector2;
  79053. /**
  79054. * When set, the up vector of the camera will be updated by the rotation of the camera
  79055. */
  79056. updateUpVectorFromRotation: boolean;
  79057. private _tmpQuaternion;
  79058. /**
  79059. * Define the current rotation of the camera
  79060. */
  79061. rotation: Vector3;
  79062. /**
  79063. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79064. */
  79065. rotationQuaternion: Quaternion;
  79066. /**
  79067. * Define the current speed of the camera
  79068. */
  79069. speed: number;
  79070. /**
  79071. * Add constraint to the camera to prevent it to move freely in all directions and
  79072. * around all axis.
  79073. */
  79074. noRotationConstraint: boolean;
  79075. /**
  79076. * Define the current target of the camera as an object or a position.
  79077. */
  79078. lockedTarget: any;
  79079. /** @hidden */
  79080. _currentTarget: Vector3;
  79081. /** @hidden */
  79082. _initialFocalDistance: number;
  79083. /** @hidden */
  79084. _viewMatrix: Matrix;
  79085. /** @hidden */
  79086. _camMatrix: Matrix;
  79087. /** @hidden */
  79088. _cameraTransformMatrix: Matrix;
  79089. /** @hidden */
  79090. _cameraRotationMatrix: Matrix;
  79091. /** @hidden */
  79092. _referencePoint: Vector3;
  79093. /** @hidden */
  79094. _transformedReferencePoint: Vector3;
  79095. protected _globalCurrentTarget: Vector3;
  79096. protected _globalCurrentUpVector: Vector3;
  79097. /** @hidden */
  79098. _reset: () => void;
  79099. private _defaultUp;
  79100. /**
  79101. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79102. * This is the base of the follow, arc rotate cameras and Free camera
  79103. * @see http://doc.babylonjs.com/features/cameras
  79104. * @param name Defines the name of the camera in the scene
  79105. * @param position Defines the start position of the camera in the scene
  79106. * @param scene Defines the scene the camera belongs to
  79107. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79108. */
  79109. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79110. /**
  79111. * Gets the position in front of the camera at a given distance.
  79112. * @param distance The distance from the camera we want the position to be
  79113. * @returns the position
  79114. */
  79115. getFrontPosition(distance: number): Vector3;
  79116. /** @hidden */
  79117. _getLockedTargetPosition(): Nullable<Vector3>;
  79118. private _storedPosition;
  79119. private _storedRotation;
  79120. private _storedRotationQuaternion;
  79121. /**
  79122. * Store current camera state of the camera (fov, position, rotation, etc..)
  79123. * @returns the camera
  79124. */
  79125. storeState(): Camera;
  79126. /**
  79127. * Restored camera state. You must call storeState() first
  79128. * @returns whether it was successful or not
  79129. * @hidden
  79130. */
  79131. _restoreStateValues(): boolean;
  79132. /** @hidden */
  79133. _initCache(): void;
  79134. /** @hidden */
  79135. _updateCache(ignoreParentClass?: boolean): void;
  79136. /** @hidden */
  79137. _isSynchronizedViewMatrix(): boolean;
  79138. /** @hidden */
  79139. _computeLocalCameraSpeed(): number;
  79140. /**
  79141. * Defines the target the camera should look at.
  79142. * @param target Defines the new target as a Vector or a mesh
  79143. */
  79144. setTarget(target: Vector3): void;
  79145. /**
  79146. * Return the current target position of the camera. This value is expressed in local space.
  79147. * @returns the target position
  79148. */
  79149. getTarget(): Vector3;
  79150. /** @hidden */
  79151. _decideIfNeedsToMove(): boolean;
  79152. /** @hidden */
  79153. _updatePosition(): void;
  79154. /** @hidden */
  79155. _checkInputs(): void;
  79156. protected _updateCameraRotationMatrix(): void;
  79157. /**
  79158. * 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)
  79159. * @returns the current camera
  79160. */
  79161. private _rotateUpVectorWithCameraRotationMatrix;
  79162. private _cachedRotationZ;
  79163. private _cachedQuaternionRotationZ;
  79164. /** @hidden */
  79165. _getViewMatrix(): Matrix;
  79166. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79167. /**
  79168. * @hidden
  79169. */
  79170. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79171. /**
  79172. * @hidden
  79173. */
  79174. _updateRigCameras(): void;
  79175. private _getRigCamPositionAndTarget;
  79176. /**
  79177. * Gets the current object class name.
  79178. * @return the class name
  79179. */
  79180. getClassName(): string;
  79181. }
  79182. }
  79183. declare module BABYLON {
  79184. /**
  79185. * Gather the list of keyboard event types as constants.
  79186. */
  79187. export class KeyboardEventTypes {
  79188. /**
  79189. * The keydown event is fired when a key becomes active (pressed).
  79190. */
  79191. static readonly KEYDOWN: number;
  79192. /**
  79193. * The keyup event is fired when a key has been released.
  79194. */
  79195. static readonly KEYUP: number;
  79196. }
  79197. /**
  79198. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79199. */
  79200. export class KeyboardInfo {
  79201. /**
  79202. * Defines the type of event (KeyboardEventTypes)
  79203. */
  79204. type: number;
  79205. /**
  79206. * Defines the related dom event
  79207. */
  79208. event: KeyboardEvent;
  79209. /**
  79210. * Instantiates a new keyboard info.
  79211. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79212. * @param type Defines the type of event (KeyboardEventTypes)
  79213. * @param event Defines the related dom event
  79214. */
  79215. constructor(
  79216. /**
  79217. * Defines the type of event (KeyboardEventTypes)
  79218. */
  79219. type: number,
  79220. /**
  79221. * Defines the related dom event
  79222. */
  79223. event: KeyboardEvent);
  79224. }
  79225. /**
  79226. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79227. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79228. */
  79229. export class KeyboardInfoPre extends KeyboardInfo {
  79230. /**
  79231. * Defines the type of event (KeyboardEventTypes)
  79232. */
  79233. type: number;
  79234. /**
  79235. * Defines the related dom event
  79236. */
  79237. event: KeyboardEvent;
  79238. /**
  79239. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79240. */
  79241. skipOnPointerObservable: boolean;
  79242. /**
  79243. * Instantiates a new keyboard pre info.
  79244. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79245. * @param type Defines the type of event (KeyboardEventTypes)
  79246. * @param event Defines the related dom event
  79247. */
  79248. constructor(
  79249. /**
  79250. * Defines the type of event (KeyboardEventTypes)
  79251. */
  79252. type: number,
  79253. /**
  79254. * Defines the related dom event
  79255. */
  79256. event: KeyboardEvent);
  79257. }
  79258. }
  79259. declare module BABYLON {
  79260. /**
  79261. * Manage the keyboard inputs to control the movement of a free camera.
  79262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79263. */
  79264. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79265. /**
  79266. * Defines the camera the input is attached to.
  79267. */
  79268. camera: FreeCamera;
  79269. /**
  79270. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79271. */
  79272. keysUp: number[];
  79273. /**
  79274. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79275. */
  79276. keysDown: number[];
  79277. /**
  79278. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79279. */
  79280. keysLeft: number[];
  79281. /**
  79282. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79283. */
  79284. keysRight: number[];
  79285. private _keys;
  79286. private _onCanvasBlurObserver;
  79287. private _onKeyboardObserver;
  79288. private _engine;
  79289. private _scene;
  79290. /**
  79291. * Attach the input controls to a specific dom element to get the input from.
  79292. * @param element Defines the element the controls should be listened from
  79293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79294. */
  79295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79296. /**
  79297. * Detach the current controls from the specified dom element.
  79298. * @param element Defines the element to stop listening the inputs from
  79299. */
  79300. detachControl(element: Nullable<HTMLElement>): void;
  79301. /**
  79302. * Update the current camera state depending on the inputs that have been used this frame.
  79303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79304. */
  79305. checkInputs(): void;
  79306. /**
  79307. * Gets the class name of the current intput.
  79308. * @returns the class name
  79309. */
  79310. getClassName(): string;
  79311. /** @hidden */
  79312. _onLostFocus(): void;
  79313. /**
  79314. * Get the friendly name associated with the input class.
  79315. * @returns the input friendly name
  79316. */
  79317. getSimpleName(): string;
  79318. }
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * Interface describing all the common properties and methods a shadow light needs to implement.
  79323. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79324. * as well as binding the different shadow properties to the effects.
  79325. */
  79326. export interface IShadowLight extends Light {
  79327. /**
  79328. * The light id in the scene (used in scene.findLighById for instance)
  79329. */
  79330. id: string;
  79331. /**
  79332. * The position the shdow will be casted from.
  79333. */
  79334. position: Vector3;
  79335. /**
  79336. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79337. */
  79338. direction: Vector3;
  79339. /**
  79340. * The transformed position. Position of the light in world space taking parenting in account.
  79341. */
  79342. transformedPosition: Vector3;
  79343. /**
  79344. * The transformed direction. Direction of the light in world space taking parenting in account.
  79345. */
  79346. transformedDirection: Vector3;
  79347. /**
  79348. * The friendly name of the light in the scene.
  79349. */
  79350. name: string;
  79351. /**
  79352. * Defines the shadow projection clipping minimum z value.
  79353. */
  79354. shadowMinZ: number;
  79355. /**
  79356. * Defines the shadow projection clipping maximum z value.
  79357. */
  79358. shadowMaxZ: number;
  79359. /**
  79360. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79361. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79362. */
  79363. computeTransformedInformation(): boolean;
  79364. /**
  79365. * Gets the scene the light belongs to.
  79366. * @returns The scene
  79367. */
  79368. getScene(): Scene;
  79369. /**
  79370. * Callback defining a custom Projection Matrix Builder.
  79371. * This can be used to override the default projection matrix computation.
  79372. */
  79373. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79374. /**
  79375. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79376. * @param matrix The materix to updated with the projection information
  79377. * @param viewMatrix The transform matrix of the light
  79378. * @param renderList The list of mesh to render in the map
  79379. * @returns The current light
  79380. */
  79381. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79382. /**
  79383. * Gets the current depth scale used in ESM.
  79384. * @returns The scale
  79385. */
  79386. getDepthScale(): number;
  79387. /**
  79388. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79389. * @returns true if a cube texture needs to be use
  79390. */
  79391. needCube(): boolean;
  79392. /**
  79393. * Detects if the projection matrix requires to be recomputed this frame.
  79394. * @returns true if it requires to be recomputed otherwise, false.
  79395. */
  79396. needProjectionMatrixCompute(): boolean;
  79397. /**
  79398. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79399. */
  79400. forceProjectionMatrixCompute(): void;
  79401. /**
  79402. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79403. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79404. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79405. */
  79406. getShadowDirection(faceIndex?: number): Vector3;
  79407. /**
  79408. * Gets the minZ used for shadow according to both the scene and the light.
  79409. * @param activeCamera The camera we are returning the min for
  79410. * @returns the depth min z
  79411. */
  79412. getDepthMinZ(activeCamera: Camera): number;
  79413. /**
  79414. * Gets the maxZ used for shadow according to both the scene and the light.
  79415. * @param activeCamera The camera we are returning the max for
  79416. * @returns the depth max z
  79417. */
  79418. getDepthMaxZ(activeCamera: Camera): number;
  79419. }
  79420. /**
  79421. * Base implementation IShadowLight
  79422. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79423. */
  79424. export abstract class ShadowLight extends Light implements IShadowLight {
  79425. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79426. protected _position: Vector3;
  79427. protected _setPosition(value: Vector3): void;
  79428. /**
  79429. * Sets the position the shadow will be casted from. Also use as the light position for both
  79430. * point and spot lights.
  79431. */
  79432. get position(): Vector3;
  79433. /**
  79434. * Sets the position the shadow will be casted from. Also use as the light position for both
  79435. * point and spot lights.
  79436. */
  79437. set position(value: Vector3);
  79438. protected _direction: Vector3;
  79439. protected _setDirection(value: Vector3): void;
  79440. /**
  79441. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79442. * Also use as the light direction on spot and directional lights.
  79443. */
  79444. get direction(): Vector3;
  79445. /**
  79446. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79447. * Also use as the light direction on spot and directional lights.
  79448. */
  79449. set direction(value: Vector3);
  79450. private _shadowMinZ;
  79451. /**
  79452. * Gets the shadow projection clipping minimum z value.
  79453. */
  79454. get shadowMinZ(): number;
  79455. /**
  79456. * Sets the shadow projection clipping minimum z value.
  79457. */
  79458. set shadowMinZ(value: number);
  79459. private _shadowMaxZ;
  79460. /**
  79461. * Sets the shadow projection clipping maximum z value.
  79462. */
  79463. get shadowMaxZ(): number;
  79464. /**
  79465. * Gets the shadow projection clipping maximum z value.
  79466. */
  79467. set shadowMaxZ(value: number);
  79468. /**
  79469. * Callback defining a custom Projection Matrix Builder.
  79470. * This can be used to override the default projection matrix computation.
  79471. */
  79472. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79473. /**
  79474. * The transformed position. Position of the light in world space taking parenting in account.
  79475. */
  79476. transformedPosition: Vector3;
  79477. /**
  79478. * The transformed direction. Direction of the light in world space taking parenting in account.
  79479. */
  79480. transformedDirection: Vector3;
  79481. private _needProjectionMatrixCompute;
  79482. /**
  79483. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79484. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79485. */
  79486. computeTransformedInformation(): boolean;
  79487. /**
  79488. * Return the depth scale used for the shadow map.
  79489. * @returns the depth scale.
  79490. */
  79491. getDepthScale(): number;
  79492. /**
  79493. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79494. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79495. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79496. */
  79497. getShadowDirection(faceIndex?: number): Vector3;
  79498. /**
  79499. * Returns the ShadowLight absolute position in the World.
  79500. * @returns the position vector in world space
  79501. */
  79502. getAbsolutePosition(): Vector3;
  79503. /**
  79504. * Sets the ShadowLight direction toward the passed target.
  79505. * @param target The point to target in local space
  79506. * @returns the updated ShadowLight direction
  79507. */
  79508. setDirectionToTarget(target: Vector3): Vector3;
  79509. /**
  79510. * Returns the light rotation in euler definition.
  79511. * @returns the x y z rotation in local space.
  79512. */
  79513. getRotation(): Vector3;
  79514. /**
  79515. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79516. * @returns true if a cube texture needs to be use
  79517. */
  79518. needCube(): boolean;
  79519. /**
  79520. * Detects if the projection matrix requires to be recomputed this frame.
  79521. * @returns true if it requires to be recomputed otherwise, false.
  79522. */
  79523. needProjectionMatrixCompute(): boolean;
  79524. /**
  79525. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79526. */
  79527. forceProjectionMatrixCompute(): void;
  79528. /** @hidden */
  79529. _initCache(): void;
  79530. /** @hidden */
  79531. _isSynchronized(): boolean;
  79532. /**
  79533. * Computes the world matrix of the node
  79534. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79535. * @returns the world matrix
  79536. */
  79537. computeWorldMatrix(force?: boolean): Matrix;
  79538. /**
  79539. * Gets the minZ used for shadow according to both the scene and the light.
  79540. * @param activeCamera The camera we are returning the min for
  79541. * @returns the depth min z
  79542. */
  79543. getDepthMinZ(activeCamera: Camera): number;
  79544. /**
  79545. * Gets the maxZ used for shadow according to both the scene and the light.
  79546. * @param activeCamera The camera we are returning the max for
  79547. * @returns the depth max z
  79548. */
  79549. getDepthMaxZ(activeCamera: Camera): number;
  79550. /**
  79551. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79552. * @param matrix The materix to updated with the projection information
  79553. * @param viewMatrix The transform matrix of the light
  79554. * @param renderList The list of mesh to render in the map
  79555. * @returns The current light
  79556. */
  79557. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79558. }
  79559. }
  79560. declare module BABYLON {
  79561. /**
  79562. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79563. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79564. */
  79565. export class EffectFallbacks implements IEffectFallbacks {
  79566. private _defines;
  79567. private _currentRank;
  79568. private _maxRank;
  79569. private _mesh;
  79570. /**
  79571. * Removes the fallback from the bound mesh.
  79572. */
  79573. unBindMesh(): void;
  79574. /**
  79575. * Adds a fallback on the specified property.
  79576. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79577. * @param define The name of the define in the shader
  79578. */
  79579. addFallback(rank: number, define: string): void;
  79580. /**
  79581. * Sets the mesh to use CPU skinning when needing to fallback.
  79582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79583. * @param mesh The mesh to use the fallbacks.
  79584. */
  79585. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79586. /**
  79587. * Checks to see if more fallbacks are still availible.
  79588. */
  79589. get hasMoreFallbacks(): boolean;
  79590. /**
  79591. * Removes the defines that should be removed when falling back.
  79592. * @param currentDefines defines the current define statements for the shader.
  79593. * @param effect defines the current effect we try to compile
  79594. * @returns The resulting defines with defines of the current rank removed.
  79595. */
  79596. reduce(currentDefines: string, effect: Effect): string;
  79597. }
  79598. }
  79599. declare module BABYLON {
  79600. /**
  79601. * "Static Class" containing the most commonly used helper while dealing with material for
  79602. * rendering purpose.
  79603. *
  79604. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79605. *
  79606. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79607. */
  79608. export class MaterialHelper {
  79609. /**
  79610. * Bind the current view position to an effect.
  79611. * @param effect The effect to be bound
  79612. * @param scene The scene the eyes position is used from
  79613. */
  79614. static BindEyePosition(effect: Effect, scene: Scene): void;
  79615. /**
  79616. * Helps preparing the defines values about the UVs in used in the effect.
  79617. * UVs are shared as much as we can accross channels in the shaders.
  79618. * @param texture The texture we are preparing the UVs for
  79619. * @param defines The defines to update
  79620. * @param key The channel key "diffuse", "specular"... used in the shader
  79621. */
  79622. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79623. /**
  79624. * Binds a texture matrix value to its corrsponding uniform
  79625. * @param texture The texture to bind the matrix for
  79626. * @param uniformBuffer The uniform buffer receivin the data
  79627. * @param key The channel key "diffuse", "specular"... used in the shader
  79628. */
  79629. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79630. /**
  79631. * Gets the current status of the fog (should it be enabled?)
  79632. * @param mesh defines the mesh to evaluate for fog support
  79633. * @param scene defines the hosting scene
  79634. * @returns true if fog must be enabled
  79635. */
  79636. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79637. /**
  79638. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79639. * @param mesh defines the current mesh
  79640. * @param scene defines the current scene
  79641. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79642. * @param pointsCloud defines if point cloud rendering has to be turned on
  79643. * @param fogEnabled defines if fog has to be turned on
  79644. * @param alphaTest defines if alpha testing has to be turned on
  79645. * @param defines defines the current list of defines
  79646. */
  79647. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79648. /**
  79649. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79650. * @param scene defines the current scene
  79651. * @param engine defines the current engine
  79652. * @param defines specifies the list of active defines
  79653. * @param useInstances defines if instances have to be turned on
  79654. * @param useClipPlane defines if clip plane have to be turned on
  79655. */
  79656. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79657. /**
  79658. * Prepares the defines for bones
  79659. * @param mesh The mesh containing the geometry data we will draw
  79660. * @param defines The defines to update
  79661. */
  79662. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79663. /**
  79664. * Prepares the defines for morph targets
  79665. * @param mesh The mesh containing the geometry data we will draw
  79666. * @param defines The defines to update
  79667. */
  79668. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79669. /**
  79670. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79671. * @param mesh The mesh containing the geometry data we will draw
  79672. * @param defines The defines to update
  79673. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79674. * @param useBones Precise whether bones should be used or not (override mesh info)
  79675. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79676. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79677. * @returns false if defines are considered not dirty and have not been checked
  79678. */
  79679. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79680. /**
  79681. * Prepares the defines related to multiview
  79682. * @param scene The scene we are intending to draw
  79683. * @param defines The defines to update
  79684. */
  79685. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79686. /**
  79687. * Prepares the defines related to the light information passed in parameter
  79688. * @param scene The scene we are intending to draw
  79689. * @param mesh The mesh the effect is compiling for
  79690. * @param light The light the effect is compiling for
  79691. * @param lightIndex The index of the light
  79692. * @param defines The defines to update
  79693. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79694. * @param state Defines the current state regarding what is needed (normals, etc...)
  79695. */
  79696. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79697. needNormals: boolean;
  79698. needRebuild: boolean;
  79699. shadowEnabled: boolean;
  79700. specularEnabled: boolean;
  79701. lightmapMode: boolean;
  79702. }): void;
  79703. /**
  79704. * Prepares the defines related to the light information passed in parameter
  79705. * @param scene The scene we are intending to draw
  79706. * @param mesh The mesh the effect is compiling for
  79707. * @param defines The defines to update
  79708. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79709. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79710. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79711. * @returns true if normals will be required for the rest of the effect
  79712. */
  79713. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79714. /**
  79715. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79716. * @param lightIndex defines the light index
  79717. * @param uniformsList The uniform list
  79718. * @param samplersList The sampler list
  79719. * @param projectedLightTexture defines if projected texture must be used
  79720. * @param uniformBuffersList defines an optional list of uniform buffers
  79721. */
  79722. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79723. /**
  79724. * Prepares the uniforms and samplers list to be used in the effect
  79725. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79726. * @param samplersList The sampler list
  79727. * @param defines The defines helping in the list generation
  79728. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79729. */
  79730. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79731. /**
  79732. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79733. * @param defines The defines to update while falling back
  79734. * @param fallbacks The authorized effect fallbacks
  79735. * @param maxSimultaneousLights The maximum number of lights allowed
  79736. * @param rank the current rank of the Effect
  79737. * @returns The newly affected rank
  79738. */
  79739. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79740. private static _TmpMorphInfluencers;
  79741. /**
  79742. * Prepares the list of attributes required for morph targets according to the effect defines.
  79743. * @param attribs The current list of supported attribs
  79744. * @param mesh The mesh to prepare the morph targets attributes for
  79745. * @param influencers The number of influencers
  79746. */
  79747. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79748. /**
  79749. * Prepares the list of attributes required for morph targets according to the effect defines.
  79750. * @param attribs The current list of supported attribs
  79751. * @param mesh The mesh to prepare the morph targets attributes for
  79752. * @param defines The current Defines of the effect
  79753. */
  79754. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79755. /**
  79756. * Prepares the list of attributes required for bones according to the effect defines.
  79757. * @param attribs The current list of supported attribs
  79758. * @param mesh The mesh to prepare the bones attributes for
  79759. * @param defines The current Defines of the effect
  79760. * @param fallbacks The current efffect fallback strategy
  79761. */
  79762. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79763. /**
  79764. * Check and prepare the list of attributes required for instances according to the effect defines.
  79765. * @param attribs The current list of supported attribs
  79766. * @param defines The current MaterialDefines of the effect
  79767. */
  79768. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79769. /**
  79770. * Add the list of attributes required for instances to the attribs array.
  79771. * @param attribs The current list of supported attribs
  79772. */
  79773. static PushAttributesForInstances(attribs: string[]): void;
  79774. /**
  79775. * Binds the light information to the effect.
  79776. * @param light The light containing the generator
  79777. * @param effect The effect we are binding the data to
  79778. * @param lightIndex The light index in the effect used to render
  79779. */
  79780. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79781. /**
  79782. * Binds the lights information from the scene to the effect for the given mesh.
  79783. * @param light Light to bind
  79784. * @param lightIndex Light index
  79785. * @param scene The scene where the light belongs to
  79786. * @param effect The effect we are binding the data to
  79787. * @param useSpecular Defines if specular is supported
  79788. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79789. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79790. */
  79791. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79792. /**
  79793. * Binds the lights information from the scene to the effect for the given mesh.
  79794. * @param scene The scene the lights belongs to
  79795. * @param mesh The mesh we are binding the information to render
  79796. * @param effect The effect we are binding the data to
  79797. * @param defines The generated defines for the effect
  79798. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79799. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79800. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79801. */
  79802. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79803. private static _tempFogColor;
  79804. /**
  79805. * Binds the fog information from the scene to the effect for the given mesh.
  79806. * @param scene The scene the lights belongs to
  79807. * @param mesh The mesh we are binding the information to render
  79808. * @param effect The effect we are binding the data to
  79809. * @param linearSpace Defines if the fog effect is applied in linear space
  79810. */
  79811. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79812. /**
  79813. * Binds the bones information from the mesh to the effect.
  79814. * @param mesh The mesh we are binding the information to render
  79815. * @param effect The effect we are binding the data to
  79816. */
  79817. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79818. /**
  79819. * Binds the morph targets information from the mesh to the effect.
  79820. * @param abstractMesh The mesh we are binding the information to render
  79821. * @param effect The effect we are binding the data to
  79822. */
  79823. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79824. /**
  79825. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79826. * @param defines The generated defines used in the effect
  79827. * @param effect The effect we are binding the data to
  79828. * @param scene The scene we are willing to render with logarithmic scale for
  79829. */
  79830. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79831. /**
  79832. * Binds the clip plane information from the scene to the effect.
  79833. * @param scene The scene the clip plane information are extracted from
  79834. * @param effect The effect we are binding the data to
  79835. */
  79836. static BindClipPlane(effect: Effect, scene: Scene): void;
  79837. }
  79838. }
  79839. declare module BABYLON {
  79840. /** @hidden */
  79841. export var packingFunctions: {
  79842. name: string;
  79843. shader: string;
  79844. };
  79845. }
  79846. declare module BABYLON {
  79847. /** @hidden */
  79848. export var shadowMapPixelShader: {
  79849. name: string;
  79850. shader: string;
  79851. };
  79852. }
  79853. declare module BABYLON {
  79854. /** @hidden */
  79855. export var bonesDeclaration: {
  79856. name: string;
  79857. shader: string;
  79858. };
  79859. }
  79860. declare module BABYLON {
  79861. /** @hidden */
  79862. export var morphTargetsVertexGlobalDeclaration: {
  79863. name: string;
  79864. shader: string;
  79865. };
  79866. }
  79867. declare module BABYLON {
  79868. /** @hidden */
  79869. export var morphTargetsVertexDeclaration: {
  79870. name: string;
  79871. shader: string;
  79872. };
  79873. }
  79874. declare module BABYLON {
  79875. /** @hidden */
  79876. export var instancesDeclaration: {
  79877. name: string;
  79878. shader: string;
  79879. };
  79880. }
  79881. declare module BABYLON {
  79882. /** @hidden */
  79883. export var helperFunctions: {
  79884. name: string;
  79885. shader: string;
  79886. };
  79887. }
  79888. declare module BABYLON {
  79889. /** @hidden */
  79890. export var morphTargetsVertex: {
  79891. name: string;
  79892. shader: string;
  79893. };
  79894. }
  79895. declare module BABYLON {
  79896. /** @hidden */
  79897. export var instancesVertex: {
  79898. name: string;
  79899. shader: string;
  79900. };
  79901. }
  79902. declare module BABYLON {
  79903. /** @hidden */
  79904. export var bonesVertex: {
  79905. name: string;
  79906. shader: string;
  79907. };
  79908. }
  79909. declare module BABYLON {
  79910. /** @hidden */
  79911. export var shadowMapVertexShader: {
  79912. name: string;
  79913. shader: string;
  79914. };
  79915. }
  79916. declare module BABYLON {
  79917. /** @hidden */
  79918. export var depthBoxBlurPixelShader: {
  79919. name: string;
  79920. shader: string;
  79921. };
  79922. }
  79923. declare module BABYLON {
  79924. /**
  79925. * Defines the options associated with the creation of a custom shader for a shadow generator.
  79926. */
  79927. export interface ICustomShaderOptions {
  79928. /**
  79929. * Gets or sets the custom shader name to use
  79930. */
  79931. shaderName: string;
  79932. /**
  79933. * The list of attribute names used in the shader
  79934. */
  79935. attributes?: string[];
  79936. /**
  79937. * The list of unifrom names used in the shader
  79938. */
  79939. uniforms?: string[];
  79940. /**
  79941. * The list of sampler names used in the shader
  79942. */
  79943. samplers?: string[];
  79944. /**
  79945. * The list of defines used in the shader
  79946. */
  79947. defines?: string[];
  79948. }
  79949. /**
  79950. * Interface to implement to create a shadow generator compatible with BJS.
  79951. */
  79952. export interface IShadowGenerator {
  79953. /**
  79954. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79955. * @returns The render target texture if present otherwise, null
  79956. */
  79957. getShadowMap(): Nullable<RenderTargetTexture>;
  79958. /**
  79959. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79960. * @returns The render target texture if the shadow map is present otherwise, null
  79961. */
  79962. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79963. /**
  79964. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79965. * @param subMesh The submesh we want to render in the shadow map
  79966. * @param useInstances Defines wether will draw in the map using instances
  79967. * @returns true if ready otherwise, false
  79968. */
  79969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79970. /**
  79971. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79972. * @param defines Defines of the material we want to update
  79973. * @param lightIndex Index of the light in the enabled light list of the material
  79974. */
  79975. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  79976. /**
  79977. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79978. * defined in the generator but impacting the effect).
  79979. * It implies the unifroms available on the materials are the standard BJS ones.
  79980. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79981. * @param effect The effect we are binfing the information for
  79982. */
  79983. bindShadowLight(lightIndex: string, effect: Effect): void;
  79984. /**
  79985. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79986. * (eq to shadow prjection matrix * light transform matrix)
  79987. * @returns The transform matrix used to create the shadow map
  79988. */
  79989. getTransformMatrix(): Matrix;
  79990. /**
  79991. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79992. * Cube and 2D textures for instance.
  79993. */
  79994. recreateShadowMap(): void;
  79995. /**
  79996. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79997. * @param onCompiled Callback triggered at the and of the effects compilation
  79998. * @param options Sets of optional options forcing the compilation with different modes
  79999. */
  80000. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80001. useInstances: boolean;
  80002. }>): void;
  80003. /**
  80004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80005. * @param options Sets of optional options forcing the compilation with different modes
  80006. * @returns A promise that resolves when the compilation completes
  80007. */
  80008. forceCompilationAsync(options?: Partial<{
  80009. useInstances: boolean;
  80010. }>): Promise<void>;
  80011. /**
  80012. * Serializes the shadow generator setup to a json object.
  80013. * @returns The serialized JSON object
  80014. */
  80015. serialize(): any;
  80016. /**
  80017. * Disposes the Shadow map and related Textures and effects.
  80018. */
  80019. dispose(): void;
  80020. }
  80021. /**
  80022. * Default implementation IShadowGenerator.
  80023. * This is the main object responsible of generating shadows in the framework.
  80024. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80025. */
  80026. export class ShadowGenerator implements IShadowGenerator {
  80027. /**
  80028. * Shadow generator mode None: no filtering applied.
  80029. */
  80030. static readonly FILTER_NONE: number;
  80031. /**
  80032. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80033. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80034. */
  80035. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80036. /**
  80037. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80038. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80039. */
  80040. static readonly FILTER_POISSONSAMPLING: number;
  80041. /**
  80042. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80043. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80044. */
  80045. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80046. /**
  80047. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80048. * edge artifacts on steep falloff.
  80049. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80050. */
  80051. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80052. /**
  80053. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80054. * edge artifacts on steep falloff.
  80055. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80056. */
  80057. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80058. /**
  80059. * Shadow generator mode PCF: Percentage Closer Filtering
  80060. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80061. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80062. */
  80063. static readonly FILTER_PCF: number;
  80064. /**
  80065. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80066. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80067. * Contact Hardening
  80068. */
  80069. static readonly FILTER_PCSS: number;
  80070. /**
  80071. * Reserved for PCF and PCSS
  80072. * Highest Quality.
  80073. *
  80074. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80075. *
  80076. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80077. */
  80078. static readonly QUALITY_HIGH: number;
  80079. /**
  80080. * Reserved for PCF and PCSS
  80081. * Good tradeoff for quality/perf cross devices
  80082. *
  80083. * Execute PCF on a 3*3 kernel.
  80084. *
  80085. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80086. */
  80087. static readonly QUALITY_MEDIUM: number;
  80088. /**
  80089. * Reserved for PCF and PCSS
  80090. * The lowest quality but the fastest.
  80091. *
  80092. * Execute PCF on a 1*1 kernel.
  80093. *
  80094. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80095. */
  80096. static readonly QUALITY_LOW: number;
  80097. /** Gets or sets the custom shader name to use */
  80098. customShaderOptions: ICustomShaderOptions;
  80099. /**
  80100. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80101. */
  80102. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80103. /**
  80104. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80105. */
  80106. onAfterShadowMapRenderObservable: Observable<Effect>;
  80107. /**
  80108. * Observable triggered before a mesh is rendered in the shadow map.
  80109. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80110. */
  80111. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80112. /**
  80113. * Observable triggered after a mesh is rendered in the shadow map.
  80114. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80115. */
  80116. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80117. private _bias;
  80118. /**
  80119. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80120. */
  80121. get bias(): number;
  80122. /**
  80123. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80124. */
  80125. set bias(bias: number);
  80126. private _normalBias;
  80127. /**
  80128. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80129. */
  80130. get normalBias(): number;
  80131. /**
  80132. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80133. */
  80134. set normalBias(normalBias: number);
  80135. private _blurBoxOffset;
  80136. /**
  80137. * Gets the blur box offset: offset applied during the blur pass.
  80138. * Only useful if useKernelBlur = false
  80139. */
  80140. get blurBoxOffset(): number;
  80141. /**
  80142. * Sets the blur box offset: offset applied during the blur pass.
  80143. * Only useful if useKernelBlur = false
  80144. */
  80145. set blurBoxOffset(value: number);
  80146. private _blurScale;
  80147. /**
  80148. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80149. * 2 means half of the size.
  80150. */
  80151. get blurScale(): number;
  80152. /**
  80153. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80154. * 2 means half of the size.
  80155. */
  80156. set blurScale(value: number);
  80157. private _blurKernel;
  80158. /**
  80159. * Gets the blur kernel: kernel size of the blur pass.
  80160. * Only useful if useKernelBlur = true
  80161. */
  80162. get blurKernel(): number;
  80163. /**
  80164. * Sets the blur kernel: kernel size of the blur pass.
  80165. * Only useful if useKernelBlur = true
  80166. */
  80167. set blurKernel(value: number);
  80168. private _useKernelBlur;
  80169. /**
  80170. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80171. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80172. */
  80173. get useKernelBlur(): boolean;
  80174. /**
  80175. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80176. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80177. */
  80178. set useKernelBlur(value: boolean);
  80179. private _depthScale;
  80180. /**
  80181. * Gets the depth scale used in ESM mode.
  80182. */
  80183. get depthScale(): number;
  80184. /**
  80185. * Sets the depth scale used in ESM mode.
  80186. * This can override the scale stored on the light.
  80187. */
  80188. set depthScale(value: number);
  80189. private _filter;
  80190. /**
  80191. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80192. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80193. */
  80194. get filter(): number;
  80195. /**
  80196. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80197. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80198. */
  80199. set filter(value: number);
  80200. /**
  80201. * Gets if the current filter is set to Poisson Sampling.
  80202. */
  80203. get usePoissonSampling(): boolean;
  80204. /**
  80205. * Sets the current filter to Poisson Sampling.
  80206. */
  80207. set usePoissonSampling(value: boolean);
  80208. /**
  80209. * Gets if the current filter is set to ESM.
  80210. */
  80211. get useExponentialShadowMap(): boolean;
  80212. /**
  80213. * Sets the current filter is to ESM.
  80214. */
  80215. set useExponentialShadowMap(value: boolean);
  80216. /**
  80217. * Gets if the current filter is set to filtered ESM.
  80218. */
  80219. get useBlurExponentialShadowMap(): boolean;
  80220. /**
  80221. * Gets if the current filter is set to filtered ESM.
  80222. */
  80223. set useBlurExponentialShadowMap(value: boolean);
  80224. /**
  80225. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80226. * exponential to prevent steep falloff artifacts).
  80227. */
  80228. get useCloseExponentialShadowMap(): boolean;
  80229. /**
  80230. * Sets the current filter to "close ESM" (using the inverse of the
  80231. * exponential to prevent steep falloff artifacts).
  80232. */
  80233. set useCloseExponentialShadowMap(value: boolean);
  80234. /**
  80235. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80236. * exponential to prevent steep falloff artifacts).
  80237. */
  80238. get useBlurCloseExponentialShadowMap(): boolean;
  80239. /**
  80240. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80241. * exponential to prevent steep falloff artifacts).
  80242. */
  80243. set useBlurCloseExponentialShadowMap(value: boolean);
  80244. /**
  80245. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80246. */
  80247. get usePercentageCloserFiltering(): boolean;
  80248. /**
  80249. * Sets the current filter to "PCF" (percentage closer filtering).
  80250. */
  80251. set usePercentageCloserFiltering(value: boolean);
  80252. private _filteringQuality;
  80253. /**
  80254. * Gets the PCF or PCSS Quality.
  80255. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80256. */
  80257. get filteringQuality(): number;
  80258. /**
  80259. * Sets the PCF or PCSS Quality.
  80260. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80261. */
  80262. set filteringQuality(filteringQuality: number);
  80263. /**
  80264. * Gets if the current filter is set to "PCSS" (contact hardening).
  80265. */
  80266. get useContactHardeningShadow(): boolean;
  80267. /**
  80268. * Sets the current filter to "PCSS" (contact hardening).
  80269. */
  80270. set useContactHardeningShadow(value: boolean);
  80271. private _contactHardeningLightSizeUVRatio;
  80272. /**
  80273. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80274. * Using a ratio helps keeping shape stability independently of the map size.
  80275. *
  80276. * It does not account for the light projection as it was having too much
  80277. * instability during the light setup or during light position changes.
  80278. *
  80279. * Only valid if useContactHardeningShadow is true.
  80280. */
  80281. get contactHardeningLightSizeUVRatio(): number;
  80282. /**
  80283. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80284. * Using a ratio helps keeping shape stability independently of the map size.
  80285. *
  80286. * It does not account for the light projection as it was having too much
  80287. * instability during the light setup or during light position changes.
  80288. *
  80289. * Only valid if useContactHardeningShadow is true.
  80290. */
  80291. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80292. private _darkness;
  80293. /** Gets or sets the actual darkness of a shadow */
  80294. get darkness(): number;
  80295. set darkness(value: number);
  80296. /**
  80297. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80298. * 0 means strongest and 1 would means no shadow.
  80299. * @returns the darkness.
  80300. */
  80301. getDarkness(): number;
  80302. /**
  80303. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80304. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80305. * @returns the shadow generator allowing fluent coding.
  80306. */
  80307. setDarkness(darkness: number): ShadowGenerator;
  80308. private _transparencyShadow;
  80309. /** Gets or sets the ability to have transparent shadow */
  80310. get transparencyShadow(): boolean;
  80311. set transparencyShadow(value: boolean);
  80312. /**
  80313. * Sets the ability to have transparent shadow (boolean).
  80314. * @param transparent True if transparent else False
  80315. * @returns the shadow generator allowing fluent coding
  80316. */
  80317. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80318. private _shadowMap;
  80319. private _shadowMap2;
  80320. /**
  80321. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80322. * @returns The render target texture if present otherwise, null
  80323. */
  80324. getShadowMap(): Nullable<RenderTargetTexture>;
  80325. /**
  80326. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80327. * @returns The render target texture if the shadow map is present otherwise, null
  80328. */
  80329. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80330. /**
  80331. * Gets the class name of that object
  80332. * @returns "ShadowGenerator"
  80333. */
  80334. getClassName(): string;
  80335. /**
  80336. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80337. * @param mesh Mesh to add
  80338. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80339. * @returns the Shadow Generator itself
  80340. */
  80341. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80342. /**
  80343. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80344. * @param mesh Mesh to remove
  80345. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80346. * @returns the Shadow Generator itself
  80347. */
  80348. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80349. /**
  80350. * Controls the extent to which the shadows fade out at the edge of the frustum
  80351. * Used only by directionals and spots
  80352. */
  80353. frustumEdgeFalloff: number;
  80354. private _light;
  80355. /**
  80356. * Returns the associated light object.
  80357. * @returns the light generating the shadow
  80358. */
  80359. getLight(): IShadowLight;
  80360. /**
  80361. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80362. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80363. * It might on the other hand introduce peter panning.
  80364. */
  80365. forceBackFacesOnly: boolean;
  80366. private _scene;
  80367. private _lightDirection;
  80368. private _effect;
  80369. private _viewMatrix;
  80370. private _projectionMatrix;
  80371. private _transformMatrix;
  80372. private _cachedPosition;
  80373. private _cachedDirection;
  80374. private _cachedDefines;
  80375. private _currentRenderID;
  80376. private _boxBlurPostprocess;
  80377. private _kernelBlurXPostprocess;
  80378. private _kernelBlurYPostprocess;
  80379. private _blurPostProcesses;
  80380. private _mapSize;
  80381. private _currentFaceIndex;
  80382. private _currentFaceIndexCache;
  80383. private _textureType;
  80384. private _defaultTextureMatrix;
  80385. private _storedUniqueId;
  80386. /** @hidden */
  80387. static _SceneComponentInitialization: (scene: Scene) => void;
  80388. /**
  80389. * Creates a ShadowGenerator object.
  80390. * A ShadowGenerator is the required tool to use the shadows.
  80391. * Each light casting shadows needs to use its own ShadowGenerator.
  80392. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80393. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80394. * @param light The light object generating the shadows.
  80395. * @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.
  80396. */
  80397. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80398. private _initializeGenerator;
  80399. private _initializeShadowMap;
  80400. private _initializeBlurRTTAndPostProcesses;
  80401. private _renderForShadowMap;
  80402. private _renderSubMeshForShadowMap;
  80403. private _applyFilterValues;
  80404. /**
  80405. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80406. * @param onCompiled Callback triggered at the and of the effects compilation
  80407. * @param options Sets of optional options forcing the compilation with different modes
  80408. */
  80409. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80410. useInstances: boolean;
  80411. }>): void;
  80412. /**
  80413. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80414. * @param options Sets of optional options forcing the compilation with different modes
  80415. * @returns A promise that resolves when the compilation completes
  80416. */
  80417. forceCompilationAsync(options?: Partial<{
  80418. useInstances: boolean;
  80419. }>): Promise<void>;
  80420. /**
  80421. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80422. * @param subMesh The submesh we want to render in the shadow map
  80423. * @param useInstances Defines wether will draw in the map using instances
  80424. * @returns true if ready otherwise, false
  80425. */
  80426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80427. /**
  80428. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80429. * @param defines Defines of the material we want to update
  80430. * @param lightIndex Index of the light in the enabled light list of the material
  80431. */
  80432. prepareDefines(defines: any, lightIndex: number): void;
  80433. /**
  80434. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80435. * defined in the generator but impacting the effect).
  80436. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80437. * @param effect The effect we are binfing the information for
  80438. */
  80439. bindShadowLight(lightIndex: string, effect: Effect): void;
  80440. /**
  80441. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80442. * (eq to shadow prjection matrix * light transform matrix)
  80443. * @returns The transform matrix used to create the shadow map
  80444. */
  80445. getTransformMatrix(): Matrix;
  80446. /**
  80447. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80448. * Cube and 2D textures for instance.
  80449. */
  80450. recreateShadowMap(): void;
  80451. private _disposeBlurPostProcesses;
  80452. private _disposeRTTandPostProcesses;
  80453. /**
  80454. * Disposes the ShadowGenerator.
  80455. * Returns nothing.
  80456. */
  80457. dispose(): void;
  80458. /**
  80459. * Serializes the shadow generator setup to a json object.
  80460. * @returns The serialized JSON object
  80461. */
  80462. serialize(): any;
  80463. /**
  80464. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80465. * @param parsedShadowGenerator The JSON object to parse
  80466. * @param scene The scene to create the shadow map for
  80467. * @returns The parsed shadow generator
  80468. */
  80469. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80470. }
  80471. }
  80472. declare module BABYLON {
  80473. /**
  80474. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80475. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80476. * 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.
  80477. */
  80478. export abstract class Light extends Node {
  80479. /**
  80480. * Falloff Default: light is falling off following the material specification:
  80481. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80482. */
  80483. static readonly FALLOFF_DEFAULT: number;
  80484. /**
  80485. * Falloff Physical: light is falling off following the inverse squared distance law.
  80486. */
  80487. static readonly FALLOFF_PHYSICAL: number;
  80488. /**
  80489. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80490. * to enhance interoperability with other engines.
  80491. */
  80492. static readonly FALLOFF_GLTF: number;
  80493. /**
  80494. * Falloff Standard: light is falling off like in the standard material
  80495. * to enhance interoperability with other materials.
  80496. */
  80497. static readonly FALLOFF_STANDARD: number;
  80498. /**
  80499. * If every light affecting the material is in this lightmapMode,
  80500. * material.lightmapTexture adds or multiplies
  80501. * (depends on material.useLightmapAsShadowmap)
  80502. * after every other light calculations.
  80503. */
  80504. static readonly LIGHTMAP_DEFAULT: number;
  80505. /**
  80506. * material.lightmapTexture as only diffuse lighting from this light
  80507. * adds only specular lighting from this light
  80508. * adds dynamic shadows
  80509. */
  80510. static readonly LIGHTMAP_SPECULAR: number;
  80511. /**
  80512. * material.lightmapTexture as only lighting
  80513. * no light calculation from this light
  80514. * only adds dynamic shadows from this light
  80515. */
  80516. static readonly LIGHTMAP_SHADOWSONLY: number;
  80517. /**
  80518. * Each light type uses the default quantity according to its type:
  80519. * point/spot lights use luminous intensity
  80520. * directional lights use illuminance
  80521. */
  80522. static readonly INTENSITYMODE_AUTOMATIC: number;
  80523. /**
  80524. * lumen (lm)
  80525. */
  80526. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80527. /**
  80528. * candela (lm/sr)
  80529. */
  80530. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80531. /**
  80532. * lux (lm/m^2)
  80533. */
  80534. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80535. /**
  80536. * nit (cd/m^2)
  80537. */
  80538. static readonly INTENSITYMODE_LUMINANCE: number;
  80539. /**
  80540. * Light type const id of the point light.
  80541. */
  80542. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80543. /**
  80544. * Light type const id of the directional light.
  80545. */
  80546. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80547. /**
  80548. * Light type const id of the spot light.
  80549. */
  80550. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80551. /**
  80552. * Light type const id of the hemispheric light.
  80553. */
  80554. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80555. /**
  80556. * Diffuse gives the basic color to an object.
  80557. */
  80558. diffuse: Color3;
  80559. /**
  80560. * Specular produces a highlight color on an object.
  80561. * Note: This is note affecting PBR materials.
  80562. */
  80563. specular: Color3;
  80564. /**
  80565. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80566. * falling off base on range or angle.
  80567. * This can be set to any values in Light.FALLOFF_x.
  80568. *
  80569. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80570. * other types of materials.
  80571. */
  80572. falloffType: number;
  80573. /**
  80574. * Strength of the light.
  80575. * Note: By default it is define in the framework own unit.
  80576. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80577. */
  80578. intensity: number;
  80579. private _range;
  80580. protected _inverseSquaredRange: number;
  80581. /**
  80582. * Defines how far from the source the light is impacting in scene units.
  80583. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80584. */
  80585. get range(): number;
  80586. /**
  80587. * Defines how far from the source the light is impacting in scene units.
  80588. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80589. */
  80590. set range(value: number);
  80591. /**
  80592. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80593. * of light.
  80594. */
  80595. private _photometricScale;
  80596. private _intensityMode;
  80597. /**
  80598. * Gets the photometric scale used to interpret the intensity.
  80599. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80600. */
  80601. get intensityMode(): number;
  80602. /**
  80603. * Sets the photometric scale used to interpret the intensity.
  80604. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80605. */
  80606. set intensityMode(value: number);
  80607. private _radius;
  80608. /**
  80609. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80610. */
  80611. get radius(): number;
  80612. /**
  80613. * sets the light radius used by PBR Materials to simulate soft area lights.
  80614. */
  80615. set radius(value: number);
  80616. private _renderPriority;
  80617. /**
  80618. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80619. * exceeding the number allowed of the materials.
  80620. */
  80621. renderPriority: number;
  80622. private _shadowEnabled;
  80623. /**
  80624. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80625. * the current shadow generator.
  80626. */
  80627. get shadowEnabled(): boolean;
  80628. /**
  80629. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80630. * the current shadow generator.
  80631. */
  80632. set shadowEnabled(value: boolean);
  80633. private _includedOnlyMeshes;
  80634. /**
  80635. * Gets the only meshes impacted by this light.
  80636. */
  80637. get includedOnlyMeshes(): AbstractMesh[];
  80638. /**
  80639. * Sets the only meshes impacted by this light.
  80640. */
  80641. set includedOnlyMeshes(value: AbstractMesh[]);
  80642. private _excludedMeshes;
  80643. /**
  80644. * Gets the meshes not impacted by this light.
  80645. */
  80646. get excludedMeshes(): AbstractMesh[];
  80647. /**
  80648. * Sets the meshes not impacted by this light.
  80649. */
  80650. set excludedMeshes(value: AbstractMesh[]);
  80651. private _excludeWithLayerMask;
  80652. /**
  80653. * Gets the layer id use to find what meshes are not impacted by the light.
  80654. * Inactive if 0
  80655. */
  80656. get excludeWithLayerMask(): number;
  80657. /**
  80658. * Sets the layer id use to find what meshes are not impacted by the light.
  80659. * Inactive if 0
  80660. */
  80661. set excludeWithLayerMask(value: number);
  80662. private _includeOnlyWithLayerMask;
  80663. /**
  80664. * Gets the layer id use to find what meshes are impacted by the light.
  80665. * Inactive if 0
  80666. */
  80667. get includeOnlyWithLayerMask(): number;
  80668. /**
  80669. * Sets the layer id use to find what meshes are impacted by the light.
  80670. * Inactive if 0
  80671. */
  80672. set includeOnlyWithLayerMask(value: number);
  80673. private _lightmapMode;
  80674. /**
  80675. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80676. */
  80677. get lightmapMode(): number;
  80678. /**
  80679. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80680. */
  80681. set lightmapMode(value: number);
  80682. /**
  80683. * Shadow generator associted to the light.
  80684. * @hidden Internal use only.
  80685. */
  80686. _shadowGenerator: Nullable<IShadowGenerator>;
  80687. /**
  80688. * @hidden Internal use only.
  80689. */
  80690. _excludedMeshesIds: string[];
  80691. /**
  80692. * @hidden Internal use only.
  80693. */
  80694. _includedOnlyMeshesIds: string[];
  80695. /**
  80696. * The current light unifom buffer.
  80697. * @hidden Internal use only.
  80698. */
  80699. _uniformBuffer: UniformBuffer;
  80700. /** @hidden */
  80701. _renderId: number;
  80702. /**
  80703. * Creates a Light object in the scene.
  80704. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80705. * @param name The firendly name of the light
  80706. * @param scene The scene the light belongs too
  80707. */
  80708. constructor(name: string, scene: Scene);
  80709. protected abstract _buildUniformLayout(): void;
  80710. /**
  80711. * Sets the passed Effect "effect" with the Light information.
  80712. * @param effect The effect to update
  80713. * @param lightIndex The index of the light in the effect to update
  80714. * @returns The light
  80715. */
  80716. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80717. /**
  80718. * Sets the passed Effect "effect" with the Light textures.
  80719. * @param effect The effect to update
  80720. * @param lightIndex The index of the light in the effect to update
  80721. * @returns The light
  80722. */
  80723. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80724. /**
  80725. * Binds the lights information from the scene to the effect for the given mesh.
  80726. * @param lightIndex Light index
  80727. * @param scene The scene where the light belongs to
  80728. * @param effect The effect we are binding the data to
  80729. * @param useSpecular Defines if specular is supported
  80730. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80731. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80732. */
  80733. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80734. /**
  80735. * Sets the passed Effect "effect" with the Light information.
  80736. * @param effect The effect to update
  80737. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80738. * @returns The light
  80739. */
  80740. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80741. /**
  80742. * Returns the string "Light".
  80743. * @returns the class name
  80744. */
  80745. getClassName(): string;
  80746. /** @hidden */
  80747. readonly _isLight: boolean;
  80748. /**
  80749. * Converts the light information to a readable string for debug purpose.
  80750. * @param fullDetails Supports for multiple levels of logging within scene loading
  80751. * @returns the human readable light info
  80752. */
  80753. toString(fullDetails?: boolean): string;
  80754. /** @hidden */
  80755. protected _syncParentEnabledState(): void;
  80756. /**
  80757. * Set the enabled state of this node.
  80758. * @param value - the new enabled state
  80759. */
  80760. setEnabled(value: boolean): void;
  80761. /**
  80762. * Returns the Light associated shadow generator if any.
  80763. * @return the associated shadow generator.
  80764. */
  80765. getShadowGenerator(): Nullable<IShadowGenerator>;
  80766. /**
  80767. * Returns a Vector3, the absolute light position in the World.
  80768. * @returns the world space position of the light
  80769. */
  80770. getAbsolutePosition(): Vector3;
  80771. /**
  80772. * Specifies if the light will affect the passed mesh.
  80773. * @param mesh The mesh to test against the light
  80774. * @return true the mesh is affected otherwise, false.
  80775. */
  80776. canAffectMesh(mesh: AbstractMesh): boolean;
  80777. /**
  80778. * Sort function to order lights for rendering.
  80779. * @param a First Light object to compare to second.
  80780. * @param b Second Light object to compare first.
  80781. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80782. */
  80783. static CompareLightsPriority(a: Light, b: Light): number;
  80784. /**
  80785. * Releases resources associated with this node.
  80786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80788. */
  80789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80790. /**
  80791. * Returns the light type ID (integer).
  80792. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80793. */
  80794. getTypeID(): number;
  80795. /**
  80796. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80797. * @returns the scaled intensity in intensity mode unit
  80798. */
  80799. getScaledIntensity(): number;
  80800. /**
  80801. * Returns a new Light object, named "name", from the current one.
  80802. * @param name The name of the cloned light
  80803. * @returns the new created light
  80804. */
  80805. clone(name: string): Nullable<Light>;
  80806. /**
  80807. * Serializes the current light into a Serialization object.
  80808. * @returns the serialized object.
  80809. */
  80810. serialize(): any;
  80811. /**
  80812. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80813. * This new light is named "name" and added to the passed scene.
  80814. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80815. * @param name The friendly name of the light
  80816. * @param scene The scene the new light will belong to
  80817. * @returns the constructor function
  80818. */
  80819. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80820. /**
  80821. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80822. * @param parsedLight The JSON representation of the light
  80823. * @param scene The scene to create the parsed light in
  80824. * @returns the created light after parsing
  80825. */
  80826. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80827. private _hookArrayForExcluded;
  80828. private _hookArrayForIncludedOnly;
  80829. private _resyncMeshes;
  80830. /**
  80831. * Forces the meshes to update their light related information in their rendering used effects
  80832. * @hidden Internal Use Only
  80833. */
  80834. _markMeshesAsLightDirty(): void;
  80835. /**
  80836. * Recomputes the cached photometric scale if needed.
  80837. */
  80838. private _computePhotometricScale;
  80839. /**
  80840. * Returns the Photometric Scale according to the light type and intensity mode.
  80841. */
  80842. private _getPhotometricScale;
  80843. /**
  80844. * Reorder the light in the scene according to their defined priority.
  80845. * @hidden Internal Use Only
  80846. */
  80847. _reorderLightsInScene(): void;
  80848. /**
  80849. * Prepares the list of defines specific to the light type.
  80850. * @param defines the list of defines
  80851. * @param lightIndex defines the index of the light for the effect
  80852. */
  80853. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80854. }
  80855. }
  80856. declare module BABYLON {
  80857. /**
  80858. * Interface used to define Action
  80859. */
  80860. export interface IAction {
  80861. /**
  80862. * Trigger for the action
  80863. */
  80864. trigger: number;
  80865. /** Options of the trigger */
  80866. triggerOptions: any;
  80867. /**
  80868. * Gets the trigger parameters
  80869. * @returns the trigger parameters
  80870. */
  80871. getTriggerParameter(): any;
  80872. /**
  80873. * Internal only - executes current action event
  80874. * @hidden
  80875. */
  80876. _executeCurrent(evt?: ActionEvent): void;
  80877. /**
  80878. * Serialize placeholder for child classes
  80879. * @param parent of child
  80880. * @returns the serialized object
  80881. */
  80882. serialize(parent: any): any;
  80883. /**
  80884. * Internal only
  80885. * @hidden
  80886. */
  80887. _prepare(): void;
  80888. /**
  80889. * Internal only - manager for action
  80890. * @hidden
  80891. */
  80892. _actionManager: AbstractActionManager;
  80893. /**
  80894. * Adds action to chain of actions, may be a DoNothingAction
  80895. * @param action defines the next action to execute
  80896. * @returns The action passed in
  80897. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80898. */
  80899. then(action: IAction): IAction;
  80900. }
  80901. /**
  80902. * The action to be carried out following a trigger
  80903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80904. */
  80905. export class Action implements IAction {
  80906. /** the trigger, with or without parameters, for the action */
  80907. triggerOptions: any;
  80908. /**
  80909. * Trigger for the action
  80910. */
  80911. trigger: number;
  80912. /**
  80913. * Internal only - manager for action
  80914. * @hidden
  80915. */
  80916. _actionManager: ActionManager;
  80917. private _nextActiveAction;
  80918. private _child;
  80919. private _condition?;
  80920. private _triggerParameter;
  80921. /**
  80922. * An event triggered prior to action being executed.
  80923. */
  80924. onBeforeExecuteObservable: Observable<Action>;
  80925. /**
  80926. * Creates a new Action
  80927. * @param triggerOptions the trigger, with or without parameters, for the action
  80928. * @param condition an optional determinant of action
  80929. */
  80930. constructor(
  80931. /** the trigger, with or without parameters, for the action */
  80932. triggerOptions: any, condition?: Condition);
  80933. /**
  80934. * Internal only
  80935. * @hidden
  80936. */
  80937. _prepare(): void;
  80938. /**
  80939. * Gets the trigger parameters
  80940. * @returns the trigger parameters
  80941. */
  80942. getTriggerParameter(): any;
  80943. /**
  80944. * Internal only - executes current action event
  80945. * @hidden
  80946. */
  80947. _executeCurrent(evt?: ActionEvent): void;
  80948. /**
  80949. * Execute placeholder for child classes
  80950. * @param evt optional action event
  80951. */
  80952. execute(evt?: ActionEvent): void;
  80953. /**
  80954. * Skips to next active action
  80955. */
  80956. skipToNextActiveAction(): void;
  80957. /**
  80958. * Adds action to chain of actions, may be a DoNothingAction
  80959. * @param action defines the next action to execute
  80960. * @returns The action passed in
  80961. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80962. */
  80963. then(action: Action): Action;
  80964. /**
  80965. * Internal only
  80966. * @hidden
  80967. */
  80968. _getProperty(propertyPath: string): string;
  80969. /**
  80970. * Internal only
  80971. * @hidden
  80972. */
  80973. _getEffectiveTarget(target: any, propertyPath: string): any;
  80974. /**
  80975. * Serialize placeholder for child classes
  80976. * @param parent of child
  80977. * @returns the serialized object
  80978. */
  80979. serialize(parent: any): any;
  80980. /**
  80981. * Internal only called by serialize
  80982. * @hidden
  80983. */
  80984. protected _serialize(serializedAction: any, parent?: any): any;
  80985. /**
  80986. * Internal only
  80987. * @hidden
  80988. */
  80989. static _SerializeValueAsString: (value: any) => string;
  80990. /**
  80991. * Internal only
  80992. * @hidden
  80993. */
  80994. static _GetTargetProperty: (target: Node | Scene) => {
  80995. name: string;
  80996. targetType: string;
  80997. value: string;
  80998. };
  80999. }
  81000. }
  81001. declare module BABYLON {
  81002. /**
  81003. * A Condition applied to an Action
  81004. */
  81005. export class Condition {
  81006. /**
  81007. * Internal only - manager for action
  81008. * @hidden
  81009. */
  81010. _actionManager: ActionManager;
  81011. /**
  81012. * Internal only
  81013. * @hidden
  81014. */
  81015. _evaluationId: number;
  81016. /**
  81017. * Internal only
  81018. * @hidden
  81019. */
  81020. _currentResult: boolean;
  81021. /**
  81022. * Creates a new Condition
  81023. * @param actionManager the manager of the action the condition is applied to
  81024. */
  81025. constructor(actionManager: ActionManager);
  81026. /**
  81027. * Check if the current condition is valid
  81028. * @returns a boolean
  81029. */
  81030. isValid(): boolean;
  81031. /**
  81032. * Internal only
  81033. * @hidden
  81034. */
  81035. _getProperty(propertyPath: string): string;
  81036. /**
  81037. * Internal only
  81038. * @hidden
  81039. */
  81040. _getEffectiveTarget(target: any, propertyPath: string): any;
  81041. /**
  81042. * Serialize placeholder for child classes
  81043. * @returns the serialized object
  81044. */
  81045. serialize(): any;
  81046. /**
  81047. * Internal only
  81048. * @hidden
  81049. */
  81050. protected _serialize(serializedCondition: any): any;
  81051. }
  81052. /**
  81053. * Defines specific conditional operators as extensions of Condition
  81054. */
  81055. export class ValueCondition extends Condition {
  81056. /** path to specify the property of the target the conditional operator uses */
  81057. propertyPath: string;
  81058. /** the value compared by the conditional operator against the current value of the property */
  81059. value: any;
  81060. /** the conditional operator, default ValueCondition.IsEqual */
  81061. operator: number;
  81062. /**
  81063. * Internal only
  81064. * @hidden
  81065. */
  81066. private static _IsEqual;
  81067. /**
  81068. * Internal only
  81069. * @hidden
  81070. */
  81071. private static _IsDifferent;
  81072. /**
  81073. * Internal only
  81074. * @hidden
  81075. */
  81076. private static _IsGreater;
  81077. /**
  81078. * Internal only
  81079. * @hidden
  81080. */
  81081. private static _IsLesser;
  81082. /**
  81083. * returns the number for IsEqual
  81084. */
  81085. static get IsEqual(): number;
  81086. /**
  81087. * Returns the number for IsDifferent
  81088. */
  81089. static get IsDifferent(): number;
  81090. /**
  81091. * Returns the number for IsGreater
  81092. */
  81093. static get IsGreater(): number;
  81094. /**
  81095. * Returns the number for IsLesser
  81096. */
  81097. static get IsLesser(): number;
  81098. /**
  81099. * Internal only The action manager for the condition
  81100. * @hidden
  81101. */
  81102. _actionManager: ActionManager;
  81103. /**
  81104. * Internal only
  81105. * @hidden
  81106. */
  81107. private _target;
  81108. /**
  81109. * Internal only
  81110. * @hidden
  81111. */
  81112. private _effectiveTarget;
  81113. /**
  81114. * Internal only
  81115. * @hidden
  81116. */
  81117. private _property;
  81118. /**
  81119. * Creates a new ValueCondition
  81120. * @param actionManager manager for the action the condition applies to
  81121. * @param target for the action
  81122. * @param propertyPath path to specify the property of the target the conditional operator uses
  81123. * @param value the value compared by the conditional operator against the current value of the property
  81124. * @param operator the conditional operator, default ValueCondition.IsEqual
  81125. */
  81126. constructor(actionManager: ActionManager, target: any,
  81127. /** path to specify the property of the target the conditional operator uses */
  81128. propertyPath: string,
  81129. /** the value compared by the conditional operator against the current value of the property */
  81130. value: any,
  81131. /** the conditional operator, default ValueCondition.IsEqual */
  81132. operator?: number);
  81133. /**
  81134. * Compares the given value with the property value for the specified conditional operator
  81135. * @returns the result of the comparison
  81136. */
  81137. isValid(): boolean;
  81138. /**
  81139. * Serialize the ValueCondition into a JSON compatible object
  81140. * @returns serialization object
  81141. */
  81142. serialize(): any;
  81143. /**
  81144. * Gets the name of the conditional operator for the ValueCondition
  81145. * @param operator the conditional operator
  81146. * @returns the name
  81147. */
  81148. static GetOperatorName(operator: number): string;
  81149. }
  81150. /**
  81151. * Defines a predicate condition as an extension of Condition
  81152. */
  81153. export class PredicateCondition extends Condition {
  81154. /** defines the predicate function used to validate the condition */
  81155. predicate: () => boolean;
  81156. /**
  81157. * Internal only - manager for action
  81158. * @hidden
  81159. */
  81160. _actionManager: ActionManager;
  81161. /**
  81162. * Creates a new PredicateCondition
  81163. * @param actionManager manager for the action the condition applies to
  81164. * @param predicate defines the predicate function used to validate the condition
  81165. */
  81166. constructor(actionManager: ActionManager,
  81167. /** defines the predicate function used to validate the condition */
  81168. predicate: () => boolean);
  81169. /**
  81170. * @returns the validity of the predicate condition
  81171. */
  81172. isValid(): boolean;
  81173. }
  81174. /**
  81175. * Defines a state condition as an extension of Condition
  81176. */
  81177. export class StateCondition extends Condition {
  81178. /** Value to compare with target state */
  81179. value: string;
  81180. /**
  81181. * Internal only - manager for action
  81182. * @hidden
  81183. */
  81184. _actionManager: ActionManager;
  81185. /**
  81186. * Internal only
  81187. * @hidden
  81188. */
  81189. private _target;
  81190. /**
  81191. * Creates a new StateCondition
  81192. * @param actionManager manager for the action the condition applies to
  81193. * @param target of the condition
  81194. * @param value to compare with target state
  81195. */
  81196. constructor(actionManager: ActionManager, target: any,
  81197. /** Value to compare with target state */
  81198. value: string);
  81199. /**
  81200. * Gets a boolean indicating if the current condition is met
  81201. * @returns the validity of the state
  81202. */
  81203. isValid(): boolean;
  81204. /**
  81205. * Serialize the StateCondition into a JSON compatible object
  81206. * @returns serialization object
  81207. */
  81208. serialize(): any;
  81209. }
  81210. }
  81211. declare module BABYLON {
  81212. /**
  81213. * This defines an action responsible to toggle a boolean once triggered.
  81214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81215. */
  81216. export class SwitchBooleanAction extends Action {
  81217. /**
  81218. * The path to the boolean property in the target object
  81219. */
  81220. propertyPath: string;
  81221. private _target;
  81222. private _effectiveTarget;
  81223. private _property;
  81224. /**
  81225. * Instantiate the action
  81226. * @param triggerOptions defines the trigger options
  81227. * @param target defines the object containing the boolean
  81228. * @param propertyPath defines the path to the boolean property in the target object
  81229. * @param condition defines the trigger related conditions
  81230. */
  81231. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81232. /** @hidden */
  81233. _prepare(): void;
  81234. /**
  81235. * Execute the action toggle the boolean value.
  81236. */
  81237. execute(): void;
  81238. /**
  81239. * Serializes the actions and its related information.
  81240. * @param parent defines the object to serialize in
  81241. * @returns the serialized object
  81242. */
  81243. serialize(parent: any): any;
  81244. }
  81245. /**
  81246. * This defines an action responsible to set a the state field of the target
  81247. * to a desired value once triggered.
  81248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81249. */
  81250. export class SetStateAction extends Action {
  81251. /**
  81252. * The value to store in the state field.
  81253. */
  81254. value: string;
  81255. private _target;
  81256. /**
  81257. * Instantiate the action
  81258. * @param triggerOptions defines the trigger options
  81259. * @param target defines the object containing the state property
  81260. * @param value defines the value to store in the state field
  81261. * @param condition defines the trigger related conditions
  81262. */
  81263. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81264. /**
  81265. * Execute the action and store the value on the target state property.
  81266. */
  81267. execute(): void;
  81268. /**
  81269. * Serializes the actions and its related information.
  81270. * @param parent defines the object to serialize in
  81271. * @returns the serialized object
  81272. */
  81273. serialize(parent: any): any;
  81274. }
  81275. /**
  81276. * This defines an action responsible to set a property of the target
  81277. * to a desired value once triggered.
  81278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81279. */
  81280. export class SetValueAction extends Action {
  81281. /**
  81282. * The path of the property to set in the target.
  81283. */
  81284. propertyPath: string;
  81285. /**
  81286. * The value to set in the property
  81287. */
  81288. value: any;
  81289. private _target;
  81290. private _effectiveTarget;
  81291. private _property;
  81292. /**
  81293. * Instantiate the action
  81294. * @param triggerOptions defines the trigger options
  81295. * @param target defines the object containing the property
  81296. * @param propertyPath defines the path of the property to set in the target
  81297. * @param value defines the value to set in the property
  81298. * @param condition defines the trigger related conditions
  81299. */
  81300. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81301. /** @hidden */
  81302. _prepare(): void;
  81303. /**
  81304. * Execute the action and set the targetted property to the desired value.
  81305. */
  81306. execute(): void;
  81307. /**
  81308. * Serializes the actions and its related information.
  81309. * @param parent defines the object to serialize in
  81310. * @returns the serialized object
  81311. */
  81312. serialize(parent: any): any;
  81313. }
  81314. /**
  81315. * This defines an action responsible to increment the target value
  81316. * to a desired value once triggered.
  81317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81318. */
  81319. export class IncrementValueAction extends Action {
  81320. /**
  81321. * The path of the property to increment in the target.
  81322. */
  81323. propertyPath: string;
  81324. /**
  81325. * The value we should increment the property by.
  81326. */
  81327. value: any;
  81328. private _target;
  81329. private _effectiveTarget;
  81330. private _property;
  81331. /**
  81332. * Instantiate the action
  81333. * @param triggerOptions defines the trigger options
  81334. * @param target defines the object containing the property
  81335. * @param propertyPath defines the path of the property to increment in the target
  81336. * @param value defines the value value we should increment the property by
  81337. * @param condition defines the trigger related conditions
  81338. */
  81339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81340. /** @hidden */
  81341. _prepare(): void;
  81342. /**
  81343. * Execute the action and increment the target of the value amount.
  81344. */
  81345. execute(): void;
  81346. /**
  81347. * Serializes the actions and its related information.
  81348. * @param parent defines the object to serialize in
  81349. * @returns the serialized object
  81350. */
  81351. serialize(parent: any): any;
  81352. }
  81353. /**
  81354. * This defines an action responsible to start an animation once triggered.
  81355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81356. */
  81357. export class PlayAnimationAction extends Action {
  81358. /**
  81359. * Where the animation should start (animation frame)
  81360. */
  81361. from: number;
  81362. /**
  81363. * Where the animation should stop (animation frame)
  81364. */
  81365. to: number;
  81366. /**
  81367. * Define if the animation should loop or stop after the first play.
  81368. */
  81369. loop?: boolean;
  81370. private _target;
  81371. /**
  81372. * Instantiate the action
  81373. * @param triggerOptions defines the trigger options
  81374. * @param target defines the target animation or animation name
  81375. * @param from defines from where the animation should start (animation frame)
  81376. * @param end defines where the animation should stop (animation frame)
  81377. * @param loop defines if the animation should loop or stop after the first play
  81378. * @param condition defines the trigger related conditions
  81379. */
  81380. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81381. /** @hidden */
  81382. _prepare(): void;
  81383. /**
  81384. * Execute the action and play the animation.
  81385. */
  81386. execute(): void;
  81387. /**
  81388. * Serializes the actions and its related information.
  81389. * @param parent defines the object to serialize in
  81390. * @returns the serialized object
  81391. */
  81392. serialize(parent: any): any;
  81393. }
  81394. /**
  81395. * This defines an action responsible to stop an animation once triggered.
  81396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81397. */
  81398. export class StopAnimationAction extends Action {
  81399. private _target;
  81400. /**
  81401. * Instantiate the action
  81402. * @param triggerOptions defines the trigger options
  81403. * @param target defines the target animation or animation name
  81404. * @param condition defines the trigger related conditions
  81405. */
  81406. constructor(triggerOptions: any, target: any, condition?: Condition);
  81407. /** @hidden */
  81408. _prepare(): void;
  81409. /**
  81410. * Execute the action and stop the animation.
  81411. */
  81412. execute(): void;
  81413. /**
  81414. * Serializes the actions and its related information.
  81415. * @param parent defines the object to serialize in
  81416. * @returns the serialized object
  81417. */
  81418. serialize(parent: any): any;
  81419. }
  81420. /**
  81421. * This defines an action responsible that does nothing once triggered.
  81422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81423. */
  81424. export class DoNothingAction extends Action {
  81425. /**
  81426. * Instantiate the action
  81427. * @param triggerOptions defines the trigger options
  81428. * @param condition defines the trigger related conditions
  81429. */
  81430. constructor(triggerOptions?: any, condition?: Condition);
  81431. /**
  81432. * Execute the action and do nothing.
  81433. */
  81434. execute(): void;
  81435. /**
  81436. * Serializes the actions and its related information.
  81437. * @param parent defines the object to serialize in
  81438. * @returns the serialized object
  81439. */
  81440. serialize(parent: any): any;
  81441. }
  81442. /**
  81443. * This defines an action responsible to trigger several actions once triggered.
  81444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81445. */
  81446. export class CombineAction extends Action {
  81447. /**
  81448. * The list of aggregated animations to run.
  81449. */
  81450. children: Action[];
  81451. /**
  81452. * Instantiate the action
  81453. * @param triggerOptions defines the trigger options
  81454. * @param children defines the list of aggregated animations to run
  81455. * @param condition defines the trigger related conditions
  81456. */
  81457. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81458. /** @hidden */
  81459. _prepare(): void;
  81460. /**
  81461. * Execute the action and executes all the aggregated actions.
  81462. */
  81463. execute(evt: ActionEvent): void;
  81464. /**
  81465. * Serializes the actions and its related information.
  81466. * @param parent defines the object to serialize in
  81467. * @returns the serialized object
  81468. */
  81469. serialize(parent: any): any;
  81470. }
  81471. /**
  81472. * This defines an action responsible to run code (external event) once triggered.
  81473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81474. */
  81475. export class ExecuteCodeAction extends Action {
  81476. /**
  81477. * The callback function to run.
  81478. */
  81479. func: (evt: ActionEvent) => void;
  81480. /**
  81481. * Instantiate the action
  81482. * @param triggerOptions defines the trigger options
  81483. * @param func defines the callback function to run
  81484. * @param condition defines the trigger related conditions
  81485. */
  81486. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81487. /**
  81488. * Execute the action and run the attached code.
  81489. */
  81490. execute(evt: ActionEvent): void;
  81491. }
  81492. /**
  81493. * This defines an action responsible to set the parent property of the target once triggered.
  81494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81495. */
  81496. export class SetParentAction extends Action {
  81497. private _parent;
  81498. private _target;
  81499. /**
  81500. * Instantiate the action
  81501. * @param triggerOptions defines the trigger options
  81502. * @param target defines the target containing the parent property
  81503. * @param parent defines from where the animation should start (animation frame)
  81504. * @param condition defines the trigger related conditions
  81505. */
  81506. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81507. /** @hidden */
  81508. _prepare(): void;
  81509. /**
  81510. * Execute the action and set the parent property.
  81511. */
  81512. execute(): void;
  81513. /**
  81514. * Serializes the actions and its related information.
  81515. * @param parent defines the object to serialize in
  81516. * @returns the serialized object
  81517. */
  81518. serialize(parent: any): any;
  81519. }
  81520. }
  81521. declare module BABYLON {
  81522. /**
  81523. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81524. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81526. */
  81527. export class ActionManager extends AbstractActionManager {
  81528. /**
  81529. * Nothing
  81530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81531. */
  81532. static readonly NothingTrigger: number;
  81533. /**
  81534. * On pick
  81535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81536. */
  81537. static readonly OnPickTrigger: number;
  81538. /**
  81539. * On left pick
  81540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81541. */
  81542. static readonly OnLeftPickTrigger: number;
  81543. /**
  81544. * On right pick
  81545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81546. */
  81547. static readonly OnRightPickTrigger: number;
  81548. /**
  81549. * On center pick
  81550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81551. */
  81552. static readonly OnCenterPickTrigger: number;
  81553. /**
  81554. * On pick down
  81555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81556. */
  81557. static readonly OnPickDownTrigger: number;
  81558. /**
  81559. * On double pick
  81560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81561. */
  81562. static readonly OnDoublePickTrigger: number;
  81563. /**
  81564. * On pick up
  81565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81566. */
  81567. static readonly OnPickUpTrigger: number;
  81568. /**
  81569. * On pick out.
  81570. * This trigger will only be raised if you also declared a OnPickDown
  81571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81572. */
  81573. static readonly OnPickOutTrigger: number;
  81574. /**
  81575. * On long press
  81576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81577. */
  81578. static readonly OnLongPressTrigger: number;
  81579. /**
  81580. * On pointer over
  81581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81582. */
  81583. static readonly OnPointerOverTrigger: number;
  81584. /**
  81585. * On pointer out
  81586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81587. */
  81588. static readonly OnPointerOutTrigger: number;
  81589. /**
  81590. * On every frame
  81591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81592. */
  81593. static readonly OnEveryFrameTrigger: number;
  81594. /**
  81595. * On intersection enter
  81596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81597. */
  81598. static readonly OnIntersectionEnterTrigger: number;
  81599. /**
  81600. * On intersection exit
  81601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81602. */
  81603. static readonly OnIntersectionExitTrigger: number;
  81604. /**
  81605. * On key down
  81606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81607. */
  81608. static readonly OnKeyDownTrigger: number;
  81609. /**
  81610. * On key up
  81611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81612. */
  81613. static readonly OnKeyUpTrigger: number;
  81614. private _scene;
  81615. /**
  81616. * Creates a new action manager
  81617. * @param scene defines the hosting scene
  81618. */
  81619. constructor(scene: Scene);
  81620. /**
  81621. * Releases all associated resources
  81622. */
  81623. dispose(): void;
  81624. /**
  81625. * Gets hosting scene
  81626. * @returns the hosting scene
  81627. */
  81628. getScene(): Scene;
  81629. /**
  81630. * Does this action manager handles actions of any of the given triggers
  81631. * @param triggers defines the triggers to be tested
  81632. * @return a boolean indicating whether one (or more) of the triggers is handled
  81633. */
  81634. hasSpecificTriggers(triggers: number[]): boolean;
  81635. /**
  81636. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81637. * speed.
  81638. * @param triggerA defines the trigger to be tested
  81639. * @param triggerB defines the trigger to be tested
  81640. * @return a boolean indicating whether one (or more) of the triggers is handled
  81641. */
  81642. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81643. /**
  81644. * Does this action manager handles actions of a given trigger
  81645. * @param trigger defines the trigger to be tested
  81646. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81647. * @return whether the trigger is handled
  81648. */
  81649. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81650. /**
  81651. * Does this action manager has pointer triggers
  81652. */
  81653. get hasPointerTriggers(): boolean;
  81654. /**
  81655. * Does this action manager has pick triggers
  81656. */
  81657. get hasPickTriggers(): boolean;
  81658. /**
  81659. * Registers an action to this action manager
  81660. * @param action defines the action to be registered
  81661. * @return the action amended (prepared) after registration
  81662. */
  81663. registerAction(action: IAction): Nullable<IAction>;
  81664. /**
  81665. * Unregisters an action to this action manager
  81666. * @param action defines the action to be unregistered
  81667. * @return a boolean indicating whether the action has been unregistered
  81668. */
  81669. unregisterAction(action: IAction): Boolean;
  81670. /**
  81671. * Process a specific trigger
  81672. * @param trigger defines the trigger to process
  81673. * @param evt defines the event details to be processed
  81674. */
  81675. processTrigger(trigger: number, evt?: IActionEvent): void;
  81676. /** @hidden */
  81677. _getEffectiveTarget(target: any, propertyPath: string): any;
  81678. /** @hidden */
  81679. _getProperty(propertyPath: string): string;
  81680. /**
  81681. * Serialize this manager to a JSON object
  81682. * @param name defines the property name to store this manager
  81683. * @returns a JSON representation of this manager
  81684. */
  81685. serialize(name: string): any;
  81686. /**
  81687. * Creates a new ActionManager from a JSON data
  81688. * @param parsedActions defines the JSON data to read from
  81689. * @param object defines the hosting mesh
  81690. * @param scene defines the hosting scene
  81691. */
  81692. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81693. /**
  81694. * Get a trigger name by index
  81695. * @param trigger defines the trigger index
  81696. * @returns a trigger name
  81697. */
  81698. static GetTriggerName(trigger: number): string;
  81699. }
  81700. }
  81701. declare module BABYLON {
  81702. /**
  81703. * Class representing a ray with position and direction
  81704. */
  81705. export class Ray {
  81706. /** origin point */
  81707. origin: Vector3;
  81708. /** direction */
  81709. direction: Vector3;
  81710. /** length of the ray */
  81711. length: number;
  81712. private static readonly TmpVector3;
  81713. private _tmpRay;
  81714. /**
  81715. * Creates a new ray
  81716. * @param origin origin point
  81717. * @param direction direction
  81718. * @param length length of the ray
  81719. */
  81720. constructor(
  81721. /** origin point */
  81722. origin: Vector3,
  81723. /** direction */
  81724. direction: Vector3,
  81725. /** length of the ray */
  81726. length?: number);
  81727. /**
  81728. * Checks if the ray intersects a box
  81729. * @param minimum bound of the box
  81730. * @param maximum bound of the box
  81731. * @param intersectionTreshold extra extend to be added to the box in all direction
  81732. * @returns if the box was hit
  81733. */
  81734. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81735. /**
  81736. * Checks if the ray intersects a box
  81737. * @param box the bounding box to check
  81738. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81739. * @returns if the box was hit
  81740. */
  81741. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81742. /**
  81743. * If the ray hits a sphere
  81744. * @param sphere the bounding sphere to check
  81745. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81746. * @returns true if it hits the sphere
  81747. */
  81748. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81749. /**
  81750. * If the ray hits a triange
  81751. * @param vertex0 triangle vertex
  81752. * @param vertex1 triangle vertex
  81753. * @param vertex2 triangle vertex
  81754. * @returns intersection information if hit
  81755. */
  81756. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81757. /**
  81758. * Checks if ray intersects a plane
  81759. * @param plane the plane to check
  81760. * @returns the distance away it was hit
  81761. */
  81762. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81763. /**
  81764. * Calculate the intercept of a ray on a given axis
  81765. * @param axis to check 'x' | 'y' | 'z'
  81766. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81767. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81768. */
  81769. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81770. /**
  81771. * Checks if ray intersects a mesh
  81772. * @param mesh the mesh to check
  81773. * @param fastCheck if only the bounding box should checked
  81774. * @returns picking info of the intersecton
  81775. */
  81776. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81777. /**
  81778. * Checks if ray intersects a mesh
  81779. * @param meshes the meshes to check
  81780. * @param fastCheck if only the bounding box should checked
  81781. * @param results array to store result in
  81782. * @returns Array of picking infos
  81783. */
  81784. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81785. private _comparePickingInfo;
  81786. private static smallnum;
  81787. private static rayl;
  81788. /**
  81789. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81790. * @param sega the first point of the segment to test the intersection against
  81791. * @param segb the second point of the segment to test the intersection against
  81792. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81793. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81794. */
  81795. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81796. /**
  81797. * Update the ray from viewport position
  81798. * @param x position
  81799. * @param y y position
  81800. * @param viewportWidth viewport width
  81801. * @param viewportHeight viewport height
  81802. * @param world world matrix
  81803. * @param view view matrix
  81804. * @param projection projection matrix
  81805. * @returns this ray updated
  81806. */
  81807. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81808. /**
  81809. * Creates a ray with origin and direction of 0,0,0
  81810. * @returns the new ray
  81811. */
  81812. static Zero(): Ray;
  81813. /**
  81814. * Creates a new ray from screen space and viewport
  81815. * @param x position
  81816. * @param y y position
  81817. * @param viewportWidth viewport width
  81818. * @param viewportHeight viewport height
  81819. * @param world world matrix
  81820. * @param view view matrix
  81821. * @param projection projection matrix
  81822. * @returns new ray
  81823. */
  81824. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81825. /**
  81826. * 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
  81827. * transformed to the given world matrix.
  81828. * @param origin The origin point
  81829. * @param end The end point
  81830. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81831. * @returns the new ray
  81832. */
  81833. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81834. /**
  81835. * Transforms a ray by a matrix
  81836. * @param ray ray to transform
  81837. * @param matrix matrix to apply
  81838. * @returns the resulting new ray
  81839. */
  81840. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81841. /**
  81842. * Transforms a ray by a matrix
  81843. * @param ray ray to transform
  81844. * @param matrix matrix to apply
  81845. * @param result ray to store result in
  81846. */
  81847. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81848. /**
  81849. * Unproject a ray from screen space to object space
  81850. * @param sourceX defines the screen space x coordinate to use
  81851. * @param sourceY defines the screen space y coordinate to use
  81852. * @param viewportWidth defines the current width of the viewport
  81853. * @param viewportHeight defines the current height of the viewport
  81854. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81855. * @param view defines the view matrix to use
  81856. * @param projection defines the projection matrix to use
  81857. */
  81858. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81859. }
  81860. /**
  81861. * Type used to define predicate used to select faces when a mesh intersection is detected
  81862. */
  81863. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81864. interface Scene {
  81865. /** @hidden */
  81866. _tempPickingRay: Nullable<Ray>;
  81867. /** @hidden */
  81868. _cachedRayForTransform: Ray;
  81869. /** @hidden */
  81870. _pickWithRayInverseMatrix: Matrix;
  81871. /** @hidden */
  81872. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81873. /** @hidden */
  81874. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81875. }
  81876. }
  81877. declare module BABYLON {
  81878. /**
  81879. * Groups all the scene component constants in one place to ease maintenance.
  81880. * @hidden
  81881. */
  81882. export class SceneComponentConstants {
  81883. static readonly NAME_EFFECTLAYER: string;
  81884. static readonly NAME_LAYER: string;
  81885. static readonly NAME_LENSFLARESYSTEM: string;
  81886. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81887. static readonly NAME_PARTICLESYSTEM: string;
  81888. static readonly NAME_GAMEPAD: string;
  81889. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81890. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81891. static readonly NAME_DEPTHRENDERER: string;
  81892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81893. static readonly NAME_SPRITE: string;
  81894. static readonly NAME_OUTLINERENDERER: string;
  81895. static readonly NAME_PROCEDURALTEXTURE: string;
  81896. static readonly NAME_SHADOWGENERATOR: string;
  81897. static readonly NAME_OCTREE: string;
  81898. static readonly NAME_PHYSICSENGINE: string;
  81899. static readonly NAME_AUDIO: string;
  81900. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81901. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81902. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81903. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81904. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81905. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81906. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  81907. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  81908. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  81909. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  81910. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  81911. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  81912. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  81913. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  81914. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  81915. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  81916. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  81917. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  81918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  81919. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  81920. static readonly STEP_AFTERRENDER_AUDIO: number;
  81921. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  81922. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  81923. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  81924. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  81925. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  81926. static readonly STEP_POINTERMOVE_SPRITE: number;
  81927. static readonly STEP_POINTERDOWN_SPRITE: number;
  81928. static readonly STEP_POINTERUP_SPRITE: number;
  81929. }
  81930. /**
  81931. * This represents a scene component.
  81932. *
  81933. * This is used to decouple the dependency the scene is having on the different workloads like
  81934. * layers, post processes...
  81935. */
  81936. export interface ISceneComponent {
  81937. /**
  81938. * The name of the component. Each component must have a unique name.
  81939. */
  81940. name: string;
  81941. /**
  81942. * The scene the component belongs to.
  81943. */
  81944. scene: Scene;
  81945. /**
  81946. * Register the component to one instance of a scene.
  81947. */
  81948. register(): void;
  81949. /**
  81950. * Rebuilds the elements related to this component in case of
  81951. * context lost for instance.
  81952. */
  81953. rebuild(): void;
  81954. /**
  81955. * Disposes the component and the associated ressources.
  81956. */
  81957. dispose(): void;
  81958. }
  81959. /**
  81960. * This represents a SERIALIZABLE scene component.
  81961. *
  81962. * This extends Scene Component to add Serialization methods on top.
  81963. */
  81964. export interface ISceneSerializableComponent extends ISceneComponent {
  81965. /**
  81966. * Adds all the elements from the container to the scene
  81967. * @param container the container holding the elements
  81968. */
  81969. addFromContainer(container: AbstractScene): void;
  81970. /**
  81971. * Removes all the elements in the container from the scene
  81972. * @param container contains the elements to remove
  81973. * @param dispose if the removed element should be disposed (default: false)
  81974. */
  81975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81976. /**
  81977. * Serializes the component data to the specified json object
  81978. * @param serializationObject The object to serialize to
  81979. */
  81980. serialize(serializationObject: any): void;
  81981. }
  81982. /**
  81983. * Strong typing of a Mesh related stage step action
  81984. */
  81985. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  81986. /**
  81987. * Strong typing of a Evaluate Sub Mesh related stage step action
  81988. */
  81989. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  81990. /**
  81991. * Strong typing of a Active Mesh related stage step action
  81992. */
  81993. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  81994. /**
  81995. * Strong typing of a Camera related stage step action
  81996. */
  81997. export type CameraStageAction = (camera: Camera) => void;
  81998. /**
  81999. * Strong typing of a Camera Frame buffer related stage step action
  82000. */
  82001. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82002. /**
  82003. * Strong typing of a Render Target related stage step action
  82004. */
  82005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82006. /**
  82007. * Strong typing of a RenderingGroup related stage step action
  82008. */
  82009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82010. /**
  82011. * Strong typing of a Mesh Render related stage step action
  82012. */
  82013. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82014. /**
  82015. * Strong typing of a simple stage step action
  82016. */
  82017. export type SimpleStageAction = () => void;
  82018. /**
  82019. * Strong typing of a render target action.
  82020. */
  82021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82022. /**
  82023. * Strong typing of a pointer move action.
  82024. */
  82025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82026. /**
  82027. * Strong typing of a pointer up/down action.
  82028. */
  82029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82030. /**
  82031. * Representation of a stage in the scene (Basically a list of ordered steps)
  82032. * @hidden
  82033. */
  82034. export class Stage<T extends Function> extends Array<{
  82035. index: number;
  82036. component: ISceneComponent;
  82037. action: T;
  82038. }> {
  82039. /**
  82040. * Hide ctor from the rest of the world.
  82041. * @param items The items to add.
  82042. */
  82043. private constructor();
  82044. /**
  82045. * Creates a new Stage.
  82046. * @returns A new instance of a Stage
  82047. */
  82048. static Create<T extends Function>(): Stage<T>;
  82049. /**
  82050. * Registers a step in an ordered way in the targeted stage.
  82051. * @param index Defines the position to register the step in
  82052. * @param component Defines the component attached to the step
  82053. * @param action Defines the action to launch during the step
  82054. */
  82055. registerStep(index: number, component: ISceneComponent, action: T): void;
  82056. /**
  82057. * Clears all the steps from the stage.
  82058. */
  82059. clear(): void;
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. interface Scene {
  82064. /** @hidden */
  82065. _pointerOverSprite: Nullable<Sprite>;
  82066. /** @hidden */
  82067. _pickedDownSprite: Nullable<Sprite>;
  82068. /** @hidden */
  82069. _tempSpritePickingRay: Nullable<Ray>;
  82070. /**
  82071. * All of the sprite managers added to this scene
  82072. * @see http://doc.babylonjs.com/babylon101/sprites
  82073. */
  82074. spriteManagers: Array<ISpriteManager>;
  82075. /**
  82076. * An event triggered when sprites rendering is about to start
  82077. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82078. */
  82079. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82080. /**
  82081. * An event triggered when sprites rendering is done
  82082. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82083. */
  82084. onAfterSpritesRenderingObservable: Observable<Scene>;
  82085. /** @hidden */
  82086. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82087. /** Launch a ray to try to pick a sprite in the scene
  82088. * @param x position on screen
  82089. * @param y position on screen
  82090. * @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
  82091. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82092. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82093. * @returns a PickingInfo
  82094. */
  82095. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82096. /** Use the given ray to pick a sprite in the scene
  82097. * @param ray The ray (in world space) to use to pick meshes
  82098. * @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
  82099. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82100. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82101. * @returns a PickingInfo
  82102. */
  82103. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82104. /** @hidden */
  82105. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82106. /** Launch a ray to try to pick sprites in the scene
  82107. * @param x position on screen
  82108. * @param y position on screen
  82109. * @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
  82110. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82111. * @returns a PickingInfo array
  82112. */
  82113. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82114. /** Use the given ray to pick sprites in the scene
  82115. * @param ray The ray (in world space) to use to pick meshes
  82116. * @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
  82117. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82118. * @returns a PickingInfo array
  82119. */
  82120. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82121. /**
  82122. * Force the sprite under the pointer
  82123. * @param sprite defines the sprite to use
  82124. */
  82125. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82126. /**
  82127. * Gets the sprite under the pointer
  82128. * @returns a Sprite or null if no sprite is under the pointer
  82129. */
  82130. getPointerOverSprite(): Nullable<Sprite>;
  82131. }
  82132. /**
  82133. * Defines the sprite scene component responsible to manage sprites
  82134. * in a given scene.
  82135. */
  82136. export class SpriteSceneComponent implements ISceneComponent {
  82137. /**
  82138. * The component name helpfull to identify the component in the list of scene components.
  82139. */
  82140. readonly name: string;
  82141. /**
  82142. * The scene the component belongs to.
  82143. */
  82144. scene: Scene;
  82145. /** @hidden */
  82146. private _spritePredicate;
  82147. /**
  82148. * Creates a new instance of the component for the given scene
  82149. * @param scene Defines the scene to register the component in
  82150. */
  82151. constructor(scene: Scene);
  82152. /**
  82153. * Registers the component in a given scene
  82154. */
  82155. register(): void;
  82156. /**
  82157. * Rebuilds the elements related to this component in case of
  82158. * context lost for instance.
  82159. */
  82160. rebuild(): void;
  82161. /**
  82162. * Disposes the component and the associated ressources.
  82163. */
  82164. dispose(): void;
  82165. private _pickSpriteButKeepRay;
  82166. private _pointerMove;
  82167. private _pointerDown;
  82168. private _pointerUp;
  82169. }
  82170. }
  82171. declare module BABYLON {
  82172. /** @hidden */
  82173. export var fogFragmentDeclaration: {
  82174. name: string;
  82175. shader: string;
  82176. };
  82177. }
  82178. declare module BABYLON {
  82179. /** @hidden */
  82180. export var fogFragment: {
  82181. name: string;
  82182. shader: string;
  82183. };
  82184. }
  82185. declare module BABYLON {
  82186. /** @hidden */
  82187. export var spritesPixelShader: {
  82188. name: string;
  82189. shader: string;
  82190. };
  82191. }
  82192. declare module BABYLON {
  82193. /** @hidden */
  82194. export var fogVertexDeclaration: {
  82195. name: string;
  82196. shader: string;
  82197. };
  82198. }
  82199. declare module BABYLON {
  82200. /** @hidden */
  82201. export var spritesVertexShader: {
  82202. name: string;
  82203. shader: string;
  82204. };
  82205. }
  82206. declare module BABYLON {
  82207. /**
  82208. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82209. */
  82210. export interface ISpriteManager extends IDisposable {
  82211. /**
  82212. * Restricts the camera to viewing objects with the same layerMask.
  82213. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82214. */
  82215. layerMask: number;
  82216. /**
  82217. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82218. */
  82219. isPickable: boolean;
  82220. /**
  82221. * Specifies the rendering group id for this mesh (0 by default)
  82222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82223. */
  82224. renderingGroupId: number;
  82225. /**
  82226. * Defines the list of sprites managed by the manager.
  82227. */
  82228. sprites: Array<Sprite>;
  82229. /**
  82230. * Tests the intersection of a sprite with a specific ray.
  82231. * @param ray The ray we are sending to test the collision
  82232. * @param camera The camera space we are sending rays in
  82233. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82234. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82235. * @returns picking info or null.
  82236. */
  82237. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82238. /**
  82239. * Intersects the sprites with a ray
  82240. * @param ray defines the ray to intersect with
  82241. * @param camera defines the current active camera
  82242. * @param predicate defines a predicate used to select candidate sprites
  82243. * @returns null if no hit or a PickingInfo array
  82244. */
  82245. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82246. /**
  82247. * Renders the list of sprites on screen.
  82248. */
  82249. render(): void;
  82250. }
  82251. /**
  82252. * Class used to manage multiple sprites on the same spritesheet
  82253. * @see http://doc.babylonjs.com/babylon101/sprites
  82254. */
  82255. export class SpriteManager implements ISpriteManager {
  82256. /** defines the manager's name */
  82257. name: string;
  82258. /** Gets the list of sprites */
  82259. sprites: Sprite[];
  82260. /** Gets or sets the rendering group id (0 by default) */
  82261. renderingGroupId: number;
  82262. /** Gets or sets camera layer mask */
  82263. layerMask: number;
  82264. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82265. fogEnabled: boolean;
  82266. /** Gets or sets a boolean indicating if the sprites are pickable */
  82267. isPickable: boolean;
  82268. /** Defines the default width of a cell in the spritesheet */
  82269. cellWidth: number;
  82270. /** Defines the default height of a cell in the spritesheet */
  82271. cellHeight: number;
  82272. /** Associative array from JSON sprite data file */
  82273. private _cellData;
  82274. /** Array of sprite names from JSON sprite data file */
  82275. private _spriteMap;
  82276. /** True when packed cell data from JSON file is ready*/
  82277. private _packedAndReady;
  82278. /**
  82279. * An event triggered when the manager is disposed.
  82280. */
  82281. onDisposeObservable: Observable<SpriteManager>;
  82282. private _onDisposeObserver;
  82283. /**
  82284. * Callback called when the manager is disposed
  82285. */
  82286. set onDispose(callback: () => void);
  82287. private _capacity;
  82288. private _fromPacked;
  82289. private _spriteTexture;
  82290. private _epsilon;
  82291. private _scene;
  82292. private _vertexData;
  82293. private _buffer;
  82294. private _vertexBuffers;
  82295. private _indexBuffer;
  82296. private _effectBase;
  82297. private _effectFog;
  82298. /**
  82299. * Gets or sets the spritesheet texture
  82300. */
  82301. get texture(): Texture;
  82302. set texture(value: Texture);
  82303. /**
  82304. * Creates a new sprite manager
  82305. * @param name defines the manager's name
  82306. * @param imgUrl defines the sprite sheet url
  82307. * @param capacity defines the maximum allowed number of sprites
  82308. * @param cellSize defines the size of a sprite cell
  82309. * @param scene defines the hosting scene
  82310. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82311. * @param samplingMode defines the smapling mode to use with spritesheet
  82312. * @param fromPacked set to false; do not alter
  82313. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82314. */
  82315. constructor(
  82316. /** defines the manager's name */
  82317. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82318. private _makePacked;
  82319. private _appendSpriteVertex;
  82320. /**
  82321. * Intersects the sprites with a ray
  82322. * @param ray defines the ray to intersect with
  82323. * @param camera defines the current active camera
  82324. * @param predicate defines a predicate used to select candidate sprites
  82325. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82326. * @returns null if no hit or a PickingInfo
  82327. */
  82328. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82329. /**
  82330. * Intersects the sprites with a ray
  82331. * @param ray defines the ray to intersect with
  82332. * @param camera defines the current active camera
  82333. * @param predicate defines a predicate used to select candidate sprites
  82334. * @returns null if no hit or a PickingInfo array
  82335. */
  82336. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82337. /**
  82338. * Render all child sprites
  82339. */
  82340. render(): void;
  82341. /**
  82342. * Release associated resources
  82343. */
  82344. dispose(): void;
  82345. }
  82346. }
  82347. declare module BABYLON {
  82348. /**
  82349. * Class used to represent a sprite
  82350. * @see http://doc.babylonjs.com/babylon101/sprites
  82351. */
  82352. export class Sprite {
  82353. /** defines the name */
  82354. name: string;
  82355. /** Gets or sets the current world position */
  82356. position: Vector3;
  82357. /** Gets or sets the main color */
  82358. color: Color4;
  82359. /** Gets or sets the width */
  82360. width: number;
  82361. /** Gets or sets the height */
  82362. height: number;
  82363. /** Gets or sets rotation angle */
  82364. angle: number;
  82365. /** Gets or sets the cell index in the sprite sheet */
  82366. cellIndex: number;
  82367. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82368. cellRef: string;
  82369. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82370. invertU: number;
  82371. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82372. invertV: number;
  82373. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82374. disposeWhenFinishedAnimating: boolean;
  82375. /** Gets the list of attached animations */
  82376. animations: Animation[];
  82377. /** Gets or sets a boolean indicating if the sprite can be picked */
  82378. isPickable: boolean;
  82379. /**
  82380. * Gets or sets the associated action manager
  82381. */
  82382. actionManager: Nullable<ActionManager>;
  82383. private _animationStarted;
  82384. private _loopAnimation;
  82385. private _fromIndex;
  82386. private _toIndex;
  82387. private _delay;
  82388. private _direction;
  82389. private _manager;
  82390. private _time;
  82391. private _onAnimationEnd;
  82392. /**
  82393. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82394. */
  82395. isVisible: boolean;
  82396. /**
  82397. * Gets or sets the sprite size
  82398. */
  82399. get size(): number;
  82400. set size(value: number);
  82401. /**
  82402. * Creates a new Sprite
  82403. * @param name defines the name
  82404. * @param manager defines the manager
  82405. */
  82406. constructor(
  82407. /** defines the name */
  82408. name: string, manager: ISpriteManager);
  82409. /**
  82410. * Starts an animation
  82411. * @param from defines the initial key
  82412. * @param to defines the end key
  82413. * @param loop defines if the animation must loop
  82414. * @param delay defines the start delay (in ms)
  82415. * @param onAnimationEnd defines a callback to call when animation ends
  82416. */
  82417. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82418. /** Stops current animation (if any) */
  82419. stopAnimation(): void;
  82420. /** @hidden */
  82421. _animate(deltaTime: number): void;
  82422. /** Release associated resources */
  82423. dispose(): void;
  82424. }
  82425. }
  82426. declare module BABYLON {
  82427. /**
  82428. * Information about the result of picking within a scene
  82429. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82430. */
  82431. export class PickingInfo {
  82432. /** @hidden */
  82433. _pickingUnavailable: boolean;
  82434. /**
  82435. * If the pick collided with an object
  82436. */
  82437. hit: boolean;
  82438. /**
  82439. * Distance away where the pick collided
  82440. */
  82441. distance: number;
  82442. /**
  82443. * The location of pick collision
  82444. */
  82445. pickedPoint: Nullable<Vector3>;
  82446. /**
  82447. * The mesh corresponding the the pick collision
  82448. */
  82449. pickedMesh: Nullable<AbstractMesh>;
  82450. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82451. bu: number;
  82452. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82453. bv: number;
  82454. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82455. faceId: number;
  82456. /** Id of the the submesh that was picked */
  82457. subMeshId: number;
  82458. /** If a sprite was picked, this will be the sprite the pick collided with */
  82459. pickedSprite: Nullable<Sprite>;
  82460. /**
  82461. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82462. */
  82463. originMesh: Nullable<AbstractMesh>;
  82464. /**
  82465. * The ray that was used to perform the picking.
  82466. */
  82467. ray: Nullable<Ray>;
  82468. /**
  82469. * Gets the normal correspodning to the face the pick collided with
  82470. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82471. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82472. * @returns The normal correspodning to the face the pick collided with
  82473. */
  82474. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82475. /**
  82476. * Gets the texture coordinates of where the pick occured
  82477. * @returns the vector containing the coordnates of the texture
  82478. */
  82479. getTextureCoordinates(): Nullable<Vector2>;
  82480. }
  82481. }
  82482. declare module BABYLON {
  82483. /**
  82484. * Gather the list of pointer event types as constants.
  82485. */
  82486. export class PointerEventTypes {
  82487. /**
  82488. * 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.
  82489. */
  82490. static readonly POINTERDOWN: number;
  82491. /**
  82492. * The pointerup event is fired when a pointer is no longer active.
  82493. */
  82494. static readonly POINTERUP: number;
  82495. /**
  82496. * The pointermove event is fired when a pointer changes coordinates.
  82497. */
  82498. static readonly POINTERMOVE: number;
  82499. /**
  82500. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82501. */
  82502. static readonly POINTERWHEEL: number;
  82503. /**
  82504. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82505. */
  82506. static readonly POINTERPICK: number;
  82507. /**
  82508. * The pointertap event is fired when a the object has been touched and released without drag.
  82509. */
  82510. static readonly POINTERTAP: number;
  82511. /**
  82512. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82513. */
  82514. static readonly POINTERDOUBLETAP: number;
  82515. }
  82516. /**
  82517. * Base class of pointer info types.
  82518. */
  82519. export class PointerInfoBase {
  82520. /**
  82521. * Defines the type of event (PointerEventTypes)
  82522. */
  82523. type: number;
  82524. /**
  82525. * Defines the related dom event
  82526. */
  82527. event: PointerEvent | MouseWheelEvent;
  82528. /**
  82529. * Instantiates the base class of pointers info.
  82530. * @param type Defines the type of event (PointerEventTypes)
  82531. * @param event Defines the related dom event
  82532. */
  82533. constructor(
  82534. /**
  82535. * Defines the type of event (PointerEventTypes)
  82536. */
  82537. type: number,
  82538. /**
  82539. * Defines the related dom event
  82540. */
  82541. event: PointerEvent | MouseWheelEvent);
  82542. }
  82543. /**
  82544. * This class is used to store pointer related info for the onPrePointerObservable event.
  82545. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82546. */
  82547. export class PointerInfoPre extends PointerInfoBase {
  82548. /**
  82549. * Ray from a pointer if availible (eg. 6dof controller)
  82550. */
  82551. ray: Nullable<Ray>;
  82552. /**
  82553. * Defines the local position of the pointer on the canvas.
  82554. */
  82555. localPosition: Vector2;
  82556. /**
  82557. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82558. */
  82559. skipOnPointerObservable: boolean;
  82560. /**
  82561. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82562. * @param type Defines the type of event (PointerEventTypes)
  82563. * @param event Defines the related dom event
  82564. * @param localX Defines the local x coordinates of the pointer when the event occured
  82565. * @param localY Defines the local y coordinates of the pointer when the event occured
  82566. */
  82567. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82568. }
  82569. /**
  82570. * This type contains all the data related to a pointer event in Babylon.js.
  82571. * 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.
  82572. */
  82573. export class PointerInfo extends PointerInfoBase {
  82574. /**
  82575. * Defines the picking info associated to the info (if any)\
  82576. */
  82577. pickInfo: Nullable<PickingInfo>;
  82578. /**
  82579. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82580. * @param type Defines the type of event (PointerEventTypes)
  82581. * @param event Defines the related dom event
  82582. * @param pickInfo Defines the picking info associated to the info (if any)\
  82583. */
  82584. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82585. /**
  82586. * Defines the picking info associated to the info (if any)\
  82587. */
  82588. pickInfo: Nullable<PickingInfo>);
  82589. }
  82590. /**
  82591. * Data relating to a touch event on the screen.
  82592. */
  82593. export interface PointerTouch {
  82594. /**
  82595. * X coordinate of touch.
  82596. */
  82597. x: number;
  82598. /**
  82599. * Y coordinate of touch.
  82600. */
  82601. y: number;
  82602. /**
  82603. * Id of touch. Unique for each finger.
  82604. */
  82605. pointerId: number;
  82606. /**
  82607. * Event type passed from DOM.
  82608. */
  82609. type: any;
  82610. }
  82611. }
  82612. declare module BABYLON {
  82613. /**
  82614. * Manage the mouse inputs to control the movement of a free camera.
  82615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82616. */
  82617. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82618. /**
  82619. * Define if touch is enabled in the mouse input
  82620. */
  82621. touchEnabled: boolean;
  82622. /**
  82623. * Defines the camera the input is attached to.
  82624. */
  82625. camera: FreeCamera;
  82626. /**
  82627. * Defines the buttons associated with the input to handle camera move.
  82628. */
  82629. buttons: number[];
  82630. /**
  82631. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82632. */
  82633. angularSensibility: number;
  82634. private _pointerInput;
  82635. private _onMouseMove;
  82636. private _observer;
  82637. private previousPosition;
  82638. /**
  82639. * Observable for when a pointer move event occurs containing the move offset
  82640. */
  82641. onPointerMovedObservable: Observable<{
  82642. offsetX: number;
  82643. offsetY: number;
  82644. }>;
  82645. /**
  82646. * @hidden
  82647. * If the camera should be rotated automatically based on pointer movement
  82648. */
  82649. _allowCameraRotation: boolean;
  82650. /**
  82651. * Manage the mouse inputs to control the movement of a free camera.
  82652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82653. * @param touchEnabled Defines if touch is enabled or not
  82654. */
  82655. constructor(
  82656. /**
  82657. * Define if touch is enabled in the mouse input
  82658. */
  82659. touchEnabled?: boolean);
  82660. /**
  82661. * Attach the input controls to a specific dom element to get the input from.
  82662. * @param element Defines the element the controls should be listened from
  82663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82664. */
  82665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82666. /**
  82667. * Called on JS contextmenu event.
  82668. * Override this method to provide functionality.
  82669. */
  82670. protected onContextMenu(evt: PointerEvent): void;
  82671. /**
  82672. * Detach the current controls from the specified dom element.
  82673. * @param element Defines the element to stop listening the inputs from
  82674. */
  82675. detachControl(element: Nullable<HTMLElement>): void;
  82676. /**
  82677. * Gets the class name of the current intput.
  82678. * @returns the class name
  82679. */
  82680. getClassName(): string;
  82681. /**
  82682. * Get the friendly name associated with the input class.
  82683. * @returns the input friendly name
  82684. */
  82685. getSimpleName(): string;
  82686. }
  82687. }
  82688. declare module BABYLON {
  82689. /**
  82690. * Manage the touch inputs to control the movement of a free camera.
  82691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82692. */
  82693. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82694. /**
  82695. * Defines the camera the input is attached to.
  82696. */
  82697. camera: FreeCamera;
  82698. /**
  82699. * Defines the touch sensibility for rotation.
  82700. * The higher the faster.
  82701. */
  82702. touchAngularSensibility: number;
  82703. /**
  82704. * Defines the touch sensibility for move.
  82705. * The higher the faster.
  82706. */
  82707. touchMoveSensibility: number;
  82708. private _offsetX;
  82709. private _offsetY;
  82710. private _pointerPressed;
  82711. private _pointerInput;
  82712. private _observer;
  82713. private _onLostFocus;
  82714. /**
  82715. * Attach the input controls to a specific dom element to get the input from.
  82716. * @param element Defines the element the controls should be listened from
  82717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82718. */
  82719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82720. /**
  82721. * Detach the current controls from the specified dom element.
  82722. * @param element Defines the element to stop listening the inputs from
  82723. */
  82724. detachControl(element: Nullable<HTMLElement>): void;
  82725. /**
  82726. * Update the current camera state depending on the inputs that have been used this frame.
  82727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82728. */
  82729. checkInputs(): void;
  82730. /**
  82731. * Gets the class name of the current intput.
  82732. * @returns the class name
  82733. */
  82734. getClassName(): string;
  82735. /**
  82736. * Get the friendly name associated with the input class.
  82737. * @returns the input friendly name
  82738. */
  82739. getSimpleName(): string;
  82740. }
  82741. }
  82742. declare module BABYLON {
  82743. /**
  82744. * Default Inputs manager for the FreeCamera.
  82745. * It groups all the default supported inputs for ease of use.
  82746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82747. */
  82748. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82749. /**
  82750. * @hidden
  82751. */
  82752. _mouseInput: Nullable<FreeCameraMouseInput>;
  82753. /**
  82754. * Instantiates a new FreeCameraInputsManager.
  82755. * @param camera Defines the camera the inputs belong to
  82756. */
  82757. constructor(camera: FreeCamera);
  82758. /**
  82759. * Add keyboard input support to the input manager.
  82760. * @returns the current input manager
  82761. */
  82762. addKeyboard(): FreeCameraInputsManager;
  82763. /**
  82764. * Add mouse input support to the input manager.
  82765. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82766. * @returns the current input manager
  82767. */
  82768. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82769. /**
  82770. * Removes the mouse input support from the manager
  82771. * @returns the current input manager
  82772. */
  82773. removeMouse(): FreeCameraInputsManager;
  82774. /**
  82775. * Add touch input support to the input manager.
  82776. * @returns the current input manager
  82777. */
  82778. addTouch(): FreeCameraInputsManager;
  82779. /**
  82780. * Remove all attached input methods from a camera
  82781. */
  82782. clear(): void;
  82783. }
  82784. }
  82785. declare module BABYLON {
  82786. /**
  82787. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82788. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82790. */
  82791. export class FreeCamera extends TargetCamera {
  82792. /**
  82793. * Define the collision ellipsoid of the camera.
  82794. * This is helpful to simulate a camera body like the player body around the camera
  82795. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82796. */
  82797. ellipsoid: Vector3;
  82798. /**
  82799. * Define an offset for the position of the ellipsoid around the camera.
  82800. * This can be helpful to determine the center of the body near the gravity center of the body
  82801. * instead of its head.
  82802. */
  82803. ellipsoidOffset: Vector3;
  82804. /**
  82805. * Enable or disable collisions of the camera with the rest of the scene objects.
  82806. */
  82807. checkCollisions: boolean;
  82808. /**
  82809. * Enable or disable gravity on the camera.
  82810. */
  82811. applyGravity: boolean;
  82812. /**
  82813. * Define the input manager associated to the camera.
  82814. */
  82815. inputs: FreeCameraInputsManager;
  82816. /**
  82817. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82818. * Higher values reduce sensitivity.
  82819. */
  82820. get angularSensibility(): number;
  82821. /**
  82822. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82823. * Higher values reduce sensitivity.
  82824. */
  82825. set angularSensibility(value: number);
  82826. /**
  82827. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82828. */
  82829. get keysUp(): number[];
  82830. set keysUp(value: number[]);
  82831. /**
  82832. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82833. */
  82834. get keysDown(): number[];
  82835. set keysDown(value: number[]);
  82836. /**
  82837. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82838. */
  82839. get keysLeft(): number[];
  82840. set keysLeft(value: number[]);
  82841. /**
  82842. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82843. */
  82844. get keysRight(): number[];
  82845. set keysRight(value: number[]);
  82846. /**
  82847. * Event raised when the camera collide with a mesh in the scene.
  82848. */
  82849. onCollide: (collidedMesh: AbstractMesh) => void;
  82850. private _collider;
  82851. private _needMoveForGravity;
  82852. private _oldPosition;
  82853. private _diffPosition;
  82854. private _newPosition;
  82855. /** @hidden */
  82856. _localDirection: Vector3;
  82857. /** @hidden */
  82858. _transformedDirection: Vector3;
  82859. /**
  82860. * Instantiates a Free Camera.
  82861. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82862. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82864. * @param name Define the name of the camera in the scene
  82865. * @param position Define the start position of the camera in the scene
  82866. * @param scene Define the scene the camera belongs to
  82867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82868. */
  82869. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82870. /**
  82871. * Attached controls to the current camera.
  82872. * @param element Defines the element the controls should be listened from
  82873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82874. */
  82875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82876. /**
  82877. * Detach the current controls from the camera.
  82878. * The camera will stop reacting to inputs.
  82879. * @param element Defines the element to stop listening the inputs from
  82880. */
  82881. detachControl(element: HTMLElement): void;
  82882. private _collisionMask;
  82883. /**
  82884. * Define a collision mask to limit the list of object the camera can collide with
  82885. */
  82886. get collisionMask(): number;
  82887. set collisionMask(mask: number);
  82888. /** @hidden */
  82889. _collideWithWorld(displacement: Vector3): void;
  82890. private _onCollisionPositionChange;
  82891. /** @hidden */
  82892. _checkInputs(): void;
  82893. /** @hidden */
  82894. _decideIfNeedsToMove(): boolean;
  82895. /** @hidden */
  82896. _updatePosition(): void;
  82897. /**
  82898. * Destroy the camera and release the current resources hold by it.
  82899. */
  82900. dispose(): void;
  82901. /**
  82902. * Gets the current object class name.
  82903. * @return the class name
  82904. */
  82905. getClassName(): string;
  82906. }
  82907. }
  82908. declare module BABYLON {
  82909. /**
  82910. * Represents a gamepad control stick position
  82911. */
  82912. export class StickValues {
  82913. /**
  82914. * The x component of the control stick
  82915. */
  82916. x: number;
  82917. /**
  82918. * The y component of the control stick
  82919. */
  82920. y: number;
  82921. /**
  82922. * Initializes the gamepad x and y control stick values
  82923. * @param x The x component of the gamepad control stick value
  82924. * @param y The y component of the gamepad control stick value
  82925. */
  82926. constructor(
  82927. /**
  82928. * The x component of the control stick
  82929. */
  82930. x: number,
  82931. /**
  82932. * The y component of the control stick
  82933. */
  82934. y: number);
  82935. }
  82936. /**
  82937. * An interface which manages callbacks for gamepad button changes
  82938. */
  82939. export interface GamepadButtonChanges {
  82940. /**
  82941. * Called when a gamepad has been changed
  82942. */
  82943. changed: boolean;
  82944. /**
  82945. * Called when a gamepad press event has been triggered
  82946. */
  82947. pressChanged: boolean;
  82948. /**
  82949. * Called when a touch event has been triggered
  82950. */
  82951. touchChanged: boolean;
  82952. /**
  82953. * Called when a value has changed
  82954. */
  82955. valueChanged: boolean;
  82956. }
  82957. /**
  82958. * Represents a gamepad
  82959. */
  82960. export class Gamepad {
  82961. /**
  82962. * The id of the gamepad
  82963. */
  82964. id: string;
  82965. /**
  82966. * The index of the gamepad
  82967. */
  82968. index: number;
  82969. /**
  82970. * The browser gamepad
  82971. */
  82972. browserGamepad: any;
  82973. /**
  82974. * Specifies what type of gamepad this represents
  82975. */
  82976. type: number;
  82977. private _leftStick;
  82978. private _rightStick;
  82979. /** @hidden */
  82980. _isConnected: boolean;
  82981. private _leftStickAxisX;
  82982. private _leftStickAxisY;
  82983. private _rightStickAxisX;
  82984. private _rightStickAxisY;
  82985. /**
  82986. * Triggered when the left control stick has been changed
  82987. */
  82988. private _onleftstickchanged;
  82989. /**
  82990. * Triggered when the right control stick has been changed
  82991. */
  82992. private _onrightstickchanged;
  82993. /**
  82994. * Represents a gamepad controller
  82995. */
  82996. static GAMEPAD: number;
  82997. /**
  82998. * Represents a generic controller
  82999. */
  83000. static GENERIC: number;
  83001. /**
  83002. * Represents an XBox controller
  83003. */
  83004. static XBOX: number;
  83005. /**
  83006. * Represents a pose-enabled controller
  83007. */
  83008. static POSE_ENABLED: number;
  83009. /**
  83010. * Represents an Dual Shock controller
  83011. */
  83012. static DUALSHOCK: number;
  83013. /**
  83014. * Specifies whether the left control stick should be Y-inverted
  83015. */
  83016. protected _invertLeftStickY: boolean;
  83017. /**
  83018. * Specifies if the gamepad has been connected
  83019. */
  83020. get isConnected(): boolean;
  83021. /**
  83022. * Initializes the gamepad
  83023. * @param id The id of the gamepad
  83024. * @param index The index of the gamepad
  83025. * @param browserGamepad The browser gamepad
  83026. * @param leftStickX The x component of the left joystick
  83027. * @param leftStickY The y component of the left joystick
  83028. * @param rightStickX The x component of the right joystick
  83029. * @param rightStickY The y component of the right joystick
  83030. */
  83031. constructor(
  83032. /**
  83033. * The id of the gamepad
  83034. */
  83035. id: string,
  83036. /**
  83037. * The index of the gamepad
  83038. */
  83039. index: number,
  83040. /**
  83041. * The browser gamepad
  83042. */
  83043. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83044. /**
  83045. * Callback triggered when the left joystick has changed
  83046. * @param callback
  83047. */
  83048. onleftstickchanged(callback: (values: StickValues) => void): void;
  83049. /**
  83050. * Callback triggered when the right joystick has changed
  83051. * @param callback
  83052. */
  83053. onrightstickchanged(callback: (values: StickValues) => void): void;
  83054. /**
  83055. * Gets the left joystick
  83056. */
  83057. get leftStick(): StickValues;
  83058. /**
  83059. * Sets the left joystick values
  83060. */
  83061. set leftStick(newValues: StickValues);
  83062. /**
  83063. * Gets the right joystick
  83064. */
  83065. get rightStick(): StickValues;
  83066. /**
  83067. * Sets the right joystick value
  83068. */
  83069. set rightStick(newValues: StickValues);
  83070. /**
  83071. * Updates the gamepad joystick positions
  83072. */
  83073. update(): void;
  83074. /**
  83075. * Disposes the gamepad
  83076. */
  83077. dispose(): void;
  83078. }
  83079. /**
  83080. * Represents a generic gamepad
  83081. */
  83082. export class GenericPad extends Gamepad {
  83083. private _buttons;
  83084. private _onbuttondown;
  83085. private _onbuttonup;
  83086. /**
  83087. * Observable triggered when a button has been pressed
  83088. */
  83089. onButtonDownObservable: Observable<number>;
  83090. /**
  83091. * Observable triggered when a button has been released
  83092. */
  83093. onButtonUpObservable: Observable<number>;
  83094. /**
  83095. * Callback triggered when a button has been pressed
  83096. * @param callback Called when a button has been pressed
  83097. */
  83098. onbuttondown(callback: (buttonPressed: number) => void): void;
  83099. /**
  83100. * Callback triggered when a button has been released
  83101. * @param callback Called when a button has been released
  83102. */
  83103. onbuttonup(callback: (buttonReleased: number) => void): void;
  83104. /**
  83105. * Initializes the generic gamepad
  83106. * @param id The id of the generic gamepad
  83107. * @param index The index of the generic gamepad
  83108. * @param browserGamepad The browser gamepad
  83109. */
  83110. constructor(id: string, index: number, browserGamepad: any);
  83111. private _setButtonValue;
  83112. /**
  83113. * Updates the generic gamepad
  83114. */
  83115. update(): void;
  83116. /**
  83117. * Disposes the generic gamepad
  83118. */
  83119. dispose(): void;
  83120. }
  83121. }
  83122. declare module BABYLON {
  83123. interface Engine {
  83124. /**
  83125. * Creates a raw texture
  83126. * @param data defines the data to store in the texture
  83127. * @param width defines the width of the texture
  83128. * @param height defines the height of the texture
  83129. * @param format defines the format of the data
  83130. * @param generateMipMaps defines if the engine should generate the mip levels
  83131. * @param invertY defines if data must be stored with Y axis inverted
  83132. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83133. * @param compression defines the compression used (null by default)
  83134. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83135. * @returns the raw texture inside an InternalTexture
  83136. */
  83137. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83138. /**
  83139. * Update a raw texture
  83140. * @param texture defines the texture to update
  83141. * @param data defines the data to store in the texture
  83142. * @param format defines the format of the data
  83143. * @param invertY defines if data must be stored with Y axis inverted
  83144. */
  83145. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83146. /**
  83147. * Update a raw texture
  83148. * @param texture defines the texture to update
  83149. * @param data defines the data to store in the texture
  83150. * @param format defines the format of the data
  83151. * @param invertY defines if data must be stored with Y axis inverted
  83152. * @param compression defines the compression used (null by default)
  83153. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83154. */
  83155. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83156. /**
  83157. * Creates a new raw cube texture
  83158. * @param data defines the array of data to use to create each face
  83159. * @param size defines the size of the textures
  83160. * @param format defines the format of the data
  83161. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83162. * @param generateMipMaps defines if the engine should generate the mip levels
  83163. * @param invertY defines if data must be stored with Y axis inverted
  83164. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83165. * @param compression defines the compression used (null by default)
  83166. * @returns the cube texture as an InternalTexture
  83167. */
  83168. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83169. /**
  83170. * Update a raw cube texture
  83171. * @param texture defines the texture to udpdate
  83172. * @param data defines the data to store
  83173. * @param format defines the data format
  83174. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83175. * @param invertY defines if data must be stored with Y axis inverted
  83176. */
  83177. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83178. /**
  83179. * Update a raw cube texture
  83180. * @param texture defines the texture to udpdate
  83181. * @param data defines the data to store
  83182. * @param format defines the data format
  83183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83184. * @param invertY defines if data must be stored with Y axis inverted
  83185. * @param compression defines the compression used (null by default)
  83186. */
  83187. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83188. /**
  83189. * Update a raw cube texture
  83190. * @param texture defines the texture to udpdate
  83191. * @param data defines the data to store
  83192. * @param format defines the data format
  83193. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83194. * @param invertY defines if data must be stored with Y axis inverted
  83195. * @param compression defines the compression used (null by default)
  83196. * @param level defines which level of the texture to update
  83197. */
  83198. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83199. /**
  83200. * Creates a new raw cube texture from a specified url
  83201. * @param url defines the url where the data is located
  83202. * @param scene defines the current scene
  83203. * @param size defines the size of the textures
  83204. * @param format defines the format of the data
  83205. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83206. * @param noMipmap defines if the engine should avoid generating the mip levels
  83207. * @param callback defines a callback used to extract texture data from loaded data
  83208. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83209. * @param onLoad defines a callback called when texture is loaded
  83210. * @param onError defines a callback called if there is an error
  83211. * @returns the cube texture as an InternalTexture
  83212. */
  83213. 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;
  83214. /**
  83215. * Creates a new raw cube texture from a specified url
  83216. * @param url defines the url where the data is located
  83217. * @param scene defines the current scene
  83218. * @param size defines the size of the textures
  83219. * @param format defines the format of the data
  83220. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83221. * @param noMipmap defines if the engine should avoid generating the mip levels
  83222. * @param callback defines a callback used to extract texture data from loaded data
  83223. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83224. * @param onLoad defines a callback called when texture is loaded
  83225. * @param onError defines a callback called if there is an error
  83226. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83227. * @param invertY defines if data must be stored with Y axis inverted
  83228. * @returns the cube texture as an InternalTexture
  83229. */
  83230. 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;
  83231. /**
  83232. * Creates a new raw 3D texture
  83233. * @param data defines the data used to create the texture
  83234. * @param width defines the width of the texture
  83235. * @param height defines the height of the texture
  83236. * @param depth defines the depth of the texture
  83237. * @param format defines the format of the texture
  83238. * @param generateMipMaps defines if the engine must generate mip levels
  83239. * @param invertY defines if data must be stored with Y axis inverted
  83240. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83241. * @param compression defines the compressed used (can be null)
  83242. * @param textureType defines the compressed used (can be null)
  83243. * @returns a new raw 3D texture (stored in an InternalTexture)
  83244. */
  83245. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83246. /**
  83247. * Update a raw 3D texture
  83248. * @param texture defines the texture to update
  83249. * @param data defines the data to store
  83250. * @param format defines the data format
  83251. * @param invertY defines if data must be stored with Y axis inverted
  83252. */
  83253. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83254. /**
  83255. * Update a raw 3D texture
  83256. * @param texture defines the texture to update
  83257. * @param data defines the data to store
  83258. * @param format defines the data format
  83259. * @param invertY defines if data must be stored with Y axis inverted
  83260. * @param compression defines the used compression (can be null)
  83261. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83262. */
  83263. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83264. /**
  83265. * Creates a new raw 2D array texture
  83266. * @param data defines the data used to create the texture
  83267. * @param width defines the width of the texture
  83268. * @param height defines the height of the texture
  83269. * @param depth defines the number of layers of the texture
  83270. * @param format defines the format of the texture
  83271. * @param generateMipMaps defines if the engine must generate mip levels
  83272. * @param invertY defines if data must be stored with Y axis inverted
  83273. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83274. * @param compression defines the compressed used (can be null)
  83275. * @param textureType defines the compressed used (can be null)
  83276. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83277. */
  83278. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83279. /**
  83280. * Update a raw 2D array texture
  83281. * @param texture defines the texture to update
  83282. * @param data defines the data to store
  83283. * @param format defines the data format
  83284. * @param invertY defines if data must be stored with Y axis inverted
  83285. */
  83286. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83287. /**
  83288. * Update a raw 2D array texture
  83289. * @param texture defines the texture to update
  83290. * @param data defines the data to store
  83291. * @param format defines the data format
  83292. * @param invertY defines if data must be stored with Y axis inverted
  83293. * @param compression defines the used compression (can be null)
  83294. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83295. */
  83296. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83297. }
  83298. }
  83299. declare module BABYLON {
  83300. /**
  83301. * Raw texture can help creating a texture directly from an array of data.
  83302. * This can be super useful if you either get the data from an uncompressed source or
  83303. * if you wish to create your texture pixel by pixel.
  83304. */
  83305. export class RawTexture extends Texture {
  83306. /**
  83307. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83308. */
  83309. format: number;
  83310. private _engine;
  83311. /**
  83312. * Instantiates a new RawTexture.
  83313. * Raw texture can help creating a texture directly from an array of data.
  83314. * This can be super useful if you either get the data from an uncompressed source or
  83315. * if you wish to create your texture pixel by pixel.
  83316. * @param data define the array of data to use to create the texture
  83317. * @param width define the width of the texture
  83318. * @param height define the height of the texture
  83319. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83320. * @param scene define the scene the texture belongs to
  83321. * @param generateMipMaps define whether mip maps should be generated or not
  83322. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83323. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83324. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83325. */
  83326. constructor(data: ArrayBufferView, width: number, height: number,
  83327. /**
  83328. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83329. */
  83330. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83331. /**
  83332. * Updates the texture underlying data.
  83333. * @param data Define the new data of the texture
  83334. */
  83335. update(data: ArrayBufferView): void;
  83336. /**
  83337. * Creates a luminance texture from some data.
  83338. * @param data Define the texture data
  83339. * @param width Define the width of the texture
  83340. * @param height Define the height of the texture
  83341. * @param scene Define the scene the texture belongs to
  83342. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83343. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83344. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83345. * @returns the luminance texture
  83346. */
  83347. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83348. /**
  83349. * Creates a luminance alpha texture from some data.
  83350. * @param data Define the texture data
  83351. * @param width Define the width of the texture
  83352. * @param height Define the height of the texture
  83353. * @param scene Define the scene the texture belongs to
  83354. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83355. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83356. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83357. * @returns the luminance alpha texture
  83358. */
  83359. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83360. /**
  83361. * Creates an alpha texture from some data.
  83362. * @param data Define the texture data
  83363. * @param width Define the width of the texture
  83364. * @param height Define the height of the texture
  83365. * @param scene Define the scene the texture belongs to
  83366. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83367. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83368. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83369. * @returns the alpha texture
  83370. */
  83371. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83372. /**
  83373. * Creates a RGB texture from some data.
  83374. * @param data Define the texture data
  83375. * @param width Define the width of the texture
  83376. * @param height Define the height of the texture
  83377. * @param scene Define the scene the texture belongs to
  83378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83381. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83382. * @returns the RGB alpha texture
  83383. */
  83384. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83385. /**
  83386. * Creates a RGBA texture from some data.
  83387. * @param data Define the texture data
  83388. * @param width Define the width of the texture
  83389. * @param height Define the height of the texture
  83390. * @param scene Define the scene the texture belongs to
  83391. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83392. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83393. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83394. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83395. * @returns the RGBA texture
  83396. */
  83397. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83398. /**
  83399. * Creates a R texture from some data.
  83400. * @param data Define the texture data
  83401. * @param width Define the width of the texture
  83402. * @param height Define the height of the texture
  83403. * @param scene Define the scene the texture belongs to
  83404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83408. * @returns the R texture
  83409. */
  83410. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83411. }
  83412. }
  83413. declare module BABYLON {
  83414. /**
  83415. * Interface for the size containing width and height
  83416. */
  83417. export interface ISize {
  83418. /**
  83419. * Width
  83420. */
  83421. width: number;
  83422. /**
  83423. * Heighht
  83424. */
  83425. height: number;
  83426. }
  83427. /**
  83428. * Size containing widht and height
  83429. */
  83430. export class Size implements ISize {
  83431. /**
  83432. * Width
  83433. */
  83434. width: number;
  83435. /**
  83436. * Height
  83437. */
  83438. height: number;
  83439. /**
  83440. * Creates a Size object from the given width and height (floats).
  83441. * @param width width of the new size
  83442. * @param height height of the new size
  83443. */
  83444. constructor(width: number, height: number);
  83445. /**
  83446. * Returns a string with the Size width and height
  83447. * @returns a string with the Size width and height
  83448. */
  83449. toString(): string;
  83450. /**
  83451. * "Size"
  83452. * @returns the string "Size"
  83453. */
  83454. getClassName(): string;
  83455. /**
  83456. * Returns the Size hash code.
  83457. * @returns a hash code for a unique width and height
  83458. */
  83459. getHashCode(): number;
  83460. /**
  83461. * Updates the current size from the given one.
  83462. * @param src the given size
  83463. */
  83464. copyFrom(src: Size): void;
  83465. /**
  83466. * Updates in place the current Size from the given floats.
  83467. * @param width width of the new size
  83468. * @param height height of the new size
  83469. * @returns the updated Size.
  83470. */
  83471. copyFromFloats(width: number, height: number): Size;
  83472. /**
  83473. * Updates in place the current Size from the given floats.
  83474. * @param width width to set
  83475. * @param height height to set
  83476. * @returns the updated Size.
  83477. */
  83478. set(width: number, height: number): Size;
  83479. /**
  83480. * Multiplies the width and height by numbers
  83481. * @param w factor to multiple the width by
  83482. * @param h factor to multiple the height by
  83483. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83484. */
  83485. multiplyByFloats(w: number, h: number): Size;
  83486. /**
  83487. * Clones the size
  83488. * @returns a new Size copied from the given one.
  83489. */
  83490. clone(): Size;
  83491. /**
  83492. * True if the current Size and the given one width and height are strictly equal.
  83493. * @param other the other size to compare against
  83494. * @returns True if the current Size and the given one width and height are strictly equal.
  83495. */
  83496. equals(other: Size): boolean;
  83497. /**
  83498. * The surface of the Size : width * height (float).
  83499. */
  83500. get surface(): number;
  83501. /**
  83502. * Create a new size of zero
  83503. * @returns a new Size set to (0.0, 0.0)
  83504. */
  83505. static Zero(): Size;
  83506. /**
  83507. * Sums the width and height of two sizes
  83508. * @param otherSize size to add to this size
  83509. * @returns a new Size set as the addition result of the current Size and the given one.
  83510. */
  83511. add(otherSize: Size): Size;
  83512. /**
  83513. * Subtracts the width and height of two
  83514. * @param otherSize size to subtract to this size
  83515. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83516. */
  83517. subtract(otherSize: Size): Size;
  83518. /**
  83519. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83520. * @param start starting size to lerp between
  83521. * @param end end size to lerp between
  83522. * @param amount amount to lerp between the start and end values
  83523. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83524. */
  83525. static Lerp(start: Size, end: Size, amount: number): Size;
  83526. }
  83527. }
  83528. declare module BABYLON {
  83529. /**
  83530. * Defines a runtime animation
  83531. */
  83532. export class RuntimeAnimation {
  83533. private _events;
  83534. /**
  83535. * The current frame of the runtime animation
  83536. */
  83537. private _currentFrame;
  83538. /**
  83539. * The animation used by the runtime animation
  83540. */
  83541. private _animation;
  83542. /**
  83543. * The target of the runtime animation
  83544. */
  83545. private _target;
  83546. /**
  83547. * The initiating animatable
  83548. */
  83549. private _host;
  83550. /**
  83551. * The original value of the runtime animation
  83552. */
  83553. private _originalValue;
  83554. /**
  83555. * The original blend value of the runtime animation
  83556. */
  83557. private _originalBlendValue;
  83558. /**
  83559. * The offsets cache of the runtime animation
  83560. */
  83561. private _offsetsCache;
  83562. /**
  83563. * The high limits cache of the runtime animation
  83564. */
  83565. private _highLimitsCache;
  83566. /**
  83567. * Specifies if the runtime animation has been stopped
  83568. */
  83569. private _stopped;
  83570. /**
  83571. * The blending factor of the runtime animation
  83572. */
  83573. private _blendingFactor;
  83574. /**
  83575. * The BabylonJS scene
  83576. */
  83577. private _scene;
  83578. /**
  83579. * The current value of the runtime animation
  83580. */
  83581. private _currentValue;
  83582. /** @hidden */
  83583. _animationState: _IAnimationState;
  83584. /**
  83585. * The active target of the runtime animation
  83586. */
  83587. private _activeTargets;
  83588. private _currentActiveTarget;
  83589. private _directTarget;
  83590. /**
  83591. * The target path of the runtime animation
  83592. */
  83593. private _targetPath;
  83594. /**
  83595. * The weight of the runtime animation
  83596. */
  83597. private _weight;
  83598. /**
  83599. * The ratio offset of the runtime animation
  83600. */
  83601. private _ratioOffset;
  83602. /**
  83603. * The previous delay of the runtime animation
  83604. */
  83605. private _previousDelay;
  83606. /**
  83607. * The previous ratio of the runtime animation
  83608. */
  83609. private _previousRatio;
  83610. private _enableBlending;
  83611. private _keys;
  83612. private _minFrame;
  83613. private _maxFrame;
  83614. private _minValue;
  83615. private _maxValue;
  83616. private _targetIsArray;
  83617. /**
  83618. * Gets the current frame of the runtime animation
  83619. */
  83620. get currentFrame(): number;
  83621. /**
  83622. * Gets the weight of the runtime animation
  83623. */
  83624. get weight(): number;
  83625. /**
  83626. * Gets the current value of the runtime animation
  83627. */
  83628. get currentValue(): any;
  83629. /**
  83630. * Gets the target path of the runtime animation
  83631. */
  83632. get targetPath(): string;
  83633. /**
  83634. * Gets the actual target of the runtime animation
  83635. */
  83636. get target(): any;
  83637. /** @hidden */
  83638. _onLoop: () => void;
  83639. /**
  83640. * Create a new RuntimeAnimation object
  83641. * @param target defines the target of the animation
  83642. * @param animation defines the source animation object
  83643. * @param scene defines the hosting scene
  83644. * @param host defines the initiating Animatable
  83645. */
  83646. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83647. private _preparePath;
  83648. /**
  83649. * Gets the animation from the runtime animation
  83650. */
  83651. get animation(): Animation;
  83652. /**
  83653. * Resets the runtime animation to the beginning
  83654. * @param restoreOriginal defines whether to restore the target property to the original value
  83655. */
  83656. reset(restoreOriginal?: boolean): void;
  83657. /**
  83658. * Specifies if the runtime animation is stopped
  83659. * @returns Boolean specifying if the runtime animation is stopped
  83660. */
  83661. isStopped(): boolean;
  83662. /**
  83663. * Disposes of the runtime animation
  83664. */
  83665. dispose(): void;
  83666. /**
  83667. * Apply the interpolated value to the target
  83668. * @param currentValue defines the value computed by the animation
  83669. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83670. */
  83671. setValue(currentValue: any, weight: number): void;
  83672. private _getOriginalValues;
  83673. private _setValue;
  83674. /**
  83675. * Gets the loop pmode of the runtime animation
  83676. * @returns Loop Mode
  83677. */
  83678. private _getCorrectLoopMode;
  83679. /**
  83680. * Move the current animation to a given frame
  83681. * @param frame defines the frame to move to
  83682. */
  83683. goToFrame(frame: number): void;
  83684. /**
  83685. * @hidden Internal use only
  83686. */
  83687. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83688. /**
  83689. * Execute the current animation
  83690. * @param delay defines the delay to add to the current frame
  83691. * @param from defines the lower bound of the animation range
  83692. * @param to defines the upper bound of the animation range
  83693. * @param loop defines if the current animation must loop
  83694. * @param speedRatio defines the current speed ratio
  83695. * @param weight defines the weight of the animation (default is -1 so no weight)
  83696. * @param onLoop optional callback called when animation loops
  83697. * @returns a boolean indicating if the animation is running
  83698. */
  83699. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83700. }
  83701. }
  83702. declare module BABYLON {
  83703. /**
  83704. * Class used to store an actual running animation
  83705. */
  83706. export class Animatable {
  83707. /** defines the target object */
  83708. target: any;
  83709. /** defines the starting frame number (default is 0) */
  83710. fromFrame: number;
  83711. /** defines the ending frame number (default is 100) */
  83712. toFrame: number;
  83713. /** defines if the animation must loop (default is false) */
  83714. loopAnimation: boolean;
  83715. /** defines a callback to call when animation ends if it is not looping */
  83716. onAnimationEnd?: (() => void) | null | undefined;
  83717. /** defines a callback to call when animation loops */
  83718. onAnimationLoop?: (() => void) | null | undefined;
  83719. private _localDelayOffset;
  83720. private _pausedDelay;
  83721. private _runtimeAnimations;
  83722. private _paused;
  83723. private _scene;
  83724. private _speedRatio;
  83725. private _weight;
  83726. private _syncRoot;
  83727. /**
  83728. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83729. * This will only apply for non looping animation (default is true)
  83730. */
  83731. disposeOnEnd: boolean;
  83732. /**
  83733. * Gets a boolean indicating if the animation has started
  83734. */
  83735. animationStarted: boolean;
  83736. /**
  83737. * Observer raised when the animation ends
  83738. */
  83739. onAnimationEndObservable: Observable<Animatable>;
  83740. /**
  83741. * Observer raised when the animation loops
  83742. */
  83743. onAnimationLoopObservable: Observable<Animatable>;
  83744. /**
  83745. * Gets the root Animatable used to synchronize and normalize animations
  83746. */
  83747. get syncRoot(): Nullable<Animatable>;
  83748. /**
  83749. * Gets the current frame of the first RuntimeAnimation
  83750. * Used to synchronize Animatables
  83751. */
  83752. get masterFrame(): number;
  83753. /**
  83754. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83755. */
  83756. get weight(): number;
  83757. set weight(value: number);
  83758. /**
  83759. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83760. */
  83761. get speedRatio(): number;
  83762. set speedRatio(value: number);
  83763. /**
  83764. * Creates a new Animatable
  83765. * @param scene defines the hosting scene
  83766. * @param target defines the target object
  83767. * @param fromFrame defines the starting frame number (default is 0)
  83768. * @param toFrame defines the ending frame number (default is 100)
  83769. * @param loopAnimation defines if the animation must loop (default is false)
  83770. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83771. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83772. * @param animations defines a group of animation to add to the new Animatable
  83773. * @param onAnimationLoop defines a callback to call when animation loops
  83774. */
  83775. constructor(scene: Scene,
  83776. /** defines the target object */
  83777. target: any,
  83778. /** defines the starting frame number (default is 0) */
  83779. fromFrame?: number,
  83780. /** defines the ending frame number (default is 100) */
  83781. toFrame?: number,
  83782. /** defines if the animation must loop (default is false) */
  83783. loopAnimation?: boolean, speedRatio?: number,
  83784. /** defines a callback to call when animation ends if it is not looping */
  83785. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83786. /** defines a callback to call when animation loops */
  83787. onAnimationLoop?: (() => void) | null | undefined);
  83788. /**
  83789. * Synchronize and normalize current Animatable with a source Animatable
  83790. * This is useful when using animation weights and when animations are not of the same length
  83791. * @param root defines the root Animatable to synchronize with
  83792. * @returns the current Animatable
  83793. */
  83794. syncWith(root: Animatable): Animatable;
  83795. /**
  83796. * Gets the list of runtime animations
  83797. * @returns an array of RuntimeAnimation
  83798. */
  83799. getAnimations(): RuntimeAnimation[];
  83800. /**
  83801. * Adds more animations to the current animatable
  83802. * @param target defines the target of the animations
  83803. * @param animations defines the new animations to add
  83804. */
  83805. appendAnimations(target: any, animations: Animation[]): void;
  83806. /**
  83807. * Gets the source animation for a specific property
  83808. * @param property defines the propertyu to look for
  83809. * @returns null or the source animation for the given property
  83810. */
  83811. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83812. /**
  83813. * Gets the runtime animation for a specific property
  83814. * @param property defines the propertyu to look for
  83815. * @returns null or the runtime animation for the given property
  83816. */
  83817. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83818. /**
  83819. * Resets the animatable to its original state
  83820. */
  83821. reset(): void;
  83822. /**
  83823. * Allows the animatable to blend with current running animations
  83824. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83825. * @param blendingSpeed defines the blending speed to use
  83826. */
  83827. enableBlending(blendingSpeed: number): void;
  83828. /**
  83829. * Disable animation blending
  83830. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83831. */
  83832. disableBlending(): void;
  83833. /**
  83834. * Jump directly to a given frame
  83835. * @param frame defines the frame to jump to
  83836. */
  83837. goToFrame(frame: number): void;
  83838. /**
  83839. * Pause the animation
  83840. */
  83841. pause(): void;
  83842. /**
  83843. * Restart the animation
  83844. */
  83845. restart(): void;
  83846. private _raiseOnAnimationEnd;
  83847. /**
  83848. * Stop and delete the current animation
  83849. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83850. * @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)
  83851. */
  83852. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83853. /**
  83854. * Wait asynchronously for the animation to end
  83855. * @returns a promise which will be fullfilled when the animation ends
  83856. */
  83857. waitAsync(): Promise<Animatable>;
  83858. /** @hidden */
  83859. _animate(delay: number): boolean;
  83860. }
  83861. interface Scene {
  83862. /** @hidden */
  83863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83864. /** @hidden */
  83865. _processLateAnimationBindingsForMatrices(holder: {
  83866. totalWeight: number;
  83867. animations: RuntimeAnimation[];
  83868. originalValue: Matrix;
  83869. }): any;
  83870. /** @hidden */
  83871. _processLateAnimationBindingsForQuaternions(holder: {
  83872. totalWeight: number;
  83873. animations: RuntimeAnimation[];
  83874. originalValue: Quaternion;
  83875. }, refQuaternion: Quaternion): Quaternion;
  83876. /** @hidden */
  83877. _processLateAnimationBindings(): void;
  83878. /**
  83879. * Will start the animation sequence of a given target
  83880. * @param target defines the target
  83881. * @param from defines from which frame should animation start
  83882. * @param to defines until which frame should animation run.
  83883. * @param weight defines the weight to apply to the animation (1.0 by default)
  83884. * @param loop defines if the animation loops
  83885. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83886. * @param onAnimationEnd defines the function to be executed when the animation ends
  83887. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83888. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83889. * @param onAnimationLoop defines the callback to call when an animation loops
  83890. * @returns the animatable object created for this animation
  83891. */
  83892. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83893. /**
  83894. * Will start the animation sequence of a given target
  83895. * @param target defines the target
  83896. * @param from defines from which frame should animation start
  83897. * @param to defines until which frame should animation run.
  83898. * @param loop defines if the animation loops
  83899. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83900. * @param onAnimationEnd defines the function to be executed when the animation ends
  83901. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83902. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83903. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83904. * @param onAnimationLoop defines the callback to call when an animation loops
  83905. * @returns the animatable object created for this animation
  83906. */
  83907. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83908. /**
  83909. * Will start the animation sequence of a given target and its hierarchy
  83910. * @param target defines the target
  83911. * @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.
  83912. * @param from defines from which frame should animation start
  83913. * @param to defines until which frame should animation run.
  83914. * @param loop defines if the animation loops
  83915. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83916. * @param onAnimationEnd defines the function to be executed when the animation ends
  83917. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83918. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83919. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83920. * @param onAnimationLoop defines the callback to call when an animation loops
  83921. * @returns the list of created animatables
  83922. */
  83923. 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[];
  83924. /**
  83925. * Begin a new animation on a given node
  83926. * @param target defines the target where the animation will take place
  83927. * @param animations defines the list of animations to start
  83928. * @param from defines the initial value
  83929. * @param to defines the final value
  83930. * @param loop defines if you want animation to loop (off by default)
  83931. * @param speedRatio defines the speed ratio to apply to all animations
  83932. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83933. * @param onAnimationLoop defines the callback to call when an animation loops
  83934. * @returns the list of created animatables
  83935. */
  83936. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  83937. /**
  83938. * Begin a new animation on a given node and its hierarchy
  83939. * @param target defines the root node where the animation will take place
  83940. * @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.
  83941. * @param animations defines the list of animations to start
  83942. * @param from defines the initial value
  83943. * @param to defines the final value
  83944. * @param loop defines if you want animation to loop (off by default)
  83945. * @param speedRatio defines the speed ratio to apply to all animations
  83946. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83947. * @param onAnimationLoop defines the callback to call when an animation loops
  83948. * @returns the list of animatables created for all nodes
  83949. */
  83950. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  83951. /**
  83952. * Gets the animatable associated with a specific target
  83953. * @param target defines the target of the animatable
  83954. * @returns the required animatable if found
  83955. */
  83956. getAnimatableByTarget(target: any): Nullable<Animatable>;
  83957. /**
  83958. * Gets all animatables associated with a given target
  83959. * @param target defines the target to look animatables for
  83960. * @returns an array of Animatables
  83961. */
  83962. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  83963. /**
  83964. * Stops and removes all animations that have been applied to the scene
  83965. */
  83966. stopAllAnimations(): void;
  83967. /**
  83968. * Gets the current delta time used by animation engine
  83969. */
  83970. deltaTime: number;
  83971. }
  83972. interface Bone {
  83973. /**
  83974. * Copy an animation range from another bone
  83975. * @param source defines the source bone
  83976. * @param rangeName defines the range name to copy
  83977. * @param frameOffset defines the frame offset
  83978. * @param rescaleAsRequired defines if rescaling must be applied if required
  83979. * @param skelDimensionsRatio defines the scaling ratio
  83980. * @returns true if operation was successful
  83981. */
  83982. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  83983. }
  83984. }
  83985. declare module BABYLON {
  83986. /**
  83987. * Class used to override all child animations of a given target
  83988. */
  83989. export class AnimationPropertiesOverride {
  83990. /**
  83991. * Gets or sets a value indicating if animation blending must be used
  83992. */
  83993. enableBlending: boolean;
  83994. /**
  83995. * Gets or sets the blending speed to use when enableBlending is true
  83996. */
  83997. blendingSpeed: number;
  83998. /**
  83999. * Gets or sets the default loop mode to use
  84000. */
  84001. loopMode: number;
  84002. }
  84003. }
  84004. declare module BABYLON {
  84005. /**
  84006. * Class used to handle skinning animations
  84007. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84008. */
  84009. export class Skeleton implements IAnimatable {
  84010. /** defines the skeleton name */
  84011. name: string;
  84012. /** defines the skeleton Id */
  84013. id: string;
  84014. /**
  84015. * Defines the list of child bones
  84016. */
  84017. bones: Bone[];
  84018. /**
  84019. * Defines an estimate of the dimension of the skeleton at rest
  84020. */
  84021. dimensionsAtRest: Vector3;
  84022. /**
  84023. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84024. */
  84025. needInitialSkinMatrix: boolean;
  84026. /**
  84027. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84028. */
  84029. overrideMesh: Nullable<AbstractMesh>;
  84030. /**
  84031. * Gets the list of animations attached to this skeleton
  84032. */
  84033. animations: Array<Animation>;
  84034. private _scene;
  84035. private _isDirty;
  84036. private _transformMatrices;
  84037. private _transformMatrixTexture;
  84038. private _meshesWithPoseMatrix;
  84039. private _animatables;
  84040. private _identity;
  84041. private _synchronizedWithMesh;
  84042. private _ranges;
  84043. private _lastAbsoluteTransformsUpdateId;
  84044. private _canUseTextureForBones;
  84045. private _uniqueId;
  84046. /** @hidden */
  84047. _numBonesWithLinkedTransformNode: number;
  84048. /** @hidden */
  84049. _hasWaitingData: Nullable<boolean>;
  84050. /**
  84051. * Specifies if the skeleton should be serialized
  84052. */
  84053. doNotSerialize: boolean;
  84054. private _useTextureToStoreBoneMatrices;
  84055. /**
  84056. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84057. * Please note that this option is not available if the hardware does not support it
  84058. */
  84059. get useTextureToStoreBoneMatrices(): boolean;
  84060. set useTextureToStoreBoneMatrices(value: boolean);
  84061. private _animationPropertiesOverride;
  84062. /**
  84063. * Gets or sets the animation properties override
  84064. */
  84065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84067. /**
  84068. * List of inspectable custom properties (used by the Inspector)
  84069. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84070. */
  84071. inspectableCustomProperties: IInspectable[];
  84072. /**
  84073. * An observable triggered before computing the skeleton's matrices
  84074. */
  84075. onBeforeComputeObservable: Observable<Skeleton>;
  84076. /**
  84077. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84078. */
  84079. get isUsingTextureForMatrices(): boolean;
  84080. /**
  84081. * Gets the unique ID of this skeleton
  84082. */
  84083. get uniqueId(): number;
  84084. /**
  84085. * Creates a new skeleton
  84086. * @param name defines the skeleton name
  84087. * @param id defines the skeleton Id
  84088. * @param scene defines the hosting scene
  84089. */
  84090. constructor(
  84091. /** defines the skeleton name */
  84092. name: string,
  84093. /** defines the skeleton Id */
  84094. id: string, scene: Scene);
  84095. /**
  84096. * Gets the current object class name.
  84097. * @return the class name
  84098. */
  84099. getClassName(): string;
  84100. /**
  84101. * Returns an array containing the root bones
  84102. * @returns an array containing the root bones
  84103. */
  84104. getChildren(): Array<Bone>;
  84105. /**
  84106. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84107. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84108. * @returns a Float32Array containing matrices data
  84109. */
  84110. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84111. /**
  84112. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84113. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84114. * @returns a raw texture containing the data
  84115. */
  84116. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84117. /**
  84118. * Gets the current hosting scene
  84119. * @returns a scene object
  84120. */
  84121. getScene(): Scene;
  84122. /**
  84123. * Gets a string representing the current skeleton data
  84124. * @param fullDetails defines a boolean indicating if we want a verbose version
  84125. * @returns a string representing the current skeleton data
  84126. */
  84127. toString(fullDetails?: boolean): string;
  84128. /**
  84129. * Get bone's index searching by name
  84130. * @param name defines bone's name to search for
  84131. * @return the indice of the bone. Returns -1 if not found
  84132. */
  84133. getBoneIndexByName(name: string): number;
  84134. /**
  84135. * Creater a new animation range
  84136. * @param name defines the name of the range
  84137. * @param from defines the start key
  84138. * @param to defines the end key
  84139. */
  84140. createAnimationRange(name: string, from: number, to: number): void;
  84141. /**
  84142. * Delete a specific animation range
  84143. * @param name defines the name of the range
  84144. * @param deleteFrames defines if frames must be removed as well
  84145. */
  84146. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84147. /**
  84148. * Gets a specific animation range
  84149. * @param name defines the name of the range to look for
  84150. * @returns the requested animation range or null if not found
  84151. */
  84152. getAnimationRange(name: string): Nullable<AnimationRange>;
  84153. /**
  84154. * Gets the list of all animation ranges defined on this skeleton
  84155. * @returns an array
  84156. */
  84157. getAnimationRanges(): Nullable<AnimationRange>[];
  84158. /**
  84159. * Copy animation range from a source skeleton.
  84160. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84161. * @param source defines the source skeleton
  84162. * @param name defines the name of the range to copy
  84163. * @param rescaleAsRequired defines if rescaling must be applied if required
  84164. * @returns true if operation was successful
  84165. */
  84166. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84167. /**
  84168. * Forces the skeleton to go to rest pose
  84169. */
  84170. returnToRest(): void;
  84171. private _getHighestAnimationFrame;
  84172. /**
  84173. * Begin a specific animation range
  84174. * @param name defines the name of the range to start
  84175. * @param loop defines if looping must be turned on (false by default)
  84176. * @param speedRatio defines the speed ratio to apply (1 by default)
  84177. * @param onAnimationEnd defines a callback which will be called when animation will end
  84178. * @returns a new animatable
  84179. */
  84180. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84181. /** @hidden */
  84182. _markAsDirty(): void;
  84183. /** @hidden */
  84184. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84185. /** @hidden */
  84186. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84187. private _computeTransformMatrices;
  84188. /**
  84189. * Build all resources required to render a skeleton
  84190. */
  84191. prepare(): void;
  84192. /**
  84193. * Gets the list of animatables currently running for this skeleton
  84194. * @returns an array of animatables
  84195. */
  84196. getAnimatables(): IAnimatable[];
  84197. /**
  84198. * Clone the current skeleton
  84199. * @param name defines the name of the new skeleton
  84200. * @param id defines the id of the new skeleton
  84201. * @returns the new skeleton
  84202. */
  84203. clone(name: string, id?: string): Skeleton;
  84204. /**
  84205. * Enable animation blending for this skeleton
  84206. * @param blendingSpeed defines the blending speed to apply
  84207. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84208. */
  84209. enableBlending(blendingSpeed?: number): void;
  84210. /**
  84211. * Releases all resources associated with the current skeleton
  84212. */
  84213. dispose(): void;
  84214. /**
  84215. * Serialize the skeleton in a JSON object
  84216. * @returns a JSON object
  84217. */
  84218. serialize(): any;
  84219. /**
  84220. * Creates a new skeleton from serialized data
  84221. * @param parsedSkeleton defines the serialized data
  84222. * @param scene defines the hosting scene
  84223. * @returns a new skeleton
  84224. */
  84225. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84226. /**
  84227. * Compute all node absolute transforms
  84228. * @param forceUpdate defines if computation must be done even if cache is up to date
  84229. */
  84230. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84231. /**
  84232. * Gets the root pose matrix
  84233. * @returns a matrix
  84234. */
  84235. getPoseMatrix(): Nullable<Matrix>;
  84236. /**
  84237. * Sorts bones per internal index
  84238. */
  84239. sortBones(): void;
  84240. private _sortBones;
  84241. }
  84242. }
  84243. declare module BABYLON {
  84244. /**
  84245. * Class used to store bone information
  84246. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84247. */
  84248. export class Bone extends Node {
  84249. /**
  84250. * defines the bone name
  84251. */
  84252. name: string;
  84253. private static _tmpVecs;
  84254. private static _tmpQuat;
  84255. private static _tmpMats;
  84256. /**
  84257. * Gets the list of child bones
  84258. */
  84259. children: Bone[];
  84260. /** Gets the animations associated with this bone */
  84261. animations: Animation[];
  84262. /**
  84263. * Gets or sets bone length
  84264. */
  84265. length: number;
  84266. /**
  84267. * @hidden Internal only
  84268. * Set this value to map this bone to a different index in the transform matrices
  84269. * Set this value to -1 to exclude the bone from the transform matrices
  84270. */
  84271. _index: Nullable<number>;
  84272. private _skeleton;
  84273. private _localMatrix;
  84274. private _restPose;
  84275. private _baseMatrix;
  84276. private _absoluteTransform;
  84277. private _invertedAbsoluteTransform;
  84278. private _parent;
  84279. private _scalingDeterminant;
  84280. private _worldTransform;
  84281. private _localScaling;
  84282. private _localRotation;
  84283. private _localPosition;
  84284. private _needToDecompose;
  84285. private _needToCompose;
  84286. /** @hidden */
  84287. _linkedTransformNode: Nullable<TransformNode>;
  84288. /** @hidden */
  84289. _waitingTransformNodeId: Nullable<string>;
  84290. /** @hidden */
  84291. get _matrix(): Matrix;
  84292. /** @hidden */
  84293. set _matrix(value: Matrix);
  84294. /**
  84295. * Create a new bone
  84296. * @param name defines the bone name
  84297. * @param skeleton defines the parent skeleton
  84298. * @param parentBone defines the parent (can be null if the bone is the root)
  84299. * @param localMatrix defines the local matrix
  84300. * @param restPose defines the rest pose matrix
  84301. * @param baseMatrix defines the base matrix
  84302. * @param index defines index of the bone in the hiearchy
  84303. */
  84304. constructor(
  84305. /**
  84306. * defines the bone name
  84307. */
  84308. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84309. /**
  84310. * Gets the current object class name.
  84311. * @return the class name
  84312. */
  84313. getClassName(): string;
  84314. /**
  84315. * Gets the parent skeleton
  84316. * @returns a skeleton
  84317. */
  84318. getSkeleton(): Skeleton;
  84319. /**
  84320. * Gets parent bone
  84321. * @returns a bone or null if the bone is the root of the bone hierarchy
  84322. */
  84323. getParent(): Nullable<Bone>;
  84324. /**
  84325. * Returns an array containing the root bones
  84326. * @returns an array containing the root bones
  84327. */
  84328. getChildren(): Array<Bone>;
  84329. /**
  84330. * Gets the node index in matrix array generated for rendering
  84331. * @returns the node index
  84332. */
  84333. getIndex(): number;
  84334. /**
  84335. * Sets the parent bone
  84336. * @param parent defines the parent (can be null if the bone is the root)
  84337. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84338. */
  84339. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84340. /**
  84341. * Gets the local matrix
  84342. * @returns a matrix
  84343. */
  84344. getLocalMatrix(): Matrix;
  84345. /**
  84346. * Gets the base matrix (initial matrix which remains unchanged)
  84347. * @returns a matrix
  84348. */
  84349. getBaseMatrix(): Matrix;
  84350. /**
  84351. * Gets the rest pose matrix
  84352. * @returns a matrix
  84353. */
  84354. getRestPose(): Matrix;
  84355. /**
  84356. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84357. */
  84358. getWorldMatrix(): Matrix;
  84359. /**
  84360. * Sets the local matrix to rest pose matrix
  84361. */
  84362. returnToRest(): void;
  84363. /**
  84364. * Gets the inverse of the absolute transform matrix.
  84365. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84366. * @returns a matrix
  84367. */
  84368. getInvertedAbsoluteTransform(): Matrix;
  84369. /**
  84370. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84371. * @returns a matrix
  84372. */
  84373. getAbsoluteTransform(): Matrix;
  84374. /**
  84375. * Links with the given transform node.
  84376. * The local matrix of this bone is copied from the transform node every frame.
  84377. * @param transformNode defines the transform node to link to
  84378. */
  84379. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84380. /**
  84381. * Gets the node used to drive the bone's transformation
  84382. * @returns a transform node or null
  84383. */
  84384. getTransformNode(): Nullable<TransformNode>;
  84385. /** Gets or sets current position (in local space) */
  84386. get position(): Vector3;
  84387. set position(newPosition: Vector3);
  84388. /** Gets or sets current rotation (in local space) */
  84389. get rotation(): Vector3;
  84390. set rotation(newRotation: Vector3);
  84391. /** Gets or sets current rotation quaternion (in local space) */
  84392. get rotationQuaternion(): Quaternion;
  84393. set rotationQuaternion(newRotation: Quaternion);
  84394. /** Gets or sets current scaling (in local space) */
  84395. get scaling(): Vector3;
  84396. set scaling(newScaling: Vector3);
  84397. /**
  84398. * Gets the animation properties override
  84399. */
  84400. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84401. private _decompose;
  84402. private _compose;
  84403. /**
  84404. * Update the base and local matrices
  84405. * @param matrix defines the new base or local matrix
  84406. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84407. * @param updateLocalMatrix defines if the local matrix should be updated
  84408. */
  84409. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84410. /** @hidden */
  84411. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84412. /**
  84413. * Flag the bone as dirty (Forcing it to update everything)
  84414. */
  84415. markAsDirty(): void;
  84416. /** @hidden */
  84417. _markAsDirtyAndCompose(): void;
  84418. private _markAsDirtyAndDecompose;
  84419. /**
  84420. * Translate the bone in local or world space
  84421. * @param vec The amount to translate the bone
  84422. * @param space The space that the translation is in
  84423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84424. */
  84425. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84426. /**
  84427. * Set the postion of the bone in local or world space
  84428. * @param position The position to set the bone
  84429. * @param space The space that the position is in
  84430. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84431. */
  84432. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84433. /**
  84434. * Set the absolute position of the bone (world space)
  84435. * @param position The position to set the bone
  84436. * @param mesh The mesh that this bone is attached to
  84437. */
  84438. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84439. /**
  84440. * Scale the bone on the x, y and z axes (in local space)
  84441. * @param x The amount to scale the bone on the x axis
  84442. * @param y The amount to scale the bone on the y axis
  84443. * @param z The amount to scale the bone on the z axis
  84444. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84445. */
  84446. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84447. /**
  84448. * Set the bone scaling in local space
  84449. * @param scale defines the scaling vector
  84450. */
  84451. setScale(scale: Vector3): void;
  84452. /**
  84453. * Gets the current scaling in local space
  84454. * @returns the current scaling vector
  84455. */
  84456. getScale(): Vector3;
  84457. /**
  84458. * Gets the current scaling in local space and stores it in a target vector
  84459. * @param result defines the target vector
  84460. */
  84461. getScaleToRef(result: Vector3): void;
  84462. /**
  84463. * Set the yaw, pitch, and roll of the bone in local or world space
  84464. * @param yaw The rotation of the bone on the y axis
  84465. * @param pitch The rotation of the bone on the x axis
  84466. * @param roll The rotation of the bone on the z axis
  84467. * @param space The space that the axes of rotation are in
  84468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84469. */
  84470. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84471. /**
  84472. * Add a rotation to the bone on an axis in local or world space
  84473. * @param axis The axis to rotate the bone on
  84474. * @param amount The amount to rotate the bone
  84475. * @param space The space that the axis is in
  84476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84477. */
  84478. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84479. /**
  84480. * Set the rotation of the bone to a particular axis angle in local or world space
  84481. * @param axis The axis to rotate the bone on
  84482. * @param angle The angle that the bone should be rotated to
  84483. * @param space The space that the axis is in
  84484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84485. */
  84486. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84487. /**
  84488. * Set the euler rotation of the bone in local of world space
  84489. * @param rotation The euler rotation that the bone should be set to
  84490. * @param space The space that the rotation is in
  84491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84492. */
  84493. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84494. /**
  84495. * Set the quaternion rotation of the bone in local of world space
  84496. * @param quat The quaternion rotation that the bone should be set to
  84497. * @param space The space that the rotation is in
  84498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84499. */
  84500. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84501. /**
  84502. * Set the rotation matrix of the bone in local of world space
  84503. * @param rotMat The rotation matrix that the bone should be set to
  84504. * @param space The space that the rotation is in
  84505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84506. */
  84507. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84508. private _rotateWithMatrix;
  84509. private _getNegativeRotationToRef;
  84510. /**
  84511. * Get the position of the bone in local or world space
  84512. * @param space The space that the returned position is in
  84513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84514. * @returns The position of the bone
  84515. */
  84516. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84517. /**
  84518. * Copy the position of the bone to a vector3 in local or world space
  84519. * @param space The space that the returned position is in
  84520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84521. * @param result The vector3 to copy the position to
  84522. */
  84523. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84524. /**
  84525. * Get the absolute position of the bone (world space)
  84526. * @param mesh The mesh that this bone is attached to
  84527. * @returns The absolute position of the bone
  84528. */
  84529. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84530. /**
  84531. * Copy the absolute position of the bone (world space) to the result param
  84532. * @param mesh The mesh that this bone is attached to
  84533. * @param result The vector3 to copy the absolute position to
  84534. */
  84535. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84536. /**
  84537. * Compute the absolute transforms of this bone and its children
  84538. */
  84539. computeAbsoluteTransforms(): void;
  84540. /**
  84541. * Get the world direction from an axis that is in the local space of the bone
  84542. * @param localAxis The local direction that is used to compute the world direction
  84543. * @param mesh The mesh that this bone is attached to
  84544. * @returns The world direction
  84545. */
  84546. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84547. /**
  84548. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84549. * @param localAxis The local direction that is used to compute the world direction
  84550. * @param mesh The mesh that this bone is attached to
  84551. * @param result The vector3 that the world direction will be copied to
  84552. */
  84553. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84554. /**
  84555. * Get the euler rotation of the bone in local or world space
  84556. * @param space The space that the rotation should be in
  84557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84558. * @returns The euler rotation
  84559. */
  84560. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84561. /**
  84562. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84563. * @param space The space that the rotation should be in
  84564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84565. * @param result The vector3 that the rotation should be copied to
  84566. */
  84567. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84568. /**
  84569. * Get the quaternion rotation of the bone in either local or world space
  84570. * @param space The space that the rotation should be in
  84571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84572. * @returns The quaternion rotation
  84573. */
  84574. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84575. /**
  84576. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84577. * @param space The space that the rotation should be in
  84578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84579. * @param result The quaternion that the rotation should be copied to
  84580. */
  84581. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84582. /**
  84583. * Get the rotation matrix of the bone in local or world space
  84584. * @param space The space that the rotation should be in
  84585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84586. * @returns The rotation matrix
  84587. */
  84588. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84589. /**
  84590. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84591. * @param space The space that the rotation should be in
  84592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84593. * @param result The quaternion that the rotation should be copied to
  84594. */
  84595. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84596. /**
  84597. * Get the world position of a point that is in the local space of the bone
  84598. * @param position The local position
  84599. * @param mesh The mesh that this bone is attached to
  84600. * @returns The world position
  84601. */
  84602. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84603. /**
  84604. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84605. * @param position The local position
  84606. * @param mesh The mesh that this bone is attached to
  84607. * @param result The vector3 that the world position should be copied to
  84608. */
  84609. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84610. /**
  84611. * Get the local position of a point that is in world space
  84612. * @param position The world position
  84613. * @param mesh The mesh that this bone is attached to
  84614. * @returns The local position
  84615. */
  84616. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84617. /**
  84618. * Get the local position of a point that is in world space and copy it to the result param
  84619. * @param position The world position
  84620. * @param mesh The mesh that this bone is attached to
  84621. * @param result The vector3 that the local position should be copied to
  84622. */
  84623. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84624. }
  84625. }
  84626. declare module BABYLON {
  84627. /**
  84628. * 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.
  84629. * @see https://doc.babylonjs.com/how_to/transformnode
  84630. */
  84631. export class TransformNode extends Node {
  84632. /**
  84633. * Object will not rotate to face the camera
  84634. */
  84635. static BILLBOARDMODE_NONE: number;
  84636. /**
  84637. * Object will rotate to face the camera but only on the x axis
  84638. */
  84639. static BILLBOARDMODE_X: number;
  84640. /**
  84641. * Object will rotate to face the camera but only on the y axis
  84642. */
  84643. static BILLBOARDMODE_Y: number;
  84644. /**
  84645. * Object will rotate to face the camera but only on the z axis
  84646. */
  84647. static BILLBOARDMODE_Z: number;
  84648. /**
  84649. * Object will rotate to face the camera
  84650. */
  84651. static BILLBOARDMODE_ALL: number;
  84652. /**
  84653. * Object will rotate to face the camera's position instead of orientation
  84654. */
  84655. static BILLBOARDMODE_USE_POSITION: number;
  84656. private _forward;
  84657. private _forwardInverted;
  84658. private _up;
  84659. private _right;
  84660. private _rightInverted;
  84661. private _position;
  84662. private _rotation;
  84663. private _rotationQuaternion;
  84664. protected _scaling: Vector3;
  84665. protected _isDirty: boolean;
  84666. private _transformToBoneReferal;
  84667. private _isAbsoluteSynced;
  84668. private _billboardMode;
  84669. /**
  84670. * Gets or sets the billboard mode. Default is 0.
  84671. *
  84672. * | Value | Type | Description |
  84673. * | --- | --- | --- |
  84674. * | 0 | BILLBOARDMODE_NONE | |
  84675. * | 1 | BILLBOARDMODE_X | |
  84676. * | 2 | BILLBOARDMODE_Y | |
  84677. * | 4 | BILLBOARDMODE_Z | |
  84678. * | 7 | BILLBOARDMODE_ALL | |
  84679. *
  84680. */
  84681. get billboardMode(): number;
  84682. set billboardMode(value: number);
  84683. private _preserveParentRotationForBillboard;
  84684. /**
  84685. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84686. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84687. */
  84688. get preserveParentRotationForBillboard(): boolean;
  84689. set preserveParentRotationForBillboard(value: boolean);
  84690. /**
  84691. * 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
  84692. */
  84693. scalingDeterminant: number;
  84694. private _infiniteDistance;
  84695. /**
  84696. * Gets or sets the distance of the object to max, often used by skybox
  84697. */
  84698. get infiniteDistance(): boolean;
  84699. set infiniteDistance(value: boolean);
  84700. /**
  84701. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84702. * By default the system will update normals to compensate
  84703. */
  84704. ignoreNonUniformScaling: boolean;
  84705. /**
  84706. * 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
  84707. */
  84708. reIntegrateRotationIntoRotationQuaternion: boolean;
  84709. /** @hidden */
  84710. _poseMatrix: Nullable<Matrix>;
  84711. /** @hidden */
  84712. _localMatrix: Matrix;
  84713. private _usePivotMatrix;
  84714. private _absolutePosition;
  84715. private _absoluteScaling;
  84716. private _absoluteRotationQuaternion;
  84717. private _pivotMatrix;
  84718. private _pivotMatrixInverse;
  84719. protected _postMultiplyPivotMatrix: boolean;
  84720. protected _isWorldMatrixFrozen: boolean;
  84721. /** @hidden */
  84722. _indexInSceneTransformNodesArray: number;
  84723. /**
  84724. * An event triggered after the world matrix is updated
  84725. */
  84726. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84727. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84728. /**
  84729. * Gets a string identifying the name of the class
  84730. * @returns "TransformNode" string
  84731. */
  84732. getClassName(): string;
  84733. /**
  84734. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84735. */
  84736. get position(): Vector3;
  84737. set position(newPosition: Vector3);
  84738. /**
  84739. * 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)).
  84740. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84741. */
  84742. get rotation(): Vector3;
  84743. set rotation(newRotation: Vector3);
  84744. /**
  84745. * 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)).
  84746. */
  84747. get scaling(): Vector3;
  84748. set scaling(newScaling: Vector3);
  84749. /**
  84750. * 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).
  84751. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84752. */
  84753. get rotationQuaternion(): Nullable<Quaternion>;
  84754. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84755. /**
  84756. * The forward direction of that transform in world space.
  84757. */
  84758. get forward(): Vector3;
  84759. /**
  84760. * The up direction of that transform in world space.
  84761. */
  84762. get up(): Vector3;
  84763. /**
  84764. * The right direction of that transform in world space.
  84765. */
  84766. get right(): Vector3;
  84767. /**
  84768. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84769. * @param matrix the matrix to copy the pose from
  84770. * @returns this TransformNode.
  84771. */
  84772. updatePoseMatrix(matrix: Matrix): TransformNode;
  84773. /**
  84774. * Returns the mesh Pose matrix.
  84775. * @returns the pose matrix
  84776. */
  84777. getPoseMatrix(): Matrix;
  84778. /** @hidden */
  84779. _isSynchronized(): boolean;
  84780. /** @hidden */
  84781. _initCache(): void;
  84782. /**
  84783. * Flag the transform node as dirty (Forcing it to update everything)
  84784. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84785. * @returns this transform node
  84786. */
  84787. markAsDirty(property: string): TransformNode;
  84788. /**
  84789. * Returns the current mesh absolute position.
  84790. * Returns a Vector3.
  84791. */
  84792. get absolutePosition(): Vector3;
  84793. /**
  84794. * Returns the current mesh absolute scaling.
  84795. * Returns a Vector3.
  84796. */
  84797. get absoluteScaling(): Vector3;
  84798. /**
  84799. * Returns the current mesh absolute rotation.
  84800. * Returns a Quaternion.
  84801. */
  84802. get absoluteRotationQuaternion(): Quaternion;
  84803. /**
  84804. * Sets a new matrix to apply before all other transformation
  84805. * @param matrix defines the transform matrix
  84806. * @returns the current TransformNode
  84807. */
  84808. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84809. /**
  84810. * Sets a new pivot matrix to the current node
  84811. * @param matrix defines the new pivot matrix to use
  84812. * @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
  84813. * @returns the current TransformNode
  84814. */
  84815. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84816. /**
  84817. * Returns the mesh pivot matrix.
  84818. * Default : Identity.
  84819. * @returns the matrix
  84820. */
  84821. getPivotMatrix(): Matrix;
  84822. /**
  84823. * Instantiate (when possible) or clone that node with its hierarchy
  84824. * @param newParent defines the new parent to use for the instance (or clone)
  84825. * @param options defines options to configure how copy is done
  84826. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84827. * @returns an instance (or a clone) of the current node with its hiearchy
  84828. */
  84829. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84830. doNotInstantiate: boolean;
  84831. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84832. /**
  84833. * Prevents the World matrix to be computed any longer
  84834. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84835. * @returns the TransformNode.
  84836. */
  84837. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84838. /**
  84839. * Allows back the World matrix computation.
  84840. * @returns the TransformNode.
  84841. */
  84842. unfreezeWorldMatrix(): this;
  84843. /**
  84844. * True if the World matrix has been frozen.
  84845. */
  84846. get isWorldMatrixFrozen(): boolean;
  84847. /**
  84848. * Retuns the mesh absolute position in the World.
  84849. * @returns a Vector3.
  84850. */
  84851. getAbsolutePosition(): Vector3;
  84852. /**
  84853. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84854. * @param absolutePosition the absolute position to set
  84855. * @returns the TransformNode.
  84856. */
  84857. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84858. /**
  84859. * Sets the mesh position in its local space.
  84860. * @param vector3 the position to set in localspace
  84861. * @returns the TransformNode.
  84862. */
  84863. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84864. /**
  84865. * Returns the mesh position in the local space from the current World matrix values.
  84866. * @returns a new Vector3.
  84867. */
  84868. getPositionExpressedInLocalSpace(): Vector3;
  84869. /**
  84870. * Translates the mesh along the passed Vector3 in its local space.
  84871. * @param vector3 the distance to translate in localspace
  84872. * @returns the TransformNode.
  84873. */
  84874. locallyTranslate(vector3: Vector3): TransformNode;
  84875. private static _lookAtVectorCache;
  84876. /**
  84877. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84878. * @param targetPoint the position (must be in same space as current mesh) to look at
  84879. * @param yawCor optional yaw (y-axis) correction in radians
  84880. * @param pitchCor optional pitch (x-axis) correction in radians
  84881. * @param rollCor optional roll (z-axis) correction in radians
  84882. * @param space the choosen space of the target
  84883. * @returns the TransformNode.
  84884. */
  84885. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84886. /**
  84887. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84888. * This Vector3 is expressed in the World space.
  84889. * @param localAxis axis to rotate
  84890. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84891. */
  84892. getDirection(localAxis: Vector3): Vector3;
  84893. /**
  84894. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84895. * localAxis is expressed in the mesh local space.
  84896. * result is computed in the Wordl space from the mesh World matrix.
  84897. * @param localAxis axis to rotate
  84898. * @param result the resulting transformnode
  84899. * @returns this TransformNode.
  84900. */
  84901. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84902. /**
  84903. * Sets this transform node rotation to the given local axis.
  84904. * @param localAxis the axis in local space
  84905. * @param yawCor optional yaw (y-axis) correction in radians
  84906. * @param pitchCor optional pitch (x-axis) correction in radians
  84907. * @param rollCor optional roll (z-axis) correction in radians
  84908. * @returns this TransformNode
  84909. */
  84910. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  84911. /**
  84912. * Sets a new pivot point to the current node
  84913. * @param point defines the new pivot point to use
  84914. * @param space defines if the point is in world or local space (local by default)
  84915. * @returns the current TransformNode
  84916. */
  84917. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  84918. /**
  84919. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  84920. * @returns the pivot point
  84921. */
  84922. getPivotPoint(): Vector3;
  84923. /**
  84924. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  84925. * @param result the vector3 to store the result
  84926. * @returns this TransformNode.
  84927. */
  84928. getPivotPointToRef(result: Vector3): TransformNode;
  84929. /**
  84930. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  84931. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  84932. */
  84933. getAbsolutePivotPoint(): Vector3;
  84934. /**
  84935. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  84936. * @param result vector3 to store the result
  84937. * @returns this TransformNode.
  84938. */
  84939. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  84940. /**
  84941. * Defines the passed node as the parent of the current node.
  84942. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  84943. * @see https://doc.babylonjs.com/how_to/parenting
  84944. * @param node the node ot set as the parent
  84945. * @returns this TransformNode.
  84946. */
  84947. setParent(node: Nullable<Node>): TransformNode;
  84948. private _nonUniformScaling;
  84949. /**
  84950. * True if the scaling property of this object is non uniform eg. (1,2,1)
  84951. */
  84952. get nonUniformScaling(): boolean;
  84953. /** @hidden */
  84954. _updateNonUniformScalingState(value: boolean): boolean;
  84955. /**
  84956. * Attach the current TransformNode to another TransformNode associated with a bone
  84957. * @param bone Bone affecting the TransformNode
  84958. * @param affectedTransformNode TransformNode associated with the bone
  84959. * @returns this object
  84960. */
  84961. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  84962. /**
  84963. * Detach the transform node if its associated with a bone
  84964. * @returns this object
  84965. */
  84966. detachFromBone(): TransformNode;
  84967. private static _rotationAxisCache;
  84968. /**
  84969. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  84970. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84971. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84972. * The passed axis is also normalized.
  84973. * @param axis the axis to rotate around
  84974. * @param amount the amount to rotate in radians
  84975. * @param space Space to rotate in (Default: local)
  84976. * @returns the TransformNode.
  84977. */
  84978. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  84979. /**
  84980. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  84981. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84982. * The passed axis is also normalized. .
  84983. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  84984. * @param point the point to rotate around
  84985. * @param axis the axis to rotate around
  84986. * @param amount the amount to rotate in radians
  84987. * @returns the TransformNode
  84988. */
  84989. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  84990. /**
  84991. * Translates the mesh along the axis vector for the passed distance in the given space.
  84992. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84993. * @param axis the axis to translate in
  84994. * @param distance the distance to translate
  84995. * @param space Space to rotate in (Default: local)
  84996. * @returns the TransformNode.
  84997. */
  84998. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  84999. /**
  85000. * Adds a rotation step to the mesh current rotation.
  85001. * x, y, z are Euler angles expressed in radians.
  85002. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85003. * This means this rotation is made in the mesh local space only.
  85004. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85005. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85006. * ```javascript
  85007. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85008. * ```
  85009. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85010. * 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.
  85011. * @param x Rotation to add
  85012. * @param y Rotation to add
  85013. * @param z Rotation to add
  85014. * @returns the TransformNode.
  85015. */
  85016. addRotation(x: number, y: number, z: number): TransformNode;
  85017. /**
  85018. * @hidden
  85019. */
  85020. protected _getEffectiveParent(): Nullable<Node>;
  85021. /**
  85022. * Computes the world matrix of the node
  85023. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85024. * @returns the world matrix
  85025. */
  85026. computeWorldMatrix(force?: boolean): Matrix;
  85027. protected _afterComputeWorldMatrix(): void;
  85028. /**
  85029. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85030. * @param func callback function to add
  85031. *
  85032. * @returns the TransformNode.
  85033. */
  85034. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85035. /**
  85036. * Removes a registered callback function.
  85037. * @param func callback function to remove
  85038. * @returns the TransformNode.
  85039. */
  85040. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85041. /**
  85042. * Gets the position of the current mesh in camera space
  85043. * @param camera defines the camera to use
  85044. * @returns a position
  85045. */
  85046. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85047. /**
  85048. * Returns the distance from the mesh to the active camera
  85049. * @param camera defines the camera to use
  85050. * @returns the distance
  85051. */
  85052. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85053. /**
  85054. * Clone the current transform node
  85055. * @param name Name of the new clone
  85056. * @param newParent New parent for the clone
  85057. * @param doNotCloneChildren Do not clone children hierarchy
  85058. * @returns the new transform node
  85059. */
  85060. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85061. /**
  85062. * Serializes the objects information.
  85063. * @param currentSerializationObject defines the object to serialize in
  85064. * @returns the serialized object
  85065. */
  85066. serialize(currentSerializationObject?: any): any;
  85067. /**
  85068. * Returns a new TransformNode object parsed from the source provided.
  85069. * @param parsedTransformNode is the source.
  85070. * @param scene the scne the object belongs to
  85071. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85072. * @returns a new TransformNode object parsed from the source provided.
  85073. */
  85074. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85075. /**
  85076. * Get all child-transformNodes of this node
  85077. * @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
  85078. * @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
  85079. * @returns an array of TransformNode
  85080. */
  85081. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85082. /**
  85083. * Releases resources associated with this transform node.
  85084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85086. */
  85087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85088. /**
  85089. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85090. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85091. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85092. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85093. * @returns the current mesh
  85094. */
  85095. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85096. private _syncAbsoluteScalingAndRotation;
  85097. }
  85098. }
  85099. declare module BABYLON {
  85100. /**
  85101. * Defines the types of pose enabled controllers that are supported
  85102. */
  85103. export enum PoseEnabledControllerType {
  85104. /**
  85105. * HTC Vive
  85106. */
  85107. VIVE = 0,
  85108. /**
  85109. * Oculus Rift
  85110. */
  85111. OCULUS = 1,
  85112. /**
  85113. * Windows mixed reality
  85114. */
  85115. WINDOWS = 2,
  85116. /**
  85117. * Samsung gear VR
  85118. */
  85119. GEAR_VR = 3,
  85120. /**
  85121. * Google Daydream
  85122. */
  85123. DAYDREAM = 4,
  85124. /**
  85125. * Generic
  85126. */
  85127. GENERIC = 5
  85128. }
  85129. /**
  85130. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85131. */
  85132. export interface MutableGamepadButton {
  85133. /**
  85134. * Value of the button/trigger
  85135. */
  85136. value: number;
  85137. /**
  85138. * If the button/trigger is currently touched
  85139. */
  85140. touched: boolean;
  85141. /**
  85142. * If the button/trigger is currently pressed
  85143. */
  85144. pressed: boolean;
  85145. }
  85146. /**
  85147. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85148. * @hidden
  85149. */
  85150. export interface ExtendedGamepadButton extends GamepadButton {
  85151. /**
  85152. * If the button/trigger is currently pressed
  85153. */
  85154. readonly pressed: boolean;
  85155. /**
  85156. * If the button/trigger is currently touched
  85157. */
  85158. readonly touched: boolean;
  85159. /**
  85160. * Value of the button/trigger
  85161. */
  85162. readonly value: number;
  85163. }
  85164. /** @hidden */
  85165. export interface _GamePadFactory {
  85166. /**
  85167. * Returns wether or not the current gamepad can be created for this type of controller.
  85168. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85169. * @returns true if it can be created, otherwise false
  85170. */
  85171. canCreate(gamepadInfo: any): boolean;
  85172. /**
  85173. * Creates a new instance of the Gamepad.
  85174. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85175. * @returns the new gamepad instance
  85176. */
  85177. create(gamepadInfo: any): Gamepad;
  85178. }
  85179. /**
  85180. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85181. */
  85182. export class PoseEnabledControllerHelper {
  85183. /** @hidden */
  85184. static _ControllerFactories: _GamePadFactory[];
  85185. /** @hidden */
  85186. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85187. /**
  85188. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85189. * @param vrGamepad the gamepad to initialized
  85190. * @returns a vr controller of the type the gamepad identified as
  85191. */
  85192. static InitiateController(vrGamepad: any): Gamepad;
  85193. }
  85194. /**
  85195. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85196. */
  85197. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85198. /**
  85199. * If the controller is used in a webXR session
  85200. */
  85201. isXR: boolean;
  85202. private _deviceRoomPosition;
  85203. private _deviceRoomRotationQuaternion;
  85204. /**
  85205. * The device position in babylon space
  85206. */
  85207. devicePosition: Vector3;
  85208. /**
  85209. * The device rotation in babylon space
  85210. */
  85211. deviceRotationQuaternion: Quaternion;
  85212. /**
  85213. * The scale factor of the device in babylon space
  85214. */
  85215. deviceScaleFactor: number;
  85216. /**
  85217. * (Likely devicePosition should be used instead) The device position in its room space
  85218. */
  85219. position: Vector3;
  85220. /**
  85221. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85222. */
  85223. rotationQuaternion: Quaternion;
  85224. /**
  85225. * The type of controller (Eg. Windows mixed reality)
  85226. */
  85227. controllerType: PoseEnabledControllerType;
  85228. protected _calculatedPosition: Vector3;
  85229. private _calculatedRotation;
  85230. /**
  85231. * The raw pose from the device
  85232. */
  85233. rawPose: DevicePose;
  85234. private _trackPosition;
  85235. private _maxRotationDistFromHeadset;
  85236. private _draggedRoomRotation;
  85237. /**
  85238. * @hidden
  85239. */
  85240. _disableTrackPosition(fixedPosition: Vector3): void;
  85241. /**
  85242. * Internal, the mesh attached to the controller
  85243. * @hidden
  85244. */
  85245. _mesh: Nullable<AbstractMesh>;
  85246. private _poseControlledCamera;
  85247. private _leftHandSystemQuaternion;
  85248. /**
  85249. * Internal, matrix used to convert room space to babylon space
  85250. * @hidden
  85251. */
  85252. _deviceToWorld: Matrix;
  85253. /**
  85254. * Node to be used when casting a ray from the controller
  85255. * @hidden
  85256. */
  85257. _pointingPoseNode: Nullable<TransformNode>;
  85258. /**
  85259. * Name of the child mesh that can be used to cast a ray from the controller
  85260. */
  85261. static readonly POINTING_POSE: string;
  85262. /**
  85263. * Creates a new PoseEnabledController from a gamepad
  85264. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85265. */
  85266. constructor(browserGamepad: any);
  85267. private _workingMatrix;
  85268. /**
  85269. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85270. */
  85271. update(): void;
  85272. /**
  85273. * Updates only the pose device and mesh without doing any button event checking
  85274. */
  85275. protected _updatePoseAndMesh(): void;
  85276. /**
  85277. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85278. * @param poseData raw pose fromthe device
  85279. */
  85280. updateFromDevice(poseData: DevicePose): void;
  85281. /**
  85282. * @hidden
  85283. */
  85284. _meshAttachedObservable: Observable<AbstractMesh>;
  85285. /**
  85286. * Attaches a mesh to the controller
  85287. * @param mesh the mesh to be attached
  85288. */
  85289. attachToMesh(mesh: AbstractMesh): void;
  85290. /**
  85291. * Attaches the controllers mesh to a camera
  85292. * @param camera the camera the mesh should be attached to
  85293. */
  85294. attachToPoseControlledCamera(camera: TargetCamera): void;
  85295. /**
  85296. * Disposes of the controller
  85297. */
  85298. dispose(): void;
  85299. /**
  85300. * The mesh that is attached to the controller
  85301. */
  85302. get mesh(): Nullable<AbstractMesh>;
  85303. /**
  85304. * Gets the ray of the controller in the direction the controller is pointing
  85305. * @param length the length the resulting ray should be
  85306. * @returns a ray in the direction the controller is pointing
  85307. */
  85308. getForwardRay(length?: number): Ray;
  85309. }
  85310. }
  85311. declare module BABYLON {
  85312. /**
  85313. * Defines the WebVRController object that represents controllers tracked in 3D space
  85314. */
  85315. export abstract class WebVRController extends PoseEnabledController {
  85316. /**
  85317. * Internal, the default controller model for the controller
  85318. */
  85319. protected _defaultModel: Nullable<AbstractMesh>;
  85320. /**
  85321. * Fired when the trigger state has changed
  85322. */
  85323. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85324. /**
  85325. * Fired when the main button state has changed
  85326. */
  85327. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85328. /**
  85329. * Fired when the secondary button state has changed
  85330. */
  85331. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85332. /**
  85333. * Fired when the pad state has changed
  85334. */
  85335. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85336. /**
  85337. * Fired when controllers stick values have changed
  85338. */
  85339. onPadValuesChangedObservable: Observable<StickValues>;
  85340. /**
  85341. * Array of button availible on the controller
  85342. */
  85343. protected _buttons: Array<MutableGamepadButton>;
  85344. private _onButtonStateChange;
  85345. /**
  85346. * Fired when a controller button's state has changed
  85347. * @param callback the callback containing the button that was modified
  85348. */
  85349. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85350. /**
  85351. * X and Y axis corresponding to the controllers joystick
  85352. */
  85353. pad: StickValues;
  85354. /**
  85355. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85356. */
  85357. hand: string;
  85358. /**
  85359. * The default controller model for the controller
  85360. */
  85361. get defaultModel(): Nullable<AbstractMesh>;
  85362. /**
  85363. * Creates a new WebVRController from a gamepad
  85364. * @param vrGamepad the gamepad that the WebVRController should be created from
  85365. */
  85366. constructor(vrGamepad: any);
  85367. /**
  85368. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85369. */
  85370. update(): void;
  85371. /**
  85372. * Function to be called when a button is modified
  85373. */
  85374. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85375. /**
  85376. * Loads a mesh and attaches it to the controller
  85377. * @param scene the scene the mesh should be added to
  85378. * @param meshLoaded callback for when the mesh has been loaded
  85379. */
  85380. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85381. private _setButtonValue;
  85382. private _changes;
  85383. private _checkChanges;
  85384. /**
  85385. * Disposes of th webVRCOntroller
  85386. */
  85387. dispose(): void;
  85388. }
  85389. }
  85390. declare module BABYLON {
  85391. /**
  85392. * The HemisphericLight simulates the ambient environment light,
  85393. * so the passed direction is the light reflection direction, not the incoming direction.
  85394. */
  85395. export class HemisphericLight extends Light {
  85396. /**
  85397. * The groundColor is the light in the opposite direction to the one specified during creation.
  85398. * 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.
  85399. */
  85400. groundColor: Color3;
  85401. /**
  85402. * The light reflection direction, not the incoming direction.
  85403. */
  85404. direction: Vector3;
  85405. /**
  85406. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85407. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85408. * The HemisphericLight can't cast shadows.
  85409. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85410. * @param name The friendly name of the light
  85411. * @param direction The direction of the light reflection
  85412. * @param scene The scene the light belongs to
  85413. */
  85414. constructor(name: string, direction: Vector3, scene: Scene);
  85415. protected _buildUniformLayout(): void;
  85416. /**
  85417. * Returns the string "HemisphericLight".
  85418. * @return The class name
  85419. */
  85420. getClassName(): string;
  85421. /**
  85422. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85423. * Returns the updated direction.
  85424. * @param target The target the direction should point to
  85425. * @return The computed direction
  85426. */
  85427. setDirectionToTarget(target: Vector3): Vector3;
  85428. /**
  85429. * Returns the shadow generator associated to the light.
  85430. * @returns Always null for hemispheric lights because it does not support shadows.
  85431. */
  85432. getShadowGenerator(): Nullable<IShadowGenerator>;
  85433. /**
  85434. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85435. * @param effect The effect to update
  85436. * @param lightIndex The index of the light in the effect to update
  85437. * @returns The hemispheric light
  85438. */
  85439. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85440. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85441. /**
  85442. * Computes the world matrix of the node
  85443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85444. * @param useWasUpdatedFlag defines a reserved property
  85445. * @returns the world matrix
  85446. */
  85447. computeWorldMatrix(): Matrix;
  85448. /**
  85449. * Returns the integer 3.
  85450. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85451. */
  85452. getTypeID(): number;
  85453. /**
  85454. * Prepares the list of defines specific to the light type.
  85455. * @param defines the list of defines
  85456. * @param lightIndex defines the index of the light for the effect
  85457. */
  85458. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85459. }
  85460. }
  85461. declare module BABYLON {
  85462. /** @hidden */
  85463. export var vrMultiviewToSingleviewPixelShader: {
  85464. name: string;
  85465. shader: string;
  85466. };
  85467. }
  85468. declare module BABYLON {
  85469. /**
  85470. * Renders to multiple views with a single draw call
  85471. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85472. */
  85473. export class MultiviewRenderTarget extends RenderTargetTexture {
  85474. /**
  85475. * Creates a multiview render target
  85476. * @param scene scene used with the render target
  85477. * @param size the size of the render target (used for each view)
  85478. */
  85479. constructor(scene: Scene, size?: number | {
  85480. width: number;
  85481. height: number;
  85482. } | {
  85483. ratio: number;
  85484. });
  85485. /**
  85486. * @hidden
  85487. * @param faceIndex the face index, if its a cube texture
  85488. */
  85489. _bindFrameBuffer(faceIndex?: number): void;
  85490. /**
  85491. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85492. * @returns the view count
  85493. */
  85494. getViewCount(): number;
  85495. }
  85496. }
  85497. declare module BABYLON {
  85498. /**
  85499. * Represents a camera frustum
  85500. */
  85501. export class Frustum {
  85502. /**
  85503. * Gets the planes representing the frustum
  85504. * @param transform matrix to be applied to the returned planes
  85505. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85506. */
  85507. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85508. /**
  85509. * Gets the near frustum plane transformed by the transform matrix
  85510. * @param transform transformation matrix to be applied to the resulting frustum plane
  85511. * @param frustumPlane the resuling frustum plane
  85512. */
  85513. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85514. /**
  85515. * Gets the far frustum plane transformed by the transform matrix
  85516. * @param transform transformation matrix to be applied to the resulting frustum plane
  85517. * @param frustumPlane the resuling frustum plane
  85518. */
  85519. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85520. /**
  85521. * Gets the left frustum plane transformed by the transform matrix
  85522. * @param transform transformation matrix to be applied to the resulting frustum plane
  85523. * @param frustumPlane the resuling frustum plane
  85524. */
  85525. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85526. /**
  85527. * Gets the right frustum plane transformed by the transform matrix
  85528. * @param transform transformation matrix to be applied to the resulting frustum plane
  85529. * @param frustumPlane the resuling frustum plane
  85530. */
  85531. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85532. /**
  85533. * Gets the top frustum plane transformed by the transform matrix
  85534. * @param transform transformation matrix to be applied to the resulting frustum plane
  85535. * @param frustumPlane the resuling frustum plane
  85536. */
  85537. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85538. /**
  85539. * Gets the bottom frustum plane transformed by the transform matrix
  85540. * @param transform transformation matrix to be applied to the resulting frustum plane
  85541. * @param frustumPlane the resuling frustum plane
  85542. */
  85543. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85544. /**
  85545. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85546. * @param transform transformation matrix to be applied to the resulting frustum planes
  85547. * @param frustumPlanes the resuling frustum planes
  85548. */
  85549. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85550. }
  85551. }
  85552. declare module BABYLON {
  85553. interface Engine {
  85554. /**
  85555. * Creates a new multiview render target
  85556. * @param width defines the width of the texture
  85557. * @param height defines the height of the texture
  85558. * @returns the created multiview texture
  85559. */
  85560. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85561. /**
  85562. * Binds a multiview framebuffer to be drawn to
  85563. * @param multiviewTexture texture to bind
  85564. */
  85565. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85566. }
  85567. interface Camera {
  85568. /**
  85569. * @hidden
  85570. * 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)
  85571. */
  85572. _useMultiviewToSingleView: boolean;
  85573. /**
  85574. * @hidden
  85575. * 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)
  85576. */
  85577. _multiviewTexture: Nullable<RenderTargetTexture>;
  85578. /**
  85579. * @hidden
  85580. * ensures the multiview texture of the camera exists and has the specified width/height
  85581. * @param width height to set on the multiview texture
  85582. * @param height width to set on the multiview texture
  85583. */
  85584. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85585. }
  85586. interface Scene {
  85587. /** @hidden */
  85588. _transformMatrixR: Matrix;
  85589. /** @hidden */
  85590. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85591. /** @hidden */
  85592. _createMultiviewUbo(): void;
  85593. /** @hidden */
  85594. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85595. /** @hidden */
  85596. _renderMultiviewToSingleView(camera: Camera): void;
  85597. }
  85598. }
  85599. declare module BABYLON {
  85600. /**
  85601. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85602. * This will not be used for webXR as it supports displaying texture arrays directly
  85603. */
  85604. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85605. /**
  85606. * Initializes a VRMultiviewToSingleview
  85607. * @param name name of the post process
  85608. * @param camera camera to be applied to
  85609. * @param scaleFactor scaling factor to the size of the output texture
  85610. */
  85611. constructor(name: string, camera: Camera, scaleFactor: number);
  85612. }
  85613. }
  85614. declare module BABYLON {
  85615. /**
  85616. * Interface used to define additional presentation attributes
  85617. */
  85618. export interface IVRPresentationAttributes {
  85619. /**
  85620. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85621. */
  85622. highRefreshRate: boolean;
  85623. /**
  85624. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85625. */
  85626. foveationLevel: number;
  85627. }
  85628. interface Engine {
  85629. /** @hidden */
  85630. _vrDisplay: any;
  85631. /** @hidden */
  85632. _vrSupported: boolean;
  85633. /** @hidden */
  85634. _oldSize: Size;
  85635. /** @hidden */
  85636. _oldHardwareScaleFactor: number;
  85637. /** @hidden */
  85638. _vrExclusivePointerMode: boolean;
  85639. /** @hidden */
  85640. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85641. /** @hidden */
  85642. _onVRDisplayPointerRestricted: () => void;
  85643. /** @hidden */
  85644. _onVRDisplayPointerUnrestricted: () => void;
  85645. /** @hidden */
  85646. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85647. /** @hidden */
  85648. _onVrDisplayDisconnect: Nullable<() => void>;
  85649. /** @hidden */
  85650. _onVrDisplayPresentChange: Nullable<() => void>;
  85651. /**
  85652. * Observable signaled when VR display mode changes
  85653. */
  85654. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85655. /**
  85656. * Observable signaled when VR request present is complete
  85657. */
  85658. onVRRequestPresentComplete: Observable<boolean>;
  85659. /**
  85660. * Observable signaled when VR request present starts
  85661. */
  85662. onVRRequestPresentStart: Observable<Engine>;
  85663. /**
  85664. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85665. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85666. */
  85667. isInVRExclusivePointerMode: boolean;
  85668. /**
  85669. * Gets a boolean indicating if a webVR device was detected
  85670. * @returns true if a webVR device was detected
  85671. */
  85672. isVRDevicePresent(): boolean;
  85673. /**
  85674. * Gets the current webVR device
  85675. * @returns the current webVR device (or null)
  85676. */
  85677. getVRDevice(): any;
  85678. /**
  85679. * Initializes a webVR display and starts listening to display change events
  85680. * The onVRDisplayChangedObservable will be notified upon these changes
  85681. * @returns A promise containing a VRDisplay and if vr is supported
  85682. */
  85683. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85684. /** @hidden */
  85685. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85686. /**
  85687. * Gets or sets the presentation attributes used to configure VR rendering
  85688. */
  85689. vrPresentationAttributes?: IVRPresentationAttributes;
  85690. /**
  85691. * Call this function to switch to webVR mode
  85692. * Will do nothing if webVR is not supported or if there is no webVR device
  85693. * @param options the webvr options provided to the camera. mainly used for multiview
  85694. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85695. */
  85696. enableVR(options: WebVROptions): void;
  85697. /** @hidden */
  85698. _onVRFullScreenTriggered(): void;
  85699. }
  85700. }
  85701. declare module BABYLON {
  85702. /**
  85703. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85704. * IMPORTANT!! The data is right-hand data.
  85705. * @export
  85706. * @interface DevicePose
  85707. */
  85708. export interface DevicePose {
  85709. /**
  85710. * The position of the device, values in array are [x,y,z].
  85711. */
  85712. readonly position: Nullable<Float32Array>;
  85713. /**
  85714. * The linearVelocity of the device, values in array are [x,y,z].
  85715. */
  85716. readonly linearVelocity: Nullable<Float32Array>;
  85717. /**
  85718. * The linearAcceleration of the device, values in array are [x,y,z].
  85719. */
  85720. readonly linearAcceleration: Nullable<Float32Array>;
  85721. /**
  85722. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85723. */
  85724. readonly orientation: Nullable<Float32Array>;
  85725. /**
  85726. * The angularVelocity of the device, values in array are [x,y,z].
  85727. */
  85728. readonly angularVelocity: Nullable<Float32Array>;
  85729. /**
  85730. * The angularAcceleration of the device, values in array are [x,y,z].
  85731. */
  85732. readonly angularAcceleration: Nullable<Float32Array>;
  85733. }
  85734. /**
  85735. * Interface representing a pose controlled object in Babylon.
  85736. * A pose controlled object has both regular pose values as well as pose values
  85737. * from an external device such as a VR head mounted display
  85738. */
  85739. export interface PoseControlled {
  85740. /**
  85741. * The position of the object in babylon space.
  85742. */
  85743. position: Vector3;
  85744. /**
  85745. * The rotation quaternion of the object in babylon space.
  85746. */
  85747. rotationQuaternion: Quaternion;
  85748. /**
  85749. * The position of the device in babylon space.
  85750. */
  85751. devicePosition?: Vector3;
  85752. /**
  85753. * The rotation quaternion of the device in babylon space.
  85754. */
  85755. deviceRotationQuaternion: Quaternion;
  85756. /**
  85757. * The raw pose coming from the device.
  85758. */
  85759. rawPose: Nullable<DevicePose>;
  85760. /**
  85761. * The scale of the device to be used when translating from device space to babylon space.
  85762. */
  85763. deviceScaleFactor: number;
  85764. /**
  85765. * Updates the poseControlled values based on the input device pose.
  85766. * @param poseData the pose data to update the object with
  85767. */
  85768. updateFromDevice(poseData: DevicePose): void;
  85769. }
  85770. /**
  85771. * Set of options to customize the webVRCamera
  85772. */
  85773. export interface WebVROptions {
  85774. /**
  85775. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85776. */
  85777. trackPosition?: boolean;
  85778. /**
  85779. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85780. */
  85781. positionScale?: number;
  85782. /**
  85783. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85784. */
  85785. displayName?: string;
  85786. /**
  85787. * Should the native controller meshes be initialized. (default: true)
  85788. */
  85789. controllerMeshes?: boolean;
  85790. /**
  85791. * Creating a default HemiLight only on controllers. (default: true)
  85792. */
  85793. defaultLightingOnControllers?: boolean;
  85794. /**
  85795. * If you don't want to use the default VR button of the helper. (default: false)
  85796. */
  85797. useCustomVRButton?: boolean;
  85798. /**
  85799. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85800. */
  85801. customVRButton?: HTMLButtonElement;
  85802. /**
  85803. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85804. */
  85805. rayLength?: number;
  85806. /**
  85807. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85808. */
  85809. defaultHeight?: number;
  85810. /**
  85811. * If multiview should be used if availible (default: false)
  85812. */
  85813. useMultiview?: boolean;
  85814. }
  85815. /**
  85816. * This represents a WebVR camera.
  85817. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85818. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85819. */
  85820. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85821. private webVROptions;
  85822. /**
  85823. * @hidden
  85824. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85825. */
  85826. _vrDevice: any;
  85827. /**
  85828. * The rawPose of the vrDevice.
  85829. */
  85830. rawPose: Nullable<DevicePose>;
  85831. private _onVREnabled;
  85832. private _specsVersion;
  85833. private _attached;
  85834. private _frameData;
  85835. protected _descendants: Array<Node>;
  85836. private _deviceRoomPosition;
  85837. /** @hidden */
  85838. _deviceRoomRotationQuaternion: Quaternion;
  85839. private _standingMatrix;
  85840. /**
  85841. * Represents device position in babylon space.
  85842. */
  85843. devicePosition: Vector3;
  85844. /**
  85845. * Represents device rotation in babylon space.
  85846. */
  85847. deviceRotationQuaternion: Quaternion;
  85848. /**
  85849. * The scale of the device to be used when translating from device space to babylon space.
  85850. */
  85851. deviceScaleFactor: number;
  85852. private _deviceToWorld;
  85853. private _worldToDevice;
  85854. /**
  85855. * References to the webVR controllers for the vrDevice.
  85856. */
  85857. controllers: Array<WebVRController>;
  85858. /**
  85859. * Emits an event when a controller is attached.
  85860. */
  85861. onControllersAttachedObservable: Observable<WebVRController[]>;
  85862. /**
  85863. * Emits an event when a controller's mesh has been loaded;
  85864. */
  85865. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85866. /**
  85867. * Emits an event when the HMD's pose has been updated.
  85868. */
  85869. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85870. private _poseSet;
  85871. /**
  85872. * If the rig cameras be used as parent instead of this camera.
  85873. */
  85874. rigParenting: boolean;
  85875. private _lightOnControllers;
  85876. private _defaultHeight?;
  85877. /**
  85878. * Instantiates a WebVRFreeCamera.
  85879. * @param name The name of the WebVRFreeCamera
  85880. * @param position The starting anchor position for the camera
  85881. * @param scene The scene the camera belongs to
  85882. * @param webVROptions a set of customizable options for the webVRCamera
  85883. */
  85884. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85885. /**
  85886. * Gets the device distance from the ground in meters.
  85887. * @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.
  85888. */
  85889. deviceDistanceToRoomGround(): number;
  85890. /**
  85891. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85892. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85893. */
  85894. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85895. /**
  85896. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85897. * @returns A promise with a boolean set to if the standing matrix is supported.
  85898. */
  85899. useStandingMatrixAsync(): Promise<boolean>;
  85900. /**
  85901. * Disposes the camera
  85902. */
  85903. dispose(): void;
  85904. /**
  85905. * Gets a vrController by name.
  85906. * @param name The name of the controller to retreive
  85907. * @returns the controller matching the name specified or null if not found
  85908. */
  85909. getControllerByName(name: string): Nullable<WebVRController>;
  85910. private _leftController;
  85911. /**
  85912. * The controller corresponding to the users left hand.
  85913. */
  85914. get leftController(): Nullable<WebVRController>;
  85915. private _rightController;
  85916. /**
  85917. * The controller corresponding to the users right hand.
  85918. */
  85919. get rightController(): Nullable<WebVRController>;
  85920. /**
  85921. * Casts a ray forward from the vrCamera's gaze.
  85922. * @param length Length of the ray (default: 100)
  85923. * @returns the ray corresponding to the gaze
  85924. */
  85925. getForwardRay(length?: number): Ray;
  85926. /**
  85927. * @hidden
  85928. * Updates the camera based on device's frame data
  85929. */
  85930. _checkInputs(): void;
  85931. /**
  85932. * Updates the poseControlled values based on the input device pose.
  85933. * @param poseData Pose coming from the device
  85934. */
  85935. updateFromDevice(poseData: DevicePose): void;
  85936. private _htmlElementAttached;
  85937. private _detachIfAttached;
  85938. /**
  85939. * WebVR's attach control will start broadcasting frames to the device.
  85940. * Note that in certain browsers (chrome for example) this function must be called
  85941. * within a user-interaction callback. Example:
  85942. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  85943. *
  85944. * @param element html element to attach the vrDevice to
  85945. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  85946. */
  85947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85948. /**
  85949. * Detaches the camera from the html element and disables VR
  85950. *
  85951. * @param element html element to detach from
  85952. */
  85953. detachControl(element: HTMLElement): void;
  85954. /**
  85955. * @returns the name of this class
  85956. */
  85957. getClassName(): string;
  85958. /**
  85959. * Calls resetPose on the vrDisplay
  85960. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  85961. */
  85962. resetToCurrentRotation(): void;
  85963. /**
  85964. * @hidden
  85965. * Updates the rig cameras (left and right eye)
  85966. */
  85967. _updateRigCameras(): void;
  85968. private _workingVector;
  85969. private _oneVector;
  85970. private _workingMatrix;
  85971. private updateCacheCalled;
  85972. private _correctPositionIfNotTrackPosition;
  85973. /**
  85974. * @hidden
  85975. * Updates the cached values of the camera
  85976. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  85977. */
  85978. _updateCache(ignoreParentClass?: boolean): void;
  85979. /**
  85980. * @hidden
  85981. * Get current device position in babylon world
  85982. */
  85983. _computeDevicePosition(): void;
  85984. /**
  85985. * Updates the current device position and rotation in the babylon world
  85986. */
  85987. update(): void;
  85988. /**
  85989. * @hidden
  85990. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  85991. * @returns an identity matrix
  85992. */
  85993. _getViewMatrix(): Matrix;
  85994. private _tmpMatrix;
  85995. /**
  85996. * This function is called by the two RIG cameras.
  85997. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  85998. * @hidden
  85999. */
  86000. _getWebVRViewMatrix(): Matrix;
  86001. /** @hidden */
  86002. _getWebVRProjectionMatrix(): Matrix;
  86003. private _onGamepadConnectedObserver;
  86004. private _onGamepadDisconnectedObserver;
  86005. private _updateCacheWhenTrackingDisabledObserver;
  86006. /**
  86007. * Initializes the controllers and their meshes
  86008. */
  86009. initControllers(): void;
  86010. }
  86011. }
  86012. declare module BABYLON {
  86013. /**
  86014. * Size options for a post process
  86015. */
  86016. export type PostProcessOptions = {
  86017. width: number;
  86018. height: number;
  86019. };
  86020. /**
  86021. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86022. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86023. */
  86024. export class PostProcess {
  86025. /** Name of the PostProcess. */
  86026. name: string;
  86027. /**
  86028. * Gets or sets the unique id of the post process
  86029. */
  86030. uniqueId: number;
  86031. /**
  86032. * Width of the texture to apply the post process on
  86033. */
  86034. width: number;
  86035. /**
  86036. * Height of the texture to apply the post process on
  86037. */
  86038. height: number;
  86039. /**
  86040. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86041. * @hidden
  86042. */
  86043. _outputTexture: Nullable<InternalTexture>;
  86044. /**
  86045. * Sampling mode used by the shader
  86046. * See https://doc.babylonjs.com/classes/3.1/texture
  86047. */
  86048. renderTargetSamplingMode: number;
  86049. /**
  86050. * Clear color to use when screen clearing
  86051. */
  86052. clearColor: Color4;
  86053. /**
  86054. * If the buffer needs to be cleared before applying the post process. (default: true)
  86055. * Should be set to false if shader will overwrite all previous pixels.
  86056. */
  86057. autoClear: boolean;
  86058. /**
  86059. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86060. */
  86061. alphaMode: number;
  86062. /**
  86063. * Sets the setAlphaBlendConstants of the babylon engine
  86064. */
  86065. alphaConstants: Color4;
  86066. /**
  86067. * Animations to be used for the post processing
  86068. */
  86069. animations: Animation[];
  86070. /**
  86071. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86072. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86073. */
  86074. enablePixelPerfectMode: boolean;
  86075. /**
  86076. * Force the postprocess to be applied without taking in account viewport
  86077. */
  86078. forceFullscreenViewport: boolean;
  86079. /**
  86080. * List of inspectable custom properties (used by the Inspector)
  86081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86082. */
  86083. inspectableCustomProperties: IInspectable[];
  86084. /**
  86085. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86086. *
  86087. * | Value | Type | Description |
  86088. * | ----- | ----------------------------------- | ----------- |
  86089. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86090. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86091. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86092. *
  86093. */
  86094. scaleMode: number;
  86095. /**
  86096. * Force textures to be a power of two (default: false)
  86097. */
  86098. alwaysForcePOT: boolean;
  86099. private _samples;
  86100. /**
  86101. * Number of sample textures (default: 1)
  86102. */
  86103. get samples(): number;
  86104. set samples(n: number);
  86105. /**
  86106. * Modify the scale of the post process to be the same as the viewport (default: false)
  86107. */
  86108. adaptScaleToCurrentViewport: boolean;
  86109. private _camera;
  86110. private _scene;
  86111. private _engine;
  86112. private _options;
  86113. private _reusable;
  86114. private _textureType;
  86115. /**
  86116. * Smart array of input and output textures for the post process.
  86117. * @hidden
  86118. */
  86119. _textures: SmartArray<InternalTexture>;
  86120. /**
  86121. * The index in _textures that corresponds to the output texture.
  86122. * @hidden
  86123. */
  86124. _currentRenderTextureInd: number;
  86125. private _effect;
  86126. private _samplers;
  86127. private _fragmentUrl;
  86128. private _vertexUrl;
  86129. private _parameters;
  86130. private _scaleRatio;
  86131. protected _indexParameters: any;
  86132. private _shareOutputWithPostProcess;
  86133. private _texelSize;
  86134. private _forcedOutputTexture;
  86135. /**
  86136. * Returns the fragment url or shader name used in the post process.
  86137. * @returns the fragment url or name in the shader store.
  86138. */
  86139. getEffectName(): string;
  86140. /**
  86141. * An event triggered when the postprocess is activated.
  86142. */
  86143. onActivateObservable: Observable<Camera>;
  86144. private _onActivateObserver;
  86145. /**
  86146. * A function that is added to the onActivateObservable
  86147. */
  86148. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86149. /**
  86150. * An event triggered when the postprocess changes its size.
  86151. */
  86152. onSizeChangedObservable: Observable<PostProcess>;
  86153. private _onSizeChangedObserver;
  86154. /**
  86155. * A function that is added to the onSizeChangedObservable
  86156. */
  86157. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86158. /**
  86159. * An event triggered when the postprocess applies its effect.
  86160. */
  86161. onApplyObservable: Observable<Effect>;
  86162. private _onApplyObserver;
  86163. /**
  86164. * A function that is added to the onApplyObservable
  86165. */
  86166. set onApply(callback: (effect: Effect) => void);
  86167. /**
  86168. * An event triggered before rendering the postprocess
  86169. */
  86170. onBeforeRenderObservable: Observable<Effect>;
  86171. private _onBeforeRenderObserver;
  86172. /**
  86173. * A function that is added to the onBeforeRenderObservable
  86174. */
  86175. set onBeforeRender(callback: (effect: Effect) => void);
  86176. /**
  86177. * An event triggered after rendering the postprocess
  86178. */
  86179. onAfterRenderObservable: Observable<Effect>;
  86180. private _onAfterRenderObserver;
  86181. /**
  86182. * A function that is added to the onAfterRenderObservable
  86183. */
  86184. set onAfterRender(callback: (efect: Effect) => void);
  86185. /**
  86186. * 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
  86187. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86188. */
  86189. get inputTexture(): InternalTexture;
  86190. set inputTexture(value: InternalTexture);
  86191. /**
  86192. * Gets the camera which post process is applied to.
  86193. * @returns The camera the post process is applied to.
  86194. */
  86195. getCamera(): Camera;
  86196. /**
  86197. * Gets the texel size of the postprocess.
  86198. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86199. */
  86200. get texelSize(): Vector2;
  86201. /**
  86202. * Creates a new instance PostProcess
  86203. * @param name The name of the PostProcess.
  86204. * @param fragmentUrl The url of the fragment shader to be used.
  86205. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86206. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86207. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86208. * @param camera The camera to apply the render pass to.
  86209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86210. * @param engine The engine which the post process will be applied. (default: current engine)
  86211. * @param reusable If the post process can be reused on the same frame. (default: false)
  86212. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86213. * @param textureType Type of textures used when performing the post process. (default: 0)
  86214. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86215. * @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
  86216. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86217. */
  86218. constructor(
  86219. /** Name of the PostProcess. */
  86220. 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);
  86221. /**
  86222. * Gets a string idenfifying the name of the class
  86223. * @returns "PostProcess" string
  86224. */
  86225. getClassName(): string;
  86226. /**
  86227. * Gets the engine which this post process belongs to.
  86228. * @returns The engine the post process was enabled with.
  86229. */
  86230. getEngine(): Engine;
  86231. /**
  86232. * The effect that is created when initializing the post process.
  86233. * @returns The created effect corresponding the the postprocess.
  86234. */
  86235. getEffect(): Effect;
  86236. /**
  86237. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86238. * @param postProcess The post process to share the output with.
  86239. * @returns This post process.
  86240. */
  86241. shareOutputWith(postProcess: PostProcess): PostProcess;
  86242. /**
  86243. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86244. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86245. */
  86246. useOwnOutput(): void;
  86247. /**
  86248. * Updates the effect with the current post process compile time values and recompiles the shader.
  86249. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86250. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86251. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86252. * @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
  86253. * @param onCompiled Called when the shader has been compiled.
  86254. * @param onError Called if there is an error when compiling a shader.
  86255. */
  86256. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86257. /**
  86258. * The post process is reusable if it can be used multiple times within one frame.
  86259. * @returns If the post process is reusable
  86260. */
  86261. isReusable(): boolean;
  86262. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86263. markTextureDirty(): void;
  86264. /**
  86265. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86266. * 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.
  86267. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86268. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86269. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86270. * @returns The target texture that was bound to be written to.
  86271. */
  86272. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86273. /**
  86274. * If the post process is supported.
  86275. */
  86276. get isSupported(): boolean;
  86277. /**
  86278. * The aspect ratio of the output texture.
  86279. */
  86280. get aspectRatio(): number;
  86281. /**
  86282. * Get a value indicating if the post-process is ready to be used
  86283. * @returns true if the post-process is ready (shader is compiled)
  86284. */
  86285. isReady(): boolean;
  86286. /**
  86287. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86288. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86289. */
  86290. apply(): Nullable<Effect>;
  86291. private _disposeTextures;
  86292. /**
  86293. * Disposes the post process.
  86294. * @param camera The camera to dispose the post process on.
  86295. */
  86296. dispose(camera?: Camera): void;
  86297. }
  86298. }
  86299. declare module BABYLON {
  86300. /** @hidden */
  86301. export var kernelBlurVaryingDeclaration: {
  86302. name: string;
  86303. shader: string;
  86304. };
  86305. }
  86306. declare module BABYLON {
  86307. /** @hidden */
  86308. export var kernelBlurFragment: {
  86309. name: string;
  86310. shader: string;
  86311. };
  86312. }
  86313. declare module BABYLON {
  86314. /** @hidden */
  86315. export var kernelBlurFragment2: {
  86316. name: string;
  86317. shader: string;
  86318. };
  86319. }
  86320. declare module BABYLON {
  86321. /** @hidden */
  86322. export var kernelBlurPixelShader: {
  86323. name: string;
  86324. shader: string;
  86325. };
  86326. }
  86327. declare module BABYLON {
  86328. /** @hidden */
  86329. export var kernelBlurVertex: {
  86330. name: string;
  86331. shader: string;
  86332. };
  86333. }
  86334. declare module BABYLON {
  86335. /** @hidden */
  86336. export var kernelBlurVertexShader: {
  86337. name: string;
  86338. shader: string;
  86339. };
  86340. }
  86341. declare module BABYLON {
  86342. /**
  86343. * The Blur Post Process which blurs an image based on a kernel and direction.
  86344. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86345. */
  86346. export class BlurPostProcess extends PostProcess {
  86347. /** The direction in which to blur the image. */
  86348. direction: Vector2;
  86349. private blockCompilation;
  86350. protected _kernel: number;
  86351. protected _idealKernel: number;
  86352. protected _packedFloat: boolean;
  86353. private _staticDefines;
  86354. /**
  86355. * Sets the length in pixels of the blur sample region
  86356. */
  86357. set kernel(v: number);
  86358. /**
  86359. * Gets the length in pixels of the blur sample region
  86360. */
  86361. get kernel(): number;
  86362. /**
  86363. * Sets wether or not the blur needs to unpack/repack floats
  86364. */
  86365. set packedFloat(v: boolean);
  86366. /**
  86367. * Gets wether or not the blur is unpacking/repacking floats
  86368. */
  86369. get packedFloat(): boolean;
  86370. /**
  86371. * Creates a new instance BlurPostProcess
  86372. * @param name The name of the effect.
  86373. * @param direction The direction in which to blur the image.
  86374. * @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.
  86375. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86376. * @param camera The camera to apply the render pass to.
  86377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86378. * @param engine The engine which the post process will be applied. (default: current engine)
  86379. * @param reusable If the post process can be reused on the same frame. (default: false)
  86380. * @param textureType Type of textures used when performing the post process. (default: 0)
  86381. * @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)
  86382. */
  86383. constructor(name: string,
  86384. /** The direction in which to blur the image. */
  86385. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86386. /**
  86387. * Updates the effect with the current post process compile time values and recompiles the shader.
  86388. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86389. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86390. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86391. * @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
  86392. * @param onCompiled Called when the shader has been compiled.
  86393. * @param onError Called if there is an error when compiling a shader.
  86394. */
  86395. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86396. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86397. /**
  86398. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86399. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86400. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86401. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86402. * The gaps between physical kernels are compensated for in the weighting of the samples
  86403. * @param idealKernel Ideal blur kernel.
  86404. * @return Nearest best kernel.
  86405. */
  86406. protected _nearestBestKernel(idealKernel: number): number;
  86407. /**
  86408. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86409. * @param x The point on the Gaussian distribution to sample.
  86410. * @return the value of the Gaussian function at x.
  86411. */
  86412. protected _gaussianWeight(x: number): number;
  86413. /**
  86414. * Generates a string that can be used as a floating point number in GLSL.
  86415. * @param x Value to print.
  86416. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86417. * @return GLSL float string.
  86418. */
  86419. protected _glslFloat(x: number, decimalFigures?: number): string;
  86420. }
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86425. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86426. * You can then easily use it as a reflectionTexture on a flat surface.
  86427. * In case the surface is not a plane, please consider relying on reflection probes.
  86428. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86429. */
  86430. export class MirrorTexture extends RenderTargetTexture {
  86431. private scene;
  86432. /**
  86433. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86434. * 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.
  86435. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86436. */
  86437. mirrorPlane: Plane;
  86438. /**
  86439. * Define the blur ratio used to blur the reflection if needed.
  86440. */
  86441. set blurRatio(value: number);
  86442. get blurRatio(): number;
  86443. /**
  86444. * Define the adaptive blur kernel used to blur the reflection if needed.
  86445. * This will autocompute the closest best match for the `blurKernel`
  86446. */
  86447. set adaptiveBlurKernel(value: number);
  86448. /**
  86449. * Define the blur kernel used to blur the reflection if needed.
  86450. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86451. */
  86452. set blurKernel(value: number);
  86453. /**
  86454. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86455. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86456. */
  86457. set blurKernelX(value: number);
  86458. get blurKernelX(): number;
  86459. /**
  86460. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86461. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86462. */
  86463. set blurKernelY(value: number);
  86464. get blurKernelY(): number;
  86465. private _autoComputeBlurKernel;
  86466. protected _onRatioRescale(): void;
  86467. private _updateGammaSpace;
  86468. private _imageProcessingConfigChangeObserver;
  86469. private _transformMatrix;
  86470. private _mirrorMatrix;
  86471. private _savedViewMatrix;
  86472. private _blurX;
  86473. private _blurY;
  86474. private _adaptiveBlurKernel;
  86475. private _blurKernelX;
  86476. private _blurKernelY;
  86477. private _blurRatio;
  86478. /**
  86479. * Instantiates a Mirror Texture.
  86480. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86481. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86482. * You can then easily use it as a reflectionTexture on a flat surface.
  86483. * In case the surface is not a plane, please consider relying on reflection probes.
  86484. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86485. * @param name
  86486. * @param size
  86487. * @param scene
  86488. * @param generateMipMaps
  86489. * @param type
  86490. * @param samplingMode
  86491. * @param generateDepthBuffer
  86492. */
  86493. constructor(name: string, size: number | {
  86494. width: number;
  86495. height: number;
  86496. } | {
  86497. ratio: number;
  86498. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86499. private _preparePostProcesses;
  86500. /**
  86501. * Clone the mirror texture.
  86502. * @returns the cloned texture
  86503. */
  86504. clone(): MirrorTexture;
  86505. /**
  86506. * Serialize the texture to a JSON representation you could use in Parse later on
  86507. * @returns the serialized JSON representation
  86508. */
  86509. serialize(): any;
  86510. /**
  86511. * Dispose the texture and release its associated resources.
  86512. */
  86513. dispose(): void;
  86514. }
  86515. }
  86516. declare module BABYLON {
  86517. /**
  86518. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86519. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86520. */
  86521. export class Texture extends BaseTexture {
  86522. /**
  86523. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86524. */
  86525. static SerializeBuffers: boolean;
  86526. /** @hidden */
  86527. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86528. /** @hidden */
  86529. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86530. /** @hidden */
  86531. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86532. /** nearest is mag = nearest and min = nearest and mip = linear */
  86533. static readonly NEAREST_SAMPLINGMODE: number;
  86534. /** nearest is mag = nearest and min = nearest and mip = linear */
  86535. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86537. static readonly BILINEAR_SAMPLINGMODE: number;
  86538. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86539. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86540. /** Trilinear is mag = linear and min = linear and mip = linear */
  86541. static readonly TRILINEAR_SAMPLINGMODE: number;
  86542. /** Trilinear is mag = linear and min = linear and mip = linear */
  86543. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86544. /** mag = nearest and min = nearest and mip = nearest */
  86545. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86546. /** mag = nearest and min = linear and mip = nearest */
  86547. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86548. /** mag = nearest and min = linear and mip = linear */
  86549. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86550. /** mag = nearest and min = linear and mip = none */
  86551. static readonly NEAREST_LINEAR: number;
  86552. /** mag = nearest and min = nearest and mip = none */
  86553. static readonly NEAREST_NEAREST: number;
  86554. /** mag = linear and min = nearest and mip = nearest */
  86555. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86556. /** mag = linear and min = nearest and mip = linear */
  86557. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86558. /** mag = linear and min = linear and mip = none */
  86559. static readonly LINEAR_LINEAR: number;
  86560. /** mag = linear and min = nearest and mip = none */
  86561. static readonly LINEAR_NEAREST: number;
  86562. /** Explicit coordinates mode */
  86563. static readonly EXPLICIT_MODE: number;
  86564. /** Spherical coordinates mode */
  86565. static readonly SPHERICAL_MODE: number;
  86566. /** Planar coordinates mode */
  86567. static readonly PLANAR_MODE: number;
  86568. /** Cubic coordinates mode */
  86569. static readonly CUBIC_MODE: number;
  86570. /** Projection coordinates mode */
  86571. static readonly PROJECTION_MODE: number;
  86572. /** Inverse Cubic coordinates mode */
  86573. static readonly SKYBOX_MODE: number;
  86574. /** Inverse Cubic coordinates mode */
  86575. static readonly INVCUBIC_MODE: number;
  86576. /** Equirectangular coordinates mode */
  86577. static readonly EQUIRECTANGULAR_MODE: number;
  86578. /** Equirectangular Fixed coordinates mode */
  86579. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86580. /** Equirectangular Fixed Mirrored coordinates mode */
  86581. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86582. /** Texture is not repeating outside of 0..1 UVs */
  86583. static readonly CLAMP_ADDRESSMODE: number;
  86584. /** Texture is repeating outside of 0..1 UVs */
  86585. static readonly WRAP_ADDRESSMODE: number;
  86586. /** Texture is repeating and mirrored */
  86587. static readonly MIRROR_ADDRESSMODE: number;
  86588. /**
  86589. * 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
  86590. */
  86591. static UseSerializedUrlIfAny: boolean;
  86592. /**
  86593. * Define the url of the texture.
  86594. */
  86595. url: Nullable<string>;
  86596. /**
  86597. * Define an offset on the texture to offset the u coordinates of the UVs
  86598. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86599. */
  86600. uOffset: number;
  86601. /**
  86602. * Define an offset on the texture to offset the v coordinates of the UVs
  86603. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86604. */
  86605. vOffset: number;
  86606. /**
  86607. * Define an offset on the texture to scale the u coordinates of the UVs
  86608. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86609. */
  86610. uScale: number;
  86611. /**
  86612. * Define an offset on the texture to scale the v coordinates of the UVs
  86613. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86614. */
  86615. vScale: number;
  86616. /**
  86617. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86618. * @see http://doc.babylonjs.com/how_to/more_materials
  86619. */
  86620. uAng: number;
  86621. /**
  86622. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86623. * @see http://doc.babylonjs.com/how_to/more_materials
  86624. */
  86625. vAng: number;
  86626. /**
  86627. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86628. * @see http://doc.babylonjs.com/how_to/more_materials
  86629. */
  86630. wAng: number;
  86631. /**
  86632. * Defines the center of rotation (U)
  86633. */
  86634. uRotationCenter: number;
  86635. /**
  86636. * Defines the center of rotation (V)
  86637. */
  86638. vRotationCenter: number;
  86639. /**
  86640. * Defines the center of rotation (W)
  86641. */
  86642. wRotationCenter: number;
  86643. /**
  86644. * Are mip maps generated for this texture or not.
  86645. */
  86646. get noMipmap(): boolean;
  86647. /**
  86648. * List of inspectable custom properties (used by the Inspector)
  86649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86650. */
  86651. inspectableCustomProperties: Nullable<IInspectable[]>;
  86652. private _noMipmap;
  86653. /** @hidden */
  86654. _invertY: boolean;
  86655. private _rowGenerationMatrix;
  86656. private _cachedTextureMatrix;
  86657. private _projectionModeMatrix;
  86658. private _t0;
  86659. private _t1;
  86660. private _t2;
  86661. private _cachedUOffset;
  86662. private _cachedVOffset;
  86663. private _cachedUScale;
  86664. private _cachedVScale;
  86665. private _cachedUAng;
  86666. private _cachedVAng;
  86667. private _cachedWAng;
  86668. private _cachedProjectionMatrixId;
  86669. private _cachedCoordinatesMode;
  86670. /** @hidden */
  86671. protected _initialSamplingMode: number;
  86672. /** @hidden */
  86673. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86674. private _deleteBuffer;
  86675. protected _format: Nullable<number>;
  86676. private _delayedOnLoad;
  86677. private _delayedOnError;
  86678. private _mimeType?;
  86679. /**
  86680. * Observable triggered once the texture has been loaded.
  86681. */
  86682. onLoadObservable: Observable<Texture>;
  86683. protected _isBlocking: boolean;
  86684. /**
  86685. * Is the texture preventing material to render while loading.
  86686. * If false, a default texture will be used instead of the loading one during the preparation step.
  86687. */
  86688. set isBlocking(value: boolean);
  86689. get isBlocking(): boolean;
  86690. /**
  86691. * Get the current sampling mode associated with the texture.
  86692. */
  86693. get samplingMode(): number;
  86694. /**
  86695. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86696. */
  86697. get invertY(): boolean;
  86698. /**
  86699. * Instantiates a new texture.
  86700. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86701. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86702. * @param url defines the url of the picture to load as a texture
  86703. * @param scene defines the scene or engine the texture will belong to
  86704. * @param noMipmap defines if the texture will require mip maps or not
  86705. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86706. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86707. * @param onLoad defines a callback triggered when the texture has been loaded
  86708. * @param onError defines a callback triggered when an error occurred during the loading session
  86709. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86710. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86711. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86712. * @param mimeType defines an optional mime type information
  86713. */
  86714. 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);
  86715. /**
  86716. * Update the url (and optional buffer) of this texture if url was null during construction.
  86717. * @param url the url of the texture
  86718. * @param buffer the buffer of the texture (defaults to null)
  86719. * @param onLoad callback called when the texture is loaded (defaults to null)
  86720. */
  86721. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86722. /**
  86723. * Finish the loading sequence of a texture flagged as delayed load.
  86724. * @hidden
  86725. */
  86726. delayLoad(): void;
  86727. private _prepareRowForTextureGeneration;
  86728. /**
  86729. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86730. * @returns the transform matrix of the texture.
  86731. */
  86732. getTextureMatrix(uBase?: number): Matrix;
  86733. /**
  86734. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86735. * @returns The reflection texture transform
  86736. */
  86737. getReflectionTextureMatrix(): Matrix;
  86738. /**
  86739. * Clones the texture.
  86740. * @returns the cloned texture
  86741. */
  86742. clone(): Texture;
  86743. /**
  86744. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86745. * @returns The JSON representation of the texture
  86746. */
  86747. serialize(): any;
  86748. /**
  86749. * Get the current class name of the texture useful for serialization or dynamic coding.
  86750. * @returns "Texture"
  86751. */
  86752. getClassName(): string;
  86753. /**
  86754. * Dispose the texture and release its associated resources.
  86755. */
  86756. dispose(): void;
  86757. /**
  86758. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86759. * @param parsedTexture Define the JSON representation of the texture
  86760. * @param scene Define the scene the parsed texture should be instantiated in
  86761. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86762. * @returns The parsed texture if successful
  86763. */
  86764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86765. /**
  86766. * Creates a texture from its base 64 representation.
  86767. * @param data Define the base64 payload without the data: prefix
  86768. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86769. * @param scene Define the scene the texture should belong to
  86770. * @param noMipmap Forces the texture to not create mip map information if true
  86771. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86772. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86773. * @param onLoad define a callback triggered when the texture has been loaded
  86774. * @param onError define a callback triggered when an error occurred during the loading session
  86775. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86776. * @returns the created texture
  86777. */
  86778. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86779. /**
  86780. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86781. * @param data Define the base64 payload without the data: prefix
  86782. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86783. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86784. * @param scene Define the scene the texture should belong to
  86785. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86786. * @param noMipmap Forces the texture to not create mip map information if true
  86787. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86788. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86789. * @param onLoad define a callback triggered when the texture has been loaded
  86790. * @param onError define a callback triggered when an error occurred during the loading session
  86791. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86792. * @returns the created texture
  86793. */
  86794. 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;
  86795. }
  86796. }
  86797. declare module BABYLON {
  86798. /**
  86799. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86800. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86801. */
  86802. export class PostProcessManager {
  86803. private _scene;
  86804. private _indexBuffer;
  86805. private _vertexBuffers;
  86806. /**
  86807. * Creates a new instance PostProcess
  86808. * @param scene The scene that the post process is associated with.
  86809. */
  86810. constructor(scene: Scene);
  86811. private _prepareBuffers;
  86812. private _buildIndexBuffer;
  86813. /**
  86814. * Rebuilds the vertex buffers of the manager.
  86815. * @hidden
  86816. */
  86817. _rebuild(): void;
  86818. /**
  86819. * Prepares a frame to be run through a post process.
  86820. * @param sourceTexture The input texture to the post procesess. (default: null)
  86821. * @param postProcesses An array of post processes to be run. (default: null)
  86822. * @returns True if the post processes were able to be run.
  86823. * @hidden
  86824. */
  86825. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86826. /**
  86827. * Manually render a set of post processes to a texture.
  86828. * @param postProcesses An array of post processes to be run.
  86829. * @param targetTexture The target texture to render to.
  86830. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86831. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86832. * @param lodLevel defines which lod of the texture to render to
  86833. */
  86834. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86835. /**
  86836. * Finalize the result of the output of the postprocesses.
  86837. * @param doNotPresent If true the result will not be displayed to the screen.
  86838. * @param targetTexture The target texture to render to.
  86839. * @param faceIndex The index of the face to bind the target texture to.
  86840. * @param postProcesses The array of post processes to render.
  86841. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86842. * @hidden
  86843. */
  86844. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86845. /**
  86846. * Disposes of the post process manager.
  86847. */
  86848. dispose(): void;
  86849. }
  86850. }
  86851. declare module BABYLON {
  86852. /** Interface used by value gradients (color, factor, ...) */
  86853. export interface IValueGradient {
  86854. /**
  86855. * Gets or sets the gradient value (between 0 and 1)
  86856. */
  86857. gradient: number;
  86858. }
  86859. /** Class used to store color4 gradient */
  86860. export class ColorGradient implements IValueGradient {
  86861. /**
  86862. * Gets or sets the gradient value (between 0 and 1)
  86863. */
  86864. gradient: number;
  86865. /**
  86866. * Gets or sets first associated color
  86867. */
  86868. color1: Color4;
  86869. /**
  86870. * Gets or sets second associated color
  86871. */
  86872. color2?: Color4;
  86873. /**
  86874. * Will get a color picked randomly between color1 and color2.
  86875. * If color2 is undefined then color1 will be used
  86876. * @param result defines the target Color4 to store the result in
  86877. */
  86878. getColorToRef(result: Color4): void;
  86879. }
  86880. /** Class used to store color 3 gradient */
  86881. export class Color3Gradient implements IValueGradient {
  86882. /**
  86883. * Gets or sets the gradient value (between 0 and 1)
  86884. */
  86885. gradient: number;
  86886. /**
  86887. * Gets or sets the associated color
  86888. */
  86889. color: Color3;
  86890. }
  86891. /** Class used to store factor gradient */
  86892. export class FactorGradient implements IValueGradient {
  86893. /**
  86894. * Gets or sets the gradient value (between 0 and 1)
  86895. */
  86896. gradient: number;
  86897. /**
  86898. * Gets or sets first associated factor
  86899. */
  86900. factor1: number;
  86901. /**
  86902. * Gets or sets second associated factor
  86903. */
  86904. factor2?: number;
  86905. /**
  86906. * Will get a number picked randomly between factor1 and factor2.
  86907. * If factor2 is undefined then factor1 will be used
  86908. * @returns the picked number
  86909. */
  86910. getFactor(): number;
  86911. }
  86912. /**
  86913. * Helper used to simplify some generic gradient tasks
  86914. */
  86915. export class GradientHelper {
  86916. /**
  86917. * Gets the current gradient from an array of IValueGradient
  86918. * @param ratio defines the current ratio to get
  86919. * @param gradients defines the array of IValueGradient
  86920. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86921. */
  86922. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86923. }
  86924. }
  86925. declare module BABYLON {
  86926. interface ThinEngine {
  86927. /**
  86928. * Creates a dynamic texture
  86929. * @param width defines the width of the texture
  86930. * @param height defines the height of the texture
  86931. * @param generateMipMaps defines if the engine should generate the mip levels
  86932. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86933. * @returns the dynamic texture inside an InternalTexture
  86934. */
  86935. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86936. /**
  86937. * Update the content of a dynamic texture
  86938. * @param texture defines the texture to update
  86939. * @param canvas defines the canvas containing the source
  86940. * @param invertY defines if data must be stored with Y axis inverted
  86941. * @param premulAlpha defines if alpha is stored as premultiplied
  86942. * @param format defines the format of the data
  86943. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86944. */
  86945. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86946. }
  86947. }
  86948. declare module BABYLON {
  86949. /**
  86950. * Helper class used to generate a canvas to manipulate images
  86951. */
  86952. export class CanvasGenerator {
  86953. /**
  86954. * Create a new canvas (or offscreen canvas depending on the context)
  86955. * @param width defines the expected width
  86956. * @param height defines the expected height
  86957. * @return a new canvas or offscreen canvas
  86958. */
  86959. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86960. }
  86961. }
  86962. declare module BABYLON {
  86963. /**
  86964. * A class extending Texture allowing drawing on a texture
  86965. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86966. */
  86967. export class DynamicTexture extends Texture {
  86968. private _generateMipMaps;
  86969. private _canvas;
  86970. private _context;
  86971. private _engine;
  86972. /**
  86973. * Creates a DynamicTexture
  86974. * @param name defines the name of the texture
  86975. * @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
  86976. * @param scene defines the scene where you want the texture
  86977. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86978. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86979. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86980. */
  86981. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86982. /**
  86983. * Get the current class name of the texture useful for serialization or dynamic coding.
  86984. * @returns "DynamicTexture"
  86985. */
  86986. getClassName(): string;
  86987. /**
  86988. * Gets the current state of canRescale
  86989. */
  86990. get canRescale(): boolean;
  86991. private _recreate;
  86992. /**
  86993. * Scales the texture
  86994. * @param ratio the scale factor to apply to both width and height
  86995. */
  86996. scale(ratio: number): void;
  86997. /**
  86998. * Resizes the texture
  86999. * @param width the new width
  87000. * @param height the new height
  87001. */
  87002. scaleTo(width: number, height: number): void;
  87003. /**
  87004. * Gets the context of the canvas used by the texture
  87005. * @returns the canvas context of the dynamic texture
  87006. */
  87007. getContext(): CanvasRenderingContext2D;
  87008. /**
  87009. * Clears the texture
  87010. */
  87011. clear(): void;
  87012. /**
  87013. * Updates the texture
  87014. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87015. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87016. */
  87017. update(invertY?: boolean, premulAlpha?: boolean): void;
  87018. /**
  87019. * Draws text onto the texture
  87020. * @param text defines the text to be drawn
  87021. * @param x defines the placement of the text from the left
  87022. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87023. * @param font defines the font to be used with font-style, font-size, font-name
  87024. * @param color defines the color used for the text
  87025. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87026. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87027. * @param update defines whether texture is immediately update (default is true)
  87028. */
  87029. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87030. /**
  87031. * Clones the texture
  87032. * @returns the clone of the texture.
  87033. */
  87034. clone(): DynamicTexture;
  87035. /**
  87036. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87037. * @returns a serialized dynamic texture object
  87038. */
  87039. serialize(): any;
  87040. /** @hidden */
  87041. _rebuild(): void;
  87042. }
  87043. }
  87044. declare module BABYLON {
  87045. interface AbstractScene {
  87046. /**
  87047. * The list of procedural textures added to the scene
  87048. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87049. */
  87050. proceduralTextures: Array<ProceduralTexture>;
  87051. }
  87052. /**
  87053. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87054. * in a given scene.
  87055. */
  87056. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87057. /**
  87058. * The component name helpfull to identify the component in the list of scene components.
  87059. */
  87060. readonly name: string;
  87061. /**
  87062. * The scene the component belongs to.
  87063. */
  87064. scene: Scene;
  87065. /**
  87066. * Creates a new instance of the component for the given scene
  87067. * @param scene Defines the scene to register the component in
  87068. */
  87069. constructor(scene: Scene);
  87070. /**
  87071. * Registers the component in a given scene
  87072. */
  87073. register(): void;
  87074. /**
  87075. * Rebuilds the elements related to this component in case of
  87076. * context lost for instance.
  87077. */
  87078. rebuild(): void;
  87079. /**
  87080. * Disposes the component and the associated ressources.
  87081. */
  87082. dispose(): void;
  87083. private _beforeClear;
  87084. }
  87085. }
  87086. declare module BABYLON {
  87087. interface ThinEngine {
  87088. /**
  87089. * Creates a new render target cube texture
  87090. * @param size defines the size of the texture
  87091. * @param options defines the options used to create the texture
  87092. * @returns a new render target cube texture stored in an InternalTexture
  87093. */
  87094. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87095. }
  87096. }
  87097. declare module BABYLON {
  87098. /** @hidden */
  87099. export var proceduralVertexShader: {
  87100. name: string;
  87101. shader: string;
  87102. };
  87103. }
  87104. declare module BABYLON {
  87105. /**
  87106. * 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.
  87107. * This is the base class of any Procedural texture and contains most of the shareable code.
  87108. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87109. */
  87110. export class ProceduralTexture extends Texture {
  87111. isCube: boolean;
  87112. /**
  87113. * Define if the texture is enabled or not (disabled texture will not render)
  87114. */
  87115. isEnabled: boolean;
  87116. /**
  87117. * Define if the texture must be cleared before rendering (default is true)
  87118. */
  87119. autoClear: boolean;
  87120. /**
  87121. * Callback called when the texture is generated
  87122. */
  87123. onGenerated: () => void;
  87124. /**
  87125. * Event raised when the texture is generated
  87126. */
  87127. onGeneratedObservable: Observable<ProceduralTexture>;
  87128. /** @hidden */
  87129. _generateMipMaps: boolean;
  87130. /** @hidden **/
  87131. _effect: Effect;
  87132. /** @hidden */
  87133. _textures: {
  87134. [key: string]: Texture;
  87135. };
  87136. private _size;
  87137. private _currentRefreshId;
  87138. private _refreshRate;
  87139. private _vertexBuffers;
  87140. private _indexBuffer;
  87141. private _uniforms;
  87142. private _samplers;
  87143. private _fragment;
  87144. private _floats;
  87145. private _ints;
  87146. private _floatsArrays;
  87147. private _colors3;
  87148. private _colors4;
  87149. private _vectors2;
  87150. private _vectors3;
  87151. private _matrices;
  87152. private _fallbackTexture;
  87153. private _fallbackTextureUsed;
  87154. private _engine;
  87155. private _cachedDefines;
  87156. private _contentUpdateId;
  87157. private _contentData;
  87158. /**
  87159. * Instantiates a new procedural texture.
  87160. * 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.
  87161. * This is the base class of any Procedural texture and contains most of the shareable code.
  87162. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87163. * @param name Define the name of the texture
  87164. * @param size Define the size of the texture to create
  87165. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87166. * @param scene Define the scene the texture belongs to
  87167. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87168. * @param generateMipMaps Define if the texture should creates mip maps or not
  87169. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87170. */
  87171. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87172. /**
  87173. * The effect that is created when initializing the post process.
  87174. * @returns The created effect corresponding the the postprocess.
  87175. */
  87176. getEffect(): Effect;
  87177. /**
  87178. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87179. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87180. */
  87181. getContent(): Nullable<ArrayBufferView>;
  87182. private _createIndexBuffer;
  87183. /** @hidden */
  87184. _rebuild(): void;
  87185. /**
  87186. * Resets the texture in order to recreate its associated resources.
  87187. * This can be called in case of context loss
  87188. */
  87189. reset(): void;
  87190. protected _getDefines(): string;
  87191. /**
  87192. * Is the texture ready to be used ? (rendered at least once)
  87193. * @returns true if ready, otherwise, false.
  87194. */
  87195. isReady(): boolean;
  87196. /**
  87197. * Resets the refresh counter of the texture and start bak from scratch.
  87198. * Could be useful to regenerate the texture if it is setup to render only once.
  87199. */
  87200. resetRefreshCounter(): void;
  87201. /**
  87202. * Set the fragment shader to use in order to render the texture.
  87203. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87204. */
  87205. setFragment(fragment: any): void;
  87206. /**
  87207. * Define the refresh rate of the texture or the rendering frequency.
  87208. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87209. */
  87210. get refreshRate(): number;
  87211. set refreshRate(value: number);
  87212. /** @hidden */
  87213. _shouldRender(): boolean;
  87214. /**
  87215. * Get the size the texture is rendering at.
  87216. * @returns the size (texture is always squared)
  87217. */
  87218. getRenderSize(): number;
  87219. /**
  87220. * Resize the texture to new value.
  87221. * @param size Define the new size the texture should have
  87222. * @param generateMipMaps Define whether the new texture should create mip maps
  87223. */
  87224. resize(size: number, generateMipMaps: boolean): void;
  87225. private _checkUniform;
  87226. /**
  87227. * Set a texture in the shader program used to render.
  87228. * @param name Define the name of the uniform samplers as defined in the shader
  87229. * @param texture Define the texture to bind to this sampler
  87230. * @return the texture itself allowing "fluent" like uniform updates
  87231. */
  87232. setTexture(name: string, texture: Texture): ProceduralTexture;
  87233. /**
  87234. * Set a float in the shader.
  87235. * @param name Define the name of the uniform as defined in the shader
  87236. * @param value Define the value to give to the uniform
  87237. * @return the texture itself allowing "fluent" like uniform updates
  87238. */
  87239. setFloat(name: string, value: number): ProceduralTexture;
  87240. /**
  87241. * Set a int in the shader.
  87242. * @param name Define the name of the uniform as defined in the shader
  87243. * @param value Define the value to give to the uniform
  87244. * @return the texture itself allowing "fluent" like uniform updates
  87245. */
  87246. setInt(name: string, value: number): ProceduralTexture;
  87247. /**
  87248. * Set an array of floats in the shader.
  87249. * @param name Define the name of the uniform as defined in the shader
  87250. * @param value Define the value to give to the uniform
  87251. * @return the texture itself allowing "fluent" like uniform updates
  87252. */
  87253. setFloats(name: string, value: number[]): ProceduralTexture;
  87254. /**
  87255. * Set a vec3 in the shader from a Color3.
  87256. * @param name Define the name of the uniform as defined in the shader
  87257. * @param value Define the value to give to the uniform
  87258. * @return the texture itself allowing "fluent" like uniform updates
  87259. */
  87260. setColor3(name: string, value: Color3): ProceduralTexture;
  87261. /**
  87262. * Set a vec4 in the shader from a Color4.
  87263. * @param name Define the name of the uniform as defined in the shader
  87264. * @param value Define the value to give to the uniform
  87265. * @return the texture itself allowing "fluent" like uniform updates
  87266. */
  87267. setColor4(name: string, value: Color4): ProceduralTexture;
  87268. /**
  87269. * Set a vec2 in the shader from a Vector2.
  87270. * @param name Define the name of the uniform as defined in the shader
  87271. * @param value Define the value to give to the uniform
  87272. * @return the texture itself allowing "fluent" like uniform updates
  87273. */
  87274. setVector2(name: string, value: Vector2): ProceduralTexture;
  87275. /**
  87276. * Set a vec3 in the shader from a Vector3.
  87277. * @param name Define the name of the uniform as defined in the shader
  87278. * @param value Define the value to give to the uniform
  87279. * @return the texture itself allowing "fluent" like uniform updates
  87280. */
  87281. setVector3(name: string, value: Vector3): ProceduralTexture;
  87282. /**
  87283. * Set a mat4 in the shader from a MAtrix.
  87284. * @param name Define the name of the uniform as defined in the shader
  87285. * @param value Define the value to give to the uniform
  87286. * @return the texture itself allowing "fluent" like uniform updates
  87287. */
  87288. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87289. /**
  87290. * Render the texture to its associated render target.
  87291. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87292. */
  87293. render(useCameraPostProcess?: boolean): void;
  87294. /**
  87295. * Clone the texture.
  87296. * @returns the cloned texture
  87297. */
  87298. clone(): ProceduralTexture;
  87299. /**
  87300. * Dispose the texture and release its asoociated resources.
  87301. */
  87302. dispose(): void;
  87303. }
  87304. }
  87305. declare module BABYLON {
  87306. /**
  87307. * This represents the base class for particle system in Babylon.
  87308. * 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.
  87309. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87310. * @example https://doc.babylonjs.com/babylon101/particles
  87311. */
  87312. export class BaseParticleSystem {
  87313. /**
  87314. * Source color is added to the destination color without alpha affecting the result
  87315. */
  87316. static BLENDMODE_ONEONE: number;
  87317. /**
  87318. * Blend current color and particle color using particle’s alpha
  87319. */
  87320. static BLENDMODE_STANDARD: number;
  87321. /**
  87322. * Add current color and particle color multiplied by particle’s alpha
  87323. */
  87324. static BLENDMODE_ADD: number;
  87325. /**
  87326. * Multiply current color with particle color
  87327. */
  87328. static BLENDMODE_MULTIPLY: number;
  87329. /**
  87330. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87331. */
  87332. static BLENDMODE_MULTIPLYADD: number;
  87333. /**
  87334. * List of animations used by the particle system.
  87335. */
  87336. animations: Animation[];
  87337. /**
  87338. * The id of the Particle system.
  87339. */
  87340. id: string;
  87341. /**
  87342. * The friendly name of the Particle system.
  87343. */
  87344. name: string;
  87345. /**
  87346. * The rendering group used by the Particle system to chose when to render.
  87347. */
  87348. renderingGroupId: number;
  87349. /**
  87350. * The emitter represents the Mesh or position we are attaching the particle system to.
  87351. */
  87352. emitter: Nullable<AbstractMesh | Vector3>;
  87353. /**
  87354. * The maximum number of particles to emit per frame
  87355. */
  87356. emitRate: number;
  87357. /**
  87358. * If you want to launch only a few particles at once, that can be done, as well.
  87359. */
  87360. manualEmitCount: number;
  87361. /**
  87362. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87363. */
  87364. updateSpeed: number;
  87365. /**
  87366. * The amount of time the particle system is running (depends of the overall update speed).
  87367. */
  87368. targetStopDuration: number;
  87369. /**
  87370. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87371. */
  87372. disposeOnStop: boolean;
  87373. /**
  87374. * Minimum power of emitting particles.
  87375. */
  87376. minEmitPower: number;
  87377. /**
  87378. * Maximum power of emitting particles.
  87379. */
  87380. maxEmitPower: number;
  87381. /**
  87382. * Minimum life time of emitting particles.
  87383. */
  87384. minLifeTime: number;
  87385. /**
  87386. * Maximum life time of emitting particles.
  87387. */
  87388. maxLifeTime: number;
  87389. /**
  87390. * Minimum Size of emitting particles.
  87391. */
  87392. minSize: number;
  87393. /**
  87394. * Maximum Size of emitting particles.
  87395. */
  87396. maxSize: number;
  87397. /**
  87398. * Minimum scale of emitting particles on X axis.
  87399. */
  87400. minScaleX: number;
  87401. /**
  87402. * Maximum scale of emitting particles on X axis.
  87403. */
  87404. maxScaleX: number;
  87405. /**
  87406. * Minimum scale of emitting particles on Y axis.
  87407. */
  87408. minScaleY: number;
  87409. /**
  87410. * Maximum scale of emitting particles on Y axis.
  87411. */
  87412. maxScaleY: number;
  87413. /**
  87414. * Gets or sets the minimal initial rotation in radians.
  87415. */
  87416. minInitialRotation: number;
  87417. /**
  87418. * Gets or sets the maximal initial rotation in radians.
  87419. */
  87420. maxInitialRotation: number;
  87421. /**
  87422. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87423. */
  87424. minAngularSpeed: number;
  87425. /**
  87426. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87427. */
  87428. maxAngularSpeed: number;
  87429. /**
  87430. * The texture used to render each particle. (this can be a spritesheet)
  87431. */
  87432. particleTexture: Nullable<Texture>;
  87433. /**
  87434. * The layer mask we are rendering the particles through.
  87435. */
  87436. layerMask: number;
  87437. /**
  87438. * This can help using your own shader to render the particle system.
  87439. * The according effect will be created
  87440. */
  87441. customShader: any;
  87442. /**
  87443. * By default particle system starts as soon as they are created. This prevents the
  87444. * automatic start to happen and let you decide when to start emitting particles.
  87445. */
  87446. preventAutoStart: boolean;
  87447. private _noiseTexture;
  87448. /**
  87449. * Gets or sets a texture used to add random noise to particle positions
  87450. */
  87451. get noiseTexture(): Nullable<ProceduralTexture>;
  87452. set noiseTexture(value: Nullable<ProceduralTexture>);
  87453. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87454. noiseStrength: Vector3;
  87455. /**
  87456. * Callback triggered when the particle animation is ending.
  87457. */
  87458. onAnimationEnd: Nullable<() => void>;
  87459. /**
  87460. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87461. */
  87462. blendMode: number;
  87463. /**
  87464. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87465. * to override the particles.
  87466. */
  87467. forceDepthWrite: boolean;
  87468. /** 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 */
  87469. preWarmCycles: number;
  87470. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87471. preWarmStepOffset: number;
  87472. /**
  87473. * 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)
  87474. */
  87475. spriteCellChangeSpeed: number;
  87476. /**
  87477. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87478. */
  87479. startSpriteCellID: number;
  87480. /**
  87481. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87482. */
  87483. endSpriteCellID: number;
  87484. /**
  87485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87486. */
  87487. spriteCellWidth: number;
  87488. /**
  87489. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87490. */
  87491. spriteCellHeight: number;
  87492. /**
  87493. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87494. */
  87495. spriteRandomStartCell: boolean;
  87496. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87497. translationPivot: Vector2;
  87498. /** @hidden */
  87499. protected _isAnimationSheetEnabled: boolean;
  87500. /**
  87501. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87502. */
  87503. beginAnimationOnStart: boolean;
  87504. /**
  87505. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87506. */
  87507. beginAnimationFrom: number;
  87508. /**
  87509. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87510. */
  87511. beginAnimationTo: number;
  87512. /**
  87513. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87514. */
  87515. beginAnimationLoop: boolean;
  87516. /**
  87517. * Gets or sets a world offset applied to all particles
  87518. */
  87519. worldOffset: Vector3;
  87520. /**
  87521. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87522. */
  87523. get isAnimationSheetEnabled(): boolean;
  87524. set isAnimationSheetEnabled(value: boolean);
  87525. /**
  87526. * Get hosting scene
  87527. * @returns the scene
  87528. */
  87529. getScene(): Scene;
  87530. /**
  87531. * You can use gravity if you want to give an orientation to your particles.
  87532. */
  87533. gravity: Vector3;
  87534. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87535. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87536. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87537. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87538. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87539. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87540. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87541. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87542. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87543. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87544. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87545. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87546. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87547. /**
  87548. * Defines the delay in milliseconds before starting the system (0 by default)
  87549. */
  87550. startDelay: number;
  87551. /**
  87552. * Gets the current list of drag gradients.
  87553. * You must use addDragGradient and removeDragGradient to udpate this list
  87554. * @returns the list of drag gradients
  87555. */
  87556. getDragGradients(): Nullable<Array<FactorGradient>>;
  87557. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87558. limitVelocityDamping: number;
  87559. /**
  87560. * Gets the current list of limit velocity gradients.
  87561. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87562. * @returns the list of limit velocity gradients
  87563. */
  87564. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87565. /**
  87566. * Gets the current list of color gradients.
  87567. * You must use addColorGradient and removeColorGradient to udpate this list
  87568. * @returns the list of color gradients
  87569. */
  87570. getColorGradients(): Nullable<Array<ColorGradient>>;
  87571. /**
  87572. * Gets the current list of size gradients.
  87573. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87574. * @returns the list of size gradients
  87575. */
  87576. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87577. /**
  87578. * Gets the current list of color remap gradients.
  87579. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87580. * @returns the list of color remap gradients
  87581. */
  87582. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87583. /**
  87584. * Gets the current list of alpha remap gradients.
  87585. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87586. * @returns the list of alpha remap gradients
  87587. */
  87588. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87589. /**
  87590. * Gets the current list of life time gradients.
  87591. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87592. * @returns the list of life time gradients
  87593. */
  87594. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87595. /**
  87596. * Gets the current list of angular speed gradients.
  87597. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87598. * @returns the list of angular speed gradients
  87599. */
  87600. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87601. /**
  87602. * Gets the current list of velocity gradients.
  87603. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87604. * @returns the list of velocity gradients
  87605. */
  87606. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87607. /**
  87608. * Gets the current list of start size gradients.
  87609. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87610. * @returns the list of start size gradients
  87611. */
  87612. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87613. /**
  87614. * Gets the current list of emit rate gradients.
  87615. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87616. * @returns the list of emit rate gradients
  87617. */
  87618. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87619. /**
  87620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87621. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87622. */
  87623. get direction1(): Vector3;
  87624. set direction1(value: Vector3);
  87625. /**
  87626. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87627. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87628. */
  87629. get direction2(): Vector3;
  87630. set direction2(value: Vector3);
  87631. /**
  87632. * 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.
  87633. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87634. */
  87635. get minEmitBox(): Vector3;
  87636. set minEmitBox(value: Vector3);
  87637. /**
  87638. * 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.
  87639. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87640. */
  87641. get maxEmitBox(): Vector3;
  87642. set maxEmitBox(value: Vector3);
  87643. /**
  87644. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87645. */
  87646. color1: Color4;
  87647. /**
  87648. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87649. */
  87650. color2: Color4;
  87651. /**
  87652. * Color the particle will have at the end of its lifetime
  87653. */
  87654. colorDead: Color4;
  87655. /**
  87656. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87657. */
  87658. textureMask: Color4;
  87659. /**
  87660. * The particle emitter type defines the emitter used by the particle system.
  87661. * It can be for example box, sphere, or cone...
  87662. */
  87663. particleEmitterType: IParticleEmitterType;
  87664. /** @hidden */
  87665. _isSubEmitter: boolean;
  87666. /**
  87667. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87668. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87669. */
  87670. billboardMode: number;
  87671. protected _isBillboardBased: boolean;
  87672. /**
  87673. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87674. */
  87675. get isBillboardBased(): boolean;
  87676. set isBillboardBased(value: boolean);
  87677. /**
  87678. * The scene the particle system belongs to.
  87679. */
  87680. protected _scene: Scene;
  87681. /**
  87682. * Local cache of defines for image processing.
  87683. */
  87684. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87685. /**
  87686. * Default configuration related to image processing available in the standard Material.
  87687. */
  87688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87689. /**
  87690. * Gets the image processing configuration used either in this material.
  87691. */
  87692. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87693. /**
  87694. * Sets the Default image processing configuration used either in the this material.
  87695. *
  87696. * If sets to null, the scene one is in use.
  87697. */
  87698. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87699. /**
  87700. * Attaches a new image processing configuration to the Standard Material.
  87701. * @param configuration
  87702. */
  87703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87704. /** @hidden */
  87705. protected _reset(): void;
  87706. /** @hidden */
  87707. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87708. /**
  87709. * Instantiates a particle system.
  87710. * 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.
  87711. * @param name The name of the particle system
  87712. */
  87713. constructor(name: string);
  87714. /**
  87715. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87718. * @returns the emitter
  87719. */
  87720. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87721. /**
  87722. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87723. * @param radius The radius of the hemisphere to emit from
  87724. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87725. * @returns the emitter
  87726. */
  87727. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87728. /**
  87729. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87730. * @param radius The radius of the sphere to emit from
  87731. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87732. * @returns the emitter
  87733. */
  87734. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87735. /**
  87736. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87737. * @param radius The radius of the sphere to emit from
  87738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87740. * @returns the emitter
  87741. */
  87742. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87743. /**
  87744. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87745. * @param radius The radius of the emission cylinder
  87746. * @param height The height of the emission cylinder
  87747. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87748. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87749. * @returns the emitter
  87750. */
  87751. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87752. /**
  87753. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87754. * @param radius The radius of the cylinder to emit from
  87755. * @param height The height of the emission cylinder
  87756. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87759. * @returns the emitter
  87760. */
  87761. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87762. /**
  87763. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87764. * @param radius The radius of the cone to emit from
  87765. * @param angle The base angle of the cone
  87766. * @returns the emitter
  87767. */
  87768. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87769. /**
  87770. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87773. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87774. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87775. * @returns the emitter
  87776. */
  87777. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87778. }
  87779. }
  87780. declare module BABYLON {
  87781. /**
  87782. * Type of sub emitter
  87783. */
  87784. export enum SubEmitterType {
  87785. /**
  87786. * Attached to the particle over it's lifetime
  87787. */
  87788. ATTACHED = 0,
  87789. /**
  87790. * Created when the particle dies
  87791. */
  87792. END = 1
  87793. }
  87794. /**
  87795. * Sub emitter class used to emit particles from an existing particle
  87796. */
  87797. export class SubEmitter {
  87798. /**
  87799. * the particle system to be used by the sub emitter
  87800. */
  87801. particleSystem: ParticleSystem;
  87802. /**
  87803. * Type of the submitter (Default: END)
  87804. */
  87805. type: SubEmitterType;
  87806. /**
  87807. * 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)
  87808. * Note: This only is supported when using an emitter of type Mesh
  87809. */
  87810. inheritDirection: boolean;
  87811. /**
  87812. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87813. */
  87814. inheritedVelocityAmount: number;
  87815. /**
  87816. * Creates a sub emitter
  87817. * @param particleSystem the particle system to be used by the sub emitter
  87818. */
  87819. constructor(
  87820. /**
  87821. * the particle system to be used by the sub emitter
  87822. */
  87823. particleSystem: ParticleSystem);
  87824. /**
  87825. * Clones the sub emitter
  87826. * @returns the cloned sub emitter
  87827. */
  87828. clone(): SubEmitter;
  87829. /**
  87830. * Serialize current object to a JSON object
  87831. * @returns the serialized object
  87832. */
  87833. serialize(): any;
  87834. /** @hidden */
  87835. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87836. /**
  87837. * Creates a new SubEmitter from a serialized JSON version
  87838. * @param serializationObject defines the JSON object to read from
  87839. * @param scene defines the hosting scene
  87840. * @param rootUrl defines the rootUrl for data loading
  87841. * @returns a new SubEmitter
  87842. */
  87843. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87844. /** Release associated resources */
  87845. dispose(): void;
  87846. }
  87847. }
  87848. declare module BABYLON {
  87849. /** @hidden */
  87850. export var clipPlaneFragmentDeclaration: {
  87851. name: string;
  87852. shader: string;
  87853. };
  87854. }
  87855. declare module BABYLON {
  87856. /** @hidden */
  87857. export var imageProcessingDeclaration: {
  87858. name: string;
  87859. shader: string;
  87860. };
  87861. }
  87862. declare module BABYLON {
  87863. /** @hidden */
  87864. export var imageProcessingFunctions: {
  87865. name: string;
  87866. shader: string;
  87867. };
  87868. }
  87869. declare module BABYLON {
  87870. /** @hidden */
  87871. export var clipPlaneFragment: {
  87872. name: string;
  87873. shader: string;
  87874. };
  87875. }
  87876. declare module BABYLON {
  87877. /** @hidden */
  87878. export var particlesPixelShader: {
  87879. name: string;
  87880. shader: string;
  87881. };
  87882. }
  87883. declare module BABYLON {
  87884. /** @hidden */
  87885. export var clipPlaneVertexDeclaration: {
  87886. name: string;
  87887. shader: string;
  87888. };
  87889. }
  87890. declare module BABYLON {
  87891. /** @hidden */
  87892. export var clipPlaneVertex: {
  87893. name: string;
  87894. shader: string;
  87895. };
  87896. }
  87897. declare module BABYLON {
  87898. /** @hidden */
  87899. export var particlesVertexShader: {
  87900. name: string;
  87901. shader: string;
  87902. };
  87903. }
  87904. declare module BABYLON {
  87905. /**
  87906. * This represents a particle system in Babylon.
  87907. * 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.
  87908. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87909. * @example https://doc.babylonjs.com/babylon101/particles
  87910. */
  87911. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87912. /**
  87913. * Billboard mode will only apply to Y axis
  87914. */
  87915. static readonly BILLBOARDMODE_Y: number;
  87916. /**
  87917. * Billboard mode will apply to all axes
  87918. */
  87919. static readonly BILLBOARDMODE_ALL: number;
  87920. /**
  87921. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87922. */
  87923. static readonly BILLBOARDMODE_STRETCHED: number;
  87924. /**
  87925. * This function can be defined to provide custom update for active particles.
  87926. * This function will be called instead of regular update (age, position, color, etc.).
  87927. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87928. */
  87929. updateFunction: (particles: Particle[]) => void;
  87930. private _emitterWorldMatrix;
  87931. /**
  87932. * This function can be defined to specify initial direction for every new particle.
  87933. * It by default use the emitterType defined function
  87934. */
  87935. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  87936. /**
  87937. * This function can be defined to specify initial position for every new particle.
  87938. * It by default use the emitterType defined function
  87939. */
  87940. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  87941. /**
  87942. * @hidden
  87943. */
  87944. _inheritedVelocityOffset: Vector3;
  87945. /**
  87946. * An event triggered when the system is disposed
  87947. */
  87948. onDisposeObservable: Observable<ParticleSystem>;
  87949. private _onDisposeObserver;
  87950. /**
  87951. * Sets a callback that will be triggered when the system is disposed
  87952. */
  87953. set onDispose(callback: () => void);
  87954. private _particles;
  87955. private _epsilon;
  87956. private _capacity;
  87957. private _stockParticles;
  87958. private _newPartsExcess;
  87959. private _vertexData;
  87960. private _vertexBuffer;
  87961. private _vertexBuffers;
  87962. private _spriteBuffer;
  87963. private _indexBuffer;
  87964. private _effect;
  87965. private _customEffect;
  87966. private _cachedDefines;
  87967. private _scaledColorStep;
  87968. private _colorDiff;
  87969. private _scaledDirection;
  87970. private _scaledGravity;
  87971. private _currentRenderId;
  87972. private _alive;
  87973. private _useInstancing;
  87974. private _started;
  87975. private _stopped;
  87976. private _actualFrame;
  87977. private _scaledUpdateSpeed;
  87978. private _vertexBufferSize;
  87979. /** @hidden */
  87980. _currentEmitRateGradient: Nullable<FactorGradient>;
  87981. /** @hidden */
  87982. _currentEmitRate1: number;
  87983. /** @hidden */
  87984. _currentEmitRate2: number;
  87985. /** @hidden */
  87986. _currentStartSizeGradient: Nullable<FactorGradient>;
  87987. /** @hidden */
  87988. _currentStartSize1: number;
  87989. /** @hidden */
  87990. _currentStartSize2: number;
  87991. private readonly _rawTextureWidth;
  87992. private _rampGradientsTexture;
  87993. private _useRampGradients;
  87994. /** Gets or sets a boolean indicating that ramp gradients must be used
  87995. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87996. */
  87997. get useRampGradients(): boolean;
  87998. set useRampGradients(value: boolean);
  87999. /**
  88000. * 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.
  88001. * 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: [])
  88002. */
  88003. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88004. private _subEmitters;
  88005. /**
  88006. * @hidden
  88007. * If the particle systems emitter should be disposed when the particle system is disposed
  88008. */
  88009. _disposeEmitterOnDispose: boolean;
  88010. /**
  88011. * The current active Sub-systems, this property is used by the root particle system only.
  88012. */
  88013. activeSubSystems: Array<ParticleSystem>;
  88014. private _rootParticleSystem;
  88015. /**
  88016. * Gets the current list of active particles
  88017. */
  88018. get particles(): Particle[];
  88019. /**
  88020. * Returns the string "ParticleSystem"
  88021. * @returns a string containing the class name
  88022. */
  88023. getClassName(): string;
  88024. /**
  88025. * Instantiates a particle system.
  88026. * 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.
  88027. * @param name The name of the particle system
  88028. * @param capacity The max number of particles alive at the same time
  88029. * @param scene The scene the particle system belongs to
  88030. * @param customEffect a custom effect used to change the way particles are rendered by default
  88031. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88032. * @param epsilon Offset used to render the particles
  88033. */
  88034. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88035. private _addFactorGradient;
  88036. private _removeFactorGradient;
  88037. /**
  88038. * Adds a new life time gradient
  88039. * @param gradient defines the gradient to use (between 0 and 1)
  88040. * @param factor defines the life time factor to affect to the specified gradient
  88041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88042. * @returns the current particle system
  88043. */
  88044. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88045. /**
  88046. * Remove a specific life time gradient
  88047. * @param gradient defines the gradient to remove
  88048. * @returns the current particle system
  88049. */
  88050. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88051. /**
  88052. * Adds a new size gradient
  88053. * @param gradient defines the gradient to use (between 0 and 1)
  88054. * @param factor defines the size factor to affect to the specified gradient
  88055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88056. * @returns the current particle system
  88057. */
  88058. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88059. /**
  88060. * Remove a specific size gradient
  88061. * @param gradient defines the gradient to remove
  88062. * @returns the current particle system
  88063. */
  88064. removeSizeGradient(gradient: number): IParticleSystem;
  88065. /**
  88066. * Adds a new color remap gradient
  88067. * @param gradient defines the gradient to use (between 0 and 1)
  88068. * @param min defines the color remap minimal range
  88069. * @param max defines the color remap maximal range
  88070. * @returns the current particle system
  88071. */
  88072. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88073. /**
  88074. * Remove a specific color remap gradient
  88075. * @param gradient defines the gradient to remove
  88076. * @returns the current particle system
  88077. */
  88078. removeColorRemapGradient(gradient: number): IParticleSystem;
  88079. /**
  88080. * Adds a new alpha remap gradient
  88081. * @param gradient defines the gradient to use (between 0 and 1)
  88082. * @param min defines the alpha remap minimal range
  88083. * @param max defines the alpha remap maximal range
  88084. * @returns the current particle system
  88085. */
  88086. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88087. /**
  88088. * Remove a specific alpha remap gradient
  88089. * @param gradient defines the gradient to remove
  88090. * @returns the current particle system
  88091. */
  88092. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88093. /**
  88094. * Adds a new angular speed gradient
  88095. * @param gradient defines the gradient to use (between 0 and 1)
  88096. * @param factor defines the angular speed to affect to the specified gradient
  88097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88098. * @returns the current particle system
  88099. */
  88100. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88101. /**
  88102. * Remove a specific angular speed gradient
  88103. * @param gradient defines the gradient to remove
  88104. * @returns the current particle system
  88105. */
  88106. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88107. /**
  88108. * Adds a new velocity gradient
  88109. * @param gradient defines the gradient to use (between 0 and 1)
  88110. * @param factor defines the velocity to affect to the specified gradient
  88111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88112. * @returns the current particle system
  88113. */
  88114. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88115. /**
  88116. * Remove a specific velocity gradient
  88117. * @param gradient defines the gradient to remove
  88118. * @returns the current particle system
  88119. */
  88120. removeVelocityGradient(gradient: number): IParticleSystem;
  88121. /**
  88122. * Adds a new limit velocity gradient
  88123. * @param gradient defines the gradient to use (between 0 and 1)
  88124. * @param factor defines the limit velocity value to affect to the specified gradient
  88125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88126. * @returns the current particle system
  88127. */
  88128. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88129. /**
  88130. * Remove a specific limit velocity gradient
  88131. * @param gradient defines the gradient to remove
  88132. * @returns the current particle system
  88133. */
  88134. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88135. /**
  88136. * Adds a new drag gradient
  88137. * @param gradient defines the gradient to use (between 0 and 1)
  88138. * @param factor defines the drag value to affect to the specified gradient
  88139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88140. * @returns the current particle system
  88141. */
  88142. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88143. /**
  88144. * Remove a specific drag gradient
  88145. * @param gradient defines the gradient to remove
  88146. * @returns the current particle system
  88147. */
  88148. removeDragGradient(gradient: number): IParticleSystem;
  88149. /**
  88150. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88151. * @param gradient defines the gradient to use (between 0 and 1)
  88152. * @param factor defines the emit rate value to affect to the specified gradient
  88153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88154. * @returns the current particle system
  88155. */
  88156. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88157. /**
  88158. * Remove a specific emit rate gradient
  88159. * @param gradient defines the gradient to remove
  88160. * @returns the current particle system
  88161. */
  88162. removeEmitRateGradient(gradient: number): IParticleSystem;
  88163. /**
  88164. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88165. * @param gradient defines the gradient to use (between 0 and 1)
  88166. * @param factor defines the start size value to affect to the specified gradient
  88167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88168. * @returns the current particle system
  88169. */
  88170. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88171. /**
  88172. * Remove a specific start size gradient
  88173. * @param gradient defines the gradient to remove
  88174. * @returns the current particle system
  88175. */
  88176. removeStartSizeGradient(gradient: number): IParticleSystem;
  88177. private _createRampGradientTexture;
  88178. /**
  88179. * Gets the current list of ramp gradients.
  88180. * You must use addRampGradient and removeRampGradient to udpate this list
  88181. * @returns the list of ramp gradients
  88182. */
  88183. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88184. /**
  88185. * Adds a new ramp gradient used to remap particle colors
  88186. * @param gradient defines the gradient to use (between 0 and 1)
  88187. * @param color defines the color to affect to the specified gradient
  88188. * @returns the current particle system
  88189. */
  88190. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88191. /**
  88192. * Remove a specific ramp gradient
  88193. * @param gradient defines the gradient to remove
  88194. * @returns the current particle system
  88195. */
  88196. removeRampGradient(gradient: number): ParticleSystem;
  88197. /**
  88198. * Adds a new color gradient
  88199. * @param gradient defines the gradient to use (between 0 and 1)
  88200. * @param color1 defines the color to affect to the specified gradient
  88201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88202. * @returns this particle system
  88203. */
  88204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88205. /**
  88206. * Remove a specific color gradient
  88207. * @param gradient defines the gradient to remove
  88208. * @returns this particle system
  88209. */
  88210. removeColorGradient(gradient: number): IParticleSystem;
  88211. private _fetchR;
  88212. protected _reset(): void;
  88213. private _resetEffect;
  88214. private _createVertexBuffers;
  88215. private _createIndexBuffer;
  88216. /**
  88217. * Gets the maximum number of particles active at the same time.
  88218. * @returns The max number of active particles.
  88219. */
  88220. getCapacity(): number;
  88221. /**
  88222. * Gets whether there are still active particles in the system.
  88223. * @returns True if it is alive, otherwise false.
  88224. */
  88225. isAlive(): boolean;
  88226. /**
  88227. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88228. * @returns True if it has been started, otherwise false.
  88229. */
  88230. isStarted(): boolean;
  88231. private _prepareSubEmitterInternalArray;
  88232. /**
  88233. * Starts the particle system and begins to emit
  88234. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88235. */
  88236. start(delay?: number): void;
  88237. /**
  88238. * Stops the particle system.
  88239. * @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.
  88240. */
  88241. stop(stopSubEmitters?: boolean): void;
  88242. /**
  88243. * Remove all active particles
  88244. */
  88245. reset(): void;
  88246. /**
  88247. * @hidden (for internal use only)
  88248. */
  88249. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88250. /**
  88251. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88252. * Its lifetime will start back at 0.
  88253. */
  88254. recycleParticle: (particle: Particle) => void;
  88255. private _stopSubEmitters;
  88256. private _createParticle;
  88257. private _removeFromRoot;
  88258. private _emitFromParticle;
  88259. private _update;
  88260. /** @hidden */
  88261. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88262. /** @hidden */
  88263. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88264. /** @hidden */
  88265. private _getEffect;
  88266. /**
  88267. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88268. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88269. */
  88270. animate(preWarmOnly?: boolean): void;
  88271. private _appendParticleVertices;
  88272. /**
  88273. * Rebuilds the particle system.
  88274. */
  88275. rebuild(): void;
  88276. /**
  88277. * Is this system ready to be used/rendered
  88278. * @return true if the system is ready
  88279. */
  88280. isReady(): boolean;
  88281. private _render;
  88282. /**
  88283. * Renders the particle system in its current state.
  88284. * @returns the current number of particles
  88285. */
  88286. render(): number;
  88287. /**
  88288. * Disposes the particle system and free the associated resources
  88289. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88290. */
  88291. dispose(disposeTexture?: boolean): void;
  88292. /**
  88293. * Clones the particle system.
  88294. * @param name The name of the cloned object
  88295. * @param newEmitter The new emitter to use
  88296. * @returns the cloned particle system
  88297. */
  88298. clone(name: string, newEmitter: any): ParticleSystem;
  88299. /**
  88300. * Serializes the particle system to a JSON object.
  88301. * @returns the JSON object
  88302. */
  88303. serialize(): any;
  88304. /** @hidden */
  88305. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88306. /** @hidden */
  88307. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88308. /**
  88309. * Parses a JSON object to create a particle system.
  88310. * @param parsedParticleSystem The JSON object to parse
  88311. * @param scene The scene to create the particle system in
  88312. * @param rootUrl The root url to use to load external dependencies like texture
  88313. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88314. * @returns the Parsed particle system
  88315. */
  88316. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88317. }
  88318. }
  88319. declare module BABYLON {
  88320. /**
  88321. * A particle represents one of the element emitted by a particle system.
  88322. * This is mainly define by its coordinates, direction, velocity and age.
  88323. */
  88324. export class Particle {
  88325. /**
  88326. * The particle system the particle belongs to.
  88327. */
  88328. particleSystem: ParticleSystem;
  88329. private static _Count;
  88330. /**
  88331. * Unique ID of the particle
  88332. */
  88333. id: number;
  88334. /**
  88335. * The world position of the particle in the scene.
  88336. */
  88337. position: Vector3;
  88338. /**
  88339. * The world direction of the particle in the scene.
  88340. */
  88341. direction: Vector3;
  88342. /**
  88343. * The color of the particle.
  88344. */
  88345. color: Color4;
  88346. /**
  88347. * The color change of the particle per step.
  88348. */
  88349. colorStep: Color4;
  88350. /**
  88351. * Defines how long will the life of the particle be.
  88352. */
  88353. lifeTime: number;
  88354. /**
  88355. * The current age of the particle.
  88356. */
  88357. age: number;
  88358. /**
  88359. * The current size of the particle.
  88360. */
  88361. size: number;
  88362. /**
  88363. * The current scale of the particle.
  88364. */
  88365. scale: Vector2;
  88366. /**
  88367. * The current angle of the particle.
  88368. */
  88369. angle: number;
  88370. /**
  88371. * Defines how fast is the angle changing.
  88372. */
  88373. angularSpeed: number;
  88374. /**
  88375. * Defines the cell index used by the particle to be rendered from a sprite.
  88376. */
  88377. cellIndex: number;
  88378. /**
  88379. * The information required to support color remapping
  88380. */
  88381. remapData: Vector4;
  88382. /** @hidden */
  88383. _randomCellOffset?: number;
  88384. /** @hidden */
  88385. _initialDirection: Nullable<Vector3>;
  88386. /** @hidden */
  88387. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88388. /** @hidden */
  88389. _initialStartSpriteCellID: number;
  88390. /** @hidden */
  88391. _initialEndSpriteCellID: number;
  88392. /** @hidden */
  88393. _currentColorGradient: Nullable<ColorGradient>;
  88394. /** @hidden */
  88395. _currentColor1: Color4;
  88396. /** @hidden */
  88397. _currentColor2: Color4;
  88398. /** @hidden */
  88399. _currentSizeGradient: Nullable<FactorGradient>;
  88400. /** @hidden */
  88401. _currentSize1: number;
  88402. /** @hidden */
  88403. _currentSize2: number;
  88404. /** @hidden */
  88405. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88406. /** @hidden */
  88407. _currentAngularSpeed1: number;
  88408. /** @hidden */
  88409. _currentAngularSpeed2: number;
  88410. /** @hidden */
  88411. _currentVelocityGradient: Nullable<FactorGradient>;
  88412. /** @hidden */
  88413. _currentVelocity1: number;
  88414. /** @hidden */
  88415. _currentVelocity2: number;
  88416. /** @hidden */
  88417. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88418. /** @hidden */
  88419. _currentLimitVelocity1: number;
  88420. /** @hidden */
  88421. _currentLimitVelocity2: number;
  88422. /** @hidden */
  88423. _currentDragGradient: Nullable<FactorGradient>;
  88424. /** @hidden */
  88425. _currentDrag1: number;
  88426. /** @hidden */
  88427. _currentDrag2: number;
  88428. /** @hidden */
  88429. _randomNoiseCoordinates1: Vector3;
  88430. /** @hidden */
  88431. _randomNoiseCoordinates2: Vector3;
  88432. /**
  88433. * Creates a new instance Particle
  88434. * @param particleSystem the particle system the particle belongs to
  88435. */
  88436. constructor(
  88437. /**
  88438. * The particle system the particle belongs to.
  88439. */
  88440. particleSystem: ParticleSystem);
  88441. private updateCellInfoFromSystem;
  88442. /**
  88443. * Defines how the sprite cell index is updated for the particle
  88444. */
  88445. updateCellIndex(): void;
  88446. /** @hidden */
  88447. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88448. /** @hidden */
  88449. _inheritParticleInfoToSubEmitters(): void;
  88450. /** @hidden */
  88451. _reset(): void;
  88452. /**
  88453. * Copy the properties of particle to another one.
  88454. * @param other the particle to copy the information to.
  88455. */
  88456. copyTo(other: Particle): void;
  88457. }
  88458. }
  88459. declare module BABYLON {
  88460. /**
  88461. * Particle emitter represents a volume emitting particles.
  88462. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88463. */
  88464. export interface IParticleEmitterType {
  88465. /**
  88466. * Called by the particle System when the direction is computed for the created particle.
  88467. * @param worldMatrix is the world matrix of the particle system
  88468. * @param directionToUpdate is the direction vector to update with the result
  88469. * @param particle is the particle we are computed the direction for
  88470. */
  88471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88472. /**
  88473. * Called by the particle System when the position is computed for the created particle.
  88474. * @param worldMatrix is the world matrix of the particle system
  88475. * @param positionToUpdate is the position vector to update with the result
  88476. * @param particle is the particle we are computed the position for
  88477. */
  88478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88479. /**
  88480. * Clones the current emitter and returns a copy of it
  88481. * @returns the new emitter
  88482. */
  88483. clone(): IParticleEmitterType;
  88484. /**
  88485. * Called by the GPUParticleSystem to setup the update shader
  88486. * @param effect defines the update shader
  88487. */
  88488. applyToShader(effect: Effect): void;
  88489. /**
  88490. * Returns a string to use to update the GPU particles update shader
  88491. * @returns the effect defines string
  88492. */
  88493. getEffectDefines(): string;
  88494. /**
  88495. * Returns a string representing the class name
  88496. * @returns a string containing the class name
  88497. */
  88498. getClassName(): string;
  88499. /**
  88500. * Serializes the particle system to a JSON object.
  88501. * @returns the JSON object
  88502. */
  88503. serialize(): any;
  88504. /**
  88505. * Parse properties from a JSON object
  88506. * @param serializationObject defines the JSON object
  88507. */
  88508. parse(serializationObject: any): void;
  88509. }
  88510. }
  88511. declare module BABYLON {
  88512. /**
  88513. * Particle emitter emitting particles from the inside of a box.
  88514. * It emits the particles randomly between 2 given directions.
  88515. */
  88516. export class BoxParticleEmitter implements IParticleEmitterType {
  88517. /**
  88518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88519. */
  88520. direction1: Vector3;
  88521. /**
  88522. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88523. */
  88524. direction2: Vector3;
  88525. /**
  88526. * 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.
  88527. */
  88528. minEmitBox: Vector3;
  88529. /**
  88530. * 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.
  88531. */
  88532. maxEmitBox: Vector3;
  88533. /**
  88534. * Creates a new instance BoxParticleEmitter
  88535. */
  88536. constructor();
  88537. /**
  88538. * Called by the particle System when the direction is computed for the created particle.
  88539. * @param worldMatrix is the world matrix of the particle system
  88540. * @param directionToUpdate is the direction vector to update with the result
  88541. * @param particle is the particle we are computed the direction for
  88542. */
  88543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88544. /**
  88545. * Called by the particle System when the position is computed for the created particle.
  88546. * @param worldMatrix is the world matrix of the particle system
  88547. * @param positionToUpdate is the position vector to update with the result
  88548. * @param particle is the particle we are computed the position for
  88549. */
  88550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88551. /**
  88552. * Clones the current emitter and returns a copy of it
  88553. * @returns the new emitter
  88554. */
  88555. clone(): BoxParticleEmitter;
  88556. /**
  88557. * Called by the GPUParticleSystem to setup the update shader
  88558. * @param effect defines the update shader
  88559. */
  88560. applyToShader(effect: Effect): void;
  88561. /**
  88562. * Returns a string to use to update the GPU particles update shader
  88563. * @returns a string containng the defines string
  88564. */
  88565. getEffectDefines(): string;
  88566. /**
  88567. * Returns the string "BoxParticleEmitter"
  88568. * @returns a string containing the class name
  88569. */
  88570. getClassName(): string;
  88571. /**
  88572. * Serializes the particle system to a JSON object.
  88573. * @returns the JSON object
  88574. */
  88575. serialize(): any;
  88576. /**
  88577. * Parse properties from a JSON object
  88578. * @param serializationObject defines the JSON object
  88579. */
  88580. parse(serializationObject: any): void;
  88581. }
  88582. }
  88583. declare module BABYLON {
  88584. /**
  88585. * Particle emitter emitting particles from the inside of a cone.
  88586. * It emits the particles alongside the cone volume from the base to the particle.
  88587. * The emission direction might be randomized.
  88588. */
  88589. export class ConeParticleEmitter implements IParticleEmitterType {
  88590. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88591. directionRandomizer: number;
  88592. private _radius;
  88593. private _angle;
  88594. private _height;
  88595. /**
  88596. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88597. */
  88598. radiusRange: number;
  88599. /**
  88600. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88601. */
  88602. heightRange: number;
  88603. /**
  88604. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88605. */
  88606. emitFromSpawnPointOnly: boolean;
  88607. /**
  88608. * Gets or sets the radius of the emission cone
  88609. */
  88610. get radius(): number;
  88611. set radius(value: number);
  88612. /**
  88613. * Gets or sets the angle of the emission cone
  88614. */
  88615. get angle(): number;
  88616. set angle(value: number);
  88617. private _buildHeight;
  88618. /**
  88619. * Creates a new instance ConeParticleEmitter
  88620. * @param radius the radius of the emission cone (1 by default)
  88621. * @param angle the cone base angle (PI by default)
  88622. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88623. */
  88624. constructor(radius?: number, angle?: number,
  88625. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88626. directionRandomizer?: number);
  88627. /**
  88628. * Called by the particle System when the direction is computed for the created particle.
  88629. * @param worldMatrix is the world matrix of the particle system
  88630. * @param directionToUpdate is the direction vector to update with the result
  88631. * @param particle is the particle we are computed the direction for
  88632. */
  88633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88634. /**
  88635. * Called by the particle System when the position is computed for the created particle.
  88636. * @param worldMatrix is the world matrix of the particle system
  88637. * @param positionToUpdate is the position vector to update with the result
  88638. * @param particle is the particle we are computed the position for
  88639. */
  88640. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88641. /**
  88642. * Clones the current emitter and returns a copy of it
  88643. * @returns the new emitter
  88644. */
  88645. clone(): ConeParticleEmitter;
  88646. /**
  88647. * Called by the GPUParticleSystem to setup the update shader
  88648. * @param effect defines the update shader
  88649. */
  88650. applyToShader(effect: Effect): void;
  88651. /**
  88652. * Returns a string to use to update the GPU particles update shader
  88653. * @returns a string containng the defines string
  88654. */
  88655. getEffectDefines(): string;
  88656. /**
  88657. * Returns the string "ConeParticleEmitter"
  88658. * @returns a string containing the class name
  88659. */
  88660. getClassName(): string;
  88661. /**
  88662. * Serializes the particle system to a JSON object.
  88663. * @returns the JSON object
  88664. */
  88665. serialize(): any;
  88666. /**
  88667. * Parse properties from a JSON object
  88668. * @param serializationObject defines the JSON object
  88669. */
  88670. parse(serializationObject: any): void;
  88671. }
  88672. }
  88673. declare module BABYLON {
  88674. /**
  88675. * Particle emitter emitting particles from the inside of a cylinder.
  88676. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88677. */
  88678. export class CylinderParticleEmitter implements IParticleEmitterType {
  88679. /**
  88680. * The radius of the emission cylinder.
  88681. */
  88682. radius: number;
  88683. /**
  88684. * The height of the emission cylinder.
  88685. */
  88686. height: number;
  88687. /**
  88688. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88689. */
  88690. radiusRange: number;
  88691. /**
  88692. * How much to randomize the particle direction [0-1].
  88693. */
  88694. directionRandomizer: number;
  88695. /**
  88696. * Creates a new instance CylinderParticleEmitter
  88697. * @param radius the radius of the emission cylinder (1 by default)
  88698. * @param height the height of the emission cylinder (1 by default)
  88699. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88700. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88701. */
  88702. constructor(
  88703. /**
  88704. * The radius of the emission cylinder.
  88705. */
  88706. radius?: number,
  88707. /**
  88708. * The height of the emission cylinder.
  88709. */
  88710. height?: number,
  88711. /**
  88712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88713. */
  88714. radiusRange?: number,
  88715. /**
  88716. * How much to randomize the particle direction [0-1].
  88717. */
  88718. directionRandomizer?: number);
  88719. /**
  88720. * Called by the particle System when the direction is computed for the created particle.
  88721. * @param worldMatrix is the world matrix of the particle system
  88722. * @param directionToUpdate is the direction vector to update with the result
  88723. * @param particle is the particle we are computed the direction for
  88724. */
  88725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88726. /**
  88727. * Called by the particle System when the position is computed for the created particle.
  88728. * @param worldMatrix is the world matrix of the particle system
  88729. * @param positionToUpdate is the position vector to update with the result
  88730. * @param particle is the particle we are computed the position for
  88731. */
  88732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88733. /**
  88734. * Clones the current emitter and returns a copy of it
  88735. * @returns the new emitter
  88736. */
  88737. clone(): CylinderParticleEmitter;
  88738. /**
  88739. * Called by the GPUParticleSystem to setup the update shader
  88740. * @param effect defines the update shader
  88741. */
  88742. applyToShader(effect: Effect): void;
  88743. /**
  88744. * Returns a string to use to update the GPU particles update shader
  88745. * @returns a string containng the defines string
  88746. */
  88747. getEffectDefines(): string;
  88748. /**
  88749. * Returns the string "CylinderParticleEmitter"
  88750. * @returns a string containing the class name
  88751. */
  88752. getClassName(): string;
  88753. /**
  88754. * Serializes the particle system to a JSON object.
  88755. * @returns the JSON object
  88756. */
  88757. serialize(): any;
  88758. /**
  88759. * Parse properties from a JSON object
  88760. * @param serializationObject defines the JSON object
  88761. */
  88762. parse(serializationObject: any): void;
  88763. }
  88764. /**
  88765. * Particle emitter emitting particles from the inside of a cylinder.
  88766. * It emits the particles randomly between two vectors.
  88767. */
  88768. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88769. /**
  88770. * The min limit of the emission direction.
  88771. */
  88772. direction1: Vector3;
  88773. /**
  88774. * The max limit of the emission direction.
  88775. */
  88776. direction2: Vector3;
  88777. /**
  88778. * Creates a new instance CylinderDirectedParticleEmitter
  88779. * @param radius the radius of the emission cylinder (1 by default)
  88780. * @param height the height of the emission cylinder (1 by default)
  88781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88782. * @param direction1 the min limit of the emission direction (up vector by default)
  88783. * @param direction2 the max limit of the emission direction (up vector by default)
  88784. */
  88785. constructor(radius?: number, height?: number, radiusRange?: number,
  88786. /**
  88787. * The min limit of the emission direction.
  88788. */
  88789. direction1?: Vector3,
  88790. /**
  88791. * The max limit of the emission direction.
  88792. */
  88793. direction2?: Vector3);
  88794. /**
  88795. * Called by the particle System when the direction is computed for the created particle.
  88796. * @param worldMatrix is the world matrix of the particle system
  88797. * @param directionToUpdate is the direction vector to update with the result
  88798. * @param particle is the particle we are computed the direction for
  88799. */
  88800. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88801. /**
  88802. * Clones the current emitter and returns a copy of it
  88803. * @returns the new emitter
  88804. */
  88805. clone(): CylinderDirectedParticleEmitter;
  88806. /**
  88807. * Called by the GPUParticleSystem to setup the update shader
  88808. * @param effect defines the update shader
  88809. */
  88810. applyToShader(effect: Effect): void;
  88811. /**
  88812. * Returns a string to use to update the GPU particles update shader
  88813. * @returns a string containng the defines string
  88814. */
  88815. getEffectDefines(): string;
  88816. /**
  88817. * Returns the string "CylinderDirectedParticleEmitter"
  88818. * @returns a string containing the class name
  88819. */
  88820. getClassName(): string;
  88821. /**
  88822. * Serializes the particle system to a JSON object.
  88823. * @returns the JSON object
  88824. */
  88825. serialize(): any;
  88826. /**
  88827. * Parse properties from a JSON object
  88828. * @param serializationObject defines the JSON object
  88829. */
  88830. parse(serializationObject: any): void;
  88831. }
  88832. }
  88833. declare module BABYLON {
  88834. /**
  88835. * Particle emitter emitting particles from the inside of a hemisphere.
  88836. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88837. */
  88838. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88839. /**
  88840. * The radius of the emission hemisphere.
  88841. */
  88842. radius: number;
  88843. /**
  88844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88845. */
  88846. radiusRange: number;
  88847. /**
  88848. * How much to randomize the particle direction [0-1].
  88849. */
  88850. directionRandomizer: number;
  88851. /**
  88852. * Creates a new instance HemisphericParticleEmitter
  88853. * @param radius the radius of the emission hemisphere (1 by default)
  88854. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88855. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88856. */
  88857. constructor(
  88858. /**
  88859. * The radius of the emission hemisphere.
  88860. */
  88861. radius?: number,
  88862. /**
  88863. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88864. */
  88865. radiusRange?: number,
  88866. /**
  88867. * How much to randomize the particle direction [0-1].
  88868. */
  88869. directionRandomizer?: number);
  88870. /**
  88871. * Called by the particle System when the direction is computed for the created particle.
  88872. * @param worldMatrix is the world matrix of the particle system
  88873. * @param directionToUpdate is the direction vector to update with the result
  88874. * @param particle is the particle we are computed the direction for
  88875. */
  88876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88877. /**
  88878. * Called by the particle System when the position is computed for the created particle.
  88879. * @param worldMatrix is the world matrix of the particle system
  88880. * @param positionToUpdate is the position vector to update with the result
  88881. * @param particle is the particle we are computed the position for
  88882. */
  88883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88884. /**
  88885. * Clones the current emitter and returns a copy of it
  88886. * @returns the new emitter
  88887. */
  88888. clone(): HemisphericParticleEmitter;
  88889. /**
  88890. * Called by the GPUParticleSystem to setup the update shader
  88891. * @param effect defines the update shader
  88892. */
  88893. applyToShader(effect: Effect): void;
  88894. /**
  88895. * Returns a string to use to update the GPU particles update shader
  88896. * @returns a string containng the defines string
  88897. */
  88898. getEffectDefines(): string;
  88899. /**
  88900. * Returns the string "HemisphericParticleEmitter"
  88901. * @returns a string containing the class name
  88902. */
  88903. getClassName(): string;
  88904. /**
  88905. * Serializes the particle system to a JSON object.
  88906. * @returns the JSON object
  88907. */
  88908. serialize(): any;
  88909. /**
  88910. * Parse properties from a JSON object
  88911. * @param serializationObject defines the JSON object
  88912. */
  88913. parse(serializationObject: any): void;
  88914. }
  88915. }
  88916. declare module BABYLON {
  88917. /**
  88918. * Particle emitter emitting particles from a point.
  88919. * It emits the particles randomly between 2 given directions.
  88920. */
  88921. export class PointParticleEmitter implements IParticleEmitterType {
  88922. /**
  88923. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88924. */
  88925. direction1: Vector3;
  88926. /**
  88927. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88928. */
  88929. direction2: Vector3;
  88930. /**
  88931. * Creates a new instance PointParticleEmitter
  88932. */
  88933. constructor();
  88934. /**
  88935. * Called by the particle System when the direction is computed for the created particle.
  88936. * @param worldMatrix is the world matrix of the particle system
  88937. * @param directionToUpdate is the direction vector to update with the result
  88938. * @param particle is the particle we are computed the direction for
  88939. */
  88940. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88941. /**
  88942. * Called by the particle System when the position is computed for the created particle.
  88943. * @param worldMatrix is the world matrix of the particle system
  88944. * @param positionToUpdate is the position vector to update with the result
  88945. * @param particle is the particle we are computed the position for
  88946. */
  88947. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88948. /**
  88949. * Clones the current emitter and returns a copy of it
  88950. * @returns the new emitter
  88951. */
  88952. clone(): PointParticleEmitter;
  88953. /**
  88954. * Called by the GPUParticleSystem to setup the update shader
  88955. * @param effect defines the update shader
  88956. */
  88957. applyToShader(effect: Effect): void;
  88958. /**
  88959. * Returns a string to use to update the GPU particles update shader
  88960. * @returns a string containng the defines string
  88961. */
  88962. getEffectDefines(): string;
  88963. /**
  88964. * Returns the string "PointParticleEmitter"
  88965. * @returns a string containing the class name
  88966. */
  88967. getClassName(): string;
  88968. /**
  88969. * Serializes the particle system to a JSON object.
  88970. * @returns the JSON object
  88971. */
  88972. serialize(): any;
  88973. /**
  88974. * Parse properties from a JSON object
  88975. * @param serializationObject defines the JSON object
  88976. */
  88977. parse(serializationObject: any): void;
  88978. }
  88979. }
  88980. declare module BABYLON {
  88981. /**
  88982. * Particle emitter emitting particles from the inside of a sphere.
  88983. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88984. */
  88985. export class SphereParticleEmitter implements IParticleEmitterType {
  88986. /**
  88987. * The radius of the emission sphere.
  88988. */
  88989. radius: number;
  88990. /**
  88991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88992. */
  88993. radiusRange: number;
  88994. /**
  88995. * How much to randomize the particle direction [0-1].
  88996. */
  88997. directionRandomizer: number;
  88998. /**
  88999. * Creates a new instance SphereParticleEmitter
  89000. * @param radius the radius of the emission sphere (1 by default)
  89001. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89002. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89003. */
  89004. constructor(
  89005. /**
  89006. * The radius of the emission sphere.
  89007. */
  89008. radius?: number,
  89009. /**
  89010. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89011. */
  89012. radiusRange?: number,
  89013. /**
  89014. * How much to randomize the particle direction [0-1].
  89015. */
  89016. directionRandomizer?: number);
  89017. /**
  89018. * Called by the particle System when the direction is computed for the created particle.
  89019. * @param worldMatrix is the world matrix of the particle system
  89020. * @param directionToUpdate is the direction vector to update with the result
  89021. * @param particle is the particle we are computed the direction for
  89022. */
  89023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89024. /**
  89025. * Called by the particle System when the position is computed for the created particle.
  89026. * @param worldMatrix is the world matrix of the particle system
  89027. * @param positionToUpdate is the position vector to update with the result
  89028. * @param particle is the particle we are computed the position for
  89029. */
  89030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89031. /**
  89032. * Clones the current emitter and returns a copy of it
  89033. * @returns the new emitter
  89034. */
  89035. clone(): SphereParticleEmitter;
  89036. /**
  89037. * Called by the GPUParticleSystem to setup the update shader
  89038. * @param effect defines the update shader
  89039. */
  89040. applyToShader(effect: Effect): void;
  89041. /**
  89042. * Returns a string to use to update the GPU particles update shader
  89043. * @returns a string containng the defines string
  89044. */
  89045. getEffectDefines(): string;
  89046. /**
  89047. * Returns the string "SphereParticleEmitter"
  89048. * @returns a string containing the class name
  89049. */
  89050. getClassName(): string;
  89051. /**
  89052. * Serializes the particle system to a JSON object.
  89053. * @returns the JSON object
  89054. */
  89055. serialize(): any;
  89056. /**
  89057. * Parse properties from a JSON object
  89058. * @param serializationObject defines the JSON object
  89059. */
  89060. parse(serializationObject: any): void;
  89061. }
  89062. /**
  89063. * Particle emitter emitting particles from the inside of a sphere.
  89064. * It emits the particles randomly between two vectors.
  89065. */
  89066. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89067. /**
  89068. * The min limit of the emission direction.
  89069. */
  89070. direction1: Vector3;
  89071. /**
  89072. * The max limit of the emission direction.
  89073. */
  89074. direction2: Vector3;
  89075. /**
  89076. * Creates a new instance SphereDirectedParticleEmitter
  89077. * @param radius the radius of the emission sphere (1 by default)
  89078. * @param direction1 the min limit of the emission direction (up vector by default)
  89079. * @param direction2 the max limit of the emission direction (up vector by default)
  89080. */
  89081. constructor(radius?: number,
  89082. /**
  89083. * The min limit of the emission direction.
  89084. */
  89085. direction1?: Vector3,
  89086. /**
  89087. * The max limit of the emission direction.
  89088. */
  89089. direction2?: Vector3);
  89090. /**
  89091. * Called by the particle System when the direction is computed for the created particle.
  89092. * @param worldMatrix is the world matrix of the particle system
  89093. * @param directionToUpdate is the direction vector to update with the result
  89094. * @param particle is the particle we are computed the direction for
  89095. */
  89096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89097. /**
  89098. * Clones the current emitter and returns a copy of it
  89099. * @returns the new emitter
  89100. */
  89101. clone(): SphereDirectedParticleEmitter;
  89102. /**
  89103. * Called by the GPUParticleSystem to setup the update shader
  89104. * @param effect defines the update shader
  89105. */
  89106. applyToShader(effect: Effect): void;
  89107. /**
  89108. * Returns a string to use to update the GPU particles update shader
  89109. * @returns a string containng the defines string
  89110. */
  89111. getEffectDefines(): string;
  89112. /**
  89113. * Returns the string "SphereDirectedParticleEmitter"
  89114. * @returns a string containing the class name
  89115. */
  89116. getClassName(): string;
  89117. /**
  89118. * Serializes the particle system to a JSON object.
  89119. * @returns the JSON object
  89120. */
  89121. serialize(): any;
  89122. /**
  89123. * Parse properties from a JSON object
  89124. * @param serializationObject defines the JSON object
  89125. */
  89126. parse(serializationObject: any): void;
  89127. }
  89128. }
  89129. declare module BABYLON {
  89130. /**
  89131. * Interface representing a particle system in Babylon.js.
  89132. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89133. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89134. */
  89135. export interface IParticleSystem {
  89136. /**
  89137. * List of animations used by the particle system.
  89138. */
  89139. animations: Animation[];
  89140. /**
  89141. * The id of the Particle system.
  89142. */
  89143. id: string;
  89144. /**
  89145. * The name of the Particle system.
  89146. */
  89147. name: string;
  89148. /**
  89149. * The emitter represents the Mesh or position we are attaching the particle system to.
  89150. */
  89151. emitter: Nullable<AbstractMesh | Vector3>;
  89152. /**
  89153. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89154. */
  89155. isBillboardBased: boolean;
  89156. /**
  89157. * The rendering group used by the Particle system to chose when to render.
  89158. */
  89159. renderingGroupId: number;
  89160. /**
  89161. * The layer mask we are rendering the particles through.
  89162. */
  89163. layerMask: number;
  89164. /**
  89165. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89166. */
  89167. updateSpeed: number;
  89168. /**
  89169. * The amount of time the particle system is running (depends of the overall update speed).
  89170. */
  89171. targetStopDuration: number;
  89172. /**
  89173. * The texture used to render each particle. (this can be a spritesheet)
  89174. */
  89175. particleTexture: Nullable<Texture>;
  89176. /**
  89177. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89178. */
  89179. blendMode: number;
  89180. /**
  89181. * Minimum life time of emitting particles.
  89182. */
  89183. minLifeTime: number;
  89184. /**
  89185. * Maximum life time of emitting particles.
  89186. */
  89187. maxLifeTime: number;
  89188. /**
  89189. * Minimum Size of emitting particles.
  89190. */
  89191. minSize: number;
  89192. /**
  89193. * Maximum Size of emitting particles.
  89194. */
  89195. maxSize: number;
  89196. /**
  89197. * Minimum scale of emitting particles on X axis.
  89198. */
  89199. minScaleX: number;
  89200. /**
  89201. * Maximum scale of emitting particles on X axis.
  89202. */
  89203. maxScaleX: number;
  89204. /**
  89205. * Minimum scale of emitting particles on Y axis.
  89206. */
  89207. minScaleY: number;
  89208. /**
  89209. * Maximum scale of emitting particles on Y axis.
  89210. */
  89211. maxScaleY: number;
  89212. /**
  89213. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89214. */
  89215. color1: Color4;
  89216. /**
  89217. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89218. */
  89219. color2: Color4;
  89220. /**
  89221. * Color the particle will have at the end of its lifetime.
  89222. */
  89223. colorDead: Color4;
  89224. /**
  89225. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89226. */
  89227. emitRate: number;
  89228. /**
  89229. * You can use gravity if you want to give an orientation to your particles.
  89230. */
  89231. gravity: Vector3;
  89232. /**
  89233. * Minimum power of emitting particles.
  89234. */
  89235. minEmitPower: number;
  89236. /**
  89237. * Maximum power of emitting particles.
  89238. */
  89239. maxEmitPower: number;
  89240. /**
  89241. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89242. */
  89243. minAngularSpeed: number;
  89244. /**
  89245. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89246. */
  89247. maxAngularSpeed: number;
  89248. /**
  89249. * Gets or sets the minimal initial rotation in radians.
  89250. */
  89251. minInitialRotation: number;
  89252. /**
  89253. * Gets or sets the maximal initial rotation in radians.
  89254. */
  89255. maxInitialRotation: number;
  89256. /**
  89257. * The particle emitter type defines the emitter used by the particle system.
  89258. * It can be for example box, sphere, or cone...
  89259. */
  89260. particleEmitterType: Nullable<IParticleEmitterType>;
  89261. /**
  89262. * Defines the delay in milliseconds before starting the system (0 by default)
  89263. */
  89264. startDelay: number;
  89265. /**
  89266. * 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
  89267. */
  89268. preWarmCycles: number;
  89269. /**
  89270. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89271. */
  89272. preWarmStepOffset: number;
  89273. /**
  89274. * 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)
  89275. */
  89276. spriteCellChangeSpeed: number;
  89277. /**
  89278. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89279. */
  89280. startSpriteCellID: number;
  89281. /**
  89282. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89283. */
  89284. endSpriteCellID: number;
  89285. /**
  89286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89287. */
  89288. spriteCellWidth: number;
  89289. /**
  89290. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89291. */
  89292. spriteCellHeight: number;
  89293. /**
  89294. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89295. */
  89296. spriteRandomStartCell: boolean;
  89297. /**
  89298. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89299. */
  89300. isAnimationSheetEnabled: boolean;
  89301. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89302. translationPivot: Vector2;
  89303. /**
  89304. * Gets or sets a texture used to add random noise to particle positions
  89305. */
  89306. noiseTexture: Nullable<BaseTexture>;
  89307. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89308. noiseStrength: Vector3;
  89309. /**
  89310. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89311. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89312. */
  89313. billboardMode: number;
  89314. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89315. limitVelocityDamping: number;
  89316. /**
  89317. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89318. */
  89319. beginAnimationOnStart: boolean;
  89320. /**
  89321. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89322. */
  89323. beginAnimationFrom: number;
  89324. /**
  89325. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89326. */
  89327. beginAnimationTo: number;
  89328. /**
  89329. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89330. */
  89331. beginAnimationLoop: boolean;
  89332. /**
  89333. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89334. */
  89335. disposeOnStop: boolean;
  89336. /**
  89337. * Gets the maximum number of particles active at the same time.
  89338. * @returns The max number of active particles.
  89339. */
  89340. getCapacity(): number;
  89341. /**
  89342. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89343. * @returns True if it has been started, otherwise false.
  89344. */
  89345. isStarted(): boolean;
  89346. /**
  89347. * Animates the particle system for this frame.
  89348. */
  89349. animate(): void;
  89350. /**
  89351. * Renders the particle system in its current state.
  89352. * @returns the current number of particles
  89353. */
  89354. render(): number;
  89355. /**
  89356. * Dispose the particle system and frees its associated resources.
  89357. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89358. */
  89359. dispose(disposeTexture?: boolean): void;
  89360. /**
  89361. * Clones the particle system.
  89362. * @param name The name of the cloned object
  89363. * @param newEmitter The new emitter to use
  89364. * @returns the cloned particle system
  89365. */
  89366. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89367. /**
  89368. * Serializes the particle system to a JSON object.
  89369. * @returns the JSON object
  89370. */
  89371. serialize(): any;
  89372. /**
  89373. * Rebuild the particle system
  89374. */
  89375. rebuild(): void;
  89376. /**
  89377. * Starts the particle system and begins to emit
  89378. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89379. */
  89380. start(delay?: number): void;
  89381. /**
  89382. * Stops the particle system.
  89383. */
  89384. stop(): void;
  89385. /**
  89386. * Remove all active particles
  89387. */
  89388. reset(): void;
  89389. /**
  89390. * Is this system ready to be used/rendered
  89391. * @return true if the system is ready
  89392. */
  89393. isReady(): boolean;
  89394. /**
  89395. * Adds a new color gradient
  89396. * @param gradient defines the gradient to use (between 0 and 1)
  89397. * @param color1 defines the color to affect to the specified gradient
  89398. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89399. * @returns the current particle system
  89400. */
  89401. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89402. /**
  89403. * Remove a specific color gradient
  89404. * @param gradient defines the gradient to remove
  89405. * @returns the current particle system
  89406. */
  89407. removeColorGradient(gradient: number): IParticleSystem;
  89408. /**
  89409. * Adds a new size gradient
  89410. * @param gradient defines the gradient to use (between 0 and 1)
  89411. * @param factor defines the size factor to affect to the specified gradient
  89412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89413. * @returns the current particle system
  89414. */
  89415. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89416. /**
  89417. * Remove a specific size gradient
  89418. * @param gradient defines the gradient to remove
  89419. * @returns the current particle system
  89420. */
  89421. removeSizeGradient(gradient: number): IParticleSystem;
  89422. /**
  89423. * Gets the current list of color gradients.
  89424. * You must use addColorGradient and removeColorGradient to udpate this list
  89425. * @returns the list of color gradients
  89426. */
  89427. getColorGradients(): Nullable<Array<ColorGradient>>;
  89428. /**
  89429. * Gets the current list of size gradients.
  89430. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89431. * @returns the list of size gradients
  89432. */
  89433. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89434. /**
  89435. * Gets the current list of angular speed gradients.
  89436. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89437. * @returns the list of angular speed gradients
  89438. */
  89439. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89440. /**
  89441. * Adds a new angular speed gradient
  89442. * @param gradient defines the gradient to use (between 0 and 1)
  89443. * @param factor defines the angular speed to affect to the specified gradient
  89444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89445. * @returns the current particle system
  89446. */
  89447. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89448. /**
  89449. * Remove a specific angular speed gradient
  89450. * @param gradient defines the gradient to remove
  89451. * @returns the current particle system
  89452. */
  89453. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89454. /**
  89455. * Gets the current list of velocity gradients.
  89456. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89457. * @returns the list of velocity gradients
  89458. */
  89459. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89460. /**
  89461. * Adds a new velocity gradient
  89462. * @param gradient defines the gradient to use (between 0 and 1)
  89463. * @param factor defines the velocity to affect to the specified gradient
  89464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89465. * @returns the current particle system
  89466. */
  89467. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89468. /**
  89469. * Remove a specific velocity gradient
  89470. * @param gradient defines the gradient to remove
  89471. * @returns the current particle system
  89472. */
  89473. removeVelocityGradient(gradient: number): IParticleSystem;
  89474. /**
  89475. * Gets the current list of limit velocity gradients.
  89476. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89477. * @returns the list of limit velocity gradients
  89478. */
  89479. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89480. /**
  89481. * Adds a new limit velocity gradient
  89482. * @param gradient defines the gradient to use (between 0 and 1)
  89483. * @param factor defines the limit velocity to affect to the specified gradient
  89484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89485. * @returns the current particle system
  89486. */
  89487. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89488. /**
  89489. * Remove a specific limit velocity gradient
  89490. * @param gradient defines the gradient to remove
  89491. * @returns the current particle system
  89492. */
  89493. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89494. /**
  89495. * Adds a new drag gradient
  89496. * @param gradient defines the gradient to use (between 0 and 1)
  89497. * @param factor defines the drag to affect to the specified gradient
  89498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89499. * @returns the current particle system
  89500. */
  89501. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89502. /**
  89503. * Remove a specific drag gradient
  89504. * @param gradient defines the gradient to remove
  89505. * @returns the current particle system
  89506. */
  89507. removeDragGradient(gradient: number): IParticleSystem;
  89508. /**
  89509. * Gets the current list of drag gradients.
  89510. * You must use addDragGradient and removeDragGradient to udpate this list
  89511. * @returns the list of drag gradients
  89512. */
  89513. getDragGradients(): Nullable<Array<FactorGradient>>;
  89514. /**
  89515. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89516. * @param gradient defines the gradient to use (between 0 and 1)
  89517. * @param factor defines the emit rate to affect to the specified gradient
  89518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89519. * @returns the current particle system
  89520. */
  89521. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89522. /**
  89523. * Remove a specific emit rate gradient
  89524. * @param gradient defines the gradient to remove
  89525. * @returns the current particle system
  89526. */
  89527. removeEmitRateGradient(gradient: number): IParticleSystem;
  89528. /**
  89529. * Gets the current list of emit rate gradients.
  89530. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89531. * @returns the list of emit rate gradients
  89532. */
  89533. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89534. /**
  89535. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89536. * @param gradient defines the gradient to use (between 0 and 1)
  89537. * @param factor defines the start size to affect to the specified gradient
  89538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89539. * @returns the current particle system
  89540. */
  89541. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89542. /**
  89543. * Remove a specific start size gradient
  89544. * @param gradient defines the gradient to remove
  89545. * @returns the current particle system
  89546. */
  89547. removeStartSizeGradient(gradient: number): IParticleSystem;
  89548. /**
  89549. * Gets the current list of start size gradients.
  89550. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89551. * @returns the list of start size gradients
  89552. */
  89553. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89554. /**
  89555. * Adds a new life time gradient
  89556. * @param gradient defines the gradient to use (between 0 and 1)
  89557. * @param factor defines the life time factor to affect to the specified gradient
  89558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89559. * @returns the current particle system
  89560. */
  89561. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89562. /**
  89563. * Remove a specific life time gradient
  89564. * @param gradient defines the gradient to remove
  89565. * @returns the current particle system
  89566. */
  89567. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89568. /**
  89569. * Gets the current list of life time gradients.
  89570. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89571. * @returns the list of life time gradients
  89572. */
  89573. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89574. /**
  89575. * Gets the current list of color gradients.
  89576. * You must use addColorGradient and removeColorGradient to udpate this list
  89577. * @returns the list of color gradients
  89578. */
  89579. getColorGradients(): Nullable<Array<ColorGradient>>;
  89580. /**
  89581. * Adds a new ramp gradient used to remap particle colors
  89582. * @param gradient defines the gradient to use (between 0 and 1)
  89583. * @param color defines the color to affect to the specified gradient
  89584. * @returns the current particle system
  89585. */
  89586. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89587. /**
  89588. * Gets the current list of ramp gradients.
  89589. * You must use addRampGradient and removeRampGradient to udpate this list
  89590. * @returns the list of ramp gradients
  89591. */
  89592. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89593. /** Gets or sets a boolean indicating that ramp gradients must be used
  89594. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89595. */
  89596. useRampGradients: boolean;
  89597. /**
  89598. * Adds a new color remap gradient
  89599. * @param gradient defines the gradient to use (between 0 and 1)
  89600. * @param min defines the color remap minimal range
  89601. * @param max defines the color remap maximal range
  89602. * @returns the current particle system
  89603. */
  89604. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89605. /**
  89606. * Gets the current list of color remap gradients.
  89607. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89608. * @returns the list of color remap gradients
  89609. */
  89610. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89611. /**
  89612. * Adds a new alpha remap gradient
  89613. * @param gradient defines the gradient to use (between 0 and 1)
  89614. * @param min defines the alpha remap minimal range
  89615. * @param max defines the alpha remap maximal range
  89616. * @returns the current particle system
  89617. */
  89618. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89619. /**
  89620. * Gets the current list of alpha remap gradients.
  89621. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89622. * @returns the list of alpha remap gradients
  89623. */
  89624. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89625. /**
  89626. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89629. * @returns the emitter
  89630. */
  89631. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89632. /**
  89633. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89634. * @param radius The radius of the hemisphere to emit from
  89635. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89636. * @returns the emitter
  89637. */
  89638. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89639. /**
  89640. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89641. * @param radius The radius of the sphere to emit from
  89642. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89643. * @returns the emitter
  89644. */
  89645. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89646. /**
  89647. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89648. * @param radius The radius of the sphere to emit from
  89649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89651. * @returns the emitter
  89652. */
  89653. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89654. /**
  89655. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89656. * @param radius The radius of the emission cylinder
  89657. * @param height The height of the emission cylinder
  89658. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89659. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89660. * @returns the emitter
  89661. */
  89662. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89663. /**
  89664. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89665. * @param radius The radius of the cylinder to emit from
  89666. * @param height The height of the emission cylinder
  89667. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89670. * @returns the emitter
  89671. */
  89672. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89673. /**
  89674. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89675. * @param radius The radius of the cone to emit from
  89676. * @param angle The base angle of the cone
  89677. * @returns the emitter
  89678. */
  89679. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89680. /**
  89681. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89684. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89685. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89686. * @returns the emitter
  89687. */
  89688. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89689. /**
  89690. * Get hosting scene
  89691. * @returns the scene
  89692. */
  89693. getScene(): Scene;
  89694. }
  89695. }
  89696. declare module BABYLON {
  89697. /**
  89698. * Creates an instance based on a source mesh.
  89699. */
  89700. export class InstancedMesh extends AbstractMesh {
  89701. private _sourceMesh;
  89702. private _currentLOD;
  89703. /** @hidden */
  89704. _indexInSourceMeshInstanceArray: number;
  89705. constructor(name: string, source: Mesh);
  89706. /**
  89707. * Returns the string "InstancedMesh".
  89708. */
  89709. getClassName(): string;
  89710. /** Gets the list of lights affecting that mesh */
  89711. get lightSources(): Light[];
  89712. _resyncLightSources(): void;
  89713. _resyncLightSource(light: Light): void;
  89714. _removeLightSource(light: Light, dispose: boolean): void;
  89715. /**
  89716. * If the source mesh receives shadows
  89717. */
  89718. get receiveShadows(): boolean;
  89719. /**
  89720. * The material of the source mesh
  89721. */
  89722. get material(): Nullable<Material>;
  89723. /**
  89724. * Visibility of the source mesh
  89725. */
  89726. get visibility(): number;
  89727. /**
  89728. * Skeleton of the source mesh
  89729. */
  89730. get skeleton(): Nullable<Skeleton>;
  89731. /**
  89732. * Rendering ground id of the source mesh
  89733. */
  89734. get renderingGroupId(): number;
  89735. set renderingGroupId(value: number);
  89736. /**
  89737. * Returns the total number of vertices (integer).
  89738. */
  89739. getTotalVertices(): number;
  89740. /**
  89741. * Returns a positive integer : the total number of indices in this mesh geometry.
  89742. * @returns the numner of indices or zero if the mesh has no geometry.
  89743. */
  89744. getTotalIndices(): number;
  89745. /**
  89746. * The source mesh of the instance
  89747. */
  89748. get sourceMesh(): Mesh;
  89749. /**
  89750. * Is this node ready to be used/rendered
  89751. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89752. * @return {boolean} is it ready
  89753. */
  89754. isReady(completeCheck?: boolean): boolean;
  89755. /**
  89756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89757. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89758. * @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.
  89759. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89760. */
  89761. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89762. /**
  89763. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89764. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89765. * The `data` are either a numeric array either a Float32Array.
  89766. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89767. * 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).
  89768. * Note that a new underlying VertexBuffer object is created each call.
  89769. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89770. *
  89771. * Possible `kind` values :
  89772. * - VertexBuffer.PositionKind
  89773. * - VertexBuffer.UVKind
  89774. * - VertexBuffer.UV2Kind
  89775. * - VertexBuffer.UV3Kind
  89776. * - VertexBuffer.UV4Kind
  89777. * - VertexBuffer.UV5Kind
  89778. * - VertexBuffer.UV6Kind
  89779. * - VertexBuffer.ColorKind
  89780. * - VertexBuffer.MatricesIndicesKind
  89781. * - VertexBuffer.MatricesIndicesExtraKind
  89782. * - VertexBuffer.MatricesWeightsKind
  89783. * - VertexBuffer.MatricesWeightsExtraKind
  89784. *
  89785. * Returns the Mesh.
  89786. */
  89787. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89788. /**
  89789. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89790. * If the mesh has no geometry, it is simply returned as it is.
  89791. * The `data` are either a numeric array either a Float32Array.
  89792. * No new underlying VertexBuffer object is created.
  89793. * 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.
  89794. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89795. *
  89796. * Possible `kind` values :
  89797. * - VertexBuffer.PositionKind
  89798. * - VertexBuffer.UVKind
  89799. * - VertexBuffer.UV2Kind
  89800. * - VertexBuffer.UV3Kind
  89801. * - VertexBuffer.UV4Kind
  89802. * - VertexBuffer.UV5Kind
  89803. * - VertexBuffer.UV6Kind
  89804. * - VertexBuffer.ColorKind
  89805. * - VertexBuffer.MatricesIndicesKind
  89806. * - VertexBuffer.MatricesIndicesExtraKind
  89807. * - VertexBuffer.MatricesWeightsKind
  89808. * - VertexBuffer.MatricesWeightsExtraKind
  89809. *
  89810. * Returns the Mesh.
  89811. */
  89812. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89813. /**
  89814. * Sets the mesh indices.
  89815. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89816. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89817. * This method creates a new index buffer each call.
  89818. * Returns the Mesh.
  89819. */
  89820. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89821. /**
  89822. * Boolean : True if the mesh owns the requested kind of data.
  89823. */
  89824. isVerticesDataPresent(kind: string): boolean;
  89825. /**
  89826. * Returns an array of indices (IndicesArray).
  89827. */
  89828. getIndices(): Nullable<IndicesArray>;
  89829. get _positions(): Nullable<Vector3[]>;
  89830. /**
  89831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89832. * This means the mesh underlying bounding box and sphere are recomputed.
  89833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89834. * @returns the current mesh
  89835. */
  89836. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89837. /** @hidden */
  89838. _preActivate(): InstancedMesh;
  89839. /** @hidden */
  89840. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89841. /** @hidden */
  89842. _postActivate(): void;
  89843. getWorldMatrix(): Matrix;
  89844. get isAnInstance(): boolean;
  89845. /**
  89846. * Returns the current associated LOD AbstractMesh.
  89847. */
  89848. getLOD(camera: Camera): AbstractMesh;
  89849. /** @hidden */
  89850. _syncSubMeshes(): InstancedMesh;
  89851. /** @hidden */
  89852. _generatePointsArray(): boolean;
  89853. /**
  89854. * Creates a new InstancedMesh from the current mesh.
  89855. * - name (string) : the cloned mesh name
  89856. * - newParent (optional Node) : the optional Node to parent the clone to.
  89857. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89858. *
  89859. * Returns the clone.
  89860. */
  89861. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89862. /**
  89863. * Disposes the InstancedMesh.
  89864. * Returns nothing.
  89865. */
  89866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89867. }
  89868. interface Mesh {
  89869. /**
  89870. * Register a custom buffer that will be instanced
  89871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89872. * @param kind defines the buffer kind
  89873. * @param stride defines the stride in floats
  89874. */
  89875. registerInstancedBuffer(kind: string, stride: number): void;
  89876. /** @hidden */
  89877. _userInstancedBuffersStorage: {
  89878. data: {
  89879. [key: string]: Float32Array;
  89880. };
  89881. sizes: {
  89882. [key: string]: number;
  89883. };
  89884. vertexBuffers: {
  89885. [key: string]: Nullable<VertexBuffer>;
  89886. };
  89887. strides: {
  89888. [key: string]: number;
  89889. };
  89890. };
  89891. }
  89892. interface AbstractMesh {
  89893. /**
  89894. * Object used to store instanced buffers defined by user
  89895. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89896. */
  89897. instancedBuffers: {
  89898. [key: string]: any;
  89899. };
  89900. }
  89901. }
  89902. declare module BABYLON {
  89903. /**
  89904. * Defines the options associated with the creation of a shader material.
  89905. */
  89906. export interface IShaderMaterialOptions {
  89907. /**
  89908. * Does the material work in alpha blend mode
  89909. */
  89910. needAlphaBlending: boolean;
  89911. /**
  89912. * Does the material work in alpha test mode
  89913. */
  89914. needAlphaTesting: boolean;
  89915. /**
  89916. * The list of attribute names used in the shader
  89917. */
  89918. attributes: string[];
  89919. /**
  89920. * The list of unifrom names used in the shader
  89921. */
  89922. uniforms: string[];
  89923. /**
  89924. * The list of UBO names used in the shader
  89925. */
  89926. uniformBuffers: string[];
  89927. /**
  89928. * The list of sampler names used in the shader
  89929. */
  89930. samplers: string[];
  89931. /**
  89932. * The list of defines used in the shader
  89933. */
  89934. defines: string[];
  89935. }
  89936. /**
  89937. * 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.
  89938. *
  89939. * This returned material effects how the mesh will look based on the code in the shaders.
  89940. *
  89941. * @see http://doc.babylonjs.com/how_to/shader_material
  89942. */
  89943. export class ShaderMaterial extends Material {
  89944. private _shaderPath;
  89945. private _options;
  89946. private _textures;
  89947. private _textureArrays;
  89948. private _floats;
  89949. private _ints;
  89950. private _floatsArrays;
  89951. private _colors3;
  89952. private _colors3Arrays;
  89953. private _colors4;
  89954. private _colors4Arrays;
  89955. private _vectors2;
  89956. private _vectors3;
  89957. private _vectors4;
  89958. private _matrices;
  89959. private _matrixArrays;
  89960. private _matrices3x3;
  89961. private _matrices2x2;
  89962. private _vectors2Arrays;
  89963. private _vectors3Arrays;
  89964. private _vectors4Arrays;
  89965. private _cachedWorldViewMatrix;
  89966. private _cachedWorldViewProjectionMatrix;
  89967. private _renderId;
  89968. private _multiview;
  89969. /**
  89970. * Instantiate a new shader material.
  89971. * 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.
  89972. * This returned material effects how the mesh will look based on the code in the shaders.
  89973. * @see http://doc.babylonjs.com/how_to/shader_material
  89974. * @param name Define the name of the material in the scene
  89975. * @param scene Define the scene the material belongs to
  89976. * @param shaderPath Defines the route to the shader code in one of three ways:
  89977. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89978. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89979. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89980. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89981. * @param options Define the options used to create the shader
  89982. */
  89983. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89984. /**
  89985. * Gets the shader path used to define the shader code
  89986. * It can be modified to trigger a new compilation
  89987. */
  89988. get shaderPath(): any;
  89989. /**
  89990. * Sets the shader path used to define the shader code
  89991. * It can be modified to trigger a new compilation
  89992. */
  89993. set shaderPath(shaderPath: any);
  89994. /**
  89995. * Gets the options used to compile the shader.
  89996. * They can be modified to trigger a new compilation
  89997. */
  89998. get options(): IShaderMaterialOptions;
  89999. /**
  90000. * Gets the current class name of the material e.g. "ShaderMaterial"
  90001. * Mainly use in serialization.
  90002. * @returns the class name
  90003. */
  90004. getClassName(): string;
  90005. /**
  90006. * Specifies if the material will require alpha blending
  90007. * @returns a boolean specifying if alpha blending is needed
  90008. */
  90009. needAlphaBlending(): boolean;
  90010. /**
  90011. * Specifies if this material should be rendered in alpha test mode
  90012. * @returns a boolean specifying if an alpha test is needed.
  90013. */
  90014. needAlphaTesting(): boolean;
  90015. private _checkUniform;
  90016. /**
  90017. * Set a texture in the shader.
  90018. * @param name Define the name of the uniform samplers as defined in the shader
  90019. * @param texture Define the texture to bind to this sampler
  90020. * @return the material itself allowing "fluent" like uniform updates
  90021. */
  90022. setTexture(name: string, texture: Texture): ShaderMaterial;
  90023. /**
  90024. * Set a texture array in the shader.
  90025. * @param name Define the name of the uniform sampler array as defined in the shader
  90026. * @param textures Define the list of textures to bind to this sampler
  90027. * @return the material itself allowing "fluent" like uniform updates
  90028. */
  90029. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90030. /**
  90031. * Set a float in the shader.
  90032. * @param name Define the name of the uniform as defined in the shader
  90033. * @param value Define the value to give to the uniform
  90034. * @return the material itself allowing "fluent" like uniform updates
  90035. */
  90036. setFloat(name: string, value: number): ShaderMaterial;
  90037. /**
  90038. * Set a int in the shader.
  90039. * @param name Define the name of the uniform as defined in the shader
  90040. * @param value Define the value to give to the uniform
  90041. * @return the material itself allowing "fluent" like uniform updates
  90042. */
  90043. setInt(name: string, value: number): ShaderMaterial;
  90044. /**
  90045. * Set an array of floats in the shader.
  90046. * @param name Define the name of the uniform as defined in the shader
  90047. * @param value Define the value to give to the uniform
  90048. * @return the material itself allowing "fluent" like uniform updates
  90049. */
  90050. setFloats(name: string, value: number[]): ShaderMaterial;
  90051. /**
  90052. * Set a vec3 in the shader from a Color3.
  90053. * @param name Define the name of the uniform as defined in the shader
  90054. * @param value Define the value to give to the uniform
  90055. * @return the material itself allowing "fluent" like uniform updates
  90056. */
  90057. setColor3(name: string, value: Color3): ShaderMaterial;
  90058. /**
  90059. * Set a vec3 array in the shader from a Color3 array.
  90060. * @param name Define the name of the uniform as defined in the shader
  90061. * @param value Define the value to give to the uniform
  90062. * @return the material itself allowing "fluent" like uniform updates
  90063. */
  90064. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90065. /**
  90066. * Set a vec4 in the shader from a Color4.
  90067. * @param name Define the name of the uniform as defined in the shader
  90068. * @param value Define the value to give to the uniform
  90069. * @return the material itself allowing "fluent" like uniform updates
  90070. */
  90071. setColor4(name: string, value: Color4): ShaderMaterial;
  90072. /**
  90073. * Set a vec4 array in the shader from a Color4 array.
  90074. * @param name Define the name of the uniform as defined in the shader
  90075. * @param value Define the value to give to the uniform
  90076. * @return the material itself allowing "fluent" like uniform updates
  90077. */
  90078. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90079. /**
  90080. * Set a vec2 in the shader from a Vector2.
  90081. * @param name Define the name of the uniform as defined in the shader
  90082. * @param value Define the value to give to the uniform
  90083. * @return the material itself allowing "fluent" like uniform updates
  90084. */
  90085. setVector2(name: string, value: Vector2): ShaderMaterial;
  90086. /**
  90087. * Set a vec3 in the shader from a Vector3.
  90088. * @param name Define the name of the uniform as defined in the shader
  90089. * @param value Define the value to give to the uniform
  90090. * @return the material itself allowing "fluent" like uniform updates
  90091. */
  90092. setVector3(name: string, value: Vector3): ShaderMaterial;
  90093. /**
  90094. * Set a vec4 in the shader from a Vector4.
  90095. * @param name Define the name of the uniform as defined in the shader
  90096. * @param value Define the value to give to the uniform
  90097. * @return the material itself allowing "fluent" like uniform updates
  90098. */
  90099. setVector4(name: string, value: Vector4): ShaderMaterial;
  90100. /**
  90101. * Set a mat4 in the shader from a Matrix.
  90102. * @param name Define the name of the uniform as defined in the shader
  90103. * @param value Define the value to give to the uniform
  90104. * @return the material itself allowing "fluent" like uniform updates
  90105. */
  90106. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90107. /**
  90108. * Set a float32Array in the shader from a matrix array.
  90109. * @param name Define the name of the uniform as defined in the shader
  90110. * @param value Define the value to give to the uniform
  90111. * @return the material itself allowing "fluent" like uniform updates
  90112. */
  90113. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90114. /**
  90115. * Set a mat3 in the shader from a Float32Array.
  90116. * @param name Define the name of the uniform as defined in the shader
  90117. * @param value Define the value to give to the uniform
  90118. * @return the material itself allowing "fluent" like uniform updates
  90119. */
  90120. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90121. /**
  90122. * Set a mat2 in the shader from a Float32Array.
  90123. * @param name Define the name of the uniform as defined in the shader
  90124. * @param value Define the value to give to the uniform
  90125. * @return the material itself allowing "fluent" like uniform updates
  90126. */
  90127. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90128. /**
  90129. * Set a vec2 array in the shader from a number array.
  90130. * @param name Define the name of the uniform as defined in the shader
  90131. * @param value Define the value to give to the uniform
  90132. * @return the material itself allowing "fluent" like uniform updates
  90133. */
  90134. setArray2(name: string, value: number[]): ShaderMaterial;
  90135. /**
  90136. * Set a vec3 array in the shader from a number array.
  90137. * @param name Define the name of the uniform as defined in the shader
  90138. * @param value Define the value to give to the uniform
  90139. * @return the material itself allowing "fluent" like uniform updates
  90140. */
  90141. setArray3(name: string, value: number[]): ShaderMaterial;
  90142. /**
  90143. * Set a vec4 array in the shader from a number array.
  90144. * @param name Define the name of the uniform as defined in the shader
  90145. * @param value Define the value to give to the uniform
  90146. * @return the material itself allowing "fluent" like uniform updates
  90147. */
  90148. setArray4(name: string, value: number[]): ShaderMaterial;
  90149. private _checkCache;
  90150. /**
  90151. * Specifies that the submesh is ready to be used
  90152. * @param mesh defines the mesh to check
  90153. * @param subMesh defines which submesh to check
  90154. * @param useInstances specifies that instances should be used
  90155. * @returns a boolean indicating that the submesh is ready or not
  90156. */
  90157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90158. /**
  90159. * Checks if the material is ready to render the requested mesh
  90160. * @param mesh Define the mesh to render
  90161. * @param useInstances Define whether or not the material is used with instances
  90162. * @returns true if ready, otherwise false
  90163. */
  90164. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90165. /**
  90166. * Binds the world matrix to the material
  90167. * @param world defines the world transformation matrix
  90168. */
  90169. bindOnlyWorldMatrix(world: Matrix): void;
  90170. /**
  90171. * Binds the material to the mesh
  90172. * @param world defines the world transformation matrix
  90173. * @param mesh defines the mesh to bind the material to
  90174. */
  90175. bind(world: Matrix, mesh?: Mesh): void;
  90176. /**
  90177. * Gets the active textures from the material
  90178. * @returns an array of textures
  90179. */
  90180. getActiveTextures(): BaseTexture[];
  90181. /**
  90182. * Specifies if the material uses a texture
  90183. * @param texture defines the texture to check against the material
  90184. * @returns a boolean specifying if the material uses the texture
  90185. */
  90186. hasTexture(texture: BaseTexture): boolean;
  90187. /**
  90188. * Makes a duplicate of the material, and gives it a new name
  90189. * @param name defines the new name for the duplicated material
  90190. * @returns the cloned material
  90191. */
  90192. clone(name: string): ShaderMaterial;
  90193. /**
  90194. * Disposes the material
  90195. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90196. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90197. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90198. */
  90199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90200. /**
  90201. * Serializes this material in a JSON representation
  90202. * @returns the serialized material object
  90203. */
  90204. serialize(): any;
  90205. /**
  90206. * Creates a shader material from parsed shader material data
  90207. * @param source defines the JSON represnetation of the material
  90208. * @param scene defines the hosting scene
  90209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90210. * @returns a new material
  90211. */
  90212. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90213. }
  90214. }
  90215. declare module BABYLON {
  90216. /** @hidden */
  90217. export var colorPixelShader: {
  90218. name: string;
  90219. shader: string;
  90220. };
  90221. }
  90222. declare module BABYLON {
  90223. /** @hidden */
  90224. export var colorVertexShader: {
  90225. name: string;
  90226. shader: string;
  90227. };
  90228. }
  90229. declare module BABYLON {
  90230. /**
  90231. * Line mesh
  90232. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90233. */
  90234. export class LinesMesh extends Mesh {
  90235. /**
  90236. * If vertex color should be applied to the mesh
  90237. */
  90238. readonly useVertexColor?: boolean | undefined;
  90239. /**
  90240. * If vertex alpha should be applied to the mesh
  90241. */
  90242. readonly useVertexAlpha?: boolean | undefined;
  90243. /**
  90244. * Color of the line (Default: White)
  90245. */
  90246. color: Color3;
  90247. /**
  90248. * Alpha of the line (Default: 1)
  90249. */
  90250. alpha: number;
  90251. /**
  90252. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90253. * This margin is expressed in world space coordinates, so its value may vary.
  90254. * Default value is 0.1
  90255. */
  90256. intersectionThreshold: number;
  90257. private _colorShader;
  90258. private color4;
  90259. /**
  90260. * Creates a new LinesMesh
  90261. * @param name defines the name
  90262. * @param scene defines the hosting scene
  90263. * @param parent defines the parent mesh if any
  90264. * @param source defines the optional source LinesMesh used to clone data from
  90265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90266. * When false, achieved by calling a clone(), also passing False.
  90267. * This will make creation of children, recursive.
  90268. * @param useVertexColor defines if this LinesMesh supports vertex color
  90269. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90270. */
  90271. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90272. /**
  90273. * If vertex color should be applied to the mesh
  90274. */
  90275. useVertexColor?: boolean | undefined,
  90276. /**
  90277. * If vertex alpha should be applied to the mesh
  90278. */
  90279. useVertexAlpha?: boolean | undefined);
  90280. private _addClipPlaneDefine;
  90281. private _removeClipPlaneDefine;
  90282. isReady(): boolean;
  90283. /**
  90284. * Returns the string "LineMesh"
  90285. */
  90286. getClassName(): string;
  90287. /**
  90288. * @hidden
  90289. */
  90290. get material(): Material;
  90291. /**
  90292. * @hidden
  90293. */
  90294. set material(value: Material);
  90295. /**
  90296. * @hidden
  90297. */
  90298. get checkCollisions(): boolean;
  90299. /** @hidden */
  90300. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90301. /** @hidden */
  90302. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90303. /**
  90304. * Disposes of the line mesh
  90305. * @param doNotRecurse If children should be disposed
  90306. */
  90307. dispose(doNotRecurse?: boolean): void;
  90308. /**
  90309. * Returns a new LineMesh object cloned from the current one.
  90310. */
  90311. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90312. /**
  90313. * Creates a new InstancedLinesMesh object from the mesh model.
  90314. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90315. * @param name defines the name of the new instance
  90316. * @returns a new InstancedLinesMesh
  90317. */
  90318. createInstance(name: string): InstancedLinesMesh;
  90319. }
  90320. /**
  90321. * Creates an instance based on a source LinesMesh
  90322. */
  90323. export class InstancedLinesMesh extends InstancedMesh {
  90324. /**
  90325. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90326. * This margin is expressed in world space coordinates, so its value may vary.
  90327. * Initilized with the intersectionThreshold value of the source LinesMesh
  90328. */
  90329. intersectionThreshold: number;
  90330. constructor(name: string, source: LinesMesh);
  90331. /**
  90332. * Returns the string "InstancedLinesMesh".
  90333. */
  90334. getClassName(): string;
  90335. }
  90336. }
  90337. declare module BABYLON {
  90338. /** @hidden */
  90339. export var linePixelShader: {
  90340. name: string;
  90341. shader: string;
  90342. };
  90343. }
  90344. declare module BABYLON {
  90345. /** @hidden */
  90346. export var lineVertexShader: {
  90347. name: string;
  90348. shader: string;
  90349. };
  90350. }
  90351. declare module BABYLON {
  90352. interface AbstractMesh {
  90353. /**
  90354. * Gets the edgesRenderer associated with the mesh
  90355. */
  90356. edgesRenderer: Nullable<EdgesRenderer>;
  90357. }
  90358. interface LinesMesh {
  90359. /**
  90360. * Enables the edge rendering mode on the mesh.
  90361. * This mode makes the mesh edges visible
  90362. * @param epsilon defines the maximal distance between two angles to detect a face
  90363. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90364. * @returns the currentAbstractMesh
  90365. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90366. */
  90367. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90368. }
  90369. interface InstancedLinesMesh {
  90370. /**
  90371. * Enables the edge rendering mode on the mesh.
  90372. * This mode makes the mesh edges visible
  90373. * @param epsilon defines the maximal distance between two angles to detect a face
  90374. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90375. * @returns the current InstancedLinesMesh
  90376. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90377. */
  90378. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90379. }
  90380. /**
  90381. * Defines the minimum contract an Edges renderer should follow.
  90382. */
  90383. export interface IEdgesRenderer extends IDisposable {
  90384. /**
  90385. * Gets or sets a boolean indicating if the edgesRenderer is active
  90386. */
  90387. isEnabled: boolean;
  90388. /**
  90389. * Renders the edges of the attached mesh,
  90390. */
  90391. render(): void;
  90392. /**
  90393. * Checks wether or not the edges renderer is ready to render.
  90394. * @return true if ready, otherwise false.
  90395. */
  90396. isReady(): boolean;
  90397. }
  90398. /**
  90399. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90400. */
  90401. export class EdgesRenderer implements IEdgesRenderer {
  90402. /**
  90403. * Define the size of the edges with an orthographic camera
  90404. */
  90405. edgesWidthScalerForOrthographic: number;
  90406. /**
  90407. * Define the size of the edges with a perspective camera
  90408. */
  90409. edgesWidthScalerForPerspective: number;
  90410. protected _source: AbstractMesh;
  90411. protected _linesPositions: number[];
  90412. protected _linesNormals: number[];
  90413. protected _linesIndices: number[];
  90414. protected _epsilon: number;
  90415. protected _indicesCount: number;
  90416. protected _lineShader: ShaderMaterial;
  90417. protected _ib: DataBuffer;
  90418. protected _buffers: {
  90419. [key: string]: Nullable<VertexBuffer>;
  90420. };
  90421. protected _checkVerticesInsteadOfIndices: boolean;
  90422. private _meshRebuildObserver;
  90423. private _meshDisposeObserver;
  90424. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90425. isEnabled: boolean;
  90426. /**
  90427. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90428. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90429. * @param source Mesh used to create edges
  90430. * @param epsilon sum of angles in adjacency to check for edge
  90431. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90432. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90433. */
  90434. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90435. protected _prepareRessources(): void;
  90436. /** @hidden */
  90437. _rebuild(): void;
  90438. /**
  90439. * Releases the required resources for the edges renderer
  90440. */
  90441. dispose(): void;
  90442. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90443. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90444. /**
  90445. * Checks if the pair of p0 and p1 is en edge
  90446. * @param faceIndex
  90447. * @param edge
  90448. * @param faceNormals
  90449. * @param p0
  90450. * @param p1
  90451. * @private
  90452. */
  90453. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90454. /**
  90455. * push line into the position, normal and index buffer
  90456. * @protected
  90457. */
  90458. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90459. /**
  90460. * Generates lines edges from adjacencjes
  90461. * @private
  90462. */
  90463. _generateEdgesLines(): void;
  90464. /**
  90465. * Checks wether or not the edges renderer is ready to render.
  90466. * @return true if ready, otherwise false.
  90467. */
  90468. isReady(): boolean;
  90469. /**
  90470. * Renders the edges of the attached mesh,
  90471. */
  90472. render(): void;
  90473. }
  90474. /**
  90475. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90476. */
  90477. export class LineEdgesRenderer extends EdgesRenderer {
  90478. /**
  90479. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90480. * @param source LineMesh used to generate edges
  90481. * @param epsilon not important (specified angle for edge detection)
  90482. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90483. */
  90484. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90485. /**
  90486. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90487. */
  90488. _generateEdgesLines(): void;
  90489. }
  90490. }
  90491. declare module BABYLON {
  90492. /**
  90493. * This represents the object necessary to create a rendering group.
  90494. * This is exclusively used and created by the rendering manager.
  90495. * To modify the behavior, you use the available helpers in your scene or meshes.
  90496. * @hidden
  90497. */
  90498. export class RenderingGroup {
  90499. index: number;
  90500. private static _zeroVector;
  90501. private _scene;
  90502. private _opaqueSubMeshes;
  90503. private _transparentSubMeshes;
  90504. private _alphaTestSubMeshes;
  90505. private _depthOnlySubMeshes;
  90506. private _particleSystems;
  90507. private _spriteManagers;
  90508. private _opaqueSortCompareFn;
  90509. private _alphaTestSortCompareFn;
  90510. private _transparentSortCompareFn;
  90511. private _renderOpaque;
  90512. private _renderAlphaTest;
  90513. private _renderTransparent;
  90514. /** @hidden */
  90515. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90516. onBeforeTransparentRendering: () => void;
  90517. /**
  90518. * Set the opaque sort comparison function.
  90519. * If null the sub meshes will be render in the order they were created
  90520. */
  90521. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90522. /**
  90523. * Set the alpha test sort comparison function.
  90524. * If null the sub meshes will be render in the order they were created
  90525. */
  90526. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90527. /**
  90528. * Set the transparent sort comparison function.
  90529. * If null the sub meshes will be render in the order they were created
  90530. */
  90531. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90532. /**
  90533. * Creates a new rendering group.
  90534. * @param index The rendering group index
  90535. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90536. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90537. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90538. */
  90539. 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>);
  90540. /**
  90541. * Render all the sub meshes contained in the group.
  90542. * @param customRenderFunction Used to override the default render behaviour of the group.
  90543. * @returns true if rendered some submeshes.
  90544. */
  90545. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90546. /**
  90547. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90548. * @param subMeshes The submeshes to render
  90549. */
  90550. private renderOpaqueSorted;
  90551. /**
  90552. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90553. * @param subMeshes The submeshes to render
  90554. */
  90555. private renderAlphaTestSorted;
  90556. /**
  90557. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90558. * @param subMeshes The submeshes to render
  90559. */
  90560. private renderTransparentSorted;
  90561. /**
  90562. * Renders the submeshes in a specified order.
  90563. * @param subMeshes The submeshes to sort before render
  90564. * @param sortCompareFn The comparison function use to sort
  90565. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90566. * @param transparent Specifies to activate blending if true
  90567. */
  90568. private static renderSorted;
  90569. /**
  90570. * Renders the submeshes in the order they were dispatched (no sort applied).
  90571. * @param subMeshes The submeshes to render
  90572. */
  90573. private static renderUnsorted;
  90574. /**
  90575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90576. * are rendered back to front if in the same alpha index.
  90577. *
  90578. * @param a The first submesh
  90579. * @param b The second submesh
  90580. * @returns The result of the comparison
  90581. */
  90582. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90583. /**
  90584. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90585. * are rendered back to front.
  90586. *
  90587. * @param a The first submesh
  90588. * @param b The second submesh
  90589. * @returns The result of the comparison
  90590. */
  90591. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90592. /**
  90593. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90594. * are rendered front to back (prevent overdraw).
  90595. *
  90596. * @param a The first submesh
  90597. * @param b The second submesh
  90598. * @returns The result of the comparison
  90599. */
  90600. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90601. /**
  90602. * Resets the different lists of submeshes to prepare a new frame.
  90603. */
  90604. prepare(): void;
  90605. dispose(): void;
  90606. /**
  90607. * Inserts the submesh in its correct queue depending on its material.
  90608. * @param subMesh The submesh to dispatch
  90609. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90610. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90611. */
  90612. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90613. dispatchSprites(spriteManager: ISpriteManager): void;
  90614. dispatchParticles(particleSystem: IParticleSystem): void;
  90615. private _renderParticles;
  90616. private _renderSprites;
  90617. }
  90618. }
  90619. declare module BABYLON {
  90620. /**
  90621. * Interface describing the different options available in the rendering manager
  90622. * regarding Auto Clear between groups.
  90623. */
  90624. export interface IRenderingManagerAutoClearSetup {
  90625. /**
  90626. * Defines whether or not autoclear is enable.
  90627. */
  90628. autoClear: boolean;
  90629. /**
  90630. * Defines whether or not to autoclear the depth buffer.
  90631. */
  90632. depth: boolean;
  90633. /**
  90634. * Defines whether or not to autoclear the stencil buffer.
  90635. */
  90636. stencil: boolean;
  90637. }
  90638. /**
  90639. * This class is used by the onRenderingGroupObservable
  90640. */
  90641. export class RenderingGroupInfo {
  90642. /**
  90643. * The Scene that being rendered
  90644. */
  90645. scene: Scene;
  90646. /**
  90647. * The camera currently used for the rendering pass
  90648. */
  90649. camera: Nullable<Camera>;
  90650. /**
  90651. * The ID of the renderingGroup being processed
  90652. */
  90653. renderingGroupId: number;
  90654. }
  90655. /**
  90656. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90657. * It is enable to manage the different groups as well as the different necessary sort functions.
  90658. * This should not be used directly aside of the few static configurations
  90659. */
  90660. export class RenderingManager {
  90661. /**
  90662. * The max id used for rendering groups (not included)
  90663. */
  90664. static MAX_RENDERINGGROUPS: number;
  90665. /**
  90666. * The min id used for rendering groups (included)
  90667. */
  90668. static MIN_RENDERINGGROUPS: number;
  90669. /**
  90670. * Used to globally prevent autoclearing scenes.
  90671. */
  90672. static AUTOCLEAR: boolean;
  90673. /**
  90674. * @hidden
  90675. */
  90676. _useSceneAutoClearSetup: boolean;
  90677. private _scene;
  90678. private _renderingGroups;
  90679. private _depthStencilBufferAlreadyCleaned;
  90680. private _autoClearDepthStencil;
  90681. private _customOpaqueSortCompareFn;
  90682. private _customAlphaTestSortCompareFn;
  90683. private _customTransparentSortCompareFn;
  90684. private _renderingGroupInfo;
  90685. /**
  90686. * Instantiates a new rendering group for a particular scene
  90687. * @param scene Defines the scene the groups belongs to
  90688. */
  90689. constructor(scene: Scene);
  90690. private _clearDepthStencilBuffer;
  90691. /**
  90692. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90693. * @hidden
  90694. */
  90695. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90696. /**
  90697. * Resets the different information of the group to prepare a new frame
  90698. * @hidden
  90699. */
  90700. reset(): void;
  90701. /**
  90702. * Dispose and release the group and its associated resources.
  90703. * @hidden
  90704. */
  90705. dispose(): void;
  90706. /**
  90707. * Clear the info related to rendering groups preventing retention points during dispose.
  90708. */
  90709. freeRenderingGroups(): void;
  90710. private _prepareRenderingGroup;
  90711. /**
  90712. * Add a sprite manager to the rendering manager in order to render it this frame.
  90713. * @param spriteManager Define the sprite manager to render
  90714. */
  90715. dispatchSprites(spriteManager: ISpriteManager): void;
  90716. /**
  90717. * Add a particle system to the rendering manager in order to render it this frame.
  90718. * @param particleSystem Define the particle system to render
  90719. */
  90720. dispatchParticles(particleSystem: IParticleSystem): void;
  90721. /**
  90722. * Add a submesh to the manager in order to render it this frame
  90723. * @param subMesh The submesh to dispatch
  90724. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90725. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90726. */
  90727. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90728. /**
  90729. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90730. * This allowed control for front to back rendering or reversly depending of the special needs.
  90731. *
  90732. * @param renderingGroupId The rendering group id corresponding to its index
  90733. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90734. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90735. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90736. */
  90737. 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;
  90738. /**
  90739. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90740. *
  90741. * @param renderingGroupId The rendering group id corresponding to its index
  90742. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90743. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90744. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90745. */
  90746. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90747. /**
  90748. * Gets the current auto clear configuration for one rendering group of the rendering
  90749. * manager.
  90750. * @param index the rendering group index to get the information for
  90751. * @returns The auto clear setup for the requested rendering group
  90752. */
  90753. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90754. }
  90755. }
  90756. declare module BABYLON {
  90757. /**
  90758. * This Helps creating a texture that will be created from a camera in your scene.
  90759. * It is basically a dynamic texture that could be used to create special effects for instance.
  90760. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90761. */
  90762. export class RenderTargetTexture extends Texture {
  90763. isCube: boolean;
  90764. /**
  90765. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90766. */
  90767. static readonly REFRESHRATE_RENDER_ONCE: number;
  90768. /**
  90769. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90770. */
  90771. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90772. /**
  90773. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90774. * the central point of your effect and can save a lot of performances.
  90775. */
  90776. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90777. /**
  90778. * Use this predicate to dynamically define the list of mesh you want to render.
  90779. * If set, the renderList property will be overwritten.
  90780. */
  90781. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90782. private _renderList;
  90783. /**
  90784. * Use this list to define the list of mesh you want to render.
  90785. */
  90786. get renderList(): Nullable<Array<AbstractMesh>>;
  90787. set renderList(value: Nullable<Array<AbstractMesh>>);
  90788. private _hookArray;
  90789. /**
  90790. * Define if particles should be rendered in your texture.
  90791. */
  90792. renderParticles: boolean;
  90793. /**
  90794. * Define if sprites should be rendered in your texture.
  90795. */
  90796. renderSprites: boolean;
  90797. /**
  90798. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90799. */
  90800. coordinatesMode: number;
  90801. /**
  90802. * Define the camera used to render the texture.
  90803. */
  90804. activeCamera: Nullable<Camera>;
  90805. /**
  90806. * Override the render function of the texture with your own one.
  90807. */
  90808. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90809. /**
  90810. * Define if camera post processes should be use while rendering the texture.
  90811. */
  90812. useCameraPostProcesses: boolean;
  90813. /**
  90814. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90815. */
  90816. ignoreCameraViewport: boolean;
  90817. private _postProcessManager;
  90818. private _postProcesses;
  90819. private _resizeObserver;
  90820. /**
  90821. * An event triggered when the texture is unbind.
  90822. */
  90823. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90824. /**
  90825. * An event triggered when the texture is unbind.
  90826. */
  90827. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90828. private _onAfterUnbindObserver;
  90829. /**
  90830. * Set a after unbind callback in the texture.
  90831. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90832. */
  90833. set onAfterUnbind(callback: () => void);
  90834. /**
  90835. * An event triggered before rendering the texture
  90836. */
  90837. onBeforeRenderObservable: Observable<number>;
  90838. private _onBeforeRenderObserver;
  90839. /**
  90840. * Set a before render callback in the texture.
  90841. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90842. */
  90843. set onBeforeRender(callback: (faceIndex: number) => void);
  90844. /**
  90845. * An event triggered after rendering the texture
  90846. */
  90847. onAfterRenderObservable: Observable<number>;
  90848. private _onAfterRenderObserver;
  90849. /**
  90850. * Set a after render callback in the texture.
  90851. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90852. */
  90853. set onAfterRender(callback: (faceIndex: number) => void);
  90854. /**
  90855. * An event triggered after the texture clear
  90856. */
  90857. onClearObservable: Observable<Engine>;
  90858. private _onClearObserver;
  90859. /**
  90860. * Set a clear callback in the texture.
  90861. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90862. */
  90863. set onClear(callback: (Engine: Engine) => void);
  90864. /**
  90865. * An event triggered when the texture is resized.
  90866. */
  90867. onResizeObservable: Observable<RenderTargetTexture>;
  90868. /**
  90869. * Define the clear color of the Render Target if it should be different from the scene.
  90870. */
  90871. clearColor: Color4;
  90872. protected _size: number | {
  90873. width: number;
  90874. height: number;
  90875. };
  90876. protected _initialSizeParameter: number | {
  90877. width: number;
  90878. height: number;
  90879. } | {
  90880. ratio: number;
  90881. };
  90882. protected _sizeRatio: Nullable<number>;
  90883. /** @hidden */
  90884. _generateMipMaps: boolean;
  90885. protected _renderingManager: RenderingManager;
  90886. /** @hidden */
  90887. _waitingRenderList: string[];
  90888. protected _doNotChangeAspectRatio: boolean;
  90889. protected _currentRefreshId: number;
  90890. protected _refreshRate: number;
  90891. protected _textureMatrix: Matrix;
  90892. protected _samples: number;
  90893. protected _renderTargetOptions: RenderTargetCreationOptions;
  90894. /**
  90895. * Gets render target creation options that were used.
  90896. */
  90897. get renderTargetOptions(): RenderTargetCreationOptions;
  90898. protected _engine: Engine;
  90899. protected _onRatioRescale(): void;
  90900. /**
  90901. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90902. * It must define where the camera used to render the texture is set
  90903. */
  90904. boundingBoxPosition: Vector3;
  90905. private _boundingBoxSize;
  90906. /**
  90907. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  90908. * When defined, the cubemap will switch to local mode
  90909. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  90910. * @example https://www.babylonjs-playground.com/#RNASML
  90911. */
  90912. set boundingBoxSize(value: Vector3);
  90913. get boundingBoxSize(): Vector3;
  90914. /**
  90915. * In case the RTT has been created with a depth texture, get the associated
  90916. * depth texture.
  90917. * Otherwise, return null.
  90918. */
  90919. depthStencilTexture: Nullable<InternalTexture>;
  90920. /**
  90921. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  90922. * or used a shadow, depth texture...
  90923. * @param name The friendly name of the texture
  90924. * @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)
  90925. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  90926. * @param generateMipMaps True if mip maps need to be generated after render.
  90927. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  90928. * @param type The type of the buffer in the RTT (int, half float, float...)
  90929. * @param isCube True if a cube texture needs to be created
  90930. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  90931. * @param generateDepthBuffer True to generate a depth buffer
  90932. * @param generateStencilBuffer True to generate a stencil buffer
  90933. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  90934. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  90935. * @param delayAllocation if the texture allocation should be delayed (default: false)
  90936. */
  90937. constructor(name: string, size: number | {
  90938. width: number;
  90939. height: number;
  90940. } | {
  90941. ratio: number;
  90942. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  90943. /**
  90944. * Creates a depth stencil texture.
  90945. * This is only available in WebGL 2 or with the depth texture extension available.
  90946. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  90947. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  90948. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  90949. */
  90950. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  90951. private _processSizeParameter;
  90952. /**
  90953. * Define the number of samples to use in case of MSAA.
  90954. * It defaults to one meaning no MSAA has been enabled.
  90955. */
  90956. get samples(): number;
  90957. set samples(value: number);
  90958. /**
  90959. * Resets the refresh counter of the texture and start bak from scratch.
  90960. * Could be useful to regenerate the texture if it is setup to render only once.
  90961. */
  90962. resetRefreshCounter(): void;
  90963. /**
  90964. * Define the refresh rate of the texture or the rendering frequency.
  90965. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90966. */
  90967. get refreshRate(): number;
  90968. set refreshRate(value: number);
  90969. /**
  90970. * Adds a post process to the render target rendering passes.
  90971. * @param postProcess define the post process to add
  90972. */
  90973. addPostProcess(postProcess: PostProcess): void;
  90974. /**
  90975. * Clear all the post processes attached to the render target
  90976. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  90977. */
  90978. clearPostProcesses(dispose?: boolean): void;
  90979. /**
  90980. * Remove one of the post process from the list of attached post processes to the texture
  90981. * @param postProcess define the post process to remove from the list
  90982. */
  90983. removePostProcess(postProcess: PostProcess): void;
  90984. /** @hidden */
  90985. _shouldRender(): boolean;
  90986. /**
  90987. * Gets the actual render size of the texture.
  90988. * @returns the width of the render size
  90989. */
  90990. getRenderSize(): number;
  90991. /**
  90992. * Gets the actual render width of the texture.
  90993. * @returns the width of the render size
  90994. */
  90995. getRenderWidth(): number;
  90996. /**
  90997. * Gets the actual render height of the texture.
  90998. * @returns the height of the render size
  90999. */
  91000. getRenderHeight(): number;
  91001. /**
  91002. * Get if the texture can be rescaled or not.
  91003. */
  91004. get canRescale(): boolean;
  91005. /**
  91006. * Resize the texture using a ratio.
  91007. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91008. */
  91009. scale(ratio: number): void;
  91010. /**
  91011. * Get the texture reflection matrix used to rotate/transform the reflection.
  91012. * @returns the reflection matrix
  91013. */
  91014. getReflectionTextureMatrix(): Matrix;
  91015. /**
  91016. * Resize the texture to a new desired size.
  91017. * Be carrefull as it will recreate all the data in the new texture.
  91018. * @param size Define the new size. It can be:
  91019. * - a number for squared texture,
  91020. * - an object containing { width: number, height: number }
  91021. * - or an object containing a ratio { ratio: number }
  91022. */
  91023. resize(size: number | {
  91024. width: number;
  91025. height: number;
  91026. } | {
  91027. ratio: number;
  91028. }): void;
  91029. /**
  91030. * Renders all the objects from the render list into the texture.
  91031. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91032. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91033. */
  91034. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91035. private _bestReflectionRenderTargetDimension;
  91036. /**
  91037. * @hidden
  91038. * @param faceIndex face index to bind to if this is a cubetexture
  91039. */
  91040. _bindFrameBuffer(faceIndex?: number): void;
  91041. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91042. private renderToTarget;
  91043. /**
  91044. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91045. * This allowed control for front to back rendering or reversly depending of the special needs.
  91046. *
  91047. * @param renderingGroupId The rendering group id corresponding to its index
  91048. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91049. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91050. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91051. */
  91052. 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;
  91053. /**
  91054. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91055. *
  91056. * @param renderingGroupId The rendering group id corresponding to its index
  91057. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91058. */
  91059. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91060. /**
  91061. * Clones the texture.
  91062. * @returns the cloned texture
  91063. */
  91064. clone(): RenderTargetTexture;
  91065. /**
  91066. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91067. * @returns The JSON representation of the texture
  91068. */
  91069. serialize(): any;
  91070. /**
  91071. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91072. */
  91073. disposeFramebufferObjects(): void;
  91074. /**
  91075. * Dispose the texture and release its associated resources.
  91076. */
  91077. dispose(): void;
  91078. /** @hidden */
  91079. _rebuild(): void;
  91080. /**
  91081. * Clear the info related to rendering groups preventing retention point in material dispose.
  91082. */
  91083. freeRenderingGroups(): void;
  91084. /**
  91085. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91086. * @returns the view count
  91087. */
  91088. getViewCount(): number;
  91089. }
  91090. }
  91091. declare module BABYLON {
  91092. /**
  91093. * Options for compiling materials.
  91094. */
  91095. export interface IMaterialCompilationOptions {
  91096. /**
  91097. * Defines whether clip planes are enabled.
  91098. */
  91099. clipPlane: boolean;
  91100. /**
  91101. * Defines whether instances are enabled.
  91102. */
  91103. useInstances: boolean;
  91104. }
  91105. /**
  91106. * Base class for the main features of a material in Babylon.js
  91107. */
  91108. export class Material implements IAnimatable {
  91109. /**
  91110. * Returns the triangle fill mode
  91111. */
  91112. static readonly TriangleFillMode: number;
  91113. /**
  91114. * Returns the wireframe mode
  91115. */
  91116. static readonly WireFrameFillMode: number;
  91117. /**
  91118. * Returns the point fill mode
  91119. */
  91120. static readonly PointFillMode: number;
  91121. /**
  91122. * Returns the point list draw mode
  91123. */
  91124. static readonly PointListDrawMode: number;
  91125. /**
  91126. * Returns the line list draw mode
  91127. */
  91128. static readonly LineListDrawMode: number;
  91129. /**
  91130. * Returns the line loop draw mode
  91131. */
  91132. static readonly LineLoopDrawMode: number;
  91133. /**
  91134. * Returns the line strip draw mode
  91135. */
  91136. static readonly LineStripDrawMode: number;
  91137. /**
  91138. * Returns the triangle strip draw mode
  91139. */
  91140. static readonly TriangleStripDrawMode: number;
  91141. /**
  91142. * Returns the triangle fan draw mode
  91143. */
  91144. static readonly TriangleFanDrawMode: number;
  91145. /**
  91146. * Stores the clock-wise side orientation
  91147. */
  91148. static readonly ClockWiseSideOrientation: number;
  91149. /**
  91150. * Stores the counter clock-wise side orientation
  91151. */
  91152. static readonly CounterClockWiseSideOrientation: number;
  91153. /**
  91154. * The dirty texture flag value
  91155. */
  91156. static readonly TextureDirtyFlag: number;
  91157. /**
  91158. * The dirty light flag value
  91159. */
  91160. static readonly LightDirtyFlag: number;
  91161. /**
  91162. * The dirty fresnel flag value
  91163. */
  91164. static readonly FresnelDirtyFlag: number;
  91165. /**
  91166. * The dirty attribute flag value
  91167. */
  91168. static readonly AttributesDirtyFlag: number;
  91169. /**
  91170. * The dirty misc flag value
  91171. */
  91172. static readonly MiscDirtyFlag: number;
  91173. /**
  91174. * The all dirty flag value
  91175. */
  91176. static readonly AllDirtyFlag: number;
  91177. /**
  91178. * The ID of the material
  91179. */
  91180. id: string;
  91181. /**
  91182. * Gets or sets the unique id of the material
  91183. */
  91184. uniqueId: number;
  91185. /**
  91186. * The name of the material
  91187. */
  91188. name: string;
  91189. /**
  91190. * Gets or sets user defined metadata
  91191. */
  91192. metadata: any;
  91193. /**
  91194. * For internal use only. Please do not use.
  91195. */
  91196. reservedDataStore: any;
  91197. /**
  91198. * Specifies if the ready state should be checked on each call
  91199. */
  91200. checkReadyOnEveryCall: boolean;
  91201. /**
  91202. * Specifies if the ready state should be checked once
  91203. */
  91204. checkReadyOnlyOnce: boolean;
  91205. /**
  91206. * The state of the material
  91207. */
  91208. state: string;
  91209. /**
  91210. * The alpha value of the material
  91211. */
  91212. protected _alpha: number;
  91213. /**
  91214. * List of inspectable custom properties (used by the Inspector)
  91215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91216. */
  91217. inspectableCustomProperties: IInspectable[];
  91218. /**
  91219. * Sets the alpha value of the material
  91220. */
  91221. set alpha(value: number);
  91222. /**
  91223. * Gets the alpha value of the material
  91224. */
  91225. get alpha(): number;
  91226. /**
  91227. * Specifies if back face culling is enabled
  91228. */
  91229. protected _backFaceCulling: boolean;
  91230. /**
  91231. * Sets the back-face culling state
  91232. */
  91233. set backFaceCulling(value: boolean);
  91234. /**
  91235. * Gets the back-face culling state
  91236. */
  91237. get backFaceCulling(): boolean;
  91238. /**
  91239. * Stores the value for side orientation
  91240. */
  91241. sideOrientation: number;
  91242. /**
  91243. * Callback triggered when the material is compiled
  91244. */
  91245. onCompiled: Nullable<(effect: Effect) => void>;
  91246. /**
  91247. * Callback triggered when an error occurs
  91248. */
  91249. onError: Nullable<(effect: Effect, errors: string) => void>;
  91250. /**
  91251. * Callback triggered to get the render target textures
  91252. */
  91253. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91254. /**
  91255. * Gets a boolean indicating that current material needs to register RTT
  91256. */
  91257. get hasRenderTargetTextures(): boolean;
  91258. /**
  91259. * Specifies if the material should be serialized
  91260. */
  91261. doNotSerialize: boolean;
  91262. /**
  91263. * @hidden
  91264. */
  91265. _storeEffectOnSubMeshes: boolean;
  91266. /**
  91267. * Stores the animations for the material
  91268. */
  91269. animations: Nullable<Array<Animation>>;
  91270. /**
  91271. * An event triggered when the material is disposed
  91272. */
  91273. onDisposeObservable: Observable<Material>;
  91274. /**
  91275. * An observer which watches for dispose events
  91276. */
  91277. private _onDisposeObserver;
  91278. private _onUnBindObservable;
  91279. /**
  91280. * Called during a dispose event
  91281. */
  91282. set onDispose(callback: () => void);
  91283. private _onBindObservable;
  91284. /**
  91285. * An event triggered when the material is bound
  91286. */
  91287. get onBindObservable(): Observable<AbstractMesh>;
  91288. /**
  91289. * An observer which watches for bind events
  91290. */
  91291. private _onBindObserver;
  91292. /**
  91293. * Called during a bind event
  91294. */
  91295. set onBind(callback: (Mesh: AbstractMesh) => void);
  91296. /**
  91297. * An event triggered when the material is unbound
  91298. */
  91299. get onUnBindObservable(): Observable<Material>;
  91300. /**
  91301. * Stores the value of the alpha mode
  91302. */
  91303. private _alphaMode;
  91304. /**
  91305. * Sets the value of the alpha mode.
  91306. *
  91307. * | Value | Type | Description |
  91308. * | --- | --- | --- |
  91309. * | 0 | ALPHA_DISABLE | |
  91310. * | 1 | ALPHA_ADD | |
  91311. * | 2 | ALPHA_COMBINE | |
  91312. * | 3 | ALPHA_SUBTRACT | |
  91313. * | 4 | ALPHA_MULTIPLY | |
  91314. * | 5 | ALPHA_MAXIMIZED | |
  91315. * | 6 | ALPHA_ONEONE | |
  91316. * | 7 | ALPHA_PREMULTIPLIED | |
  91317. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91318. * | 9 | ALPHA_INTERPOLATE | |
  91319. * | 10 | ALPHA_SCREENMODE | |
  91320. *
  91321. */
  91322. set alphaMode(value: number);
  91323. /**
  91324. * Gets the value of the alpha mode
  91325. */
  91326. get alphaMode(): number;
  91327. /**
  91328. * Stores the state of the need depth pre-pass value
  91329. */
  91330. private _needDepthPrePass;
  91331. /**
  91332. * Sets the need depth pre-pass value
  91333. */
  91334. set needDepthPrePass(value: boolean);
  91335. /**
  91336. * Gets the depth pre-pass value
  91337. */
  91338. get needDepthPrePass(): boolean;
  91339. /**
  91340. * Specifies if depth writing should be disabled
  91341. */
  91342. disableDepthWrite: boolean;
  91343. /**
  91344. * Specifies if depth writing should be forced
  91345. */
  91346. forceDepthWrite: boolean;
  91347. /**
  91348. * Specifies the depth function that should be used. 0 means the default engine function
  91349. */
  91350. depthFunction: number;
  91351. /**
  91352. * Specifies if there should be a separate pass for culling
  91353. */
  91354. separateCullingPass: boolean;
  91355. /**
  91356. * Stores the state specifing if fog should be enabled
  91357. */
  91358. private _fogEnabled;
  91359. /**
  91360. * Sets the state for enabling fog
  91361. */
  91362. set fogEnabled(value: boolean);
  91363. /**
  91364. * Gets the value of the fog enabled state
  91365. */
  91366. get fogEnabled(): boolean;
  91367. /**
  91368. * Stores the size of points
  91369. */
  91370. pointSize: number;
  91371. /**
  91372. * Stores the z offset value
  91373. */
  91374. zOffset: number;
  91375. /**
  91376. * Gets a value specifying if wireframe mode is enabled
  91377. */
  91378. get wireframe(): boolean;
  91379. /**
  91380. * Sets the state of wireframe mode
  91381. */
  91382. set wireframe(value: boolean);
  91383. /**
  91384. * Gets the value specifying if point clouds are enabled
  91385. */
  91386. get pointsCloud(): boolean;
  91387. /**
  91388. * Sets the state of point cloud mode
  91389. */
  91390. set pointsCloud(value: boolean);
  91391. /**
  91392. * Gets the material fill mode
  91393. */
  91394. get fillMode(): number;
  91395. /**
  91396. * Sets the material fill mode
  91397. */
  91398. set fillMode(value: number);
  91399. /**
  91400. * @hidden
  91401. * Stores the effects for the material
  91402. */
  91403. _effect: Nullable<Effect>;
  91404. /**
  91405. * @hidden
  91406. * Specifies if the material was previously ready
  91407. */
  91408. _wasPreviouslyReady: boolean;
  91409. /**
  91410. * Specifies if uniform buffers should be used
  91411. */
  91412. private _useUBO;
  91413. /**
  91414. * Stores a reference to the scene
  91415. */
  91416. private _scene;
  91417. /**
  91418. * Stores the fill mode state
  91419. */
  91420. private _fillMode;
  91421. /**
  91422. * Specifies if the depth write state should be cached
  91423. */
  91424. private _cachedDepthWriteState;
  91425. /**
  91426. * Specifies if the depth function state should be cached
  91427. */
  91428. private _cachedDepthFunctionState;
  91429. /**
  91430. * Stores the uniform buffer
  91431. */
  91432. protected _uniformBuffer: UniformBuffer;
  91433. /** @hidden */
  91434. _indexInSceneMaterialArray: number;
  91435. /** @hidden */
  91436. meshMap: Nullable<{
  91437. [id: string]: AbstractMesh | undefined;
  91438. }>;
  91439. /**
  91440. * Creates a material instance
  91441. * @param name defines the name of the material
  91442. * @param scene defines the scene to reference
  91443. * @param doNotAdd specifies if the material should be added to the scene
  91444. */
  91445. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91446. /**
  91447. * Returns a string representation of the current material
  91448. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91449. * @returns a string with material information
  91450. */
  91451. toString(fullDetails?: boolean): string;
  91452. /**
  91453. * Gets the class name of the material
  91454. * @returns a string with the class name of the material
  91455. */
  91456. getClassName(): string;
  91457. /**
  91458. * Specifies if updates for the material been locked
  91459. */
  91460. get isFrozen(): boolean;
  91461. /**
  91462. * Locks updates for the material
  91463. */
  91464. freeze(): void;
  91465. /**
  91466. * Unlocks updates for the material
  91467. */
  91468. unfreeze(): void;
  91469. /**
  91470. * Specifies if the material is ready to be used
  91471. * @param mesh defines the mesh to check
  91472. * @param useInstances specifies if instances should be used
  91473. * @returns a boolean indicating if the material is ready to be used
  91474. */
  91475. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91476. /**
  91477. * Specifies that the submesh is ready to be used
  91478. * @param mesh defines the mesh to check
  91479. * @param subMesh defines which submesh to check
  91480. * @param useInstances specifies that instances should be used
  91481. * @returns a boolean indicating that the submesh is ready or not
  91482. */
  91483. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91484. /**
  91485. * Returns the material effect
  91486. * @returns the effect associated with the material
  91487. */
  91488. getEffect(): Nullable<Effect>;
  91489. /**
  91490. * Returns the current scene
  91491. * @returns a Scene
  91492. */
  91493. getScene(): Scene;
  91494. /**
  91495. * Specifies if the material will require alpha blending
  91496. * @returns a boolean specifying if alpha blending is needed
  91497. */
  91498. needAlphaBlending(): boolean;
  91499. /**
  91500. * Specifies if the mesh will require alpha blending
  91501. * @param mesh defines the mesh to check
  91502. * @returns a boolean specifying if alpha blending is needed for the mesh
  91503. */
  91504. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91505. /**
  91506. * Specifies if this material should be rendered in alpha test mode
  91507. * @returns a boolean specifying if an alpha test is needed.
  91508. */
  91509. needAlphaTesting(): boolean;
  91510. /**
  91511. * Gets the texture used for the alpha test
  91512. * @returns the texture to use for alpha testing
  91513. */
  91514. getAlphaTestTexture(): Nullable<BaseTexture>;
  91515. /**
  91516. * Marks the material to indicate that it needs to be re-calculated
  91517. */
  91518. markDirty(): void;
  91519. /** @hidden */
  91520. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91521. /**
  91522. * Binds the material to the mesh
  91523. * @param world defines the world transformation matrix
  91524. * @param mesh defines the mesh to bind the material to
  91525. */
  91526. bind(world: Matrix, mesh?: Mesh): void;
  91527. /**
  91528. * Binds the submesh to the material
  91529. * @param world defines the world transformation matrix
  91530. * @param mesh defines the mesh containing the submesh
  91531. * @param subMesh defines the submesh to bind the material to
  91532. */
  91533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91534. /**
  91535. * Binds the world matrix to the material
  91536. * @param world defines the world transformation matrix
  91537. */
  91538. bindOnlyWorldMatrix(world: Matrix): void;
  91539. /**
  91540. * Binds the scene's uniform buffer to the effect.
  91541. * @param effect defines the effect to bind to the scene uniform buffer
  91542. * @param sceneUbo defines the uniform buffer storing scene data
  91543. */
  91544. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91545. /**
  91546. * Binds the view matrix to the effect
  91547. * @param effect defines the effect to bind the view matrix to
  91548. */
  91549. bindView(effect: Effect): void;
  91550. /**
  91551. * Binds the view projection matrix to the effect
  91552. * @param effect defines the effect to bind the view projection matrix to
  91553. */
  91554. bindViewProjection(effect: Effect): void;
  91555. /**
  91556. * Specifies if material alpha testing should be turned on for the mesh
  91557. * @param mesh defines the mesh to check
  91558. */
  91559. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91560. /**
  91561. * Processes to execute after binding the material to a mesh
  91562. * @param mesh defines the rendered mesh
  91563. */
  91564. protected _afterBind(mesh?: Mesh): void;
  91565. /**
  91566. * Unbinds the material from the mesh
  91567. */
  91568. unbind(): void;
  91569. /**
  91570. * Gets the active textures from the material
  91571. * @returns an array of textures
  91572. */
  91573. getActiveTextures(): BaseTexture[];
  91574. /**
  91575. * Specifies if the material uses a texture
  91576. * @param texture defines the texture to check against the material
  91577. * @returns a boolean specifying if the material uses the texture
  91578. */
  91579. hasTexture(texture: BaseTexture): boolean;
  91580. /**
  91581. * Makes a duplicate of the material, and gives it a new name
  91582. * @param name defines the new name for the duplicated material
  91583. * @returns the cloned material
  91584. */
  91585. clone(name: string): Nullable<Material>;
  91586. /**
  91587. * Gets the meshes bound to the material
  91588. * @returns an array of meshes bound to the material
  91589. */
  91590. getBindedMeshes(): AbstractMesh[];
  91591. /**
  91592. * Force shader compilation
  91593. * @param mesh defines the mesh associated with this material
  91594. * @param onCompiled defines a function to execute once the material is compiled
  91595. * @param options defines the options to configure the compilation
  91596. * @param onError defines a function to execute if the material fails compiling
  91597. */
  91598. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91599. /**
  91600. * Force shader compilation
  91601. * @param mesh defines the mesh that will use this material
  91602. * @param options defines additional options for compiling the shaders
  91603. * @returns a promise that resolves when the compilation completes
  91604. */
  91605. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91606. private static readonly _AllDirtyCallBack;
  91607. private static readonly _ImageProcessingDirtyCallBack;
  91608. private static readonly _TextureDirtyCallBack;
  91609. private static readonly _FresnelDirtyCallBack;
  91610. private static readonly _MiscDirtyCallBack;
  91611. private static readonly _LightsDirtyCallBack;
  91612. private static readonly _AttributeDirtyCallBack;
  91613. private static _FresnelAndMiscDirtyCallBack;
  91614. private static _TextureAndMiscDirtyCallBack;
  91615. private static readonly _DirtyCallbackArray;
  91616. private static readonly _RunDirtyCallBacks;
  91617. /**
  91618. * Marks a define in the material to indicate that it needs to be re-computed
  91619. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91620. */
  91621. markAsDirty(flag: number): void;
  91622. /**
  91623. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91624. * @param func defines a function which checks material defines against the submeshes
  91625. */
  91626. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91627. /**
  91628. * Indicates that we need to re-calculated for all submeshes
  91629. */
  91630. protected _markAllSubMeshesAsAllDirty(): void;
  91631. /**
  91632. * Indicates that image processing needs to be re-calculated for all submeshes
  91633. */
  91634. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91635. /**
  91636. * Indicates that textures need to be re-calculated for all submeshes
  91637. */
  91638. protected _markAllSubMeshesAsTexturesDirty(): void;
  91639. /**
  91640. * Indicates that fresnel needs to be re-calculated for all submeshes
  91641. */
  91642. protected _markAllSubMeshesAsFresnelDirty(): void;
  91643. /**
  91644. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91645. */
  91646. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91647. /**
  91648. * Indicates that lights need to be re-calculated for all submeshes
  91649. */
  91650. protected _markAllSubMeshesAsLightsDirty(): void;
  91651. /**
  91652. * Indicates that attributes need to be re-calculated for all submeshes
  91653. */
  91654. protected _markAllSubMeshesAsAttributesDirty(): void;
  91655. /**
  91656. * Indicates that misc needs to be re-calculated for all submeshes
  91657. */
  91658. protected _markAllSubMeshesAsMiscDirty(): void;
  91659. /**
  91660. * Indicates that textures and misc need to be re-calculated for all submeshes
  91661. */
  91662. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91663. /**
  91664. * Disposes the material
  91665. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91666. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91667. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91668. */
  91669. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91670. /** @hidden */
  91671. private releaseVertexArrayObject;
  91672. /**
  91673. * Serializes this material
  91674. * @returns the serialized material object
  91675. */
  91676. serialize(): any;
  91677. /**
  91678. * Creates a material from parsed material data
  91679. * @param parsedMaterial defines parsed material data
  91680. * @param scene defines the hosting scene
  91681. * @param rootUrl defines the root URL to use to load textures
  91682. * @returns a new material
  91683. */
  91684. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91685. }
  91686. }
  91687. declare module BABYLON {
  91688. /**
  91689. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91690. * separate meshes. This can be use to improve performances.
  91691. * @see http://doc.babylonjs.com/how_to/multi_materials
  91692. */
  91693. export class MultiMaterial extends Material {
  91694. private _subMaterials;
  91695. /**
  91696. * Gets or Sets the list of Materials used within the multi material.
  91697. * They need to be ordered according to the submeshes order in the associated mesh
  91698. */
  91699. get subMaterials(): Nullable<Material>[];
  91700. set subMaterials(value: Nullable<Material>[]);
  91701. /**
  91702. * Function used to align with Node.getChildren()
  91703. * @returns the list of Materials used within the multi material
  91704. */
  91705. getChildren(): Nullable<Material>[];
  91706. /**
  91707. * Instantiates a new Multi Material
  91708. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91709. * separate meshes. This can be use to improve performances.
  91710. * @see http://doc.babylonjs.com/how_to/multi_materials
  91711. * @param name Define the name in the scene
  91712. * @param scene Define the scene the material belongs to
  91713. */
  91714. constructor(name: string, scene: Scene);
  91715. private _hookArray;
  91716. /**
  91717. * Get one of the submaterial by its index in the submaterials array
  91718. * @param index The index to look the sub material at
  91719. * @returns The Material if the index has been defined
  91720. */
  91721. getSubMaterial(index: number): Nullable<Material>;
  91722. /**
  91723. * Get the list of active textures for the whole sub materials list.
  91724. * @returns All the textures that will be used during the rendering
  91725. */
  91726. getActiveTextures(): BaseTexture[];
  91727. /**
  91728. * Gets the current class name of the material e.g. "MultiMaterial"
  91729. * Mainly use in serialization.
  91730. * @returns the class name
  91731. */
  91732. getClassName(): string;
  91733. /**
  91734. * Checks if the material is ready to render the requested sub mesh
  91735. * @param mesh Define the mesh the submesh belongs to
  91736. * @param subMesh Define the sub mesh to look readyness for
  91737. * @param useInstances Define whether or not the material is used with instances
  91738. * @returns true if ready, otherwise false
  91739. */
  91740. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91741. /**
  91742. * Clones the current material and its related sub materials
  91743. * @param name Define the name of the newly cloned material
  91744. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91745. * @returns the cloned material
  91746. */
  91747. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91748. /**
  91749. * Serializes the materials into a JSON representation.
  91750. * @returns the JSON representation
  91751. */
  91752. serialize(): any;
  91753. /**
  91754. * Dispose the material and release its associated resources
  91755. * @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)
  91756. * @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)
  91757. * @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)
  91758. */
  91759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91760. /**
  91761. * Creates a MultiMaterial from parsed MultiMaterial data.
  91762. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91763. * @param scene defines the hosting scene
  91764. * @returns a new MultiMaterial
  91765. */
  91766. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91767. }
  91768. }
  91769. declare module BABYLON {
  91770. /**
  91771. * Base class for submeshes
  91772. */
  91773. export class BaseSubMesh {
  91774. /** @hidden */
  91775. _materialDefines: Nullable<MaterialDefines>;
  91776. /** @hidden */
  91777. _materialEffect: Nullable<Effect>;
  91778. /**
  91779. * Gets material defines used by the effect associated to the sub mesh
  91780. */
  91781. get materialDefines(): Nullable<MaterialDefines>;
  91782. /**
  91783. * Sets material defines used by the effect associated to the sub mesh
  91784. */
  91785. set materialDefines(defines: Nullable<MaterialDefines>);
  91786. /**
  91787. * Gets associated effect
  91788. */
  91789. get effect(): Nullable<Effect>;
  91790. /**
  91791. * Sets associated effect (effect used to render this submesh)
  91792. * @param effect defines the effect to associate with
  91793. * @param defines defines the set of defines used to compile this effect
  91794. */
  91795. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91796. }
  91797. /**
  91798. * Defines a subdivision inside a mesh
  91799. */
  91800. export class SubMesh extends BaseSubMesh implements ICullable {
  91801. /** the material index to use */
  91802. materialIndex: number;
  91803. /** vertex index start */
  91804. verticesStart: number;
  91805. /** vertices count */
  91806. verticesCount: number;
  91807. /** index start */
  91808. indexStart: number;
  91809. /** indices count */
  91810. indexCount: number;
  91811. /** @hidden */
  91812. _linesIndexCount: number;
  91813. private _mesh;
  91814. private _renderingMesh;
  91815. private _boundingInfo;
  91816. private _linesIndexBuffer;
  91817. /** @hidden */
  91818. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91819. /** @hidden */
  91820. _trianglePlanes: Plane[];
  91821. /** @hidden */
  91822. _lastColliderTransformMatrix: Nullable<Matrix>;
  91823. /** @hidden */
  91824. _renderId: number;
  91825. /** @hidden */
  91826. _alphaIndex: number;
  91827. /** @hidden */
  91828. _distanceToCamera: number;
  91829. /** @hidden */
  91830. _id: number;
  91831. private _currentMaterial;
  91832. /**
  91833. * Add a new submesh to a mesh
  91834. * @param materialIndex defines the material index to use
  91835. * @param verticesStart defines vertex index start
  91836. * @param verticesCount defines vertices count
  91837. * @param indexStart defines index start
  91838. * @param indexCount defines indices count
  91839. * @param mesh defines the parent mesh
  91840. * @param renderingMesh defines an optional rendering mesh
  91841. * @param createBoundingBox defines if bounding box should be created for this submesh
  91842. * @returns the new submesh
  91843. */
  91844. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91845. /**
  91846. * Creates a new submesh
  91847. * @param materialIndex defines the material index to use
  91848. * @param verticesStart defines vertex index start
  91849. * @param verticesCount defines vertices count
  91850. * @param indexStart defines index start
  91851. * @param indexCount defines indices count
  91852. * @param mesh defines the parent mesh
  91853. * @param renderingMesh defines an optional rendering mesh
  91854. * @param createBoundingBox defines if bounding box should be created for this submesh
  91855. */
  91856. constructor(
  91857. /** the material index to use */
  91858. materialIndex: number,
  91859. /** vertex index start */
  91860. verticesStart: number,
  91861. /** vertices count */
  91862. verticesCount: number,
  91863. /** index start */
  91864. indexStart: number,
  91865. /** indices count */
  91866. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91867. /**
  91868. * Returns true if this submesh covers the entire parent mesh
  91869. * @ignorenaming
  91870. */
  91871. get IsGlobal(): boolean;
  91872. /**
  91873. * Returns the submesh BoudingInfo object
  91874. * @returns current bounding info (or mesh's one if the submesh is global)
  91875. */
  91876. getBoundingInfo(): BoundingInfo;
  91877. /**
  91878. * Sets the submesh BoundingInfo
  91879. * @param boundingInfo defines the new bounding info to use
  91880. * @returns the SubMesh
  91881. */
  91882. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91883. /**
  91884. * Returns the mesh of the current submesh
  91885. * @return the parent mesh
  91886. */
  91887. getMesh(): AbstractMesh;
  91888. /**
  91889. * Returns the rendering mesh of the submesh
  91890. * @returns the rendering mesh (could be different from parent mesh)
  91891. */
  91892. getRenderingMesh(): Mesh;
  91893. /**
  91894. * Returns the submesh material
  91895. * @returns null or the current material
  91896. */
  91897. getMaterial(): Nullable<Material>;
  91898. /**
  91899. * Sets a new updated BoundingInfo object to the submesh
  91900. * @param data defines an optional position array to use to determine the bounding info
  91901. * @returns the SubMesh
  91902. */
  91903. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91904. /** @hidden */
  91905. _checkCollision(collider: Collider): boolean;
  91906. /**
  91907. * Updates the submesh BoundingInfo
  91908. * @param world defines the world matrix to use to update the bounding info
  91909. * @returns the submesh
  91910. */
  91911. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  91912. /**
  91913. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91914. * @param frustumPlanes defines the frustum planes
  91915. * @returns true if the submesh is intersecting with the frustum
  91916. */
  91917. isInFrustum(frustumPlanes: Plane[]): boolean;
  91918. /**
  91919. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91920. * @param frustumPlanes defines the frustum planes
  91921. * @returns true if the submesh is inside the frustum
  91922. */
  91923. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91924. /**
  91925. * Renders the submesh
  91926. * @param enableAlphaMode defines if alpha needs to be used
  91927. * @returns the submesh
  91928. */
  91929. render(enableAlphaMode: boolean): SubMesh;
  91930. /**
  91931. * @hidden
  91932. */
  91933. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  91934. /**
  91935. * Checks if the submesh intersects with a ray
  91936. * @param ray defines the ray to test
  91937. * @returns true is the passed ray intersects the submesh bounding box
  91938. */
  91939. canIntersects(ray: Ray): boolean;
  91940. /**
  91941. * Intersects current submesh with a ray
  91942. * @param ray defines the ray to test
  91943. * @param positions defines mesh's positions array
  91944. * @param indices defines mesh's indices array
  91945. * @param fastCheck defines if only bounding info should be used
  91946. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91947. * @returns intersection info or null if no intersection
  91948. */
  91949. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  91950. /** @hidden */
  91951. private _intersectLines;
  91952. /** @hidden */
  91953. private _intersectUnIndexedLines;
  91954. /** @hidden */
  91955. private _intersectTriangles;
  91956. /** @hidden */
  91957. private _intersectUnIndexedTriangles;
  91958. /** @hidden */
  91959. _rebuild(): void;
  91960. /**
  91961. * Creates a new submesh from the passed mesh
  91962. * @param newMesh defines the new hosting mesh
  91963. * @param newRenderingMesh defines an optional rendering mesh
  91964. * @returns the new submesh
  91965. */
  91966. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  91967. /**
  91968. * Release associated resources
  91969. */
  91970. dispose(): void;
  91971. /**
  91972. * Gets the class name
  91973. * @returns the string "SubMesh".
  91974. */
  91975. getClassName(): string;
  91976. /**
  91977. * Creates a new submesh from indices data
  91978. * @param materialIndex the index of the main mesh material
  91979. * @param startIndex the index where to start the copy in the mesh indices array
  91980. * @param indexCount the number of indices to copy then from the startIndex
  91981. * @param mesh the main mesh to create the submesh from
  91982. * @param renderingMesh the optional rendering mesh
  91983. * @returns a new submesh
  91984. */
  91985. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  91986. }
  91987. }
  91988. declare module BABYLON {
  91989. /**
  91990. * Class used to represent data loading progression
  91991. */
  91992. export class SceneLoaderFlags {
  91993. private static _ForceFullSceneLoadingForIncremental;
  91994. private static _ShowLoadingScreen;
  91995. private static _CleanBoneMatrixWeights;
  91996. private static _loggingLevel;
  91997. /**
  91998. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  91999. */
  92000. static get ForceFullSceneLoadingForIncremental(): boolean;
  92001. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92002. /**
  92003. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92004. */
  92005. static get ShowLoadingScreen(): boolean;
  92006. static set ShowLoadingScreen(value: boolean);
  92007. /**
  92008. * Defines the current logging level (while loading the scene)
  92009. * @ignorenaming
  92010. */
  92011. static get loggingLevel(): number;
  92012. static set loggingLevel(value: number);
  92013. /**
  92014. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92015. */
  92016. static get CleanBoneMatrixWeights(): boolean;
  92017. static set CleanBoneMatrixWeights(value: boolean);
  92018. }
  92019. }
  92020. declare module BABYLON {
  92021. /**
  92022. * Class used to store geometry data (vertex buffers + index buffer)
  92023. */
  92024. export class Geometry implements IGetSetVerticesData {
  92025. /**
  92026. * Gets or sets the ID of the geometry
  92027. */
  92028. id: string;
  92029. /**
  92030. * Gets or sets the unique ID of the geometry
  92031. */
  92032. uniqueId: number;
  92033. /**
  92034. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92035. */
  92036. delayLoadState: number;
  92037. /**
  92038. * Gets the file containing the data to load when running in delay load state
  92039. */
  92040. delayLoadingFile: Nullable<string>;
  92041. /**
  92042. * Callback called when the geometry is updated
  92043. */
  92044. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92045. private _scene;
  92046. private _engine;
  92047. private _meshes;
  92048. private _totalVertices;
  92049. /** @hidden */
  92050. _indices: IndicesArray;
  92051. /** @hidden */
  92052. _vertexBuffers: {
  92053. [key: string]: VertexBuffer;
  92054. };
  92055. private _isDisposed;
  92056. private _extend;
  92057. private _boundingBias;
  92058. /** @hidden */
  92059. _delayInfo: Array<string>;
  92060. private _indexBuffer;
  92061. private _indexBufferIsUpdatable;
  92062. /** @hidden */
  92063. _boundingInfo: Nullable<BoundingInfo>;
  92064. /** @hidden */
  92065. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92066. /** @hidden */
  92067. _softwareSkinningFrameId: number;
  92068. private _vertexArrayObjects;
  92069. private _updatable;
  92070. /** @hidden */
  92071. _positions: Nullable<Vector3[]>;
  92072. /**
  92073. * 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
  92074. */
  92075. get boundingBias(): Vector2;
  92076. /**
  92077. * 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
  92078. */
  92079. set boundingBias(value: Vector2);
  92080. /**
  92081. * Static function used to attach a new empty geometry to a mesh
  92082. * @param mesh defines the mesh to attach the geometry to
  92083. * @returns the new Geometry
  92084. */
  92085. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92086. /**
  92087. * Creates a new geometry
  92088. * @param id defines the unique ID
  92089. * @param scene defines the hosting scene
  92090. * @param vertexData defines the VertexData used to get geometry data
  92091. * @param updatable defines if geometry must be updatable (false by default)
  92092. * @param mesh defines the mesh that will be associated with the geometry
  92093. */
  92094. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92095. /**
  92096. * Gets the current extend of the geometry
  92097. */
  92098. get extend(): {
  92099. minimum: Vector3;
  92100. maximum: Vector3;
  92101. };
  92102. /**
  92103. * Gets the hosting scene
  92104. * @returns the hosting Scene
  92105. */
  92106. getScene(): Scene;
  92107. /**
  92108. * Gets the hosting engine
  92109. * @returns the hosting Engine
  92110. */
  92111. getEngine(): Engine;
  92112. /**
  92113. * Defines if the geometry is ready to use
  92114. * @returns true if the geometry is ready to be used
  92115. */
  92116. isReady(): boolean;
  92117. /**
  92118. * Gets a value indicating that the geometry should not be serialized
  92119. */
  92120. get doNotSerialize(): boolean;
  92121. /** @hidden */
  92122. _rebuild(): void;
  92123. /**
  92124. * Affects all geometry data in one call
  92125. * @param vertexData defines the geometry data
  92126. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92127. */
  92128. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92129. /**
  92130. * Set specific vertex data
  92131. * @param kind defines the data kind (Position, normal, etc...)
  92132. * @param data defines the vertex data to use
  92133. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92134. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92135. */
  92136. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92137. /**
  92138. * Removes a specific vertex data
  92139. * @param kind defines the data kind (Position, normal, etc...)
  92140. */
  92141. removeVerticesData(kind: string): void;
  92142. /**
  92143. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92144. * @param buffer defines the vertex buffer to use
  92145. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92146. */
  92147. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92148. /**
  92149. * Update a specific vertex buffer
  92150. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92151. * It will do nothing if the buffer is not updatable
  92152. * @param kind defines the data kind (Position, normal, etc...)
  92153. * @param data defines the data to use
  92154. * @param offset defines the offset in the target buffer where to store the data
  92155. * @param useBytes set to true if the offset is in bytes
  92156. */
  92157. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92158. /**
  92159. * Update a specific vertex buffer
  92160. * This function will create a new buffer if the current one is not updatable
  92161. * @param kind defines the data kind (Position, normal, etc...)
  92162. * @param data defines the data to use
  92163. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92164. */
  92165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92166. private _updateBoundingInfo;
  92167. /** @hidden */
  92168. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92169. /**
  92170. * Gets total number of vertices
  92171. * @returns the total number of vertices
  92172. */
  92173. getTotalVertices(): number;
  92174. /**
  92175. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92176. * @param kind defines the data kind (Position, normal, etc...)
  92177. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92178. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92179. * @returns a float array containing vertex data
  92180. */
  92181. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92182. /**
  92183. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92184. * @param kind defines the data kind (Position, normal, etc...)
  92185. * @returns true if the vertex buffer with the specified kind is updatable
  92186. */
  92187. isVertexBufferUpdatable(kind: string): boolean;
  92188. /**
  92189. * Gets a specific vertex buffer
  92190. * @param kind defines the data kind (Position, normal, etc...)
  92191. * @returns a VertexBuffer
  92192. */
  92193. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92194. /**
  92195. * Returns all vertex buffers
  92196. * @return an object holding all vertex buffers indexed by kind
  92197. */
  92198. getVertexBuffers(): Nullable<{
  92199. [key: string]: VertexBuffer;
  92200. }>;
  92201. /**
  92202. * Gets a boolean indicating if specific vertex buffer is present
  92203. * @param kind defines the data kind (Position, normal, etc...)
  92204. * @returns true if data is present
  92205. */
  92206. isVerticesDataPresent(kind: string): boolean;
  92207. /**
  92208. * Gets a list of all attached data kinds (Position, normal, etc...)
  92209. * @returns a list of string containing all kinds
  92210. */
  92211. getVerticesDataKinds(): string[];
  92212. /**
  92213. * Update index buffer
  92214. * @param indices defines the indices to store in the index buffer
  92215. * @param offset defines the offset in the target buffer where to store the data
  92216. * @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)
  92217. */
  92218. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92219. /**
  92220. * Creates a new index buffer
  92221. * @param indices defines the indices to store in the index buffer
  92222. * @param totalVertices defines the total number of vertices (could be null)
  92223. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92224. */
  92225. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92226. /**
  92227. * Return the total number of indices
  92228. * @returns the total number of indices
  92229. */
  92230. getTotalIndices(): number;
  92231. /**
  92232. * Gets the index buffer array
  92233. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92234. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92235. * @returns the index buffer array
  92236. */
  92237. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92238. /**
  92239. * Gets the index buffer
  92240. * @return the index buffer
  92241. */
  92242. getIndexBuffer(): Nullable<DataBuffer>;
  92243. /** @hidden */
  92244. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92245. /**
  92246. * Release the associated resources for a specific mesh
  92247. * @param mesh defines the source mesh
  92248. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92249. */
  92250. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92251. /**
  92252. * Apply current geometry to a given mesh
  92253. * @param mesh defines the mesh to apply geometry to
  92254. */
  92255. applyToMesh(mesh: Mesh): void;
  92256. private _updateExtend;
  92257. private _applyToMesh;
  92258. private notifyUpdate;
  92259. /**
  92260. * Load the geometry if it was flagged as delay loaded
  92261. * @param scene defines the hosting scene
  92262. * @param onLoaded defines a callback called when the geometry is loaded
  92263. */
  92264. load(scene: Scene, onLoaded?: () => void): void;
  92265. private _queueLoad;
  92266. /**
  92267. * Invert the geometry to move from a right handed system to a left handed one.
  92268. */
  92269. toLeftHanded(): void;
  92270. /** @hidden */
  92271. _resetPointsArrayCache(): void;
  92272. /** @hidden */
  92273. _generatePointsArray(): boolean;
  92274. /**
  92275. * Gets a value indicating if the geometry is disposed
  92276. * @returns true if the geometry was disposed
  92277. */
  92278. isDisposed(): boolean;
  92279. private _disposeVertexArrayObjects;
  92280. /**
  92281. * Free all associated resources
  92282. */
  92283. dispose(): void;
  92284. /**
  92285. * Clone the current geometry into a new geometry
  92286. * @param id defines the unique ID of the new geometry
  92287. * @returns a new geometry object
  92288. */
  92289. copy(id: string): Geometry;
  92290. /**
  92291. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92292. * @return a JSON representation of the current geometry data (without the vertices data)
  92293. */
  92294. serialize(): any;
  92295. private toNumberArray;
  92296. /**
  92297. * Serialize all vertices data into a JSON oject
  92298. * @returns a JSON representation of the current geometry data
  92299. */
  92300. serializeVerticeData(): any;
  92301. /**
  92302. * Extracts a clone of a mesh geometry
  92303. * @param mesh defines the source mesh
  92304. * @param id defines the unique ID of the new geometry object
  92305. * @returns the new geometry object
  92306. */
  92307. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92308. /**
  92309. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92310. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92311. * Be aware Math.random() could cause collisions, but:
  92312. * "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"
  92313. * @returns a string containing a new GUID
  92314. */
  92315. static RandomId(): string;
  92316. /** @hidden */
  92317. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92318. private static _CleanMatricesWeights;
  92319. /**
  92320. * Create a new geometry from persisted data (Using .babylon file format)
  92321. * @param parsedVertexData defines the persisted data
  92322. * @param scene defines the hosting scene
  92323. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92324. * @returns the new geometry object
  92325. */
  92326. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92327. }
  92328. }
  92329. declare module BABYLON {
  92330. /**
  92331. * Define an interface for all classes that will get and set the data on vertices
  92332. */
  92333. export interface IGetSetVerticesData {
  92334. /**
  92335. * Gets a boolean indicating if specific vertex data is present
  92336. * @param kind defines the vertex data kind to use
  92337. * @returns true is data kind is present
  92338. */
  92339. isVerticesDataPresent(kind: string): boolean;
  92340. /**
  92341. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92342. * @param kind defines the data kind (Position, normal, etc...)
  92343. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92345. * @returns a float array containing vertex data
  92346. */
  92347. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92348. /**
  92349. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92350. * @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.
  92351. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92352. * @returns the indices array or an empty array if the mesh has no geometry
  92353. */
  92354. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92355. /**
  92356. * Set specific vertex data
  92357. * @param kind defines the data kind (Position, normal, etc...)
  92358. * @param data defines the vertex data to use
  92359. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92360. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92361. */
  92362. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92363. /**
  92364. * Update a specific associated vertex buffer
  92365. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92366. * - VertexBuffer.PositionKind
  92367. * - VertexBuffer.UVKind
  92368. * - VertexBuffer.UV2Kind
  92369. * - VertexBuffer.UV3Kind
  92370. * - VertexBuffer.UV4Kind
  92371. * - VertexBuffer.UV5Kind
  92372. * - VertexBuffer.UV6Kind
  92373. * - VertexBuffer.ColorKind
  92374. * - VertexBuffer.MatricesIndicesKind
  92375. * - VertexBuffer.MatricesIndicesExtraKind
  92376. * - VertexBuffer.MatricesWeightsKind
  92377. * - VertexBuffer.MatricesWeightsExtraKind
  92378. * @param data defines the data source
  92379. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92380. * @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)
  92381. */
  92382. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92383. /**
  92384. * Creates a new index buffer
  92385. * @param indices defines the indices to store in the index buffer
  92386. * @param totalVertices defines the total number of vertices (could be null)
  92387. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92388. */
  92389. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92390. }
  92391. /**
  92392. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92393. */
  92394. export class VertexData {
  92395. /**
  92396. * Mesh side orientation : usually the external or front surface
  92397. */
  92398. static readonly FRONTSIDE: number;
  92399. /**
  92400. * Mesh side orientation : usually the internal or back surface
  92401. */
  92402. static readonly BACKSIDE: number;
  92403. /**
  92404. * Mesh side orientation : both internal and external or front and back surfaces
  92405. */
  92406. static readonly DOUBLESIDE: number;
  92407. /**
  92408. * Mesh side orientation : by default, `FRONTSIDE`
  92409. */
  92410. static readonly DEFAULTSIDE: number;
  92411. /**
  92412. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92413. */
  92414. positions: Nullable<FloatArray>;
  92415. /**
  92416. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92417. */
  92418. normals: Nullable<FloatArray>;
  92419. /**
  92420. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92421. */
  92422. tangents: Nullable<FloatArray>;
  92423. /**
  92424. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92425. */
  92426. uvs: Nullable<FloatArray>;
  92427. /**
  92428. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92429. */
  92430. uvs2: Nullable<FloatArray>;
  92431. /**
  92432. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92433. */
  92434. uvs3: Nullable<FloatArray>;
  92435. /**
  92436. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92437. */
  92438. uvs4: Nullable<FloatArray>;
  92439. /**
  92440. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92441. */
  92442. uvs5: Nullable<FloatArray>;
  92443. /**
  92444. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92445. */
  92446. uvs6: Nullable<FloatArray>;
  92447. /**
  92448. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92449. */
  92450. colors: Nullable<FloatArray>;
  92451. /**
  92452. * 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).
  92453. */
  92454. matricesIndices: Nullable<FloatArray>;
  92455. /**
  92456. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92457. */
  92458. matricesWeights: Nullable<FloatArray>;
  92459. /**
  92460. * An array extending the number of possible indices
  92461. */
  92462. matricesIndicesExtra: Nullable<FloatArray>;
  92463. /**
  92464. * An array extending the number of possible weights when the number of indices is extended
  92465. */
  92466. matricesWeightsExtra: Nullable<FloatArray>;
  92467. /**
  92468. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92469. */
  92470. indices: Nullable<IndicesArray>;
  92471. /**
  92472. * Uses the passed data array to set the set the values for the specified kind of data
  92473. * @param data a linear array of floating numbers
  92474. * @param kind the type of data that is being set, eg positions, colors etc
  92475. */
  92476. set(data: FloatArray, kind: string): void;
  92477. /**
  92478. * Associates the vertexData to the passed Mesh.
  92479. * Sets it as updatable or not (default `false`)
  92480. * @param mesh the mesh the vertexData is applied to
  92481. * @param updatable when used and having the value true allows new data to update the vertexData
  92482. * @returns the VertexData
  92483. */
  92484. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92485. /**
  92486. * Associates the vertexData to the passed Geometry.
  92487. * Sets it as updatable or not (default `false`)
  92488. * @param geometry the geometry the vertexData is applied to
  92489. * @param updatable when used and having the value true allows new data to update the vertexData
  92490. * @returns VertexData
  92491. */
  92492. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92493. /**
  92494. * Updates the associated mesh
  92495. * @param mesh the mesh to be updated
  92496. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92497. * @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
  92498. * @returns VertexData
  92499. */
  92500. updateMesh(mesh: Mesh): VertexData;
  92501. /**
  92502. * Updates the associated geometry
  92503. * @param geometry the geometry to be updated
  92504. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92505. * @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
  92506. * @returns VertexData.
  92507. */
  92508. updateGeometry(geometry: Geometry): VertexData;
  92509. private _applyTo;
  92510. private _update;
  92511. /**
  92512. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92513. * @param matrix the transforming matrix
  92514. * @returns the VertexData
  92515. */
  92516. transform(matrix: Matrix): VertexData;
  92517. /**
  92518. * Merges the passed VertexData into the current one
  92519. * @param other the VertexData to be merged into the current one
  92520. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92521. * @returns the modified VertexData
  92522. */
  92523. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92524. private _mergeElement;
  92525. private _validate;
  92526. /**
  92527. * Serializes the VertexData
  92528. * @returns a serialized object
  92529. */
  92530. serialize(): any;
  92531. /**
  92532. * Extracts the vertexData from a mesh
  92533. * @param mesh the mesh from which to extract the VertexData
  92534. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92535. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92536. * @returns the object VertexData associated to the passed mesh
  92537. */
  92538. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92539. /**
  92540. * Extracts the vertexData from the geometry
  92541. * @param geometry the geometry from which to extract the VertexData
  92542. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92543. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92544. * @returns the object VertexData associated to the passed mesh
  92545. */
  92546. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92547. private static _ExtractFrom;
  92548. /**
  92549. * Creates the VertexData for a Ribbon
  92550. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92551. * * pathArray array of paths, each of which an array of successive Vector3
  92552. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92553. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92554. * * 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
  92555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92556. * * 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)
  92557. * * 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)
  92558. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92559. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92560. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92561. * @returns the VertexData of the ribbon
  92562. */
  92563. static CreateRibbon(options: {
  92564. pathArray: Vector3[][];
  92565. closeArray?: boolean;
  92566. closePath?: boolean;
  92567. offset?: number;
  92568. sideOrientation?: number;
  92569. frontUVs?: Vector4;
  92570. backUVs?: Vector4;
  92571. invertUV?: boolean;
  92572. uvs?: Vector2[];
  92573. colors?: Color4[];
  92574. }): VertexData;
  92575. /**
  92576. * Creates the VertexData for a box
  92577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92578. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92579. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92580. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92581. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92582. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92583. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92584. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92585. * * 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)
  92586. * * 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)
  92587. * @returns the VertexData of the box
  92588. */
  92589. static CreateBox(options: {
  92590. size?: number;
  92591. width?: number;
  92592. height?: number;
  92593. depth?: number;
  92594. faceUV?: Vector4[];
  92595. faceColors?: Color4[];
  92596. sideOrientation?: number;
  92597. frontUVs?: Vector4;
  92598. backUVs?: Vector4;
  92599. }): VertexData;
  92600. /**
  92601. * Creates the VertexData for a tiled box
  92602. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92603. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92604. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92605. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92607. * @returns the VertexData of the box
  92608. */
  92609. static CreateTiledBox(options: {
  92610. pattern?: number;
  92611. width?: number;
  92612. height?: number;
  92613. depth?: number;
  92614. tileSize?: number;
  92615. tileWidth?: number;
  92616. tileHeight?: number;
  92617. alignHorizontal?: number;
  92618. alignVertical?: number;
  92619. faceUV?: Vector4[];
  92620. faceColors?: Color4[];
  92621. sideOrientation?: number;
  92622. }): VertexData;
  92623. /**
  92624. * Creates the VertexData for a tiled plane
  92625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92626. * * pattern a limited pattern arrangement depending on the number
  92627. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92628. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92629. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92631. * * 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)
  92632. * * 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)
  92633. * @returns the VertexData of the tiled plane
  92634. */
  92635. static CreateTiledPlane(options: {
  92636. pattern?: number;
  92637. tileSize?: number;
  92638. tileWidth?: number;
  92639. tileHeight?: number;
  92640. size?: number;
  92641. width?: number;
  92642. height?: number;
  92643. alignHorizontal?: number;
  92644. alignVertical?: number;
  92645. sideOrientation?: number;
  92646. frontUVs?: Vector4;
  92647. backUVs?: Vector4;
  92648. }): VertexData;
  92649. /**
  92650. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92651. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92652. * * segments sets the number of horizontal strips optional, default 32
  92653. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92654. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92655. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92656. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92657. * * 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
  92658. * * 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
  92659. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92660. * * 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)
  92661. * * 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)
  92662. * @returns the VertexData of the ellipsoid
  92663. */
  92664. static CreateSphere(options: {
  92665. segments?: number;
  92666. diameter?: number;
  92667. diameterX?: number;
  92668. diameterY?: number;
  92669. diameterZ?: number;
  92670. arc?: number;
  92671. slice?: number;
  92672. sideOrientation?: number;
  92673. frontUVs?: Vector4;
  92674. backUVs?: Vector4;
  92675. }): VertexData;
  92676. /**
  92677. * Creates the VertexData for a cylinder, cone or prism
  92678. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92679. * * height sets the height (y direction) of the cylinder, optional, default 2
  92680. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92681. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92682. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92683. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92684. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92685. * * 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
  92686. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92687. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92688. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92689. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92691. * * 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)
  92692. * * 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)
  92693. * @returns the VertexData of the cylinder, cone or prism
  92694. */
  92695. static CreateCylinder(options: {
  92696. height?: number;
  92697. diameterTop?: number;
  92698. diameterBottom?: number;
  92699. diameter?: number;
  92700. tessellation?: number;
  92701. subdivisions?: number;
  92702. arc?: number;
  92703. faceColors?: Color4[];
  92704. faceUV?: Vector4[];
  92705. hasRings?: boolean;
  92706. enclose?: boolean;
  92707. sideOrientation?: number;
  92708. frontUVs?: Vector4;
  92709. backUVs?: Vector4;
  92710. }): VertexData;
  92711. /**
  92712. * Creates the VertexData for a torus
  92713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92714. * * diameter the diameter of the torus, optional default 1
  92715. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92716. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92718. * * 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)
  92719. * * 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)
  92720. * @returns the VertexData of the torus
  92721. */
  92722. static CreateTorus(options: {
  92723. diameter?: number;
  92724. thickness?: number;
  92725. tessellation?: number;
  92726. sideOrientation?: number;
  92727. frontUVs?: Vector4;
  92728. backUVs?: Vector4;
  92729. }): VertexData;
  92730. /**
  92731. * Creates the VertexData of the LineSystem
  92732. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92733. * - lines an array of lines, each line being an array of successive Vector3
  92734. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92735. * @returns the VertexData of the LineSystem
  92736. */
  92737. static CreateLineSystem(options: {
  92738. lines: Vector3[][];
  92739. colors?: Nullable<Color4[][]>;
  92740. }): VertexData;
  92741. /**
  92742. * Create the VertexData for a DashedLines
  92743. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92744. * - points an array successive Vector3
  92745. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92746. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92747. * - dashNb the intended total number of dashes, optional, default 200
  92748. * @returns the VertexData for the DashedLines
  92749. */
  92750. static CreateDashedLines(options: {
  92751. points: Vector3[];
  92752. dashSize?: number;
  92753. gapSize?: number;
  92754. dashNb?: number;
  92755. }): VertexData;
  92756. /**
  92757. * Creates the VertexData for a Ground
  92758. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92759. * - width the width (x direction) of the ground, optional, default 1
  92760. * - height the height (z direction) of the ground, optional, default 1
  92761. * - subdivisions the number of subdivisions per side, optional, default 1
  92762. * @returns the VertexData of the Ground
  92763. */
  92764. static CreateGround(options: {
  92765. width?: number;
  92766. height?: number;
  92767. subdivisions?: number;
  92768. subdivisionsX?: number;
  92769. subdivisionsY?: number;
  92770. }): VertexData;
  92771. /**
  92772. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92773. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92774. * * xmin the ground minimum X coordinate, optional, default -1
  92775. * * zmin the ground minimum Z coordinate, optional, default -1
  92776. * * xmax the ground maximum X coordinate, optional, default 1
  92777. * * zmax the ground maximum Z coordinate, optional, default 1
  92778. * * 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}
  92779. * * 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}
  92780. * @returns the VertexData of the TiledGround
  92781. */
  92782. static CreateTiledGround(options: {
  92783. xmin: number;
  92784. zmin: number;
  92785. xmax: number;
  92786. zmax: number;
  92787. subdivisions?: {
  92788. w: number;
  92789. h: number;
  92790. };
  92791. precision?: {
  92792. w: number;
  92793. h: number;
  92794. };
  92795. }): VertexData;
  92796. /**
  92797. * Creates the VertexData of the Ground designed from a heightmap
  92798. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92799. * * width the width (x direction) of the ground
  92800. * * height the height (z direction) of the ground
  92801. * * subdivisions the number of subdivisions per side
  92802. * * minHeight the minimum altitude on the ground, optional, default 0
  92803. * * maxHeight the maximum altitude on the ground, optional default 1
  92804. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92805. * * buffer the array holding the image color data
  92806. * * bufferWidth the width of image
  92807. * * bufferHeight the height of image
  92808. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92809. * @returns the VertexData of the Ground designed from a heightmap
  92810. */
  92811. static CreateGroundFromHeightMap(options: {
  92812. width: number;
  92813. height: number;
  92814. subdivisions: number;
  92815. minHeight: number;
  92816. maxHeight: number;
  92817. colorFilter: Color3;
  92818. buffer: Uint8Array;
  92819. bufferWidth: number;
  92820. bufferHeight: number;
  92821. alphaFilter: number;
  92822. }): VertexData;
  92823. /**
  92824. * Creates the VertexData for a Plane
  92825. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92826. * * size sets the width and height of the plane to the value of size, optional default 1
  92827. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92828. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92830. * * 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)
  92831. * * 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)
  92832. * @returns the VertexData of the box
  92833. */
  92834. static CreatePlane(options: {
  92835. size?: number;
  92836. width?: number;
  92837. height?: number;
  92838. sideOrientation?: number;
  92839. frontUVs?: Vector4;
  92840. backUVs?: Vector4;
  92841. }): VertexData;
  92842. /**
  92843. * Creates the VertexData of the Disc or regular Polygon
  92844. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92845. * * radius the radius of the disc, optional default 0.5
  92846. * * tessellation the number of polygon sides, optional, default 64
  92847. * * 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
  92848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92849. * * 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)
  92850. * * 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)
  92851. * @returns the VertexData of the box
  92852. */
  92853. static CreateDisc(options: {
  92854. radius?: number;
  92855. tessellation?: number;
  92856. arc?: number;
  92857. sideOrientation?: number;
  92858. frontUVs?: Vector4;
  92859. backUVs?: Vector4;
  92860. }): VertexData;
  92861. /**
  92862. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92863. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92864. * @param polygon a mesh built from polygonTriangulation.build()
  92865. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92866. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92867. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92868. * @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)
  92869. * @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)
  92870. * @returns the VertexData of the Polygon
  92871. */
  92872. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92873. /**
  92874. * Creates the VertexData of the IcoSphere
  92875. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92876. * * radius the radius of the IcoSphere, optional default 1
  92877. * * radiusX allows stretching in the x direction, optional, default radius
  92878. * * radiusY allows stretching in the y direction, optional, default radius
  92879. * * radiusZ allows stretching in the z direction, optional, default radius
  92880. * * flat when true creates a flat shaded mesh, optional, default true
  92881. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92883. * * 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)
  92884. * * 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)
  92885. * @returns the VertexData of the IcoSphere
  92886. */
  92887. static CreateIcoSphere(options: {
  92888. radius?: number;
  92889. radiusX?: number;
  92890. radiusY?: number;
  92891. radiusZ?: number;
  92892. flat?: boolean;
  92893. subdivisions?: number;
  92894. sideOrientation?: number;
  92895. frontUVs?: Vector4;
  92896. backUVs?: Vector4;
  92897. }): VertexData;
  92898. /**
  92899. * Creates the VertexData for a Polyhedron
  92900. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92901. * * type provided types are:
  92902. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92903. * * 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)
  92904. * * size the size of the IcoSphere, optional default 1
  92905. * * sizeX allows stretching in the x direction, optional, default size
  92906. * * sizeY allows stretching in the y direction, optional, default size
  92907. * * sizeZ allows stretching in the z direction, optional, default size
  92908. * * 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
  92909. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92910. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92911. * * flat when true creates a flat shaded mesh, optional, default true
  92912. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92914. * * 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)
  92915. * * 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)
  92916. * @returns the VertexData of the Polyhedron
  92917. */
  92918. static CreatePolyhedron(options: {
  92919. type?: number;
  92920. size?: number;
  92921. sizeX?: number;
  92922. sizeY?: number;
  92923. sizeZ?: number;
  92924. custom?: any;
  92925. faceUV?: Vector4[];
  92926. faceColors?: Color4[];
  92927. flat?: boolean;
  92928. sideOrientation?: number;
  92929. frontUVs?: Vector4;
  92930. backUVs?: Vector4;
  92931. }): VertexData;
  92932. /**
  92933. * Creates the VertexData for a TorusKnot
  92934. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  92935. * * radius the radius of the torus knot, optional, default 2
  92936. * * tube the thickness of the tube, optional, default 0.5
  92937. * * radialSegments the number of sides on each tube segments, optional, default 32
  92938. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  92939. * * p the number of windings around the z axis, optional, default 2
  92940. * * q the number of windings around the x axis, optional, default 3
  92941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92942. * * 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)
  92943. * * 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)
  92944. * @returns the VertexData of the Torus Knot
  92945. */
  92946. static CreateTorusKnot(options: {
  92947. radius?: number;
  92948. tube?: number;
  92949. radialSegments?: number;
  92950. tubularSegments?: number;
  92951. p?: number;
  92952. q?: number;
  92953. sideOrientation?: number;
  92954. frontUVs?: Vector4;
  92955. backUVs?: Vector4;
  92956. }): VertexData;
  92957. /**
  92958. * Compute normals for given positions and indices
  92959. * @param positions an array of vertex positions, [...., x, y, z, ......]
  92960. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  92961. * @param normals an array of vertex normals, [...., x, y, z, ......]
  92962. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  92963. * * facetNormals : optional array of facet normals (vector3)
  92964. * * facetPositions : optional array of facet positions (vector3)
  92965. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  92966. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  92967. * * bInfo : optional bounding info, required for facetPartitioning computation
  92968. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  92969. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  92970. * * useRightHandedSystem: optional boolean to for right handed system computation
  92971. * * depthSort : optional boolean to enable the facet depth sort computation
  92972. * * distanceTo : optional Vector3 to compute the facet depth from this location
  92973. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  92974. */
  92975. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  92976. facetNormals?: any;
  92977. facetPositions?: any;
  92978. facetPartitioning?: any;
  92979. ratio?: number;
  92980. bInfo?: any;
  92981. bbSize?: Vector3;
  92982. subDiv?: any;
  92983. useRightHandedSystem?: boolean;
  92984. depthSort?: boolean;
  92985. distanceTo?: Vector3;
  92986. depthSortedFacets?: any;
  92987. }): void;
  92988. /** @hidden */
  92989. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  92990. /**
  92991. * Applies VertexData created from the imported parameters to the geometry
  92992. * @param parsedVertexData the parsed data from an imported file
  92993. * @param geometry the geometry to apply the VertexData to
  92994. */
  92995. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  92996. }
  92997. }
  92998. declare module BABYLON {
  92999. /**
  93000. * Defines a target to use with MorphTargetManager
  93001. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93002. */
  93003. export class MorphTarget implements IAnimatable {
  93004. /** defines the name of the target */
  93005. name: string;
  93006. /**
  93007. * Gets or sets the list of animations
  93008. */
  93009. animations: Animation[];
  93010. private _scene;
  93011. private _positions;
  93012. private _normals;
  93013. private _tangents;
  93014. private _uvs;
  93015. private _influence;
  93016. private _uniqueId;
  93017. /**
  93018. * Observable raised when the influence changes
  93019. */
  93020. onInfluenceChanged: Observable<boolean>;
  93021. /** @hidden */
  93022. _onDataLayoutChanged: Observable<void>;
  93023. /**
  93024. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93025. */
  93026. get influence(): number;
  93027. set influence(influence: number);
  93028. /**
  93029. * Gets or sets the id of the morph Target
  93030. */
  93031. id: string;
  93032. private _animationPropertiesOverride;
  93033. /**
  93034. * Gets or sets the animation properties override
  93035. */
  93036. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93037. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93038. /**
  93039. * Creates a new MorphTarget
  93040. * @param name defines the name of the target
  93041. * @param influence defines the influence to use
  93042. * @param scene defines the scene the morphtarget belongs to
  93043. */
  93044. constructor(
  93045. /** defines the name of the target */
  93046. name: string, influence?: number, scene?: Nullable<Scene>);
  93047. /**
  93048. * Gets the unique ID of this manager
  93049. */
  93050. get uniqueId(): number;
  93051. /**
  93052. * Gets a boolean defining if the target contains position data
  93053. */
  93054. get hasPositions(): boolean;
  93055. /**
  93056. * Gets a boolean defining if the target contains normal data
  93057. */
  93058. get hasNormals(): boolean;
  93059. /**
  93060. * Gets a boolean defining if the target contains tangent data
  93061. */
  93062. get hasTangents(): boolean;
  93063. /**
  93064. * Gets a boolean defining if the target contains texture coordinates data
  93065. */
  93066. get hasUVs(): boolean;
  93067. /**
  93068. * Affects position data to this target
  93069. * @param data defines the position data to use
  93070. */
  93071. setPositions(data: Nullable<FloatArray>): void;
  93072. /**
  93073. * Gets the position data stored in this target
  93074. * @returns a FloatArray containing the position data (or null if not present)
  93075. */
  93076. getPositions(): Nullable<FloatArray>;
  93077. /**
  93078. * Affects normal data to this target
  93079. * @param data defines the normal data to use
  93080. */
  93081. setNormals(data: Nullable<FloatArray>): void;
  93082. /**
  93083. * Gets the normal data stored in this target
  93084. * @returns a FloatArray containing the normal data (or null if not present)
  93085. */
  93086. getNormals(): Nullable<FloatArray>;
  93087. /**
  93088. * Affects tangent data to this target
  93089. * @param data defines the tangent data to use
  93090. */
  93091. setTangents(data: Nullable<FloatArray>): void;
  93092. /**
  93093. * Gets the tangent data stored in this target
  93094. * @returns a FloatArray containing the tangent data (or null if not present)
  93095. */
  93096. getTangents(): Nullable<FloatArray>;
  93097. /**
  93098. * Affects texture coordinates data to this target
  93099. * @param data defines the texture coordinates data to use
  93100. */
  93101. setUVs(data: Nullable<FloatArray>): void;
  93102. /**
  93103. * Gets the texture coordinates data stored in this target
  93104. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93105. */
  93106. getUVs(): Nullable<FloatArray>;
  93107. /**
  93108. * Clone the current target
  93109. * @returns a new MorphTarget
  93110. */
  93111. clone(): MorphTarget;
  93112. /**
  93113. * Serializes the current target into a Serialization object
  93114. * @returns the serialized object
  93115. */
  93116. serialize(): any;
  93117. /**
  93118. * Returns the string "MorphTarget"
  93119. * @returns "MorphTarget"
  93120. */
  93121. getClassName(): string;
  93122. /**
  93123. * Creates a new target from serialized data
  93124. * @param serializationObject defines the serialized data to use
  93125. * @returns a new MorphTarget
  93126. */
  93127. static Parse(serializationObject: any): MorphTarget;
  93128. /**
  93129. * Creates a MorphTarget from mesh data
  93130. * @param mesh defines the source mesh
  93131. * @param name defines the name to use for the new target
  93132. * @param influence defines the influence to attach to the target
  93133. * @returns a new MorphTarget
  93134. */
  93135. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. /**
  93140. * This class is used to deform meshes using morphing between different targets
  93141. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93142. */
  93143. export class MorphTargetManager {
  93144. private _targets;
  93145. private _targetInfluenceChangedObservers;
  93146. private _targetDataLayoutChangedObservers;
  93147. private _activeTargets;
  93148. private _scene;
  93149. private _influences;
  93150. private _supportsNormals;
  93151. private _supportsTangents;
  93152. private _supportsUVs;
  93153. private _vertexCount;
  93154. private _uniqueId;
  93155. private _tempInfluences;
  93156. /**
  93157. * Gets or sets a boolean indicating if normals must be morphed
  93158. */
  93159. enableNormalMorphing: boolean;
  93160. /**
  93161. * Gets or sets a boolean indicating if tangents must be morphed
  93162. */
  93163. enableTangentMorphing: boolean;
  93164. /**
  93165. * Gets or sets a boolean indicating if UV must be morphed
  93166. */
  93167. enableUVMorphing: boolean;
  93168. /**
  93169. * Creates a new MorphTargetManager
  93170. * @param scene defines the current scene
  93171. */
  93172. constructor(scene?: Nullable<Scene>);
  93173. /**
  93174. * Gets the unique ID of this manager
  93175. */
  93176. get uniqueId(): number;
  93177. /**
  93178. * Gets the number of vertices handled by this manager
  93179. */
  93180. get vertexCount(): number;
  93181. /**
  93182. * Gets a boolean indicating if this manager supports morphing of normals
  93183. */
  93184. get supportsNormals(): boolean;
  93185. /**
  93186. * Gets a boolean indicating if this manager supports morphing of tangents
  93187. */
  93188. get supportsTangents(): boolean;
  93189. /**
  93190. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93191. */
  93192. get supportsUVs(): boolean;
  93193. /**
  93194. * Gets the number of targets stored in this manager
  93195. */
  93196. get numTargets(): number;
  93197. /**
  93198. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93199. */
  93200. get numInfluencers(): number;
  93201. /**
  93202. * Gets the list of influences (one per target)
  93203. */
  93204. get influences(): Float32Array;
  93205. /**
  93206. * Gets the active target at specified index. An active target is a target with an influence > 0
  93207. * @param index defines the index to check
  93208. * @returns the requested target
  93209. */
  93210. getActiveTarget(index: number): MorphTarget;
  93211. /**
  93212. * Gets the target at specified index
  93213. * @param index defines the index to check
  93214. * @returns the requested target
  93215. */
  93216. getTarget(index: number): MorphTarget;
  93217. /**
  93218. * Add a new target to this manager
  93219. * @param target defines the target to add
  93220. */
  93221. addTarget(target: MorphTarget): void;
  93222. /**
  93223. * Removes a target from the manager
  93224. * @param target defines the target to remove
  93225. */
  93226. removeTarget(target: MorphTarget): void;
  93227. /**
  93228. * Clone the current manager
  93229. * @returns a new MorphTargetManager
  93230. */
  93231. clone(): MorphTargetManager;
  93232. /**
  93233. * Serializes the current manager into a Serialization object
  93234. * @returns the serialized object
  93235. */
  93236. serialize(): any;
  93237. private _syncActiveTargets;
  93238. /**
  93239. * Syncrhonize the targets with all the meshes using this morph target manager
  93240. */
  93241. synchronize(): void;
  93242. /**
  93243. * Creates a new MorphTargetManager from serialized data
  93244. * @param serializationObject defines the serialized data
  93245. * @param scene defines the hosting scene
  93246. * @returns the new MorphTargetManager
  93247. */
  93248. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93249. }
  93250. }
  93251. declare module BABYLON {
  93252. /**
  93253. * Class used to represent a specific level of detail of a mesh
  93254. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93255. */
  93256. export class MeshLODLevel {
  93257. /** Defines the distance where this level should start being displayed */
  93258. distance: number;
  93259. /** Defines the mesh to use to render this level */
  93260. mesh: Nullable<Mesh>;
  93261. /**
  93262. * Creates a new LOD level
  93263. * @param distance defines the distance where this level should star being displayed
  93264. * @param mesh defines the mesh to use to render this level
  93265. */
  93266. constructor(
  93267. /** Defines the distance where this level should start being displayed */
  93268. distance: number,
  93269. /** Defines the mesh to use to render this level */
  93270. mesh: Nullable<Mesh>);
  93271. }
  93272. }
  93273. declare module BABYLON {
  93274. /**
  93275. * Mesh representing the gorund
  93276. */
  93277. export class GroundMesh extends Mesh {
  93278. /** If octree should be generated */
  93279. generateOctree: boolean;
  93280. private _heightQuads;
  93281. /** @hidden */
  93282. _subdivisionsX: number;
  93283. /** @hidden */
  93284. _subdivisionsY: number;
  93285. /** @hidden */
  93286. _width: number;
  93287. /** @hidden */
  93288. _height: number;
  93289. /** @hidden */
  93290. _minX: number;
  93291. /** @hidden */
  93292. _maxX: number;
  93293. /** @hidden */
  93294. _minZ: number;
  93295. /** @hidden */
  93296. _maxZ: number;
  93297. constructor(name: string, scene: Scene);
  93298. /**
  93299. * "GroundMesh"
  93300. * @returns "GroundMesh"
  93301. */
  93302. getClassName(): string;
  93303. /**
  93304. * The minimum of x and y subdivisions
  93305. */
  93306. get subdivisions(): number;
  93307. /**
  93308. * X subdivisions
  93309. */
  93310. get subdivisionsX(): number;
  93311. /**
  93312. * Y subdivisions
  93313. */
  93314. get subdivisionsY(): number;
  93315. /**
  93316. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93317. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93318. * @param chunksCount the number of subdivisions for x and y
  93319. * @param octreeBlocksSize (Default: 32)
  93320. */
  93321. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93322. /**
  93323. * Returns a height (y) value in the Worl system :
  93324. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93325. * @param x x coordinate
  93326. * @param z z coordinate
  93327. * @returns the ground y position if (x, z) are outside the ground surface.
  93328. */
  93329. getHeightAtCoordinates(x: number, z: number): number;
  93330. /**
  93331. * Returns a normalized vector (Vector3) orthogonal to the ground
  93332. * at the ground coordinates (x, z) expressed in the World system.
  93333. * @param x x coordinate
  93334. * @param z z coordinate
  93335. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93336. */
  93337. getNormalAtCoordinates(x: number, z: number): Vector3;
  93338. /**
  93339. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93340. * at the ground coordinates (x, z) expressed in the World system.
  93341. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93342. * @param x x coordinate
  93343. * @param z z coordinate
  93344. * @param ref vector to store the result
  93345. * @returns the GroundMesh.
  93346. */
  93347. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93348. /**
  93349. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93350. * if the ground has been updated.
  93351. * This can be used in the render loop.
  93352. * @returns the GroundMesh.
  93353. */
  93354. updateCoordinateHeights(): GroundMesh;
  93355. private _getFacetAt;
  93356. private _initHeightQuads;
  93357. private _computeHeightQuads;
  93358. /**
  93359. * Serializes this ground mesh
  93360. * @param serializationObject object to write serialization to
  93361. */
  93362. serialize(serializationObject: any): void;
  93363. /**
  93364. * Parses a serialized ground mesh
  93365. * @param parsedMesh the serialized mesh
  93366. * @param scene the scene to create the ground mesh in
  93367. * @returns the created ground mesh
  93368. */
  93369. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93370. }
  93371. }
  93372. declare module BABYLON {
  93373. /**
  93374. * Interface for Physics-Joint data
  93375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93376. */
  93377. export interface PhysicsJointData {
  93378. /**
  93379. * The main pivot of the joint
  93380. */
  93381. mainPivot?: Vector3;
  93382. /**
  93383. * The connected pivot of the joint
  93384. */
  93385. connectedPivot?: Vector3;
  93386. /**
  93387. * The main axis of the joint
  93388. */
  93389. mainAxis?: Vector3;
  93390. /**
  93391. * The connected axis of the joint
  93392. */
  93393. connectedAxis?: Vector3;
  93394. /**
  93395. * The collision of the joint
  93396. */
  93397. collision?: boolean;
  93398. /**
  93399. * Native Oimo/Cannon/Energy data
  93400. */
  93401. nativeParams?: any;
  93402. }
  93403. /**
  93404. * This is a holder class for the physics joint created by the physics plugin
  93405. * It holds a set of functions to control the underlying joint
  93406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93407. */
  93408. export class PhysicsJoint {
  93409. /**
  93410. * The type of the physics joint
  93411. */
  93412. type: number;
  93413. /**
  93414. * The data for the physics joint
  93415. */
  93416. jointData: PhysicsJointData;
  93417. private _physicsJoint;
  93418. protected _physicsPlugin: IPhysicsEnginePlugin;
  93419. /**
  93420. * Initializes the physics joint
  93421. * @param type The type of the physics joint
  93422. * @param jointData The data for the physics joint
  93423. */
  93424. constructor(
  93425. /**
  93426. * The type of the physics joint
  93427. */
  93428. type: number,
  93429. /**
  93430. * The data for the physics joint
  93431. */
  93432. jointData: PhysicsJointData);
  93433. /**
  93434. * Gets the physics joint
  93435. */
  93436. get physicsJoint(): any;
  93437. /**
  93438. * Sets the physics joint
  93439. */
  93440. set physicsJoint(newJoint: any);
  93441. /**
  93442. * Sets the physics plugin
  93443. */
  93444. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93445. /**
  93446. * Execute a function that is physics-plugin specific.
  93447. * @param {Function} func the function that will be executed.
  93448. * It accepts two parameters: the physics world and the physics joint
  93449. */
  93450. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93451. /**
  93452. * Distance-Joint type
  93453. */
  93454. static DistanceJoint: number;
  93455. /**
  93456. * Hinge-Joint type
  93457. */
  93458. static HingeJoint: number;
  93459. /**
  93460. * Ball-and-Socket joint type
  93461. */
  93462. static BallAndSocketJoint: number;
  93463. /**
  93464. * Wheel-Joint type
  93465. */
  93466. static WheelJoint: number;
  93467. /**
  93468. * Slider-Joint type
  93469. */
  93470. static SliderJoint: number;
  93471. /**
  93472. * Prismatic-Joint type
  93473. */
  93474. static PrismaticJoint: number;
  93475. /**
  93476. * Universal-Joint type
  93477. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93478. */
  93479. static UniversalJoint: number;
  93480. /**
  93481. * Hinge-Joint 2 type
  93482. */
  93483. static Hinge2Joint: number;
  93484. /**
  93485. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93486. */
  93487. static PointToPointJoint: number;
  93488. /**
  93489. * Spring-Joint type
  93490. */
  93491. static SpringJoint: number;
  93492. /**
  93493. * Lock-Joint type
  93494. */
  93495. static LockJoint: number;
  93496. }
  93497. /**
  93498. * A class representing a physics distance joint
  93499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93500. */
  93501. export class DistanceJoint extends PhysicsJoint {
  93502. /**
  93503. *
  93504. * @param jointData The data for the Distance-Joint
  93505. */
  93506. constructor(jointData: DistanceJointData);
  93507. /**
  93508. * Update the predefined distance.
  93509. * @param maxDistance The maximum preferred distance
  93510. * @param minDistance The minimum preferred distance
  93511. */
  93512. updateDistance(maxDistance: number, minDistance?: number): void;
  93513. }
  93514. /**
  93515. * Represents a Motor-Enabled Joint
  93516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93517. */
  93518. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93519. /**
  93520. * Initializes the Motor-Enabled Joint
  93521. * @param type The type of the joint
  93522. * @param jointData The physica joint data for the joint
  93523. */
  93524. constructor(type: number, jointData: PhysicsJointData);
  93525. /**
  93526. * Set the motor values.
  93527. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93528. * @param force the force to apply
  93529. * @param maxForce max force for this motor.
  93530. */
  93531. setMotor(force?: number, maxForce?: number): void;
  93532. /**
  93533. * Set the motor's limits.
  93534. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93535. * @param upperLimit The upper limit of the motor
  93536. * @param lowerLimit The lower limit of the motor
  93537. */
  93538. setLimit(upperLimit: number, lowerLimit?: number): void;
  93539. }
  93540. /**
  93541. * This class represents a single physics Hinge-Joint
  93542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93543. */
  93544. export class HingeJoint extends MotorEnabledJoint {
  93545. /**
  93546. * Initializes the Hinge-Joint
  93547. * @param jointData The joint data for the Hinge-Joint
  93548. */
  93549. constructor(jointData: PhysicsJointData);
  93550. /**
  93551. * Set the motor values.
  93552. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93553. * @param {number} force the force to apply
  93554. * @param {number} maxForce max force for this motor.
  93555. */
  93556. setMotor(force?: number, maxForce?: number): void;
  93557. /**
  93558. * Set the motor's limits.
  93559. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93560. * @param upperLimit The upper limit of the motor
  93561. * @param lowerLimit The lower limit of the motor
  93562. */
  93563. setLimit(upperLimit: number, lowerLimit?: number): void;
  93564. }
  93565. /**
  93566. * This class represents a dual hinge physics joint (same as wheel joint)
  93567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93568. */
  93569. export class Hinge2Joint extends MotorEnabledJoint {
  93570. /**
  93571. * Initializes the Hinge2-Joint
  93572. * @param jointData The joint data for the Hinge2-Joint
  93573. */
  93574. constructor(jointData: PhysicsJointData);
  93575. /**
  93576. * Set the motor values.
  93577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93578. * @param {number} targetSpeed the speed the motor is to reach
  93579. * @param {number} maxForce max force for this motor.
  93580. * @param {motorIndex} the motor's index, 0 or 1.
  93581. */
  93582. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93583. /**
  93584. * Set the motor limits.
  93585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93586. * @param {number} upperLimit the upper limit
  93587. * @param {number} lowerLimit lower limit
  93588. * @param {motorIndex} the motor's index, 0 or 1.
  93589. */
  93590. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93591. }
  93592. /**
  93593. * Interface for a motor enabled joint
  93594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93595. */
  93596. export interface IMotorEnabledJoint {
  93597. /**
  93598. * Physics joint
  93599. */
  93600. physicsJoint: any;
  93601. /**
  93602. * Sets the motor of the motor-enabled joint
  93603. * @param force The force of the motor
  93604. * @param maxForce The maximum force of the motor
  93605. * @param motorIndex The index of the motor
  93606. */
  93607. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93608. /**
  93609. * Sets the limit of the motor
  93610. * @param upperLimit The upper limit of the motor
  93611. * @param lowerLimit The lower limit of the motor
  93612. * @param motorIndex The index of the motor
  93613. */
  93614. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93615. }
  93616. /**
  93617. * Joint data for a Distance-Joint
  93618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93619. */
  93620. export interface DistanceJointData extends PhysicsJointData {
  93621. /**
  93622. * Max distance the 2 joint objects can be apart
  93623. */
  93624. maxDistance: number;
  93625. }
  93626. /**
  93627. * Joint data from a spring joint
  93628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93629. */
  93630. export interface SpringJointData extends PhysicsJointData {
  93631. /**
  93632. * Length of the spring
  93633. */
  93634. length: number;
  93635. /**
  93636. * Stiffness of the spring
  93637. */
  93638. stiffness: number;
  93639. /**
  93640. * Damping of the spring
  93641. */
  93642. damping: number;
  93643. /** this callback will be called when applying the force to the impostors. */
  93644. forceApplicationCallback: () => void;
  93645. }
  93646. }
  93647. declare module BABYLON {
  93648. /**
  93649. * Holds the data for the raycast result
  93650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93651. */
  93652. export class PhysicsRaycastResult {
  93653. private _hasHit;
  93654. private _hitDistance;
  93655. private _hitNormalWorld;
  93656. private _hitPointWorld;
  93657. private _rayFromWorld;
  93658. private _rayToWorld;
  93659. /**
  93660. * Gets if there was a hit
  93661. */
  93662. get hasHit(): boolean;
  93663. /**
  93664. * Gets the distance from the hit
  93665. */
  93666. get hitDistance(): number;
  93667. /**
  93668. * Gets the hit normal/direction in the world
  93669. */
  93670. get hitNormalWorld(): Vector3;
  93671. /**
  93672. * Gets the hit point in the world
  93673. */
  93674. get hitPointWorld(): Vector3;
  93675. /**
  93676. * Gets the ray "start point" of the ray in the world
  93677. */
  93678. get rayFromWorld(): Vector3;
  93679. /**
  93680. * Gets the ray "end point" of the ray in the world
  93681. */
  93682. get rayToWorld(): Vector3;
  93683. /**
  93684. * Sets the hit data (normal & point in world space)
  93685. * @param hitNormalWorld defines the normal in world space
  93686. * @param hitPointWorld defines the point in world space
  93687. */
  93688. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93689. /**
  93690. * Sets the distance from the start point to the hit point
  93691. * @param distance
  93692. */
  93693. setHitDistance(distance: number): void;
  93694. /**
  93695. * Calculates the distance manually
  93696. */
  93697. calculateHitDistance(): void;
  93698. /**
  93699. * Resets all the values to default
  93700. * @param from The from point on world space
  93701. * @param to The to point on world space
  93702. */
  93703. reset(from?: Vector3, to?: Vector3): void;
  93704. }
  93705. /**
  93706. * Interface for the size containing width and height
  93707. */
  93708. interface IXYZ {
  93709. /**
  93710. * X
  93711. */
  93712. x: number;
  93713. /**
  93714. * Y
  93715. */
  93716. y: number;
  93717. /**
  93718. * Z
  93719. */
  93720. z: number;
  93721. }
  93722. }
  93723. declare module BABYLON {
  93724. /**
  93725. * Interface used to describe a physics joint
  93726. */
  93727. export interface PhysicsImpostorJoint {
  93728. /** Defines the main impostor to which the joint is linked */
  93729. mainImpostor: PhysicsImpostor;
  93730. /** Defines the impostor that is connected to the main impostor using this joint */
  93731. connectedImpostor: PhysicsImpostor;
  93732. /** Defines the joint itself */
  93733. joint: PhysicsJoint;
  93734. }
  93735. /** @hidden */
  93736. export interface IPhysicsEnginePlugin {
  93737. world: any;
  93738. name: string;
  93739. setGravity(gravity: Vector3): void;
  93740. setTimeStep(timeStep: number): void;
  93741. getTimeStep(): number;
  93742. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93743. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93744. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93745. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93746. removePhysicsBody(impostor: PhysicsImpostor): void;
  93747. generateJoint(joint: PhysicsImpostorJoint): void;
  93748. removeJoint(joint: PhysicsImpostorJoint): void;
  93749. isSupported(): boolean;
  93750. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93756. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93757. getBodyMass(impostor: PhysicsImpostor): number;
  93758. getBodyFriction(impostor: PhysicsImpostor): number;
  93759. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93760. getBodyRestitution(impostor: PhysicsImpostor): number;
  93761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93762. getBodyPressure?(impostor: PhysicsImpostor): number;
  93763. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93764. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93765. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93766. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93767. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93768. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93769. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93770. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93771. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93772. sleepBody(impostor: PhysicsImpostor): void;
  93773. wakeUpBody(impostor: PhysicsImpostor): void;
  93774. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93775. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93776. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93777. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93778. getRadius(impostor: PhysicsImpostor): number;
  93779. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93780. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93781. dispose(): void;
  93782. }
  93783. /**
  93784. * Interface used to define a physics engine
  93785. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93786. */
  93787. export interface IPhysicsEngine {
  93788. /**
  93789. * Gets the gravity vector used by the simulation
  93790. */
  93791. gravity: Vector3;
  93792. /**
  93793. * Sets the gravity vector used by the simulation
  93794. * @param gravity defines the gravity vector to use
  93795. */
  93796. setGravity(gravity: Vector3): void;
  93797. /**
  93798. * Set the time step of the physics engine.
  93799. * Default is 1/60.
  93800. * To slow it down, enter 1/600 for example.
  93801. * To speed it up, 1/30
  93802. * @param newTimeStep the new timestep to apply to this world.
  93803. */
  93804. setTimeStep(newTimeStep: number): void;
  93805. /**
  93806. * Get the time step of the physics engine.
  93807. * @returns the current time step
  93808. */
  93809. getTimeStep(): number;
  93810. /**
  93811. * Set the sub time step of the physics engine.
  93812. * Default is 0 meaning there is no sub steps
  93813. * To increase physics resolution precision, set a small value (like 1 ms)
  93814. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93815. */
  93816. setSubTimeStep(subTimeStep: number): void;
  93817. /**
  93818. * Get the sub time step of the physics engine.
  93819. * @returns the current sub time step
  93820. */
  93821. getSubTimeStep(): number;
  93822. /**
  93823. * Release all resources
  93824. */
  93825. dispose(): void;
  93826. /**
  93827. * Gets the name of the current physics plugin
  93828. * @returns the name of the plugin
  93829. */
  93830. getPhysicsPluginName(): string;
  93831. /**
  93832. * Adding a new impostor for the impostor tracking.
  93833. * This will be done by the impostor itself.
  93834. * @param impostor the impostor to add
  93835. */
  93836. addImpostor(impostor: PhysicsImpostor): void;
  93837. /**
  93838. * Remove an impostor from the engine.
  93839. * This impostor and its mesh will not longer be updated by the physics engine.
  93840. * @param impostor the impostor to remove
  93841. */
  93842. removeImpostor(impostor: PhysicsImpostor): void;
  93843. /**
  93844. * Add a joint to the physics engine
  93845. * @param mainImpostor defines the main impostor to which the joint is added.
  93846. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93847. * @param joint defines the joint that will connect both impostors.
  93848. */
  93849. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93850. /**
  93851. * Removes a joint from the simulation
  93852. * @param mainImpostor defines the impostor used with the joint
  93853. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93854. * @param joint defines the joint to remove
  93855. */
  93856. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93857. /**
  93858. * Gets the current plugin used to run the simulation
  93859. * @returns current plugin
  93860. */
  93861. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93862. /**
  93863. * Gets the list of physic impostors
  93864. * @returns an array of PhysicsImpostor
  93865. */
  93866. getImpostors(): Array<PhysicsImpostor>;
  93867. /**
  93868. * Gets the impostor for a physics enabled object
  93869. * @param object defines the object impersonated by the impostor
  93870. * @returns the PhysicsImpostor or null if not found
  93871. */
  93872. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93873. /**
  93874. * Gets the impostor for a physics body object
  93875. * @param body defines physics body used by the impostor
  93876. * @returns the PhysicsImpostor or null if not found
  93877. */
  93878. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93879. /**
  93880. * Does a raycast in the physics world
  93881. * @param from when should the ray start?
  93882. * @param to when should the ray end?
  93883. * @returns PhysicsRaycastResult
  93884. */
  93885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93886. /**
  93887. * Called by the scene. No need to call it.
  93888. * @param delta defines the timespam between frames
  93889. */
  93890. _step(delta: number): void;
  93891. }
  93892. }
  93893. declare module BABYLON {
  93894. /**
  93895. * The interface for the physics imposter parameters
  93896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93897. */
  93898. export interface PhysicsImpostorParameters {
  93899. /**
  93900. * The mass of the physics imposter
  93901. */
  93902. mass: number;
  93903. /**
  93904. * The friction of the physics imposter
  93905. */
  93906. friction?: number;
  93907. /**
  93908. * The coefficient of restitution of the physics imposter
  93909. */
  93910. restitution?: number;
  93911. /**
  93912. * The native options of the physics imposter
  93913. */
  93914. nativeOptions?: any;
  93915. /**
  93916. * Specifies if the parent should be ignored
  93917. */
  93918. ignoreParent?: boolean;
  93919. /**
  93920. * Specifies if bi-directional transformations should be disabled
  93921. */
  93922. disableBidirectionalTransformation?: boolean;
  93923. /**
  93924. * The pressure inside the physics imposter, soft object only
  93925. */
  93926. pressure?: number;
  93927. /**
  93928. * The stiffness the physics imposter, soft object only
  93929. */
  93930. stiffness?: number;
  93931. /**
  93932. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  93933. */
  93934. velocityIterations?: number;
  93935. /**
  93936. * The number of iterations used in maintaining consistent vertex positions, soft object only
  93937. */
  93938. positionIterations?: number;
  93939. /**
  93940. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  93941. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  93942. * Add to fix multiple points
  93943. */
  93944. fixedPoints?: number;
  93945. /**
  93946. * The collision margin around a soft object
  93947. */
  93948. margin?: number;
  93949. /**
  93950. * The collision margin around a soft object
  93951. */
  93952. damping?: number;
  93953. /**
  93954. * The path for a rope based on an extrusion
  93955. */
  93956. path?: any;
  93957. /**
  93958. * The shape of an extrusion used for a rope based on an extrusion
  93959. */
  93960. shape?: any;
  93961. }
  93962. /**
  93963. * Interface for a physics-enabled object
  93964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93965. */
  93966. export interface IPhysicsEnabledObject {
  93967. /**
  93968. * The position of the physics-enabled object
  93969. */
  93970. position: Vector3;
  93971. /**
  93972. * The rotation of the physics-enabled object
  93973. */
  93974. rotationQuaternion: Nullable<Quaternion>;
  93975. /**
  93976. * The scale of the physics-enabled object
  93977. */
  93978. scaling: Vector3;
  93979. /**
  93980. * The rotation of the physics-enabled object
  93981. */
  93982. rotation?: Vector3;
  93983. /**
  93984. * The parent of the physics-enabled object
  93985. */
  93986. parent?: any;
  93987. /**
  93988. * The bounding info of the physics-enabled object
  93989. * @returns The bounding info of the physics-enabled object
  93990. */
  93991. getBoundingInfo(): BoundingInfo;
  93992. /**
  93993. * Computes the world matrix
  93994. * @param force Specifies if the world matrix should be computed by force
  93995. * @returns A world matrix
  93996. */
  93997. computeWorldMatrix(force: boolean): Matrix;
  93998. /**
  93999. * Gets the world matrix
  94000. * @returns A world matrix
  94001. */
  94002. getWorldMatrix?(): Matrix;
  94003. /**
  94004. * Gets the child meshes
  94005. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94006. * @returns An array of abstract meshes
  94007. */
  94008. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94009. /**
  94010. * Gets the vertex data
  94011. * @param kind The type of vertex data
  94012. * @returns A nullable array of numbers, or a float32 array
  94013. */
  94014. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94015. /**
  94016. * Gets the indices from the mesh
  94017. * @returns A nullable array of index arrays
  94018. */
  94019. getIndices?(): Nullable<IndicesArray>;
  94020. /**
  94021. * Gets the scene from the mesh
  94022. * @returns the indices array or null
  94023. */
  94024. getScene?(): Scene;
  94025. /**
  94026. * Gets the absolute position from the mesh
  94027. * @returns the absolute position
  94028. */
  94029. getAbsolutePosition(): Vector3;
  94030. /**
  94031. * Gets the absolute pivot point from the mesh
  94032. * @returns the absolute pivot point
  94033. */
  94034. getAbsolutePivotPoint(): Vector3;
  94035. /**
  94036. * Rotates the mesh
  94037. * @param axis The axis of rotation
  94038. * @param amount The amount of rotation
  94039. * @param space The space of the rotation
  94040. * @returns The rotation transform node
  94041. */
  94042. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94043. /**
  94044. * Translates the mesh
  94045. * @param axis The axis of translation
  94046. * @param distance The distance of translation
  94047. * @param space The space of the translation
  94048. * @returns The transform node
  94049. */
  94050. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94051. /**
  94052. * Sets the absolute position of the mesh
  94053. * @param absolutePosition The absolute position of the mesh
  94054. * @returns The transform node
  94055. */
  94056. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94057. /**
  94058. * Gets the class name of the mesh
  94059. * @returns The class name
  94060. */
  94061. getClassName(): string;
  94062. }
  94063. /**
  94064. * Represents a physics imposter
  94065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94066. */
  94067. export class PhysicsImpostor {
  94068. /**
  94069. * The physics-enabled object used as the physics imposter
  94070. */
  94071. object: IPhysicsEnabledObject;
  94072. /**
  94073. * The type of the physics imposter
  94074. */
  94075. type: number;
  94076. private _options;
  94077. private _scene?;
  94078. /**
  94079. * The default object size of the imposter
  94080. */
  94081. static DEFAULT_OBJECT_SIZE: Vector3;
  94082. /**
  94083. * The identity quaternion of the imposter
  94084. */
  94085. static IDENTITY_QUATERNION: Quaternion;
  94086. /** @hidden */
  94087. _pluginData: any;
  94088. private _physicsEngine;
  94089. private _physicsBody;
  94090. private _bodyUpdateRequired;
  94091. private _onBeforePhysicsStepCallbacks;
  94092. private _onAfterPhysicsStepCallbacks;
  94093. /** @hidden */
  94094. _onPhysicsCollideCallbacks: Array<{
  94095. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94096. otherImpostors: Array<PhysicsImpostor>;
  94097. }>;
  94098. private _deltaPosition;
  94099. private _deltaRotation;
  94100. private _deltaRotationConjugated;
  94101. /** @hidden */
  94102. _isFromLine: boolean;
  94103. private _parent;
  94104. private _isDisposed;
  94105. private static _tmpVecs;
  94106. private static _tmpQuat;
  94107. /**
  94108. * Specifies if the physics imposter is disposed
  94109. */
  94110. get isDisposed(): boolean;
  94111. /**
  94112. * Gets the mass of the physics imposter
  94113. */
  94114. get mass(): number;
  94115. set mass(value: number);
  94116. /**
  94117. * Gets the coefficient of friction
  94118. */
  94119. get friction(): number;
  94120. /**
  94121. * Sets the coefficient of friction
  94122. */
  94123. set friction(value: number);
  94124. /**
  94125. * Gets the coefficient of restitution
  94126. */
  94127. get restitution(): number;
  94128. /**
  94129. * Sets the coefficient of restitution
  94130. */
  94131. set restitution(value: number);
  94132. /**
  94133. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94134. */
  94135. get pressure(): number;
  94136. /**
  94137. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94138. */
  94139. set pressure(value: number);
  94140. /**
  94141. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94142. */
  94143. get stiffness(): number;
  94144. /**
  94145. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94146. */
  94147. set stiffness(value: number);
  94148. /**
  94149. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94150. */
  94151. get velocityIterations(): number;
  94152. /**
  94153. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94154. */
  94155. set velocityIterations(value: number);
  94156. /**
  94157. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94158. */
  94159. get positionIterations(): number;
  94160. /**
  94161. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94162. */
  94163. set positionIterations(value: number);
  94164. /**
  94165. * The unique id of the physics imposter
  94166. * set by the physics engine when adding this impostor to the array
  94167. */
  94168. uniqueId: number;
  94169. /**
  94170. * @hidden
  94171. */
  94172. soft: boolean;
  94173. /**
  94174. * @hidden
  94175. */
  94176. segments: number;
  94177. private _joints;
  94178. /**
  94179. * Initializes the physics imposter
  94180. * @param object The physics-enabled object used as the physics imposter
  94181. * @param type The type of the physics imposter
  94182. * @param _options The options for the physics imposter
  94183. * @param _scene The Babylon scene
  94184. */
  94185. constructor(
  94186. /**
  94187. * The physics-enabled object used as the physics imposter
  94188. */
  94189. object: IPhysicsEnabledObject,
  94190. /**
  94191. * The type of the physics imposter
  94192. */
  94193. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94194. /**
  94195. * This function will completly initialize this impostor.
  94196. * It will create a new body - but only if this mesh has no parent.
  94197. * If it has, this impostor will not be used other than to define the impostor
  94198. * of the child mesh.
  94199. * @hidden
  94200. */
  94201. _init(): void;
  94202. private _getPhysicsParent;
  94203. /**
  94204. * Should a new body be generated.
  94205. * @returns boolean specifying if body initialization is required
  94206. */
  94207. isBodyInitRequired(): boolean;
  94208. /**
  94209. * Sets the updated scaling
  94210. * @param updated Specifies if the scaling is updated
  94211. */
  94212. setScalingUpdated(): void;
  94213. /**
  94214. * Force a regeneration of this or the parent's impostor's body.
  94215. * Use under cautious - This will remove all joints already implemented.
  94216. */
  94217. forceUpdate(): void;
  94218. /**
  94219. * Gets the body that holds this impostor. Either its own, or its parent.
  94220. */
  94221. get physicsBody(): any;
  94222. /**
  94223. * Get the parent of the physics imposter
  94224. * @returns Physics imposter or null
  94225. */
  94226. get parent(): Nullable<PhysicsImpostor>;
  94227. /**
  94228. * Sets the parent of the physics imposter
  94229. */
  94230. set parent(value: Nullable<PhysicsImpostor>);
  94231. /**
  94232. * Set the physics body. Used mainly by the physics engine/plugin
  94233. */
  94234. set physicsBody(physicsBody: any);
  94235. /**
  94236. * Resets the update flags
  94237. */
  94238. resetUpdateFlags(): void;
  94239. /**
  94240. * Gets the object extend size
  94241. * @returns the object extend size
  94242. */
  94243. getObjectExtendSize(): Vector3;
  94244. /**
  94245. * Gets the object center
  94246. * @returns The object center
  94247. */
  94248. getObjectCenter(): Vector3;
  94249. /**
  94250. * Get a specific parametes from the options parameter
  94251. * @param paramName The object parameter name
  94252. * @returns The object parameter
  94253. */
  94254. getParam(paramName: string): any;
  94255. /**
  94256. * Sets a specific parameter in the options given to the physics plugin
  94257. * @param paramName The parameter name
  94258. * @param value The value of the parameter
  94259. */
  94260. setParam(paramName: string, value: number): void;
  94261. /**
  94262. * Specifically change the body's mass option. Won't recreate the physics body object
  94263. * @param mass The mass of the physics imposter
  94264. */
  94265. setMass(mass: number): void;
  94266. /**
  94267. * Gets the linear velocity
  94268. * @returns linear velocity or null
  94269. */
  94270. getLinearVelocity(): Nullable<Vector3>;
  94271. /**
  94272. * Sets the linear velocity
  94273. * @param velocity linear velocity or null
  94274. */
  94275. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94276. /**
  94277. * Gets the angular velocity
  94278. * @returns angular velocity or null
  94279. */
  94280. getAngularVelocity(): Nullable<Vector3>;
  94281. /**
  94282. * Sets the angular velocity
  94283. * @param velocity The velocity or null
  94284. */
  94285. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94286. /**
  94287. * Execute a function with the physics plugin native code
  94288. * Provide a function the will have two variables - the world object and the physics body object
  94289. * @param func The function to execute with the physics plugin native code
  94290. */
  94291. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94292. /**
  94293. * Register a function that will be executed before the physics world is stepping forward
  94294. * @param func The function to execute before the physics world is stepped forward
  94295. */
  94296. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94297. /**
  94298. * Unregister a function that will be executed before the physics world is stepping forward
  94299. * @param func The function to execute before the physics world is stepped forward
  94300. */
  94301. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94302. /**
  94303. * Register a function that will be executed after the physics step
  94304. * @param func The function to execute after physics step
  94305. */
  94306. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94307. /**
  94308. * Unregisters a function that will be executed after the physics step
  94309. * @param func The function to execute after physics step
  94310. */
  94311. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94312. /**
  94313. * register a function that will be executed when this impostor collides against a different body
  94314. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94315. * @param func Callback that is executed on collision
  94316. */
  94317. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94318. /**
  94319. * Unregisters the physics imposter on contact
  94320. * @param collideAgainst The physics object to collide against
  94321. * @param func Callback to execute on collision
  94322. */
  94323. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94324. private _tmpQuat;
  94325. private _tmpQuat2;
  94326. /**
  94327. * Get the parent rotation
  94328. * @returns The parent rotation
  94329. */
  94330. getParentsRotation(): Quaternion;
  94331. /**
  94332. * this function is executed by the physics engine.
  94333. */
  94334. beforeStep: () => void;
  94335. /**
  94336. * this function is executed by the physics engine
  94337. */
  94338. afterStep: () => void;
  94339. /**
  94340. * Legacy collision detection event support
  94341. */
  94342. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94343. /**
  94344. * event and body object due to cannon's event-based architecture.
  94345. */
  94346. onCollide: (e: {
  94347. body: any;
  94348. }) => void;
  94349. /**
  94350. * Apply a force
  94351. * @param force The force to apply
  94352. * @param contactPoint The contact point for the force
  94353. * @returns The physics imposter
  94354. */
  94355. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94356. /**
  94357. * Apply an impulse
  94358. * @param force The impulse force
  94359. * @param contactPoint The contact point for the impulse force
  94360. * @returns The physics imposter
  94361. */
  94362. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94363. /**
  94364. * A help function to create a joint
  94365. * @param otherImpostor A physics imposter used to create a joint
  94366. * @param jointType The type of joint
  94367. * @param jointData The data for the joint
  94368. * @returns The physics imposter
  94369. */
  94370. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94371. /**
  94372. * Add a joint to this impostor with a different impostor
  94373. * @param otherImpostor A physics imposter used to add a joint
  94374. * @param joint The joint to add
  94375. * @returns The physics imposter
  94376. */
  94377. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94378. /**
  94379. * Add an anchor to a cloth impostor
  94380. * @param otherImpostor rigid impostor to anchor to
  94381. * @param width ratio across width from 0 to 1
  94382. * @param height ratio up height from 0 to 1
  94383. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94384. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94385. * @returns impostor the soft imposter
  94386. */
  94387. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94388. /**
  94389. * Add a hook to a rope impostor
  94390. * @param otherImpostor rigid impostor to anchor to
  94391. * @param length ratio across rope from 0 to 1
  94392. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94393. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94394. * @returns impostor the rope imposter
  94395. */
  94396. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94397. /**
  94398. * Will keep this body still, in a sleep mode.
  94399. * @returns the physics imposter
  94400. */
  94401. sleep(): PhysicsImpostor;
  94402. /**
  94403. * Wake the body up.
  94404. * @returns The physics imposter
  94405. */
  94406. wakeUp(): PhysicsImpostor;
  94407. /**
  94408. * Clones the physics imposter
  94409. * @param newObject The physics imposter clones to this physics-enabled object
  94410. * @returns A nullable physics imposter
  94411. */
  94412. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94413. /**
  94414. * Disposes the physics imposter
  94415. */
  94416. dispose(): void;
  94417. /**
  94418. * Sets the delta position
  94419. * @param position The delta position amount
  94420. */
  94421. setDeltaPosition(position: Vector3): void;
  94422. /**
  94423. * Sets the delta rotation
  94424. * @param rotation The delta rotation amount
  94425. */
  94426. setDeltaRotation(rotation: Quaternion): void;
  94427. /**
  94428. * Gets the box size of the physics imposter and stores the result in the input parameter
  94429. * @param result Stores the box size
  94430. * @returns The physics imposter
  94431. */
  94432. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94433. /**
  94434. * Gets the radius of the physics imposter
  94435. * @returns Radius of the physics imposter
  94436. */
  94437. getRadius(): number;
  94438. /**
  94439. * Sync a bone with this impostor
  94440. * @param bone The bone to sync to the impostor.
  94441. * @param boneMesh The mesh that the bone is influencing.
  94442. * @param jointPivot The pivot of the joint / bone in local space.
  94443. * @param distToJoint Optional distance from the impostor to the joint.
  94444. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94445. */
  94446. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94447. /**
  94448. * Sync impostor to a bone
  94449. * @param bone The bone that the impostor will be synced to.
  94450. * @param boneMesh The mesh that the bone is influencing.
  94451. * @param jointPivot The pivot of the joint / bone in local space.
  94452. * @param distToJoint Optional distance from the impostor to the joint.
  94453. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94454. * @param boneAxis Optional vector3 axis the bone is aligned with
  94455. */
  94456. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94457. /**
  94458. * No-Imposter type
  94459. */
  94460. static NoImpostor: number;
  94461. /**
  94462. * Sphere-Imposter type
  94463. */
  94464. static SphereImpostor: number;
  94465. /**
  94466. * Box-Imposter type
  94467. */
  94468. static BoxImpostor: number;
  94469. /**
  94470. * Plane-Imposter type
  94471. */
  94472. static PlaneImpostor: number;
  94473. /**
  94474. * Mesh-imposter type
  94475. */
  94476. static MeshImpostor: number;
  94477. /**
  94478. * Capsule-Impostor type (Ammo.js plugin only)
  94479. */
  94480. static CapsuleImpostor: number;
  94481. /**
  94482. * Cylinder-Imposter type
  94483. */
  94484. static CylinderImpostor: number;
  94485. /**
  94486. * Particle-Imposter type
  94487. */
  94488. static ParticleImpostor: number;
  94489. /**
  94490. * Heightmap-Imposter type
  94491. */
  94492. static HeightmapImpostor: number;
  94493. /**
  94494. * ConvexHull-Impostor type (Ammo.js plugin only)
  94495. */
  94496. static ConvexHullImpostor: number;
  94497. /**
  94498. * Custom-Imposter type (Ammo.js plugin only)
  94499. */
  94500. static CustomImpostor: number;
  94501. /**
  94502. * Rope-Imposter type
  94503. */
  94504. static RopeImpostor: number;
  94505. /**
  94506. * Cloth-Imposter type
  94507. */
  94508. static ClothImpostor: number;
  94509. /**
  94510. * Softbody-Imposter type
  94511. */
  94512. static SoftbodyImpostor: number;
  94513. }
  94514. }
  94515. declare module BABYLON {
  94516. /**
  94517. * @hidden
  94518. **/
  94519. export class _CreationDataStorage {
  94520. closePath?: boolean;
  94521. closeArray?: boolean;
  94522. idx: number[];
  94523. dashSize: number;
  94524. gapSize: number;
  94525. path3D: Path3D;
  94526. pathArray: Vector3[][];
  94527. arc: number;
  94528. radius: number;
  94529. cap: number;
  94530. tessellation: number;
  94531. }
  94532. /**
  94533. * @hidden
  94534. **/
  94535. class _InstanceDataStorage {
  94536. visibleInstances: any;
  94537. batchCache: _InstancesBatch;
  94538. instancesBufferSize: number;
  94539. instancesBuffer: Nullable<Buffer>;
  94540. instancesData: Float32Array;
  94541. overridenInstanceCount: number;
  94542. isFrozen: boolean;
  94543. previousBatch: Nullable<_InstancesBatch>;
  94544. hardwareInstancedRendering: boolean;
  94545. sideOrientation: number;
  94546. manualUpdate: boolean;
  94547. }
  94548. /**
  94549. * @hidden
  94550. **/
  94551. export class _InstancesBatch {
  94552. mustReturn: boolean;
  94553. visibleInstances: Nullable<InstancedMesh[]>[];
  94554. renderSelf: boolean[];
  94555. hardwareInstancedRendering: boolean[];
  94556. }
  94557. /**
  94558. * Class used to represent renderable models
  94559. */
  94560. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94561. /**
  94562. * Mesh side orientation : usually the external or front surface
  94563. */
  94564. static readonly FRONTSIDE: number;
  94565. /**
  94566. * Mesh side orientation : usually the internal or back surface
  94567. */
  94568. static readonly BACKSIDE: number;
  94569. /**
  94570. * Mesh side orientation : both internal and external or front and back surfaces
  94571. */
  94572. static readonly DOUBLESIDE: number;
  94573. /**
  94574. * Mesh side orientation : by default, `FRONTSIDE`
  94575. */
  94576. static readonly DEFAULTSIDE: number;
  94577. /**
  94578. * Mesh cap setting : no cap
  94579. */
  94580. static readonly NO_CAP: number;
  94581. /**
  94582. * Mesh cap setting : one cap at the beginning of the mesh
  94583. */
  94584. static readonly CAP_START: number;
  94585. /**
  94586. * Mesh cap setting : one cap at the end of the mesh
  94587. */
  94588. static readonly CAP_END: number;
  94589. /**
  94590. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94591. */
  94592. static readonly CAP_ALL: number;
  94593. /**
  94594. * Mesh pattern setting : no flip or rotate
  94595. */
  94596. static readonly NO_FLIP: number;
  94597. /**
  94598. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94599. */
  94600. static readonly FLIP_TILE: number;
  94601. /**
  94602. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94603. */
  94604. static readonly ROTATE_TILE: number;
  94605. /**
  94606. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94607. */
  94608. static readonly FLIP_ROW: number;
  94609. /**
  94610. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94611. */
  94612. static readonly ROTATE_ROW: number;
  94613. /**
  94614. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94615. */
  94616. static readonly FLIP_N_ROTATE_TILE: number;
  94617. /**
  94618. * Mesh pattern setting : rotate pattern and rotate
  94619. */
  94620. static readonly FLIP_N_ROTATE_ROW: number;
  94621. /**
  94622. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94623. */
  94624. static readonly CENTER: number;
  94625. /**
  94626. * Mesh tile positioning : part tiles on left
  94627. */
  94628. static readonly LEFT: number;
  94629. /**
  94630. * Mesh tile positioning : part tiles on right
  94631. */
  94632. static readonly RIGHT: number;
  94633. /**
  94634. * Mesh tile positioning : part tiles on top
  94635. */
  94636. static readonly TOP: number;
  94637. /**
  94638. * Mesh tile positioning : part tiles on bottom
  94639. */
  94640. static readonly BOTTOM: number;
  94641. /**
  94642. * Gets the default side orientation.
  94643. * @param orientation the orientation to value to attempt to get
  94644. * @returns the default orientation
  94645. * @hidden
  94646. */
  94647. static _GetDefaultSideOrientation(orientation?: number): number;
  94648. private _internalMeshDataInfo;
  94649. /**
  94650. * An event triggered before rendering the mesh
  94651. */
  94652. get onBeforeRenderObservable(): Observable<Mesh>;
  94653. /**
  94654. * An event triggered before binding the mesh
  94655. */
  94656. get onBeforeBindObservable(): Observable<Mesh>;
  94657. /**
  94658. * An event triggered after rendering the mesh
  94659. */
  94660. get onAfterRenderObservable(): Observable<Mesh>;
  94661. /**
  94662. * An event triggered before drawing the mesh
  94663. */
  94664. get onBeforeDrawObservable(): Observable<Mesh>;
  94665. private _onBeforeDrawObserver;
  94666. /**
  94667. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94668. */
  94669. set onBeforeDraw(callback: () => void);
  94670. get hasInstances(): boolean;
  94671. /**
  94672. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94673. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94674. */
  94675. delayLoadState: number;
  94676. /**
  94677. * Gets the list of instances created from this mesh
  94678. * it is not supposed to be modified manually.
  94679. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94680. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94681. */
  94682. instances: InstancedMesh[];
  94683. /**
  94684. * Gets the file containing delay loading data for this mesh
  94685. */
  94686. delayLoadingFile: string;
  94687. /** @hidden */
  94688. _binaryInfo: any;
  94689. /**
  94690. * User defined function used to change how LOD level selection is done
  94691. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94692. */
  94693. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94694. /**
  94695. * Gets or sets the morph target manager
  94696. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94697. */
  94698. get morphTargetManager(): Nullable<MorphTargetManager>;
  94699. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94700. /** @hidden */
  94701. _creationDataStorage: Nullable<_CreationDataStorage>;
  94702. /** @hidden */
  94703. _geometry: Nullable<Geometry>;
  94704. /** @hidden */
  94705. _delayInfo: Array<string>;
  94706. /** @hidden */
  94707. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94708. /** @hidden */
  94709. _instanceDataStorage: _InstanceDataStorage;
  94710. private _effectiveMaterial;
  94711. /** @hidden */
  94712. _shouldGenerateFlatShading: boolean;
  94713. /** @hidden */
  94714. _originalBuilderSideOrientation: number;
  94715. /**
  94716. * Use this property to change the original side orientation defined at construction time
  94717. */
  94718. overrideMaterialSideOrientation: Nullable<number>;
  94719. /**
  94720. * Gets the source mesh (the one used to clone this one from)
  94721. */
  94722. get source(): Nullable<Mesh>;
  94723. /**
  94724. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94725. */
  94726. get isUnIndexed(): boolean;
  94727. set isUnIndexed(value: boolean);
  94728. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94729. get worldMatrixInstancedBuffer(): Float32Array;
  94730. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94731. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94732. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94733. /**
  94734. * @constructor
  94735. * @param name The value used by scene.getMeshByName() to do a lookup.
  94736. * @param scene The scene to add this mesh to.
  94737. * @param parent The parent of this mesh, if it has one
  94738. * @param source An optional Mesh from which geometry is shared, cloned.
  94739. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94740. * When false, achieved by calling a clone(), also passing False.
  94741. * This will make creation of children, recursive.
  94742. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94743. */
  94744. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94745. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94746. doNotInstantiate: boolean;
  94747. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94748. /**
  94749. * Gets the class name
  94750. * @returns the string "Mesh".
  94751. */
  94752. getClassName(): string;
  94753. /** @hidden */
  94754. get _isMesh(): boolean;
  94755. /**
  94756. * Returns a description of this mesh
  94757. * @param fullDetails define if full details about this mesh must be used
  94758. * @returns a descriptive string representing this mesh
  94759. */
  94760. toString(fullDetails?: boolean): string;
  94761. /** @hidden */
  94762. _unBindEffect(): void;
  94763. /**
  94764. * Gets a boolean indicating if this mesh has LOD
  94765. */
  94766. get hasLODLevels(): boolean;
  94767. /**
  94768. * Gets the list of MeshLODLevel associated with the current mesh
  94769. * @returns an array of MeshLODLevel
  94770. */
  94771. getLODLevels(): MeshLODLevel[];
  94772. private _sortLODLevels;
  94773. /**
  94774. * Add a mesh as LOD level triggered at the given distance.
  94775. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94776. * @param distance The distance from the center of the object to show this level
  94777. * @param mesh The mesh to be added as LOD level (can be null)
  94778. * @return This mesh (for chaining)
  94779. */
  94780. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94781. /**
  94782. * Returns the LOD level mesh at the passed distance or null if not found.
  94783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94784. * @param distance The distance from the center of the object to show this level
  94785. * @returns a Mesh or `null`
  94786. */
  94787. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94788. /**
  94789. * Remove a mesh from the LOD array
  94790. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94791. * @param mesh defines the mesh to be removed
  94792. * @return This mesh (for chaining)
  94793. */
  94794. removeLODLevel(mesh: Mesh): Mesh;
  94795. /**
  94796. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94797. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94798. * @param camera defines the camera to use to compute distance
  94799. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94800. * @return This mesh (for chaining)
  94801. */
  94802. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94803. /**
  94804. * Gets the mesh internal Geometry object
  94805. */
  94806. get geometry(): Nullable<Geometry>;
  94807. /**
  94808. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94809. * @returns the total number of vertices
  94810. */
  94811. getTotalVertices(): number;
  94812. /**
  94813. * Returns the content of an associated vertex buffer
  94814. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94815. * - VertexBuffer.PositionKind
  94816. * - VertexBuffer.UVKind
  94817. * - VertexBuffer.UV2Kind
  94818. * - VertexBuffer.UV3Kind
  94819. * - VertexBuffer.UV4Kind
  94820. * - VertexBuffer.UV5Kind
  94821. * - VertexBuffer.UV6Kind
  94822. * - VertexBuffer.ColorKind
  94823. * - VertexBuffer.MatricesIndicesKind
  94824. * - VertexBuffer.MatricesIndicesExtraKind
  94825. * - VertexBuffer.MatricesWeightsKind
  94826. * - VertexBuffer.MatricesWeightsExtraKind
  94827. * @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
  94828. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94829. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94830. */
  94831. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94832. /**
  94833. * Returns the mesh VertexBuffer object from the requested `kind`
  94834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94835. * - VertexBuffer.PositionKind
  94836. * - VertexBuffer.NormalKind
  94837. * - VertexBuffer.UVKind
  94838. * - VertexBuffer.UV2Kind
  94839. * - VertexBuffer.UV3Kind
  94840. * - VertexBuffer.UV4Kind
  94841. * - VertexBuffer.UV5Kind
  94842. * - VertexBuffer.UV6Kind
  94843. * - VertexBuffer.ColorKind
  94844. * - VertexBuffer.MatricesIndicesKind
  94845. * - VertexBuffer.MatricesIndicesExtraKind
  94846. * - VertexBuffer.MatricesWeightsKind
  94847. * - VertexBuffer.MatricesWeightsExtraKind
  94848. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94849. */
  94850. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94851. /**
  94852. * Tests if a specific vertex buffer is associated with this mesh
  94853. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94854. * - VertexBuffer.PositionKind
  94855. * - VertexBuffer.NormalKind
  94856. * - VertexBuffer.UVKind
  94857. * - VertexBuffer.UV2Kind
  94858. * - VertexBuffer.UV3Kind
  94859. * - VertexBuffer.UV4Kind
  94860. * - VertexBuffer.UV5Kind
  94861. * - VertexBuffer.UV6Kind
  94862. * - VertexBuffer.ColorKind
  94863. * - VertexBuffer.MatricesIndicesKind
  94864. * - VertexBuffer.MatricesIndicesExtraKind
  94865. * - VertexBuffer.MatricesWeightsKind
  94866. * - VertexBuffer.MatricesWeightsExtraKind
  94867. * @returns a boolean
  94868. */
  94869. isVerticesDataPresent(kind: string): boolean;
  94870. /**
  94871. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94872. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94873. * - VertexBuffer.PositionKind
  94874. * - VertexBuffer.UVKind
  94875. * - VertexBuffer.UV2Kind
  94876. * - VertexBuffer.UV3Kind
  94877. * - VertexBuffer.UV4Kind
  94878. * - VertexBuffer.UV5Kind
  94879. * - VertexBuffer.UV6Kind
  94880. * - VertexBuffer.ColorKind
  94881. * - VertexBuffer.MatricesIndicesKind
  94882. * - VertexBuffer.MatricesIndicesExtraKind
  94883. * - VertexBuffer.MatricesWeightsKind
  94884. * - VertexBuffer.MatricesWeightsExtraKind
  94885. * @returns a boolean
  94886. */
  94887. isVertexBufferUpdatable(kind: string): boolean;
  94888. /**
  94889. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94890. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94891. * - VertexBuffer.PositionKind
  94892. * - VertexBuffer.NormalKind
  94893. * - VertexBuffer.UVKind
  94894. * - VertexBuffer.UV2Kind
  94895. * - VertexBuffer.UV3Kind
  94896. * - VertexBuffer.UV4Kind
  94897. * - VertexBuffer.UV5Kind
  94898. * - VertexBuffer.UV6Kind
  94899. * - VertexBuffer.ColorKind
  94900. * - VertexBuffer.MatricesIndicesKind
  94901. * - VertexBuffer.MatricesIndicesExtraKind
  94902. * - VertexBuffer.MatricesWeightsKind
  94903. * - VertexBuffer.MatricesWeightsExtraKind
  94904. * @returns an array of strings
  94905. */
  94906. getVerticesDataKinds(): string[];
  94907. /**
  94908. * Returns a positive integer : the total number of indices in this mesh geometry.
  94909. * @returns the numner of indices or zero if the mesh has no geometry.
  94910. */
  94911. getTotalIndices(): number;
  94912. /**
  94913. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94914. * @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.
  94915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94916. * @returns the indices array or an empty array if the mesh has no geometry
  94917. */
  94918. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94919. get isBlocked(): boolean;
  94920. /**
  94921. * Determine if the current mesh is ready to be rendered
  94922. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94923. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  94924. * @returns true if all associated assets are ready (material, textures, shaders)
  94925. */
  94926. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  94927. /**
  94928. * 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.
  94929. */
  94930. get areNormalsFrozen(): boolean;
  94931. /**
  94932. * 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.
  94933. * @returns the current mesh
  94934. */
  94935. freezeNormals(): Mesh;
  94936. /**
  94937. * 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
  94938. * @returns the current mesh
  94939. */
  94940. unfreezeNormals(): Mesh;
  94941. /**
  94942. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  94943. */
  94944. set overridenInstanceCount(count: number);
  94945. /** @hidden */
  94946. _preActivate(): Mesh;
  94947. /** @hidden */
  94948. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94949. /** @hidden */
  94950. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  94951. /**
  94952. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94953. * This means the mesh underlying bounding box and sphere are recomputed.
  94954. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94955. * @returns the current mesh
  94956. */
  94957. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  94958. /** @hidden */
  94959. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  94960. /**
  94961. * This function will subdivide the mesh into multiple submeshes
  94962. * @param count defines the expected number of submeshes
  94963. */
  94964. subdivide(count: number): void;
  94965. /**
  94966. * Copy a FloatArray into a specific associated vertex buffer
  94967. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94968. * - VertexBuffer.PositionKind
  94969. * - VertexBuffer.UVKind
  94970. * - VertexBuffer.UV2Kind
  94971. * - VertexBuffer.UV3Kind
  94972. * - VertexBuffer.UV4Kind
  94973. * - VertexBuffer.UV5Kind
  94974. * - VertexBuffer.UV6Kind
  94975. * - VertexBuffer.ColorKind
  94976. * - VertexBuffer.MatricesIndicesKind
  94977. * - VertexBuffer.MatricesIndicesExtraKind
  94978. * - VertexBuffer.MatricesWeightsKind
  94979. * - VertexBuffer.MatricesWeightsExtraKind
  94980. * @param data defines the data source
  94981. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  94982. * @param stride defines the data stride size (can be null)
  94983. * @returns the current mesh
  94984. */
  94985. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94986. /**
  94987. * Delete a vertex buffer associated with this mesh
  94988. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  94989. * - VertexBuffer.PositionKind
  94990. * - VertexBuffer.UVKind
  94991. * - VertexBuffer.UV2Kind
  94992. * - VertexBuffer.UV3Kind
  94993. * - VertexBuffer.UV4Kind
  94994. * - VertexBuffer.UV5Kind
  94995. * - VertexBuffer.UV6Kind
  94996. * - VertexBuffer.ColorKind
  94997. * - VertexBuffer.MatricesIndicesKind
  94998. * - VertexBuffer.MatricesIndicesExtraKind
  94999. * - VertexBuffer.MatricesWeightsKind
  95000. * - VertexBuffer.MatricesWeightsExtraKind
  95001. */
  95002. removeVerticesData(kind: string): void;
  95003. /**
  95004. * Flags an associated vertex buffer as updatable
  95005. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95006. * - VertexBuffer.PositionKind
  95007. * - VertexBuffer.UVKind
  95008. * - VertexBuffer.UV2Kind
  95009. * - VertexBuffer.UV3Kind
  95010. * - VertexBuffer.UV4Kind
  95011. * - VertexBuffer.UV5Kind
  95012. * - VertexBuffer.UV6Kind
  95013. * - VertexBuffer.ColorKind
  95014. * - VertexBuffer.MatricesIndicesKind
  95015. * - VertexBuffer.MatricesIndicesExtraKind
  95016. * - VertexBuffer.MatricesWeightsKind
  95017. * - VertexBuffer.MatricesWeightsExtraKind
  95018. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95019. */
  95020. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95021. /**
  95022. * Sets the mesh global Vertex Buffer
  95023. * @param buffer defines the buffer to use
  95024. * @returns the current mesh
  95025. */
  95026. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95027. /**
  95028. * Update a specific associated vertex buffer
  95029. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95030. * - VertexBuffer.PositionKind
  95031. * - VertexBuffer.UVKind
  95032. * - VertexBuffer.UV2Kind
  95033. * - VertexBuffer.UV3Kind
  95034. * - VertexBuffer.UV4Kind
  95035. * - VertexBuffer.UV5Kind
  95036. * - VertexBuffer.UV6Kind
  95037. * - VertexBuffer.ColorKind
  95038. * - VertexBuffer.MatricesIndicesKind
  95039. * - VertexBuffer.MatricesIndicesExtraKind
  95040. * - VertexBuffer.MatricesWeightsKind
  95041. * - VertexBuffer.MatricesWeightsExtraKind
  95042. * @param data defines the data source
  95043. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95044. * @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)
  95045. * @returns the current mesh
  95046. */
  95047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95048. /**
  95049. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95050. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95051. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95052. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95053. * @returns the current mesh
  95054. */
  95055. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95056. /**
  95057. * Creates a un-shared specific occurence of the geometry for the mesh.
  95058. * @returns the current mesh
  95059. */
  95060. makeGeometryUnique(): Mesh;
  95061. /**
  95062. * Set the index buffer of this mesh
  95063. * @param indices defines the source data
  95064. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95065. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95066. * @returns the current mesh
  95067. */
  95068. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95069. /**
  95070. * Update the current index buffer
  95071. * @param indices defines the source data
  95072. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95073. * @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)
  95074. * @returns the current mesh
  95075. */
  95076. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95077. /**
  95078. * Invert the geometry to move from a right handed system to a left handed one.
  95079. * @returns the current mesh
  95080. */
  95081. toLeftHanded(): Mesh;
  95082. /** @hidden */
  95083. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95084. /** @hidden */
  95085. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95086. /**
  95087. * Registers for this mesh a javascript function called just before the rendering process
  95088. * @param func defines the function to call before rendering this mesh
  95089. * @returns the current mesh
  95090. */
  95091. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95092. /**
  95093. * Disposes a previously registered javascript function called before the rendering
  95094. * @param func defines the function to remove
  95095. * @returns the current mesh
  95096. */
  95097. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95098. /**
  95099. * Registers for this mesh a javascript function called just after the rendering is complete
  95100. * @param func defines the function to call after rendering this mesh
  95101. * @returns the current mesh
  95102. */
  95103. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95104. /**
  95105. * Disposes a previously registered javascript function called after the rendering.
  95106. * @param func defines the function to remove
  95107. * @returns the current mesh
  95108. */
  95109. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95110. /** @hidden */
  95111. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95112. /** @hidden */
  95113. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95114. /** @hidden */
  95115. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95116. /** @hidden */
  95117. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95118. /** @hidden */
  95119. _rebuild(): void;
  95120. /** @hidden */
  95121. _freeze(): void;
  95122. /** @hidden */
  95123. _unFreeze(): void;
  95124. /**
  95125. * 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
  95126. * @param subMesh defines the subMesh to render
  95127. * @param enableAlphaMode defines if alpha mode can be changed
  95128. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95129. * @returns the current mesh
  95130. */
  95131. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95132. private _onBeforeDraw;
  95133. /**
  95134. * Renormalize the mesh and patch it up if there are no weights
  95135. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95136. * However in the case of zero weights then we set just a single influence to 1.
  95137. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95138. */
  95139. cleanMatrixWeights(): void;
  95140. private normalizeSkinFourWeights;
  95141. private normalizeSkinWeightsAndExtra;
  95142. /**
  95143. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95144. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95145. * the user know there was an issue with importing the mesh
  95146. * @returns a validation object with skinned, valid and report string
  95147. */
  95148. validateSkinning(): {
  95149. skinned: boolean;
  95150. valid: boolean;
  95151. report: string;
  95152. };
  95153. /** @hidden */
  95154. _checkDelayState(): Mesh;
  95155. private _queueLoad;
  95156. /**
  95157. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95158. * A mesh is in the frustum if its bounding box intersects the frustum
  95159. * @param frustumPlanes defines the frustum to test
  95160. * @returns true if the mesh is in the frustum planes
  95161. */
  95162. isInFrustum(frustumPlanes: Plane[]): boolean;
  95163. /**
  95164. * Sets the mesh material by the material or multiMaterial `id` property
  95165. * @param id is a string identifying the material or the multiMaterial
  95166. * @returns the current mesh
  95167. */
  95168. setMaterialByID(id: string): Mesh;
  95169. /**
  95170. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95171. * @returns an array of IAnimatable
  95172. */
  95173. getAnimatables(): IAnimatable[];
  95174. /**
  95175. * Modifies the mesh geometry according to the passed transformation matrix.
  95176. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95177. * The mesh normals are modified using the same transformation.
  95178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95179. * @param transform defines the transform matrix to use
  95180. * @see http://doc.babylonjs.com/resources/baking_transformations
  95181. * @returns the current mesh
  95182. */
  95183. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95184. /**
  95185. * Modifies the mesh geometry according to its own current World Matrix.
  95186. * The mesh World Matrix is then reset.
  95187. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95188. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95189. * @see http://doc.babylonjs.com/resources/baking_transformations
  95190. * @returns the current mesh
  95191. */
  95192. bakeCurrentTransformIntoVertices(): Mesh;
  95193. /** @hidden */
  95194. get _positions(): Nullable<Vector3[]>;
  95195. /** @hidden */
  95196. _resetPointsArrayCache(): Mesh;
  95197. /** @hidden */
  95198. _generatePointsArray(): boolean;
  95199. /**
  95200. * Returns a new Mesh object generated from the current mesh properties.
  95201. * This method must not get confused with createInstance()
  95202. * @param name is a string, the name given to the new mesh
  95203. * @param newParent can be any Node object (default `null`)
  95204. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95205. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95206. * @returns a new mesh
  95207. */
  95208. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95209. /**
  95210. * Releases resources associated with this mesh.
  95211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95213. */
  95214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95215. /** @hidden */
  95216. _disposeInstanceSpecificData(): void;
  95217. /**
  95218. * Modifies the mesh geometry according to a displacement map.
  95219. * 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.
  95220. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95221. * @param url is a string, the URL from the image file is to be downloaded.
  95222. * @param minHeight is the lower limit of the displacement.
  95223. * @param maxHeight is the upper limit of the displacement.
  95224. * @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.
  95225. * @param uvOffset is an optional vector2 used to offset UV.
  95226. * @param uvScale is an optional vector2 used to scale UV.
  95227. * @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.
  95228. * @returns the Mesh.
  95229. */
  95230. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95231. /**
  95232. * Modifies the mesh geometry according to a displacementMap buffer.
  95233. * 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.
  95234. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95235. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95236. * @param heightMapWidth is the width of the buffer image.
  95237. * @param heightMapHeight is the height of the buffer image.
  95238. * @param minHeight is the lower limit of the displacement.
  95239. * @param maxHeight is the upper limit of the displacement.
  95240. * @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.
  95241. * @param uvOffset is an optional vector2 used to offset UV.
  95242. * @param uvScale is an optional vector2 used to scale UV.
  95243. * @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.
  95244. * @returns the Mesh.
  95245. */
  95246. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95247. /**
  95248. * Modify the mesh to get a flat shading rendering.
  95249. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95250. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95251. * @returns current mesh
  95252. */
  95253. convertToFlatShadedMesh(): Mesh;
  95254. /**
  95255. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95256. * In other words, more vertices, no more indices and a single bigger VBO.
  95257. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95258. * @returns current mesh
  95259. */
  95260. convertToUnIndexedMesh(): Mesh;
  95261. /**
  95262. * Inverses facet orientations.
  95263. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95264. * @param flipNormals will also inverts the normals
  95265. * @returns current mesh
  95266. */
  95267. flipFaces(flipNormals?: boolean): Mesh;
  95268. /**
  95269. * Increase the number of facets and hence vertices in a mesh
  95270. * Vertex normals are interpolated from existing vertex normals
  95271. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95272. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95273. */
  95274. increaseVertices(numberPerEdge: number): void;
  95275. /**
  95276. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95277. * This will undo any application of covertToFlatShadedMesh
  95278. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95279. */
  95280. forceSharedVertices(): void;
  95281. /** @hidden */
  95282. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95283. /** @hidden */
  95284. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95285. /**
  95286. * Creates a new InstancedMesh object from the mesh model.
  95287. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95288. * @param name defines the name of the new instance
  95289. * @returns a new InstancedMesh
  95290. */
  95291. createInstance(name: string): InstancedMesh;
  95292. /**
  95293. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95294. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95295. * @returns the current mesh
  95296. */
  95297. synchronizeInstances(): Mesh;
  95298. /**
  95299. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95300. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95301. * This should be used together with the simplification to avoid disappearing triangles.
  95302. * @param successCallback an optional success callback to be called after the optimization finished.
  95303. * @returns the current mesh
  95304. */
  95305. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95306. /**
  95307. * Serialize current mesh
  95308. * @param serializationObject defines the object which will receive the serialization data
  95309. */
  95310. serialize(serializationObject: any): void;
  95311. /** @hidden */
  95312. _syncGeometryWithMorphTargetManager(): void;
  95313. /** @hidden */
  95314. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95315. /**
  95316. * Returns a new Mesh object parsed from the source provided.
  95317. * @param parsedMesh is the source
  95318. * @param scene defines the hosting scene
  95319. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95320. * @returns a new Mesh
  95321. */
  95322. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95323. /**
  95324. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95325. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95326. * @param name defines the name of the mesh to create
  95327. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95328. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95329. * @param closePath creates a seam between the first and the last points of each path of the path array
  95330. * @param offset is taken in account only if the `pathArray` is containing a single path
  95331. * @param scene defines the hosting scene
  95332. * @param updatable defines if the mesh must be flagged as updatable
  95333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95334. * @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)
  95335. * @returns a new Mesh
  95336. */
  95337. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95338. /**
  95339. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95340. * @param name defines the name of the mesh to create
  95341. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95342. * @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
  95343. * @param scene defines the hosting scene
  95344. * @param updatable defines if the mesh must be flagged as updatable
  95345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95346. * @returns a new Mesh
  95347. */
  95348. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95349. /**
  95350. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95351. * @param name defines the name of the mesh to create
  95352. * @param size sets the size (float) of each box side (default 1)
  95353. * @param scene defines the hosting scene
  95354. * @param updatable defines if the mesh must be flagged as updatable
  95355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95356. * @returns a new Mesh
  95357. */
  95358. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95359. /**
  95360. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95361. * @param name defines the name of the mesh to create
  95362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95364. * @param scene defines the hosting scene
  95365. * @param updatable defines if the mesh must be flagged as updatable
  95366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95367. * @returns a new Mesh
  95368. */
  95369. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95370. /**
  95371. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95372. * @param name defines the name of the mesh to create
  95373. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95374. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95375. * @param scene defines the hosting scene
  95376. * @returns a new Mesh
  95377. */
  95378. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95379. /**
  95380. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95381. * @param name defines the name of the mesh to create
  95382. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95383. * @param diameterTop set the top cap diameter (floats, default 1)
  95384. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95385. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95386. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95387. * @param scene defines the hosting scene
  95388. * @param updatable defines if the mesh must be flagged as updatable
  95389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95390. * @returns a new Mesh
  95391. */
  95392. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95393. /**
  95394. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95395. * @param name defines the name of the mesh to create
  95396. * @param diameter sets the diameter size (float) of the torus (default 1)
  95397. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95398. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95399. * @param scene defines the hosting scene
  95400. * @param updatable defines if the mesh must be flagged as updatable
  95401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95402. * @returns a new Mesh
  95403. */
  95404. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95405. /**
  95406. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95407. * @param name defines the name of the mesh to create
  95408. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95409. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95410. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95411. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95412. * @param p the number of windings on X axis (positive integers, default 2)
  95413. * @param q the number of windings on Y axis (positive integers, default 3)
  95414. * @param scene defines the hosting scene
  95415. * @param updatable defines if the mesh must be flagged as updatable
  95416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95417. * @returns a new Mesh
  95418. */
  95419. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95420. /**
  95421. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95422. * @param name defines the name of the mesh to create
  95423. * @param points is an array successive Vector3
  95424. * @param scene defines the hosting scene
  95425. * @param updatable defines if the mesh must be flagged as updatable
  95426. * @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).
  95427. * @returns a new Mesh
  95428. */
  95429. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95430. /**
  95431. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95432. * @param name defines the name of the mesh to create
  95433. * @param points is an array successive Vector3
  95434. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95435. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95436. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95437. * @param scene defines the hosting scene
  95438. * @param updatable defines if the mesh must be flagged as updatable
  95439. * @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)
  95440. * @returns a new Mesh
  95441. */
  95442. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95443. /**
  95444. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95445. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95446. * 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.
  95447. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95448. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95449. * Remember you can only change the shape positions, not their number when updating a polygon.
  95450. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95451. * @param name defines the name of the mesh to create
  95452. * @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
  95453. * @param scene defines the hosting scene
  95454. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95455. * @param updatable defines if the mesh must be flagged as updatable
  95456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95457. * @param earcutInjection can be used to inject your own earcut reference
  95458. * @returns a new Mesh
  95459. */
  95460. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95461. /**
  95462. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95463. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95464. * @param name defines the name of the mesh to create
  95465. * @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
  95466. * @param depth defines the height of extrusion
  95467. * @param scene defines the hosting scene
  95468. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95469. * @param updatable defines if the mesh must be flagged as updatable
  95470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95471. * @param earcutInjection can be used to inject your own earcut reference
  95472. * @returns a new Mesh
  95473. */
  95474. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95475. /**
  95476. * Creates an extruded shape mesh.
  95477. * 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
  95478. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95479. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95480. * @param name defines the name of the mesh to create
  95481. * @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
  95482. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95483. * @param scale is the value to scale the shape
  95484. * @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
  95485. * @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
  95486. * @param scene defines the hosting scene
  95487. * @param updatable defines if the mesh must be flagged as updatable
  95488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95489. * @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)
  95490. * @returns a new Mesh
  95491. */
  95492. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95493. /**
  95494. * Creates an custom extruded shape mesh.
  95495. * The custom extrusion is a parametric shape.
  95496. * It has no predefined shape. Its final shape will depend on the input parameters.
  95497. * Please consider using the same method from the MeshBuilder class instead
  95498. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95499. * @param name defines the name of the mesh to create
  95500. * @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
  95501. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95502. * @param scaleFunction is a custom Javascript function called on each path point
  95503. * @param rotationFunction is a custom Javascript function called on each path point
  95504. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95505. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95506. * @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
  95507. * @param scene defines the hosting scene
  95508. * @param updatable defines if the mesh must be flagged as updatable
  95509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95510. * @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)
  95511. * @returns a new Mesh
  95512. */
  95513. 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;
  95514. /**
  95515. * Creates lathe mesh.
  95516. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95517. * Please consider using the same method from the MeshBuilder class instead
  95518. * @param name defines the name of the mesh to create
  95519. * @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
  95520. * @param radius is the radius value of the lathe
  95521. * @param tessellation is the side number of the lathe.
  95522. * @param scene defines the hosting scene
  95523. * @param updatable defines if the mesh must be flagged as updatable
  95524. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95525. * @returns a new Mesh
  95526. */
  95527. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95528. /**
  95529. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95530. * @param name defines the name of the mesh to create
  95531. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95532. * @param scene defines the hosting scene
  95533. * @param updatable defines if the mesh must be flagged as updatable
  95534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95535. * @returns a new Mesh
  95536. */
  95537. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95538. /**
  95539. * Creates a ground mesh.
  95540. * Please consider using the same method from the MeshBuilder class instead
  95541. * @param name defines the name of the mesh to create
  95542. * @param width set the width of the ground
  95543. * @param height set the height of the ground
  95544. * @param subdivisions sets the number of subdivisions per side
  95545. * @param scene defines the hosting scene
  95546. * @param updatable defines if the mesh must be flagged as updatable
  95547. * @returns a new Mesh
  95548. */
  95549. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95550. /**
  95551. * Creates a tiled ground mesh.
  95552. * Please consider using the same method from the MeshBuilder class instead
  95553. * @param name defines the name of the mesh to create
  95554. * @param xmin set the ground minimum X coordinate
  95555. * @param zmin set the ground minimum Y coordinate
  95556. * @param xmax set the ground maximum X coordinate
  95557. * @param zmax set the ground maximum Z coordinate
  95558. * @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
  95559. * @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
  95560. * @param scene defines the hosting scene
  95561. * @param updatable defines if the mesh must be flagged as updatable
  95562. * @returns a new Mesh
  95563. */
  95564. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95565. w: number;
  95566. h: number;
  95567. }, precision: {
  95568. w: number;
  95569. h: number;
  95570. }, scene: Scene, updatable?: boolean): Mesh;
  95571. /**
  95572. * Creates a ground mesh from a height map.
  95573. * Please consider using the same method from the MeshBuilder class instead
  95574. * @see http://doc.babylonjs.com/babylon101/height_map
  95575. * @param name defines the name of the mesh to create
  95576. * @param url sets the URL of the height map image resource
  95577. * @param width set the ground width size
  95578. * @param height set the ground height size
  95579. * @param subdivisions sets the number of subdivision per side
  95580. * @param minHeight is the minimum altitude on the ground
  95581. * @param maxHeight is the maximum altitude on the ground
  95582. * @param scene defines the hosting scene
  95583. * @param updatable defines if the mesh must be flagged as updatable
  95584. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95585. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95586. * @returns a new Mesh
  95587. */
  95588. 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;
  95589. /**
  95590. * Creates a tube mesh.
  95591. * The tube is a parametric shape.
  95592. * It has no predefined shape. Its final shape will depend on the input parameters.
  95593. * Please consider using the same method from the MeshBuilder class instead
  95594. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95595. * @param name defines the name of the mesh to create
  95596. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95597. * @param radius sets the tube radius size
  95598. * @param tessellation is the number of sides on the tubular surface
  95599. * @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
  95600. * @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
  95601. * @param scene defines the hosting scene
  95602. * @param updatable defines if the mesh must be flagged as updatable
  95603. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95604. * @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)
  95605. * @returns a new Mesh
  95606. */
  95607. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95608. (i: number, distance: number): number;
  95609. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95610. /**
  95611. * Creates a polyhedron mesh.
  95612. * Please consider using the same method from the MeshBuilder class instead.
  95613. * * 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
  95614. * * The parameter `size` (positive float, default 1) sets the polygon size
  95615. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95616. * * 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`
  95617. * * 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
  95618. * * 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)`)
  95619. * * 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
  95620. * * 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
  95621. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95622. * * If you create a double-sided mesh, you can choose what parts of 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
  95623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95624. * @param name defines the name of the mesh to create
  95625. * @param options defines the options used to create the mesh
  95626. * @param scene defines the hosting scene
  95627. * @returns a new Mesh
  95628. */
  95629. static CreatePolyhedron(name: string, options: {
  95630. type?: number;
  95631. size?: number;
  95632. sizeX?: number;
  95633. sizeY?: number;
  95634. sizeZ?: number;
  95635. custom?: any;
  95636. faceUV?: Vector4[];
  95637. faceColors?: Color4[];
  95638. updatable?: boolean;
  95639. sideOrientation?: number;
  95640. }, scene: Scene): Mesh;
  95641. /**
  95642. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95643. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95644. * * 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`)
  95645. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95646. * * 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
  95647. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95648. * * If you create a double-sided mesh, you can choose what parts of 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
  95649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95650. * @param name defines the name of the mesh
  95651. * @param options defines the options used to create the mesh
  95652. * @param scene defines the hosting scene
  95653. * @returns a new Mesh
  95654. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95655. */
  95656. static CreateIcoSphere(name: string, options: {
  95657. radius?: number;
  95658. flat?: boolean;
  95659. subdivisions?: number;
  95660. sideOrientation?: number;
  95661. updatable?: boolean;
  95662. }, scene: Scene): Mesh;
  95663. /**
  95664. * Creates a decal mesh.
  95665. * Please consider using the same method from the MeshBuilder class instead.
  95666. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95667. * @param name defines the name of the mesh
  95668. * @param sourceMesh defines the mesh receiving the decal
  95669. * @param position sets the position of the decal in world coordinates
  95670. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95671. * @param size sets the decal scaling
  95672. * @param angle sets the angle to rotate the decal
  95673. * @returns a new Mesh
  95674. */
  95675. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95676. /**
  95677. * Prepare internal position array for software CPU skinning
  95678. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95679. */
  95680. setPositionsForCPUSkinning(): Float32Array;
  95681. /**
  95682. * Prepare internal normal array for software CPU skinning
  95683. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95684. */
  95685. setNormalsForCPUSkinning(): Float32Array;
  95686. /**
  95687. * Updates the vertex buffer by applying transformation from the bones
  95688. * @param skeleton defines the skeleton to apply to current mesh
  95689. * @returns the current mesh
  95690. */
  95691. applySkeleton(skeleton: Skeleton): Mesh;
  95692. /**
  95693. * 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
  95694. * @param meshes defines the list of meshes to scan
  95695. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95696. */
  95697. static MinMax(meshes: AbstractMesh[]): {
  95698. min: Vector3;
  95699. max: Vector3;
  95700. };
  95701. /**
  95702. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95703. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95704. * @returns a vector3
  95705. */
  95706. static Center(meshesOrMinMaxVector: {
  95707. min: Vector3;
  95708. max: Vector3;
  95709. } | AbstractMesh[]): Vector3;
  95710. /**
  95711. * Merge the array of meshes into a single mesh for performance reasons.
  95712. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95713. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95714. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95715. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95716. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95717. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95718. * @returns a new mesh
  95719. */
  95720. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95721. /** @hidden */
  95722. addInstance(instance: InstancedMesh): void;
  95723. /** @hidden */
  95724. removeInstance(instance: InstancedMesh): void;
  95725. }
  95726. }
  95727. declare module BABYLON {
  95728. /**
  95729. * This is the base class of all the camera used in the application.
  95730. * @see http://doc.babylonjs.com/features/cameras
  95731. */
  95732. export class Camera extends Node {
  95733. /** @hidden */
  95734. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95735. /**
  95736. * This is the default projection mode used by the cameras.
  95737. * It helps recreating a feeling of perspective and better appreciate depth.
  95738. * This is the best way to simulate real life cameras.
  95739. */
  95740. static readonly PERSPECTIVE_CAMERA: number;
  95741. /**
  95742. * This helps creating camera with an orthographic mode.
  95743. * 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.
  95744. */
  95745. static readonly ORTHOGRAPHIC_CAMERA: number;
  95746. /**
  95747. * This is the default FOV mode for perspective cameras.
  95748. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95749. */
  95750. static readonly FOVMODE_VERTICAL_FIXED: number;
  95751. /**
  95752. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95753. */
  95754. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95755. /**
  95756. * This specifies ther is no need for a camera rig.
  95757. * Basically only one eye is rendered corresponding to the camera.
  95758. */
  95759. static readonly RIG_MODE_NONE: number;
  95760. /**
  95761. * Simulates a camera Rig with one blue eye and one red eye.
  95762. * This can be use with 3d blue and red glasses.
  95763. */
  95764. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95765. /**
  95766. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95767. */
  95768. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95769. /**
  95770. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95771. */
  95772. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95773. /**
  95774. * Defines that both eyes of the camera will be rendered over under each other.
  95775. */
  95776. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95777. /**
  95778. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95779. */
  95780. static readonly RIG_MODE_VR: number;
  95781. /**
  95782. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95783. */
  95784. static readonly RIG_MODE_WEBVR: number;
  95785. /**
  95786. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95787. */
  95788. static readonly RIG_MODE_CUSTOM: number;
  95789. /**
  95790. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95791. */
  95792. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95793. /**
  95794. * Define the input manager associated with the camera.
  95795. */
  95796. inputs: CameraInputsManager<Camera>;
  95797. /** @hidden */
  95798. _position: Vector3;
  95799. /**
  95800. * Define the current local position of the camera in the scene
  95801. */
  95802. get position(): Vector3;
  95803. set position(newPosition: Vector3);
  95804. /**
  95805. * The vector the camera should consider as up.
  95806. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95807. */
  95808. upVector: Vector3;
  95809. /**
  95810. * Define the current limit on the left side for an orthographic camera
  95811. * In scene unit
  95812. */
  95813. orthoLeft: Nullable<number>;
  95814. /**
  95815. * Define the current limit on the right side for an orthographic camera
  95816. * In scene unit
  95817. */
  95818. orthoRight: Nullable<number>;
  95819. /**
  95820. * Define the current limit on the bottom side for an orthographic camera
  95821. * In scene unit
  95822. */
  95823. orthoBottom: Nullable<number>;
  95824. /**
  95825. * Define the current limit on the top side for an orthographic camera
  95826. * In scene unit
  95827. */
  95828. orthoTop: Nullable<number>;
  95829. /**
  95830. * Field Of View is set in Radians. (default is 0.8)
  95831. */
  95832. fov: number;
  95833. /**
  95834. * Define the minimum distance the camera can see from.
  95835. * This is important to note that the depth buffer are not infinite and the closer it starts
  95836. * the more your scene might encounter depth fighting issue.
  95837. */
  95838. minZ: number;
  95839. /**
  95840. * Define the maximum distance the camera can see to.
  95841. * This is important to note that the depth buffer are not infinite and the further it end
  95842. * the more your scene might encounter depth fighting issue.
  95843. */
  95844. maxZ: number;
  95845. /**
  95846. * Define the default inertia of the camera.
  95847. * This helps giving a smooth feeling to the camera movement.
  95848. */
  95849. inertia: number;
  95850. /**
  95851. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95852. */
  95853. mode: number;
  95854. /**
  95855. * Define wether the camera is intermediate.
  95856. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95857. */
  95858. isIntermediate: boolean;
  95859. /**
  95860. * Define the viewport of the camera.
  95861. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95862. */
  95863. viewport: Viewport;
  95864. /**
  95865. * Restricts the camera to viewing objects with the same layerMask.
  95866. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95867. */
  95868. layerMask: number;
  95869. /**
  95870. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95871. */
  95872. fovMode: number;
  95873. /**
  95874. * Rig mode of the camera.
  95875. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95876. * This is normally controlled byt the camera themselves as internal use.
  95877. */
  95878. cameraRigMode: number;
  95879. /**
  95880. * Defines the distance between both "eyes" in case of a RIG
  95881. */
  95882. interaxialDistance: number;
  95883. /**
  95884. * Defines if stereoscopic rendering is done side by side or over under.
  95885. */
  95886. isStereoscopicSideBySide: boolean;
  95887. /**
  95888. * 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
  95889. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95890. * else in the scene. (Eg. security camera)
  95891. *
  95892. * 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)
  95893. */
  95894. customRenderTargets: RenderTargetTexture[];
  95895. /**
  95896. * When set, the camera will render to this render target instead of the default canvas
  95897. *
  95898. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95899. */
  95900. outputRenderTarget: Nullable<RenderTargetTexture>;
  95901. /**
  95902. * Observable triggered when the camera view matrix has changed.
  95903. */
  95904. onViewMatrixChangedObservable: Observable<Camera>;
  95905. /**
  95906. * Observable triggered when the camera Projection matrix has changed.
  95907. */
  95908. onProjectionMatrixChangedObservable: Observable<Camera>;
  95909. /**
  95910. * Observable triggered when the inputs have been processed.
  95911. */
  95912. onAfterCheckInputsObservable: Observable<Camera>;
  95913. /**
  95914. * Observable triggered when reset has been called and applied to the camera.
  95915. */
  95916. onRestoreStateObservable: Observable<Camera>;
  95917. /** @hidden */
  95918. _cameraRigParams: any;
  95919. /** @hidden */
  95920. _rigCameras: Camera[];
  95921. /** @hidden */
  95922. _rigPostProcess: Nullable<PostProcess>;
  95923. protected _webvrViewMatrix: Matrix;
  95924. /** @hidden */
  95925. _skipRendering: boolean;
  95926. /** @hidden */
  95927. _projectionMatrix: Matrix;
  95928. /** @hidden */
  95929. _postProcesses: Nullable<PostProcess>[];
  95930. /** @hidden */
  95931. _activeMeshes: SmartArray<AbstractMesh>;
  95932. protected _globalPosition: Vector3;
  95933. /** @hidden */
  95934. _computedViewMatrix: Matrix;
  95935. private _doNotComputeProjectionMatrix;
  95936. private _transformMatrix;
  95937. private _frustumPlanes;
  95938. private _refreshFrustumPlanes;
  95939. private _storedFov;
  95940. private _stateStored;
  95941. /**
  95942. * Instantiates a new camera object.
  95943. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  95944. * @see http://doc.babylonjs.com/features/cameras
  95945. * @param name Defines the name of the camera in the scene
  95946. * @param position Defines the position of the camera
  95947. * @param scene Defines the scene the camera belongs too
  95948. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  95949. */
  95950. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95951. /**
  95952. * Store current camera state (fov, position, etc..)
  95953. * @returns the camera
  95954. */
  95955. storeState(): Camera;
  95956. /**
  95957. * Restores the camera state values if it has been stored. You must call storeState() first
  95958. */
  95959. protected _restoreStateValues(): boolean;
  95960. /**
  95961. * Restored camera state. You must call storeState() first.
  95962. * @returns true if restored and false otherwise
  95963. */
  95964. restoreState(): boolean;
  95965. /**
  95966. * Gets the class name of the camera.
  95967. * @returns the class name
  95968. */
  95969. getClassName(): string;
  95970. /** @hidden */
  95971. readonly _isCamera: boolean;
  95972. /**
  95973. * Gets a string representation of the camera useful for debug purpose.
  95974. * @param fullDetails Defines that a more verboe level of logging is required
  95975. * @returns the string representation
  95976. */
  95977. toString(fullDetails?: boolean): string;
  95978. /**
  95979. * Gets the current world space position of the camera.
  95980. */
  95981. get globalPosition(): Vector3;
  95982. /**
  95983. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  95984. * @returns the active meshe list
  95985. */
  95986. getActiveMeshes(): SmartArray<AbstractMesh>;
  95987. /**
  95988. * Check wether a mesh is part of the current active mesh list of the camera
  95989. * @param mesh Defines the mesh to check
  95990. * @returns true if active, false otherwise
  95991. */
  95992. isActiveMesh(mesh: Mesh): boolean;
  95993. /**
  95994. * Is this camera ready to be used/rendered
  95995. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  95996. * @return true if the camera is ready
  95997. */
  95998. isReady(completeCheck?: boolean): boolean;
  95999. /** @hidden */
  96000. _initCache(): void;
  96001. /** @hidden */
  96002. _updateCache(ignoreParentClass?: boolean): void;
  96003. /** @hidden */
  96004. _isSynchronized(): boolean;
  96005. /** @hidden */
  96006. _isSynchronizedViewMatrix(): boolean;
  96007. /** @hidden */
  96008. _isSynchronizedProjectionMatrix(): boolean;
  96009. /**
  96010. * Attach the input controls to a specific dom element to get the input from.
  96011. * @param element Defines the element the controls should be listened from
  96012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96013. */
  96014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96015. /**
  96016. * Detach the current controls from the specified dom element.
  96017. * @param element Defines the element to stop listening the inputs from
  96018. */
  96019. detachControl(element: HTMLElement): void;
  96020. /**
  96021. * Update the camera state according to the different inputs gathered during the frame.
  96022. */
  96023. update(): void;
  96024. /** @hidden */
  96025. _checkInputs(): void;
  96026. /** @hidden */
  96027. get rigCameras(): Camera[];
  96028. /**
  96029. * Gets the post process used by the rig cameras
  96030. */
  96031. get rigPostProcess(): Nullable<PostProcess>;
  96032. /**
  96033. * Internal, gets the first post proces.
  96034. * @returns the first post process to be run on this camera.
  96035. */
  96036. _getFirstPostProcess(): Nullable<PostProcess>;
  96037. private _cascadePostProcessesToRigCams;
  96038. /**
  96039. * Attach a post process to the camera.
  96040. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96041. * @param postProcess The post process to attach to the camera
  96042. * @param insertAt The position of the post process in case several of them are in use in the scene
  96043. * @returns the position the post process has been inserted at
  96044. */
  96045. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96046. /**
  96047. * Detach a post process to the camera.
  96048. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96049. * @param postProcess The post process to detach from the camera
  96050. */
  96051. detachPostProcess(postProcess: PostProcess): void;
  96052. /**
  96053. * Gets the current world matrix of the camera
  96054. */
  96055. getWorldMatrix(): Matrix;
  96056. /** @hidden */
  96057. _getViewMatrix(): Matrix;
  96058. /**
  96059. * Gets the current view matrix of the camera.
  96060. * @param force forces the camera to recompute the matrix without looking at the cached state
  96061. * @returns the view matrix
  96062. */
  96063. getViewMatrix(force?: boolean): Matrix;
  96064. /**
  96065. * Freeze the projection matrix.
  96066. * It will prevent the cache check of the camera projection compute and can speed up perf
  96067. * if no parameter of the camera are meant to change
  96068. * @param projection Defines manually a projection if necessary
  96069. */
  96070. freezeProjectionMatrix(projection?: Matrix): void;
  96071. /**
  96072. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96073. */
  96074. unfreezeProjectionMatrix(): void;
  96075. /**
  96076. * Gets the current projection matrix of the camera.
  96077. * @param force forces the camera to recompute the matrix without looking at the cached state
  96078. * @returns the projection matrix
  96079. */
  96080. getProjectionMatrix(force?: boolean): Matrix;
  96081. /**
  96082. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96083. * @returns a Matrix
  96084. */
  96085. getTransformationMatrix(): Matrix;
  96086. private _updateFrustumPlanes;
  96087. /**
  96088. * Checks if a cullable object (mesh...) is in the camera frustum
  96089. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96090. * @param target The object to check
  96091. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96092. * @returns true if the object is in frustum otherwise false
  96093. */
  96094. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96095. /**
  96096. * Checks if a cullable object (mesh...) is in the camera frustum
  96097. * Unlike isInFrustum this cheks the full bounding box
  96098. * @param target The object to check
  96099. * @returns true if the object is in frustum otherwise false
  96100. */
  96101. isCompletelyInFrustum(target: ICullable): boolean;
  96102. /**
  96103. * Gets a ray in the forward direction from the camera.
  96104. * @param length Defines the length of the ray to create
  96105. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96106. * @param origin Defines the start point of the ray which defaults to the camera position
  96107. * @returns the forward ray
  96108. */
  96109. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96110. /**
  96111. * Releases resources associated with this node.
  96112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96114. */
  96115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96116. /** @hidden */
  96117. _isLeftCamera: boolean;
  96118. /**
  96119. * Gets the left camera of a rig setup in case of Rigged Camera
  96120. */
  96121. get isLeftCamera(): boolean;
  96122. /** @hidden */
  96123. _isRightCamera: boolean;
  96124. /**
  96125. * Gets the right camera of a rig setup in case of Rigged Camera
  96126. */
  96127. get isRightCamera(): boolean;
  96128. /**
  96129. * Gets the left camera of a rig setup in case of Rigged Camera
  96130. */
  96131. get leftCamera(): Nullable<FreeCamera>;
  96132. /**
  96133. * Gets the right camera of a rig setup in case of Rigged Camera
  96134. */
  96135. get rightCamera(): Nullable<FreeCamera>;
  96136. /**
  96137. * Gets the left camera target of a rig setup in case of Rigged Camera
  96138. * @returns the target position
  96139. */
  96140. getLeftTarget(): Nullable<Vector3>;
  96141. /**
  96142. * Gets the right camera target of a rig setup in case of Rigged Camera
  96143. * @returns the target position
  96144. */
  96145. getRightTarget(): Nullable<Vector3>;
  96146. /**
  96147. * @hidden
  96148. */
  96149. setCameraRigMode(mode: number, rigParams: any): void;
  96150. /** @hidden */
  96151. static _setStereoscopicRigMode(camera: Camera): void;
  96152. /** @hidden */
  96153. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96154. /** @hidden */
  96155. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96156. /** @hidden */
  96157. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96158. /** @hidden */
  96159. _getVRProjectionMatrix(): Matrix;
  96160. protected _updateCameraRotationMatrix(): void;
  96161. protected _updateWebVRCameraRotationMatrix(): void;
  96162. /**
  96163. * This function MUST be overwritten by the different WebVR cameras available.
  96164. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96165. * @hidden
  96166. */
  96167. _getWebVRProjectionMatrix(): Matrix;
  96168. /**
  96169. * This function MUST be overwritten by the different WebVR cameras available.
  96170. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96171. * @hidden
  96172. */
  96173. _getWebVRViewMatrix(): Matrix;
  96174. /** @hidden */
  96175. setCameraRigParameter(name: string, value: any): void;
  96176. /**
  96177. * needs to be overridden by children so sub has required properties to be copied
  96178. * @hidden
  96179. */
  96180. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96181. /**
  96182. * May need to be overridden by children
  96183. * @hidden
  96184. */
  96185. _updateRigCameras(): void;
  96186. /** @hidden */
  96187. _setupInputs(): void;
  96188. /**
  96189. * Serialiaze the camera setup to a json represention
  96190. * @returns the JSON representation
  96191. */
  96192. serialize(): any;
  96193. /**
  96194. * Clones the current camera.
  96195. * @param name The cloned camera name
  96196. * @returns the cloned camera
  96197. */
  96198. clone(name: string): Camera;
  96199. /**
  96200. * Gets the direction of the camera relative to a given local axis.
  96201. * @param localAxis Defines the reference axis to provide a relative direction.
  96202. * @return the direction
  96203. */
  96204. getDirection(localAxis: Vector3): Vector3;
  96205. /**
  96206. * Returns the current camera absolute rotation
  96207. */
  96208. get absoluteRotation(): Quaternion;
  96209. /**
  96210. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96211. * @param localAxis Defines the reference axis to provide a relative direction.
  96212. * @param result Defines the vector to store the result in
  96213. */
  96214. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96215. /**
  96216. * Gets a camera constructor for a given camera type
  96217. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96218. * @param name The name of the camera the result will be able to instantiate
  96219. * @param scene The scene the result will construct the camera in
  96220. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96221. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96222. * @returns a factory method to construc the camera
  96223. */
  96224. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96225. /**
  96226. * Compute the world matrix of the camera.
  96227. * @returns the camera world matrix
  96228. */
  96229. computeWorldMatrix(): Matrix;
  96230. /**
  96231. * Parse a JSON and creates the camera from the parsed information
  96232. * @param parsedCamera The JSON to parse
  96233. * @param scene The scene to instantiate the camera in
  96234. * @returns the newly constructed camera
  96235. */
  96236. static Parse(parsedCamera: any, scene: Scene): Camera;
  96237. }
  96238. }
  96239. declare module BABYLON {
  96240. /**
  96241. * Class containing static functions to help procedurally build meshes
  96242. */
  96243. export class DiscBuilder {
  96244. /**
  96245. * Creates a plane polygonal mesh. By default, this is a disc
  96246. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96247. * * 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
  96248. * * 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
  96249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96252. * @param name defines the name of the mesh
  96253. * @param options defines the options used to create the mesh
  96254. * @param scene defines the hosting scene
  96255. * @returns the plane polygonal mesh
  96256. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96257. */
  96258. static CreateDisc(name: string, options: {
  96259. radius?: number;
  96260. tessellation?: number;
  96261. arc?: number;
  96262. updatable?: boolean;
  96263. sideOrientation?: number;
  96264. frontUVs?: Vector4;
  96265. backUVs?: Vector4;
  96266. }, scene?: Nullable<Scene>): Mesh;
  96267. }
  96268. }
  96269. declare module BABYLON {
  96270. /**
  96271. * This represents all the required information to add a fresnel effect on a material:
  96272. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96273. */
  96274. export class FresnelParameters {
  96275. private _isEnabled;
  96276. /**
  96277. * Define if the fresnel effect is enable or not.
  96278. */
  96279. get isEnabled(): boolean;
  96280. set isEnabled(value: boolean);
  96281. /**
  96282. * Define the color used on edges (grazing angle)
  96283. */
  96284. leftColor: Color3;
  96285. /**
  96286. * Define the color used on center
  96287. */
  96288. rightColor: Color3;
  96289. /**
  96290. * Define bias applied to computed fresnel term
  96291. */
  96292. bias: number;
  96293. /**
  96294. * Defined the power exponent applied to fresnel term
  96295. */
  96296. power: number;
  96297. /**
  96298. * Clones the current fresnel and its valuues
  96299. * @returns a clone fresnel configuration
  96300. */
  96301. clone(): FresnelParameters;
  96302. /**
  96303. * Serializes the current fresnel parameters to a JSON representation.
  96304. * @return the JSON serialization
  96305. */
  96306. serialize(): any;
  96307. /**
  96308. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96309. * @param parsedFresnelParameters Define the JSON representation
  96310. * @returns the parsed parameters
  96311. */
  96312. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96313. }
  96314. }
  96315. declare module BABYLON {
  96316. /**
  96317. * Base class of materials working in push mode in babylon JS
  96318. * @hidden
  96319. */
  96320. export class PushMaterial extends Material {
  96321. protected _activeEffect: Effect;
  96322. protected _normalMatrix: Matrix;
  96323. /**
  96324. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96325. * This means that the material can keep using a previous shader while a new one is being compiled.
  96326. * This is mostly used when shader parallel compilation is supported (true by default)
  96327. */
  96328. allowShaderHotSwapping: boolean;
  96329. constructor(name: string, scene: Scene);
  96330. getEffect(): Effect;
  96331. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96332. /**
  96333. * Binds the given world matrix to the active effect
  96334. *
  96335. * @param world the matrix to bind
  96336. */
  96337. bindOnlyWorldMatrix(world: Matrix): void;
  96338. /**
  96339. * Binds the given normal matrix to the active effect
  96340. *
  96341. * @param normalMatrix the matrix to bind
  96342. */
  96343. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96344. bind(world: Matrix, mesh?: Mesh): void;
  96345. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96346. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96347. }
  96348. }
  96349. declare module BABYLON {
  96350. /**
  96351. * This groups all the flags used to control the materials channel.
  96352. */
  96353. export class MaterialFlags {
  96354. private static _DiffuseTextureEnabled;
  96355. /**
  96356. * Are diffuse textures enabled in the application.
  96357. */
  96358. static get DiffuseTextureEnabled(): boolean;
  96359. static set DiffuseTextureEnabled(value: boolean);
  96360. private static _AmbientTextureEnabled;
  96361. /**
  96362. * Are ambient textures enabled in the application.
  96363. */
  96364. static get AmbientTextureEnabled(): boolean;
  96365. static set AmbientTextureEnabled(value: boolean);
  96366. private static _OpacityTextureEnabled;
  96367. /**
  96368. * Are opacity textures enabled in the application.
  96369. */
  96370. static get OpacityTextureEnabled(): boolean;
  96371. static set OpacityTextureEnabled(value: boolean);
  96372. private static _ReflectionTextureEnabled;
  96373. /**
  96374. * Are reflection textures enabled in the application.
  96375. */
  96376. static get ReflectionTextureEnabled(): boolean;
  96377. static set ReflectionTextureEnabled(value: boolean);
  96378. private static _EmissiveTextureEnabled;
  96379. /**
  96380. * Are emissive textures enabled in the application.
  96381. */
  96382. static get EmissiveTextureEnabled(): boolean;
  96383. static set EmissiveTextureEnabled(value: boolean);
  96384. private static _SpecularTextureEnabled;
  96385. /**
  96386. * Are specular textures enabled in the application.
  96387. */
  96388. static get SpecularTextureEnabled(): boolean;
  96389. static set SpecularTextureEnabled(value: boolean);
  96390. private static _BumpTextureEnabled;
  96391. /**
  96392. * Are bump textures enabled in the application.
  96393. */
  96394. static get BumpTextureEnabled(): boolean;
  96395. static set BumpTextureEnabled(value: boolean);
  96396. private static _LightmapTextureEnabled;
  96397. /**
  96398. * Are lightmap textures enabled in the application.
  96399. */
  96400. static get LightmapTextureEnabled(): boolean;
  96401. static set LightmapTextureEnabled(value: boolean);
  96402. private static _RefractionTextureEnabled;
  96403. /**
  96404. * Are refraction textures enabled in the application.
  96405. */
  96406. static get RefractionTextureEnabled(): boolean;
  96407. static set RefractionTextureEnabled(value: boolean);
  96408. private static _ColorGradingTextureEnabled;
  96409. /**
  96410. * Are color grading textures enabled in the application.
  96411. */
  96412. static get ColorGradingTextureEnabled(): boolean;
  96413. static set ColorGradingTextureEnabled(value: boolean);
  96414. private static _FresnelEnabled;
  96415. /**
  96416. * Are fresnels enabled in the application.
  96417. */
  96418. static get FresnelEnabled(): boolean;
  96419. static set FresnelEnabled(value: boolean);
  96420. private static _ClearCoatTextureEnabled;
  96421. /**
  96422. * Are clear coat textures enabled in the application.
  96423. */
  96424. static get ClearCoatTextureEnabled(): boolean;
  96425. static set ClearCoatTextureEnabled(value: boolean);
  96426. private static _ClearCoatBumpTextureEnabled;
  96427. /**
  96428. * Are clear coat bump textures enabled in the application.
  96429. */
  96430. static get ClearCoatBumpTextureEnabled(): boolean;
  96431. static set ClearCoatBumpTextureEnabled(value: boolean);
  96432. private static _ClearCoatTintTextureEnabled;
  96433. /**
  96434. * Are clear coat tint textures enabled in the application.
  96435. */
  96436. static get ClearCoatTintTextureEnabled(): boolean;
  96437. static set ClearCoatTintTextureEnabled(value: boolean);
  96438. private static _SheenTextureEnabled;
  96439. /**
  96440. * Are sheen textures enabled in the application.
  96441. */
  96442. static get SheenTextureEnabled(): boolean;
  96443. static set SheenTextureEnabled(value: boolean);
  96444. private static _AnisotropicTextureEnabled;
  96445. /**
  96446. * Are anisotropic textures enabled in the application.
  96447. */
  96448. static get AnisotropicTextureEnabled(): boolean;
  96449. static set AnisotropicTextureEnabled(value: boolean);
  96450. private static _ThicknessTextureEnabled;
  96451. /**
  96452. * Are thickness textures enabled in the application.
  96453. */
  96454. static get ThicknessTextureEnabled(): boolean;
  96455. static set ThicknessTextureEnabled(value: boolean);
  96456. }
  96457. }
  96458. declare module BABYLON {
  96459. /** @hidden */
  96460. export var defaultFragmentDeclaration: {
  96461. name: string;
  96462. shader: string;
  96463. };
  96464. }
  96465. declare module BABYLON {
  96466. /** @hidden */
  96467. export var defaultUboDeclaration: {
  96468. name: string;
  96469. shader: string;
  96470. };
  96471. }
  96472. declare module BABYLON {
  96473. /** @hidden */
  96474. export var lightFragmentDeclaration: {
  96475. name: string;
  96476. shader: string;
  96477. };
  96478. }
  96479. declare module BABYLON {
  96480. /** @hidden */
  96481. export var lightUboDeclaration: {
  96482. name: string;
  96483. shader: string;
  96484. };
  96485. }
  96486. declare module BABYLON {
  96487. /** @hidden */
  96488. export var lightsFragmentFunctions: {
  96489. name: string;
  96490. shader: string;
  96491. };
  96492. }
  96493. declare module BABYLON {
  96494. /** @hidden */
  96495. export var shadowsFragmentFunctions: {
  96496. name: string;
  96497. shader: string;
  96498. };
  96499. }
  96500. declare module BABYLON {
  96501. /** @hidden */
  96502. export var fresnelFunction: {
  96503. name: string;
  96504. shader: string;
  96505. };
  96506. }
  96507. declare module BABYLON {
  96508. /** @hidden */
  96509. export var reflectionFunction: {
  96510. name: string;
  96511. shader: string;
  96512. };
  96513. }
  96514. declare module BABYLON {
  96515. /** @hidden */
  96516. export var bumpFragmentFunctions: {
  96517. name: string;
  96518. shader: string;
  96519. };
  96520. }
  96521. declare module BABYLON {
  96522. /** @hidden */
  96523. export var logDepthDeclaration: {
  96524. name: string;
  96525. shader: string;
  96526. };
  96527. }
  96528. declare module BABYLON {
  96529. /** @hidden */
  96530. export var bumpFragment: {
  96531. name: string;
  96532. shader: string;
  96533. };
  96534. }
  96535. declare module BABYLON {
  96536. /** @hidden */
  96537. export var depthPrePass: {
  96538. name: string;
  96539. shader: string;
  96540. };
  96541. }
  96542. declare module BABYLON {
  96543. /** @hidden */
  96544. export var lightFragment: {
  96545. name: string;
  96546. shader: string;
  96547. };
  96548. }
  96549. declare module BABYLON {
  96550. /** @hidden */
  96551. export var logDepthFragment: {
  96552. name: string;
  96553. shader: string;
  96554. };
  96555. }
  96556. declare module BABYLON {
  96557. /** @hidden */
  96558. export var defaultPixelShader: {
  96559. name: string;
  96560. shader: string;
  96561. };
  96562. }
  96563. declare module BABYLON {
  96564. /** @hidden */
  96565. export var defaultVertexDeclaration: {
  96566. name: string;
  96567. shader: string;
  96568. };
  96569. }
  96570. declare module BABYLON {
  96571. /** @hidden */
  96572. export var bumpVertexDeclaration: {
  96573. name: string;
  96574. shader: string;
  96575. };
  96576. }
  96577. declare module BABYLON {
  96578. /** @hidden */
  96579. export var bumpVertex: {
  96580. name: string;
  96581. shader: string;
  96582. };
  96583. }
  96584. declare module BABYLON {
  96585. /** @hidden */
  96586. export var fogVertex: {
  96587. name: string;
  96588. shader: string;
  96589. };
  96590. }
  96591. declare module BABYLON {
  96592. /** @hidden */
  96593. export var shadowsVertex: {
  96594. name: string;
  96595. shader: string;
  96596. };
  96597. }
  96598. declare module BABYLON {
  96599. /** @hidden */
  96600. export var pointCloudVertex: {
  96601. name: string;
  96602. shader: string;
  96603. };
  96604. }
  96605. declare module BABYLON {
  96606. /** @hidden */
  96607. export var logDepthVertex: {
  96608. name: string;
  96609. shader: string;
  96610. };
  96611. }
  96612. declare module BABYLON {
  96613. /** @hidden */
  96614. export var defaultVertexShader: {
  96615. name: string;
  96616. shader: string;
  96617. };
  96618. }
  96619. declare module BABYLON {
  96620. /** @hidden */
  96621. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96622. MAINUV1: boolean;
  96623. MAINUV2: boolean;
  96624. DIFFUSE: boolean;
  96625. DIFFUSEDIRECTUV: number;
  96626. AMBIENT: boolean;
  96627. AMBIENTDIRECTUV: number;
  96628. OPACITY: boolean;
  96629. OPACITYDIRECTUV: number;
  96630. OPACITYRGB: boolean;
  96631. REFLECTION: boolean;
  96632. EMISSIVE: boolean;
  96633. EMISSIVEDIRECTUV: number;
  96634. SPECULAR: boolean;
  96635. SPECULARDIRECTUV: number;
  96636. BUMP: boolean;
  96637. BUMPDIRECTUV: number;
  96638. PARALLAX: boolean;
  96639. PARALLAXOCCLUSION: boolean;
  96640. SPECULAROVERALPHA: boolean;
  96641. CLIPPLANE: boolean;
  96642. CLIPPLANE2: boolean;
  96643. CLIPPLANE3: boolean;
  96644. CLIPPLANE4: boolean;
  96645. ALPHATEST: boolean;
  96646. DEPTHPREPASS: boolean;
  96647. ALPHAFROMDIFFUSE: boolean;
  96648. POINTSIZE: boolean;
  96649. FOG: boolean;
  96650. SPECULARTERM: boolean;
  96651. DIFFUSEFRESNEL: boolean;
  96652. OPACITYFRESNEL: boolean;
  96653. REFLECTIONFRESNEL: boolean;
  96654. REFRACTIONFRESNEL: boolean;
  96655. EMISSIVEFRESNEL: boolean;
  96656. FRESNEL: boolean;
  96657. NORMAL: boolean;
  96658. UV1: boolean;
  96659. UV2: boolean;
  96660. VERTEXCOLOR: boolean;
  96661. VERTEXALPHA: boolean;
  96662. NUM_BONE_INFLUENCERS: number;
  96663. BonesPerMesh: number;
  96664. BONETEXTURE: boolean;
  96665. INSTANCES: boolean;
  96666. GLOSSINESS: boolean;
  96667. ROUGHNESS: boolean;
  96668. EMISSIVEASILLUMINATION: boolean;
  96669. LINKEMISSIVEWITHDIFFUSE: boolean;
  96670. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96671. LIGHTMAP: boolean;
  96672. LIGHTMAPDIRECTUV: number;
  96673. OBJECTSPACE_NORMALMAP: boolean;
  96674. USELIGHTMAPASSHADOWMAP: boolean;
  96675. REFLECTIONMAP_3D: boolean;
  96676. REFLECTIONMAP_SPHERICAL: boolean;
  96677. REFLECTIONMAP_PLANAR: boolean;
  96678. REFLECTIONMAP_CUBIC: boolean;
  96679. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96680. REFLECTIONMAP_PROJECTION: boolean;
  96681. REFLECTIONMAP_SKYBOX: boolean;
  96682. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96683. REFLECTIONMAP_EXPLICIT: boolean;
  96684. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96685. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96686. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96687. INVERTCUBICMAP: boolean;
  96688. LOGARITHMICDEPTH: boolean;
  96689. REFRACTION: boolean;
  96690. REFRACTIONMAP_3D: boolean;
  96691. REFLECTIONOVERALPHA: boolean;
  96692. TWOSIDEDLIGHTING: boolean;
  96693. SHADOWFLOAT: boolean;
  96694. MORPHTARGETS: boolean;
  96695. MORPHTARGETS_NORMAL: boolean;
  96696. MORPHTARGETS_TANGENT: boolean;
  96697. MORPHTARGETS_UV: boolean;
  96698. NUM_MORPH_INFLUENCERS: number;
  96699. NONUNIFORMSCALING: boolean;
  96700. PREMULTIPLYALPHA: boolean;
  96701. IMAGEPROCESSING: boolean;
  96702. VIGNETTE: boolean;
  96703. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96704. VIGNETTEBLENDMODEOPAQUE: boolean;
  96705. TONEMAPPING: boolean;
  96706. TONEMAPPING_ACES: boolean;
  96707. CONTRAST: boolean;
  96708. COLORCURVES: boolean;
  96709. COLORGRADING: boolean;
  96710. COLORGRADING3D: boolean;
  96711. SAMPLER3DGREENDEPTH: boolean;
  96712. SAMPLER3DBGRMAP: boolean;
  96713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96714. MULTIVIEW: boolean;
  96715. /**
  96716. * If the reflection texture on this material is in linear color space
  96717. * @hidden
  96718. */
  96719. IS_REFLECTION_LINEAR: boolean;
  96720. /**
  96721. * If the refraction texture on this material is in linear color space
  96722. * @hidden
  96723. */
  96724. IS_REFRACTION_LINEAR: boolean;
  96725. EXPOSURE: boolean;
  96726. constructor();
  96727. setReflectionMode(modeToEnable: string): void;
  96728. }
  96729. /**
  96730. * This is the default material used in Babylon. It is the best trade off between quality
  96731. * and performances.
  96732. * @see http://doc.babylonjs.com/babylon101/materials
  96733. */
  96734. export class StandardMaterial extends PushMaterial {
  96735. private _diffuseTexture;
  96736. /**
  96737. * The basic texture of the material as viewed under a light.
  96738. */
  96739. diffuseTexture: Nullable<BaseTexture>;
  96740. private _ambientTexture;
  96741. /**
  96742. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96743. */
  96744. ambientTexture: Nullable<BaseTexture>;
  96745. private _opacityTexture;
  96746. /**
  96747. * Define the transparency of the material from a texture.
  96748. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96749. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96750. */
  96751. opacityTexture: Nullable<BaseTexture>;
  96752. private _reflectionTexture;
  96753. /**
  96754. * Define the texture used to display the reflection.
  96755. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96756. */
  96757. reflectionTexture: Nullable<BaseTexture>;
  96758. private _emissiveTexture;
  96759. /**
  96760. * Define texture of the material as if self lit.
  96761. * This will be mixed in the final result even in the absence of light.
  96762. */
  96763. emissiveTexture: Nullable<BaseTexture>;
  96764. private _specularTexture;
  96765. /**
  96766. * Define how the color and intensity of the highlight given by the light in the material.
  96767. */
  96768. specularTexture: Nullable<BaseTexture>;
  96769. private _bumpTexture;
  96770. /**
  96771. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96772. * 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.
  96773. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96774. */
  96775. bumpTexture: Nullable<BaseTexture>;
  96776. private _lightmapTexture;
  96777. /**
  96778. * Complex lighting can be computationally expensive to compute at runtime.
  96779. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96780. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96781. */
  96782. lightmapTexture: Nullable<BaseTexture>;
  96783. private _refractionTexture;
  96784. /**
  96785. * Define the texture used to display the refraction.
  96786. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96787. */
  96788. refractionTexture: Nullable<BaseTexture>;
  96789. /**
  96790. * The color of the material lit by the environmental background lighting.
  96791. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96792. */
  96793. ambientColor: Color3;
  96794. /**
  96795. * The basic color of the material as viewed under a light.
  96796. */
  96797. diffuseColor: Color3;
  96798. /**
  96799. * Define how the color and intensity of the highlight given by the light in the material.
  96800. */
  96801. specularColor: Color3;
  96802. /**
  96803. * Define the color of the material as if self lit.
  96804. * This will be mixed in the final result even in the absence of light.
  96805. */
  96806. emissiveColor: Color3;
  96807. /**
  96808. * Defines how sharp are the highlights in the material.
  96809. * The bigger the value the sharper giving a more glossy feeling to the result.
  96810. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96811. */
  96812. specularPower: number;
  96813. private _useAlphaFromDiffuseTexture;
  96814. /**
  96815. * Does the transparency come from the diffuse texture alpha channel.
  96816. */
  96817. useAlphaFromDiffuseTexture: boolean;
  96818. private _useEmissiveAsIllumination;
  96819. /**
  96820. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96821. */
  96822. useEmissiveAsIllumination: boolean;
  96823. private _linkEmissiveWithDiffuse;
  96824. /**
  96825. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96826. * the emissive level when the final color is close to one.
  96827. */
  96828. linkEmissiveWithDiffuse: boolean;
  96829. private _useSpecularOverAlpha;
  96830. /**
  96831. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96832. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96833. */
  96834. useSpecularOverAlpha: boolean;
  96835. private _useReflectionOverAlpha;
  96836. /**
  96837. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96838. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96839. */
  96840. useReflectionOverAlpha: boolean;
  96841. private _disableLighting;
  96842. /**
  96843. * Does lights from the scene impacts this material.
  96844. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96845. */
  96846. disableLighting: boolean;
  96847. private _useObjectSpaceNormalMap;
  96848. /**
  96849. * Allows using an object space normal map (instead of tangent space).
  96850. */
  96851. useObjectSpaceNormalMap: boolean;
  96852. private _useParallax;
  96853. /**
  96854. * Is parallax enabled or not.
  96855. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96856. */
  96857. useParallax: boolean;
  96858. private _useParallaxOcclusion;
  96859. /**
  96860. * Is parallax occlusion enabled or not.
  96861. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96862. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96863. */
  96864. useParallaxOcclusion: boolean;
  96865. /**
  96866. * 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.
  96867. */
  96868. parallaxScaleBias: number;
  96869. private _roughness;
  96870. /**
  96871. * Helps to define how blurry the reflections should appears in the material.
  96872. */
  96873. roughness: number;
  96874. /**
  96875. * In case of refraction, define the value of the index of refraction.
  96876. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96877. */
  96878. indexOfRefraction: number;
  96879. /**
  96880. * Invert the refraction texture alongside the y axis.
  96881. * It can be useful with procedural textures or probe for instance.
  96882. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96883. */
  96884. invertRefractionY: boolean;
  96885. /**
  96886. * Defines the alpha limits in alpha test mode.
  96887. */
  96888. alphaCutOff: number;
  96889. private _useLightmapAsShadowmap;
  96890. /**
  96891. * In case of light mapping, define whether the map contains light or shadow informations.
  96892. */
  96893. useLightmapAsShadowmap: boolean;
  96894. private _diffuseFresnelParameters;
  96895. /**
  96896. * Define the diffuse fresnel parameters of the material.
  96897. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96898. */
  96899. diffuseFresnelParameters: FresnelParameters;
  96900. private _opacityFresnelParameters;
  96901. /**
  96902. * Define the opacity fresnel parameters of the material.
  96903. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96904. */
  96905. opacityFresnelParameters: FresnelParameters;
  96906. private _reflectionFresnelParameters;
  96907. /**
  96908. * Define the reflection fresnel parameters of the material.
  96909. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96910. */
  96911. reflectionFresnelParameters: FresnelParameters;
  96912. private _refractionFresnelParameters;
  96913. /**
  96914. * Define the refraction fresnel parameters of the material.
  96915. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96916. */
  96917. refractionFresnelParameters: FresnelParameters;
  96918. private _emissiveFresnelParameters;
  96919. /**
  96920. * Define the emissive fresnel parameters of the material.
  96921. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96922. */
  96923. emissiveFresnelParameters: FresnelParameters;
  96924. private _useReflectionFresnelFromSpecular;
  96925. /**
  96926. * If true automatically deducts the fresnels values from the material specularity.
  96927. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96928. */
  96929. useReflectionFresnelFromSpecular: boolean;
  96930. private _useGlossinessFromSpecularMapAlpha;
  96931. /**
  96932. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96933. */
  96934. useGlossinessFromSpecularMapAlpha: boolean;
  96935. private _maxSimultaneousLights;
  96936. /**
  96937. * Defines the maximum number of lights that can be used in the material
  96938. */
  96939. maxSimultaneousLights: number;
  96940. private _invertNormalMapX;
  96941. /**
  96942. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96943. */
  96944. invertNormalMapX: boolean;
  96945. private _invertNormalMapY;
  96946. /**
  96947. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96948. */
  96949. invertNormalMapY: boolean;
  96950. private _twoSidedLighting;
  96951. /**
  96952. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96953. */
  96954. twoSidedLighting: boolean;
  96955. /**
  96956. * Default configuration related to image processing available in the standard Material.
  96957. */
  96958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96959. /**
  96960. * Gets the image processing configuration used either in this material.
  96961. */
  96962. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  96963. /**
  96964. * Sets the Default image processing configuration used either in the this material.
  96965. *
  96966. * If sets to null, the scene one is in use.
  96967. */
  96968. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  96969. /**
  96970. * Keep track of the image processing observer to allow dispose and replace.
  96971. */
  96972. private _imageProcessingObserver;
  96973. /**
  96974. * Attaches a new image processing configuration to the Standard Material.
  96975. * @param configuration
  96976. */
  96977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96978. /**
  96979. * Gets wether the color curves effect is enabled.
  96980. */
  96981. get cameraColorCurvesEnabled(): boolean;
  96982. /**
  96983. * Sets wether the color curves effect is enabled.
  96984. */
  96985. set cameraColorCurvesEnabled(value: boolean);
  96986. /**
  96987. * Gets wether the color grading effect is enabled.
  96988. */
  96989. get cameraColorGradingEnabled(): boolean;
  96990. /**
  96991. * Gets wether the color grading effect is enabled.
  96992. */
  96993. set cameraColorGradingEnabled(value: boolean);
  96994. /**
  96995. * Gets wether tonemapping is enabled or not.
  96996. */
  96997. get cameraToneMappingEnabled(): boolean;
  96998. /**
  96999. * Sets wether tonemapping is enabled or not
  97000. */
  97001. set cameraToneMappingEnabled(value: boolean);
  97002. /**
  97003. * The camera exposure used on this material.
  97004. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97005. * This corresponds to a photographic exposure.
  97006. */
  97007. get cameraExposure(): number;
  97008. /**
  97009. * The camera exposure used on this material.
  97010. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97011. * This corresponds to a photographic exposure.
  97012. */
  97013. set cameraExposure(value: number);
  97014. /**
  97015. * Gets The camera contrast used on this material.
  97016. */
  97017. get cameraContrast(): number;
  97018. /**
  97019. * Sets The camera contrast used on this material.
  97020. */
  97021. set cameraContrast(value: number);
  97022. /**
  97023. * Gets the Color Grading 2D Lookup Texture.
  97024. */
  97025. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97026. /**
  97027. * Sets the Color Grading 2D Lookup Texture.
  97028. */
  97029. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97030. /**
  97031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97033. * 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;
  97034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97035. */
  97036. get cameraColorCurves(): Nullable<ColorCurves>;
  97037. /**
  97038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97040. * 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;
  97041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97042. */
  97043. set cameraColorCurves(value: Nullable<ColorCurves>);
  97044. /**
  97045. * Custom callback helping to override the default shader used in the material.
  97046. */
  97047. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97048. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97049. protected _worldViewProjectionMatrix: Matrix;
  97050. protected _globalAmbientColor: Color3;
  97051. protected _useLogarithmicDepth: boolean;
  97052. protected _rebuildInParallel: boolean;
  97053. /**
  97054. * Instantiates a new standard material.
  97055. * This is the default material used in Babylon. It is the best trade off between quality
  97056. * and performances.
  97057. * @see http://doc.babylonjs.com/babylon101/materials
  97058. * @param name Define the name of the material in the scene
  97059. * @param scene Define the scene the material belong to
  97060. */
  97061. constructor(name: string, scene: Scene);
  97062. /**
  97063. * Gets a boolean indicating that current material needs to register RTT
  97064. */
  97065. get hasRenderTargetTextures(): boolean;
  97066. /**
  97067. * Gets the current class name of the material e.g. "StandardMaterial"
  97068. * Mainly use in serialization.
  97069. * @returns the class name
  97070. */
  97071. getClassName(): string;
  97072. /**
  97073. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97074. * You can try switching to logarithmic depth.
  97075. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97076. */
  97077. get useLogarithmicDepth(): boolean;
  97078. set useLogarithmicDepth(value: boolean);
  97079. /**
  97080. * Specifies if the material will require alpha blending
  97081. * @returns a boolean specifying if alpha blending is needed
  97082. */
  97083. needAlphaBlending(): boolean;
  97084. /**
  97085. * Specifies if this material should be rendered in alpha test mode
  97086. * @returns a boolean specifying if an alpha test is needed.
  97087. */
  97088. needAlphaTesting(): boolean;
  97089. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97090. /**
  97091. * Get the texture used for alpha test purpose.
  97092. * @returns the diffuse texture in case of the standard material.
  97093. */
  97094. getAlphaTestTexture(): Nullable<BaseTexture>;
  97095. /**
  97096. * Get if the submesh is ready to be used and all its information available.
  97097. * Child classes can use it to update shaders
  97098. * @param mesh defines the mesh to check
  97099. * @param subMesh defines which submesh to check
  97100. * @param useInstances specifies that instances should be used
  97101. * @returns a boolean indicating that the submesh is ready or not
  97102. */
  97103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97104. /**
  97105. * Builds the material UBO layouts.
  97106. * Used internally during the effect preparation.
  97107. */
  97108. buildUniformLayout(): void;
  97109. /**
  97110. * Unbinds the material from the mesh
  97111. */
  97112. unbind(): void;
  97113. /**
  97114. * Binds the submesh to this material by preparing the effect and shader to draw
  97115. * @param world defines the world transformation matrix
  97116. * @param mesh defines the mesh containing the submesh
  97117. * @param subMesh defines the submesh to bind the material to
  97118. */
  97119. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97120. /**
  97121. * Get the list of animatables in the material.
  97122. * @returns the list of animatables object used in the material
  97123. */
  97124. getAnimatables(): IAnimatable[];
  97125. /**
  97126. * Gets the active textures from the material
  97127. * @returns an array of textures
  97128. */
  97129. getActiveTextures(): BaseTexture[];
  97130. /**
  97131. * Specifies if the material uses a texture
  97132. * @param texture defines the texture to check against the material
  97133. * @returns a boolean specifying if the material uses the texture
  97134. */
  97135. hasTexture(texture: BaseTexture): boolean;
  97136. /**
  97137. * Disposes the material
  97138. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97139. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97140. */
  97141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97142. /**
  97143. * Makes a duplicate of the material, and gives it a new name
  97144. * @param name defines the new name for the duplicated material
  97145. * @returns the cloned material
  97146. */
  97147. clone(name: string): StandardMaterial;
  97148. /**
  97149. * Serializes this material in a JSON representation
  97150. * @returns the serialized material object
  97151. */
  97152. serialize(): any;
  97153. /**
  97154. * Creates a standard material from parsed material data
  97155. * @param source defines the JSON representation of the material
  97156. * @param scene defines the hosting scene
  97157. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97158. * @returns a new standard material
  97159. */
  97160. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97161. /**
  97162. * Are diffuse textures enabled in the application.
  97163. */
  97164. static get DiffuseTextureEnabled(): boolean;
  97165. static set DiffuseTextureEnabled(value: boolean);
  97166. /**
  97167. * Are ambient textures enabled in the application.
  97168. */
  97169. static get AmbientTextureEnabled(): boolean;
  97170. static set AmbientTextureEnabled(value: boolean);
  97171. /**
  97172. * Are opacity textures enabled in the application.
  97173. */
  97174. static get OpacityTextureEnabled(): boolean;
  97175. static set OpacityTextureEnabled(value: boolean);
  97176. /**
  97177. * Are reflection textures enabled in the application.
  97178. */
  97179. static get ReflectionTextureEnabled(): boolean;
  97180. static set ReflectionTextureEnabled(value: boolean);
  97181. /**
  97182. * Are emissive textures enabled in the application.
  97183. */
  97184. static get EmissiveTextureEnabled(): boolean;
  97185. static set EmissiveTextureEnabled(value: boolean);
  97186. /**
  97187. * Are specular textures enabled in the application.
  97188. */
  97189. static get SpecularTextureEnabled(): boolean;
  97190. static set SpecularTextureEnabled(value: boolean);
  97191. /**
  97192. * Are bump textures enabled in the application.
  97193. */
  97194. static get BumpTextureEnabled(): boolean;
  97195. static set BumpTextureEnabled(value: boolean);
  97196. /**
  97197. * Are lightmap textures enabled in the application.
  97198. */
  97199. static get LightmapTextureEnabled(): boolean;
  97200. static set LightmapTextureEnabled(value: boolean);
  97201. /**
  97202. * Are refraction textures enabled in the application.
  97203. */
  97204. static get RefractionTextureEnabled(): boolean;
  97205. static set RefractionTextureEnabled(value: boolean);
  97206. /**
  97207. * Are color grading textures enabled in the application.
  97208. */
  97209. static get ColorGradingTextureEnabled(): boolean;
  97210. static set ColorGradingTextureEnabled(value: boolean);
  97211. /**
  97212. * Are fresnels enabled in the application.
  97213. */
  97214. static get FresnelEnabled(): boolean;
  97215. static set FresnelEnabled(value: boolean);
  97216. }
  97217. }
  97218. declare module BABYLON {
  97219. /**
  97220. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97221. *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.
  97222. * The SPS is also a particle system. It provides some methods to manage the particles.
  97223. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97224. *
  97225. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97226. */
  97227. export class SolidParticleSystem implements IDisposable {
  97228. /**
  97229. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97230. * Example : var p = SPS.particles[i];
  97231. */
  97232. particles: SolidParticle[];
  97233. /**
  97234. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97235. */
  97236. nbParticles: number;
  97237. /**
  97238. * If the particles must ever face the camera (default false). Useful for planar particles.
  97239. */
  97240. billboard: boolean;
  97241. /**
  97242. * Recompute normals when adding a shape
  97243. */
  97244. recomputeNormals: boolean;
  97245. /**
  97246. * This a counter ofr your own usage. It's not set by any SPS functions.
  97247. */
  97248. counter: number;
  97249. /**
  97250. * The SPS name. This name is also given to the underlying mesh.
  97251. */
  97252. name: string;
  97253. /**
  97254. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97255. */
  97256. mesh: Mesh;
  97257. /**
  97258. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97259. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97260. */
  97261. vars: any;
  97262. /**
  97263. * This array is populated when the SPS is set as 'pickable'.
  97264. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97265. * Each element of this array is an object `{idx: int, faceId: int}`.
  97266. * `idx` is the picked particle index in the `SPS.particles` array
  97267. * `faceId` is the picked face index counted within this particle.
  97268. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97269. */
  97270. pickedParticles: {
  97271. idx: number;
  97272. faceId: number;
  97273. }[];
  97274. /**
  97275. * This array is populated when `enableDepthSort` is set to true.
  97276. * Each element of this array is an instance of the class DepthSortedParticle.
  97277. */
  97278. depthSortedParticles: DepthSortedParticle[];
  97279. /**
  97280. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97281. * @hidden
  97282. */
  97283. _bSphereOnly: boolean;
  97284. /**
  97285. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97286. * @hidden
  97287. */
  97288. _bSphereRadiusFactor: number;
  97289. private _scene;
  97290. private _positions;
  97291. private _indices;
  97292. private _normals;
  97293. private _colors;
  97294. private _uvs;
  97295. private _indices32;
  97296. private _positions32;
  97297. private _normals32;
  97298. private _fixedNormal32;
  97299. private _colors32;
  97300. private _uvs32;
  97301. private _index;
  97302. private _updatable;
  97303. private _pickable;
  97304. private _isVisibilityBoxLocked;
  97305. private _alwaysVisible;
  97306. private _depthSort;
  97307. private _expandable;
  97308. private _shapeCounter;
  97309. private _copy;
  97310. private _color;
  97311. private _computeParticleColor;
  97312. private _computeParticleTexture;
  97313. private _computeParticleRotation;
  97314. private _computeParticleVertex;
  97315. private _computeBoundingBox;
  97316. private _depthSortParticles;
  97317. private _camera;
  97318. private _mustUnrotateFixedNormals;
  97319. private _particlesIntersect;
  97320. private _needs32Bits;
  97321. private _isNotBuilt;
  97322. private _lastParticleId;
  97323. private _idxOfId;
  97324. private _multimaterialEnabled;
  97325. private _useModelMaterial;
  97326. private _indicesByMaterial;
  97327. private _materialIndexes;
  97328. private _depthSortFunction;
  97329. private _materialSortFunction;
  97330. private _materials;
  97331. private _multimaterial;
  97332. private _materialIndexesById;
  97333. private _defaultMaterial;
  97334. private _autoUpdateSubMeshes;
  97335. /**
  97336. * Creates a SPS (Solid Particle System) object.
  97337. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97338. * @param scene (Scene) is the scene in which the SPS is added.
  97339. * @param options defines the options of the sps e.g.
  97340. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97341. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97342. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97343. * * 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.
  97344. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97345. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97346. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97347. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97348. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97349. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97350. */
  97351. constructor(name: string, scene: Scene, options?: {
  97352. updatable?: boolean;
  97353. isPickable?: boolean;
  97354. enableDepthSort?: boolean;
  97355. particleIntersection?: boolean;
  97356. boundingSphereOnly?: boolean;
  97357. bSphereRadiusFactor?: number;
  97358. expandable?: boolean;
  97359. useModelMaterial?: boolean;
  97360. enableMultiMaterial?: boolean;
  97361. });
  97362. /**
  97363. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97364. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97365. * @returns the created mesh
  97366. */
  97367. buildMesh(): Mesh;
  97368. /**
  97369. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97370. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97371. * Thus the particles generated from `digest()` have their property `position` set yet.
  97372. * @param mesh ( Mesh ) is the mesh to be digested
  97373. * @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
  97374. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97375. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97376. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97377. * @returns the current SPS
  97378. */
  97379. digest(mesh: Mesh, options?: {
  97380. facetNb?: number;
  97381. number?: number;
  97382. delta?: number;
  97383. storage?: [];
  97384. }): SolidParticleSystem;
  97385. /**
  97386. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97387. * @hidden
  97388. */
  97389. private _unrotateFixedNormals;
  97390. /**
  97391. * Resets the temporary working copy particle
  97392. * @hidden
  97393. */
  97394. private _resetCopy;
  97395. /**
  97396. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97397. * @param p the current index in the positions array to be updated
  97398. * @param ind the current index in the indices array
  97399. * @param shape a Vector3 array, the shape geometry
  97400. * @param positions the positions array to be updated
  97401. * @param meshInd the shape indices array
  97402. * @param indices the indices array to be updated
  97403. * @param meshUV the shape uv array
  97404. * @param uvs the uv array to be updated
  97405. * @param meshCol the shape color array
  97406. * @param colors the color array to be updated
  97407. * @param meshNor the shape normals array
  97408. * @param normals the normals array to be updated
  97409. * @param idx the particle index
  97410. * @param idxInShape the particle index in its shape
  97411. * @param options the addShape() method passed options
  97412. * @model the particle model
  97413. * @hidden
  97414. */
  97415. private _meshBuilder;
  97416. /**
  97417. * Returns a shape Vector3 array from positions float array
  97418. * @param positions float array
  97419. * @returns a vector3 array
  97420. * @hidden
  97421. */
  97422. private _posToShape;
  97423. /**
  97424. * Returns a shapeUV array from a float uvs (array deep copy)
  97425. * @param uvs as a float array
  97426. * @returns a shapeUV array
  97427. * @hidden
  97428. */
  97429. private _uvsToShapeUV;
  97430. /**
  97431. * Adds a new particle object in the particles array
  97432. * @param idx particle index in particles array
  97433. * @param id particle id
  97434. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97435. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97436. * @param model particle ModelShape object
  97437. * @param shapeId model shape identifier
  97438. * @param idxInShape index of the particle in the current model
  97439. * @param bInfo model bounding info object
  97440. * @param storage target storage array, if any
  97441. * @hidden
  97442. */
  97443. private _addParticle;
  97444. /**
  97445. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97446. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97447. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97448. * @param nb (positive integer) the number of particles to be created from this model
  97449. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97450. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97451. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97452. * @returns the number of shapes in the system
  97453. */
  97454. addShape(mesh: Mesh, nb: number, options?: {
  97455. positionFunction?: any;
  97456. vertexFunction?: any;
  97457. storage?: [];
  97458. }): number;
  97459. /**
  97460. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97461. * @hidden
  97462. */
  97463. private _rebuildParticle;
  97464. /**
  97465. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97466. * @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.
  97467. * @returns the SPS.
  97468. */
  97469. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97470. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97471. * Returns an array with the removed particles.
  97472. * 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.
  97473. * The SPS can't be empty so at least one particle needs to remain in place.
  97474. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97475. * @param start index of the first particle to remove
  97476. * @param end index of the last particle to remove (included)
  97477. * @returns an array populated with the removed particles
  97478. */
  97479. removeParticles(start: number, end: number): SolidParticle[];
  97480. /**
  97481. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97482. * @param solidParticleArray an array populated with Solid Particles objects
  97483. * @returns the SPS
  97484. */
  97485. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97486. /**
  97487. * Creates a new particle and modifies the SPS mesh geometry :
  97488. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97489. * - calls _addParticle() to populate the particle array
  97490. * factorized code from addShape() and insertParticlesFromArray()
  97491. * @param idx particle index in the particles array
  97492. * @param i particle index in its shape
  97493. * @param modelShape particle ModelShape object
  97494. * @param shape shape vertex array
  97495. * @param meshInd shape indices array
  97496. * @param meshUV shape uv array
  97497. * @param meshCol shape color array
  97498. * @param meshNor shape normals array
  97499. * @param bbInfo shape bounding info
  97500. * @param storage target particle storage
  97501. * @options addShape() passed options
  97502. * @hidden
  97503. */
  97504. private _insertNewParticle;
  97505. /**
  97506. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97507. * This method calls `updateParticle()` for each particle of the SPS.
  97508. * For an animated SPS, it is usually called within the render loop.
  97509. * 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.
  97510. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97511. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97512. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97513. * @returns the SPS.
  97514. */
  97515. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97516. /**
  97517. * Disposes the SPS.
  97518. */
  97519. dispose(): void;
  97520. /**
  97521. * Returns a SolidParticle object from its identifier : particle.id
  97522. * @param id (integer) the particle Id
  97523. * @returns the searched particle or null if not found in the SPS.
  97524. */
  97525. getParticleById(id: number): Nullable<SolidParticle>;
  97526. /**
  97527. * Returns a new array populated with the particles having the passed shapeId.
  97528. * @param shapeId (integer) the shape identifier
  97529. * @returns a new solid particle array
  97530. */
  97531. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97532. /**
  97533. * Populates the passed array "ref" with the particles having the passed shapeId.
  97534. * @param shapeId the shape identifier
  97535. * @returns the SPS
  97536. * @param ref
  97537. */
  97538. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97539. /**
  97540. * Computes the required SubMeshes according the materials assigned to the particles.
  97541. * @returns the solid particle system.
  97542. * Does nothing if called before the SPS mesh is built.
  97543. */
  97544. computeSubMeshes(): SolidParticleSystem;
  97545. /**
  97546. * Sorts the solid particles by material when MultiMaterial is enabled.
  97547. * Updates the indices32 array.
  97548. * Updates the indicesByMaterial array.
  97549. * Updates the mesh indices array.
  97550. * @returns the SPS
  97551. * @hidden
  97552. */
  97553. private _sortParticlesByMaterial;
  97554. /**
  97555. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97556. * @hidden
  97557. */
  97558. private _setMaterialIndexesById;
  97559. /**
  97560. * Returns an array with unique values of Materials from the passed array
  97561. * @param array the material array to be checked and filtered
  97562. * @hidden
  97563. */
  97564. private _filterUniqueMaterialId;
  97565. /**
  97566. * Sets a new Standard Material as _defaultMaterial if not already set.
  97567. * @hidden
  97568. */
  97569. private _setDefaultMaterial;
  97570. /**
  97571. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97572. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97573. * @returns the SPS.
  97574. */
  97575. refreshVisibleSize(): SolidParticleSystem;
  97576. /**
  97577. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97578. * @param size the size (float) of the visibility box
  97579. * note : this doesn't lock the SPS mesh bounding box.
  97580. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97581. */
  97582. setVisibilityBox(size: number): void;
  97583. /**
  97584. * Gets whether the SPS as always visible or not
  97585. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97586. */
  97587. get isAlwaysVisible(): boolean;
  97588. /**
  97589. * Sets the SPS as always visible or not
  97590. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97591. */
  97592. set isAlwaysVisible(val: boolean);
  97593. /**
  97594. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97595. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97596. */
  97597. set isVisibilityBoxLocked(val: boolean);
  97598. /**
  97599. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97600. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97601. */
  97602. get isVisibilityBoxLocked(): boolean;
  97603. /**
  97604. * Tells to `setParticles()` to compute the particle rotations or not.
  97605. * Default value : true. The SPS is faster when it's set to false.
  97606. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97607. */
  97608. set computeParticleRotation(val: boolean);
  97609. /**
  97610. * Tells to `setParticles()` to compute the particle colors or not.
  97611. * Default value : true. The SPS is faster when it's set to false.
  97612. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97613. */
  97614. set computeParticleColor(val: boolean);
  97615. set computeParticleTexture(val: boolean);
  97616. /**
  97617. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97618. * Default value : false. The SPS is faster when it's set to false.
  97619. * Note : the particle custom vertex positions aren't stored values.
  97620. */
  97621. set computeParticleVertex(val: boolean);
  97622. /**
  97623. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97624. */
  97625. set computeBoundingBox(val: boolean);
  97626. /**
  97627. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97628. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97629. * Default : `true`
  97630. */
  97631. set depthSortParticles(val: boolean);
  97632. /**
  97633. * Gets if `setParticles()` computes the particle rotations or not.
  97634. * Default value : true. The SPS is faster when it's set to false.
  97635. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97636. */
  97637. get computeParticleRotation(): boolean;
  97638. /**
  97639. * Gets if `setParticles()` computes the particle colors or not.
  97640. * Default value : true. The SPS is faster when it's set to false.
  97641. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97642. */
  97643. get computeParticleColor(): boolean;
  97644. /**
  97645. * Gets if `setParticles()` computes the particle textures or not.
  97646. * Default value : true. The SPS is faster when it's set to false.
  97647. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97648. */
  97649. get computeParticleTexture(): boolean;
  97650. /**
  97651. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97652. * Default value : false. The SPS is faster when it's set to false.
  97653. * Note : the particle custom vertex positions aren't stored values.
  97654. */
  97655. get computeParticleVertex(): boolean;
  97656. /**
  97657. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97658. */
  97659. get computeBoundingBox(): boolean;
  97660. /**
  97661. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97662. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97663. * Default : `true`
  97664. */
  97665. get depthSortParticles(): boolean;
  97666. /**
  97667. * Gets if the SPS is created as expandable at construction time.
  97668. * Default : `false`
  97669. */
  97670. get expandable(): boolean;
  97671. /**
  97672. * Gets if the SPS supports the Multi Materials
  97673. */
  97674. get multimaterialEnabled(): boolean;
  97675. /**
  97676. * Gets if the SPS uses the model materials for its own multimaterial.
  97677. */
  97678. get useModelMaterial(): boolean;
  97679. /**
  97680. * The SPS used material array.
  97681. */
  97682. get materials(): Material[];
  97683. /**
  97684. * Sets the SPS MultiMaterial from the passed materials.
  97685. * Note : the passed array is internally copied and not used then by reference.
  97686. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97687. */
  97688. setMultiMaterial(materials: Material[]): void;
  97689. /**
  97690. * The SPS computed multimaterial object
  97691. */
  97692. get multimaterial(): MultiMaterial;
  97693. set multimaterial(mm: MultiMaterial);
  97694. /**
  97695. * If the subMeshes must be updated on the next call to setParticles()
  97696. */
  97697. get autoUpdateSubMeshes(): boolean;
  97698. set autoUpdateSubMeshes(val: boolean);
  97699. /**
  97700. * This function does nothing. It may be overwritten to set all the particle first values.
  97701. * The SPS doesn't call this function, you may have to call it by your own.
  97702. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97703. */
  97704. initParticles(): void;
  97705. /**
  97706. * This function does nothing. It may be overwritten to recycle a particle.
  97707. * The SPS doesn't call this function, you may have to call it by your own.
  97708. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97709. * @param particle The particle to recycle
  97710. * @returns the recycled particle
  97711. */
  97712. recycleParticle(particle: SolidParticle): SolidParticle;
  97713. /**
  97714. * Updates a particle : this function should be overwritten by the user.
  97715. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97716. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97717. * @example : just set a particle position or velocity and recycle conditions
  97718. * @param particle The particle to update
  97719. * @returns the updated particle
  97720. */
  97721. updateParticle(particle: SolidParticle): SolidParticle;
  97722. /**
  97723. * Updates a vertex of a particle : it can be overwritten by the user.
  97724. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97725. * @param particle the current particle
  97726. * @param vertex the current index of the current particle
  97727. * @param pt the index of the current vertex in the particle shape
  97728. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97729. * @example : just set a vertex particle position
  97730. * @returns the updated vertex
  97731. */
  97732. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97733. /**
  97734. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97735. * This does nothing and may be overwritten by the user.
  97736. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97737. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97738. * @param update the boolean update value actually passed to setParticles()
  97739. */
  97740. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97741. /**
  97742. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97743. * This will be passed three parameters.
  97744. * This does nothing and may be overwritten by the user.
  97745. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97746. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97747. * @param update the boolean update value actually passed to setParticles()
  97748. */
  97749. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97750. }
  97751. }
  97752. declare module BABYLON {
  97753. /**
  97754. * Represents one particle of a solid particle system.
  97755. */
  97756. export class SolidParticle {
  97757. /**
  97758. * particle global index
  97759. */
  97760. idx: number;
  97761. /**
  97762. * particle identifier
  97763. */
  97764. id: number;
  97765. /**
  97766. * The color of the particle
  97767. */
  97768. color: Nullable<Color4>;
  97769. /**
  97770. * The world space position of the particle.
  97771. */
  97772. position: Vector3;
  97773. /**
  97774. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97775. */
  97776. rotation: Vector3;
  97777. /**
  97778. * The world space rotation quaternion of the particle.
  97779. */
  97780. rotationQuaternion: Nullable<Quaternion>;
  97781. /**
  97782. * The scaling of the particle.
  97783. */
  97784. scaling: Vector3;
  97785. /**
  97786. * The uvs of the particle.
  97787. */
  97788. uvs: Vector4;
  97789. /**
  97790. * The current speed of the particle.
  97791. */
  97792. velocity: Vector3;
  97793. /**
  97794. * The pivot point in the particle local space.
  97795. */
  97796. pivot: Vector3;
  97797. /**
  97798. * Must the particle be translated from its pivot point in its local space ?
  97799. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97800. * Default : false
  97801. */
  97802. translateFromPivot: boolean;
  97803. /**
  97804. * Is the particle active or not ?
  97805. */
  97806. alive: boolean;
  97807. /**
  97808. * Is the particle visible or not ?
  97809. */
  97810. isVisible: boolean;
  97811. /**
  97812. * Index of this particle in the global "positions" array (Internal use)
  97813. * @hidden
  97814. */
  97815. _pos: number;
  97816. /**
  97817. * @hidden Index of this particle in the global "indices" array (Internal use)
  97818. */
  97819. _ind: number;
  97820. /**
  97821. * @hidden ModelShape of this particle (Internal use)
  97822. */
  97823. _model: ModelShape;
  97824. /**
  97825. * ModelShape id of this particle
  97826. */
  97827. shapeId: number;
  97828. /**
  97829. * Index of the particle in its shape id
  97830. */
  97831. idxInShape: number;
  97832. /**
  97833. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97834. */
  97835. _modelBoundingInfo: BoundingInfo;
  97836. /**
  97837. * @hidden Particle BoundingInfo object (Internal use)
  97838. */
  97839. _boundingInfo: BoundingInfo;
  97840. /**
  97841. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97842. */
  97843. _sps: SolidParticleSystem;
  97844. /**
  97845. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97846. */
  97847. _stillInvisible: boolean;
  97848. /**
  97849. * @hidden Last computed particle rotation matrix
  97850. */
  97851. _rotationMatrix: number[];
  97852. /**
  97853. * Parent particle Id, if any.
  97854. * Default null.
  97855. */
  97856. parentId: Nullable<number>;
  97857. /**
  97858. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97859. */
  97860. materialIndex: Nullable<number>;
  97861. /**
  97862. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97863. * The possible values are :
  97864. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97865. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97866. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97867. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97868. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97869. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97870. * */
  97871. cullingStrategy: number;
  97872. /**
  97873. * @hidden Internal global position in the SPS.
  97874. */
  97875. _globalPosition: Vector3;
  97876. /**
  97877. * Creates a Solid Particle object.
  97878. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97879. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97880. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97881. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97882. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97883. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97884. * @param shapeId (integer) is the model shape identifier in the SPS.
  97885. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97886. * @param sps defines the sps it is associated to
  97887. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97888. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97889. */
  97890. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97891. /**
  97892. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97893. * @param target the particle target
  97894. * @returns the current particle
  97895. */
  97896. copyToRef(target: SolidParticle): SolidParticle;
  97897. /**
  97898. * Legacy support, changed scale to scaling
  97899. */
  97900. get scale(): Vector3;
  97901. /**
  97902. * Legacy support, changed scale to scaling
  97903. */
  97904. set scale(scale: Vector3);
  97905. /**
  97906. * Legacy support, changed quaternion to rotationQuaternion
  97907. */
  97908. get quaternion(): Nullable<Quaternion>;
  97909. /**
  97910. * Legacy support, changed quaternion to rotationQuaternion
  97911. */
  97912. set quaternion(q: Nullable<Quaternion>);
  97913. /**
  97914. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  97915. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  97916. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  97917. * @returns true if it intersects
  97918. */
  97919. intersectsMesh(target: Mesh | SolidParticle): boolean;
  97920. /**
  97921. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  97922. * A particle is in the frustum if its bounding box intersects the frustum
  97923. * @param frustumPlanes defines the frustum to test
  97924. * @returns true if the particle is in the frustum planes
  97925. */
  97926. isInFrustum(frustumPlanes: Plane[]): boolean;
  97927. /**
  97928. * get the rotation matrix of the particle
  97929. * @hidden
  97930. */
  97931. getRotationMatrix(m: Matrix): void;
  97932. }
  97933. /**
  97934. * Represents the shape of the model used by one particle of a solid particle system.
  97935. * SPS internal tool, don't use it manually.
  97936. */
  97937. export class ModelShape {
  97938. /**
  97939. * The shape id
  97940. * @hidden
  97941. */
  97942. shapeID: number;
  97943. /**
  97944. * flat array of model positions (internal use)
  97945. * @hidden
  97946. */
  97947. _shape: Vector3[];
  97948. /**
  97949. * flat array of model UVs (internal use)
  97950. * @hidden
  97951. */
  97952. _shapeUV: number[];
  97953. /**
  97954. * color array of the model
  97955. * @hidden
  97956. */
  97957. _shapeColors: number[];
  97958. /**
  97959. * indices array of the model
  97960. * @hidden
  97961. */
  97962. _indices: number[];
  97963. /**
  97964. * normals array of the model
  97965. * @hidden
  97966. */
  97967. _normals: number[];
  97968. /**
  97969. * length of the shape in the model indices array (internal use)
  97970. * @hidden
  97971. */
  97972. _indicesLength: number;
  97973. /**
  97974. * Custom position function (internal use)
  97975. * @hidden
  97976. */
  97977. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  97978. /**
  97979. * Custom vertex function (internal use)
  97980. * @hidden
  97981. */
  97982. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  97983. /**
  97984. * Model material (internal use)
  97985. * @hidden
  97986. */
  97987. _material: Nullable<Material>;
  97988. /**
  97989. * 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.
  97990. * SPS internal tool, don't use it manually.
  97991. * @hidden
  97992. */
  97993. 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>);
  97994. }
  97995. /**
  97996. * Represents a Depth Sorted Particle in the solid particle system.
  97997. * @hidden
  97998. */
  97999. export class DepthSortedParticle {
  98000. /**
  98001. * Index of the particle in the "indices" array
  98002. */
  98003. ind: number;
  98004. /**
  98005. * Length of the particle shape in the "indices" array
  98006. */
  98007. indicesLength: number;
  98008. /**
  98009. * Squared distance from the particle to the camera
  98010. */
  98011. sqDistance: number;
  98012. /**
  98013. * Material index when used with MultiMaterials
  98014. */
  98015. materialIndex: number;
  98016. /**
  98017. * Creates a new sorted particle
  98018. * @param materialIndex
  98019. */
  98020. constructor(ind: number, indLength: number, materialIndex: number);
  98021. }
  98022. }
  98023. declare module BABYLON {
  98024. /**
  98025. * @hidden
  98026. */
  98027. export class _MeshCollisionData {
  98028. _checkCollisions: boolean;
  98029. _collisionMask: number;
  98030. _collisionGroup: number;
  98031. _collider: Nullable<Collider>;
  98032. _oldPositionForCollisions: Vector3;
  98033. _diffPositionForCollisions: Vector3;
  98034. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98035. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98036. }
  98037. }
  98038. declare module BABYLON {
  98039. /** @hidden */
  98040. class _FacetDataStorage {
  98041. facetPositions: Vector3[];
  98042. facetNormals: Vector3[];
  98043. facetPartitioning: number[][];
  98044. facetNb: number;
  98045. partitioningSubdivisions: number;
  98046. partitioningBBoxRatio: number;
  98047. facetDataEnabled: boolean;
  98048. facetParameters: any;
  98049. bbSize: Vector3;
  98050. subDiv: {
  98051. max: number;
  98052. X: number;
  98053. Y: number;
  98054. Z: number;
  98055. };
  98056. facetDepthSort: boolean;
  98057. facetDepthSortEnabled: boolean;
  98058. depthSortedIndices: IndicesArray;
  98059. depthSortedFacets: {
  98060. ind: number;
  98061. sqDistance: number;
  98062. }[];
  98063. facetDepthSortFunction: (f1: {
  98064. ind: number;
  98065. sqDistance: number;
  98066. }, f2: {
  98067. ind: number;
  98068. sqDistance: number;
  98069. }) => number;
  98070. facetDepthSortFrom: Vector3;
  98071. facetDepthSortOrigin: Vector3;
  98072. invertedMatrix: Matrix;
  98073. }
  98074. /**
  98075. * @hidden
  98076. **/
  98077. class _InternalAbstractMeshDataInfo {
  98078. _hasVertexAlpha: boolean;
  98079. _useVertexColors: boolean;
  98080. _numBoneInfluencers: number;
  98081. _applyFog: boolean;
  98082. _receiveShadows: boolean;
  98083. _facetData: _FacetDataStorage;
  98084. _visibility: number;
  98085. _skeleton: Nullable<Skeleton>;
  98086. _layerMask: number;
  98087. _computeBonesUsingShaders: boolean;
  98088. _isActive: boolean;
  98089. _onlyForInstances: boolean;
  98090. _isActiveIntermediate: boolean;
  98091. _onlyForInstancesIntermediate: boolean;
  98092. _actAsRegularMesh: boolean;
  98093. }
  98094. /**
  98095. * Class used to store all common mesh properties
  98096. */
  98097. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98098. /** No occlusion */
  98099. static OCCLUSION_TYPE_NONE: number;
  98100. /** Occlusion set to optimisitic */
  98101. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98102. /** Occlusion set to strict */
  98103. static OCCLUSION_TYPE_STRICT: number;
  98104. /** Use an accurante occlusion algorithm */
  98105. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98106. /** Use a conservative occlusion algorithm */
  98107. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98108. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98109. * Test order :
  98110. * Is the bounding sphere outside the frustum ?
  98111. * If not, are the bounding box vertices outside the frustum ?
  98112. * It not, then the cullable object is in the frustum.
  98113. */
  98114. static readonly CULLINGSTRATEGY_STANDARD: number;
  98115. /** Culling strategy : Bounding Sphere Only.
  98116. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98117. * It's also less accurate than the standard because some not visible objects can still be selected.
  98118. * Test : is the bounding sphere outside the frustum ?
  98119. * If not, then the cullable object is in the frustum.
  98120. */
  98121. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98122. /** Culling strategy : Optimistic Inclusion.
  98123. * This in an inclusion test first, then the standard exclusion test.
  98124. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98125. * 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.
  98126. * Anyway, it's as accurate as the standard strategy.
  98127. * Test :
  98128. * Is the cullable object bounding sphere center in the frustum ?
  98129. * If not, apply the default culling strategy.
  98130. */
  98131. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98132. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98133. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98134. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98135. * 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.
  98136. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98137. * Test :
  98138. * Is the cullable object bounding sphere center in the frustum ?
  98139. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98140. */
  98141. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98142. /**
  98143. * No billboard
  98144. */
  98145. static get BILLBOARDMODE_NONE(): number;
  98146. /** Billboard on X axis */
  98147. static get BILLBOARDMODE_X(): number;
  98148. /** Billboard on Y axis */
  98149. static get BILLBOARDMODE_Y(): number;
  98150. /** Billboard on Z axis */
  98151. static get BILLBOARDMODE_Z(): number;
  98152. /** Billboard on all axes */
  98153. static get BILLBOARDMODE_ALL(): number;
  98154. /** Billboard on using position instead of orientation */
  98155. static get BILLBOARDMODE_USE_POSITION(): number;
  98156. /** @hidden */
  98157. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98158. /**
  98159. * The culling strategy to use to check whether the mesh must be rendered or not.
  98160. * This value can be changed at any time and will be used on the next render mesh selection.
  98161. * The possible values are :
  98162. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98163. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98164. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98165. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98166. * Please read each static variable documentation to get details about the culling process.
  98167. * */
  98168. cullingStrategy: number;
  98169. /**
  98170. * Gets the number of facets in the mesh
  98171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98172. */
  98173. get facetNb(): number;
  98174. /**
  98175. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98177. */
  98178. get partitioningSubdivisions(): number;
  98179. set partitioningSubdivisions(nb: number);
  98180. /**
  98181. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98182. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98184. */
  98185. get partitioningBBoxRatio(): number;
  98186. set partitioningBBoxRatio(ratio: number);
  98187. /**
  98188. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98189. * Works only for updatable meshes.
  98190. * Doesn't work with multi-materials
  98191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98192. */
  98193. get mustDepthSortFacets(): boolean;
  98194. set mustDepthSortFacets(sort: boolean);
  98195. /**
  98196. * The location (Vector3) where the facet depth sort must be computed from.
  98197. * By default, the active camera position.
  98198. * Used only when facet depth sort is enabled
  98199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98200. */
  98201. get facetDepthSortFrom(): Vector3;
  98202. set facetDepthSortFrom(location: Vector3);
  98203. /**
  98204. * gets a boolean indicating if facetData is enabled
  98205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98206. */
  98207. get isFacetDataEnabled(): boolean;
  98208. /** @hidden */
  98209. _updateNonUniformScalingState(value: boolean): boolean;
  98210. /**
  98211. * An event triggered when this mesh collides with another one
  98212. */
  98213. onCollideObservable: Observable<AbstractMesh>;
  98214. /** Set a function to call when this mesh collides with another one */
  98215. set onCollide(callback: () => void);
  98216. /**
  98217. * An event triggered when the collision's position changes
  98218. */
  98219. onCollisionPositionChangeObservable: Observable<Vector3>;
  98220. /** Set a function to call when the collision's position changes */
  98221. set onCollisionPositionChange(callback: () => void);
  98222. /**
  98223. * An event triggered when material is changed
  98224. */
  98225. onMaterialChangedObservable: Observable<AbstractMesh>;
  98226. /**
  98227. * Gets or sets the orientation for POV movement & rotation
  98228. */
  98229. definedFacingForward: boolean;
  98230. /** @hidden */
  98231. _occlusionQuery: Nullable<WebGLQuery>;
  98232. /** @hidden */
  98233. _renderingGroup: Nullable<RenderingGroup>;
  98234. /**
  98235. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98236. */
  98237. get visibility(): number;
  98238. /**
  98239. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98240. */
  98241. set visibility(value: number);
  98242. /** Gets or sets the alpha index used to sort transparent meshes
  98243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98244. */
  98245. alphaIndex: number;
  98246. /**
  98247. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98248. */
  98249. isVisible: boolean;
  98250. /**
  98251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98252. */
  98253. isPickable: boolean;
  98254. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98255. showSubMeshesBoundingBox: boolean;
  98256. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98258. */
  98259. isBlocker: boolean;
  98260. /**
  98261. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98262. */
  98263. enablePointerMoveEvents: boolean;
  98264. /**
  98265. * Specifies the rendering group id for this mesh (0 by default)
  98266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98267. */
  98268. renderingGroupId: number;
  98269. private _material;
  98270. /** Gets or sets current material */
  98271. get material(): Nullable<Material>;
  98272. set material(value: Nullable<Material>);
  98273. /**
  98274. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98275. * @see http://doc.babylonjs.com/babylon101/shadows
  98276. */
  98277. get receiveShadows(): boolean;
  98278. set receiveShadows(value: boolean);
  98279. /** Defines color to use when rendering outline */
  98280. outlineColor: Color3;
  98281. /** Define width to use when rendering outline */
  98282. outlineWidth: number;
  98283. /** Defines color to use when rendering overlay */
  98284. overlayColor: Color3;
  98285. /** Defines alpha to use when rendering overlay */
  98286. overlayAlpha: number;
  98287. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98288. get hasVertexAlpha(): boolean;
  98289. set hasVertexAlpha(value: boolean);
  98290. /** 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) */
  98291. get useVertexColors(): boolean;
  98292. set useVertexColors(value: boolean);
  98293. /**
  98294. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98295. */
  98296. get computeBonesUsingShaders(): boolean;
  98297. set computeBonesUsingShaders(value: boolean);
  98298. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98299. get numBoneInfluencers(): number;
  98300. set numBoneInfluencers(value: number);
  98301. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98302. get applyFog(): boolean;
  98303. set applyFog(value: boolean);
  98304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98305. useOctreeForRenderingSelection: boolean;
  98306. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98307. useOctreeForPicking: boolean;
  98308. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98309. useOctreeForCollisions: boolean;
  98310. /**
  98311. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98312. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98313. */
  98314. get layerMask(): number;
  98315. set layerMask(value: number);
  98316. /**
  98317. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98318. */
  98319. alwaysSelectAsActiveMesh: boolean;
  98320. /**
  98321. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98322. */
  98323. doNotSyncBoundingInfo: boolean;
  98324. /**
  98325. * Gets or sets the current action manager
  98326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98327. */
  98328. actionManager: Nullable<AbstractActionManager>;
  98329. private _meshCollisionData;
  98330. /**
  98331. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98333. */
  98334. ellipsoid: Vector3;
  98335. /**
  98336. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98337. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98338. */
  98339. ellipsoidOffset: Vector3;
  98340. /**
  98341. * Gets or sets a collision mask used to mask collisions (default is -1).
  98342. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98343. */
  98344. get collisionMask(): number;
  98345. set collisionMask(mask: number);
  98346. /**
  98347. * Gets or sets the current collision group mask (-1 by default).
  98348. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98349. */
  98350. get collisionGroup(): number;
  98351. set collisionGroup(mask: number);
  98352. /**
  98353. * Defines edge width used when edgesRenderer is enabled
  98354. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98355. */
  98356. edgesWidth: number;
  98357. /**
  98358. * Defines edge color used when edgesRenderer is enabled
  98359. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98360. */
  98361. edgesColor: Color4;
  98362. /** @hidden */
  98363. _edgesRenderer: Nullable<IEdgesRenderer>;
  98364. /** @hidden */
  98365. _masterMesh: Nullable<AbstractMesh>;
  98366. /** @hidden */
  98367. _boundingInfo: Nullable<BoundingInfo>;
  98368. /** @hidden */
  98369. _renderId: number;
  98370. /**
  98371. * Gets or sets the list of subMeshes
  98372. * @see http://doc.babylonjs.com/how_to/multi_materials
  98373. */
  98374. subMeshes: SubMesh[];
  98375. /** @hidden */
  98376. _intersectionsInProgress: AbstractMesh[];
  98377. /** @hidden */
  98378. _unIndexed: boolean;
  98379. /** @hidden */
  98380. _lightSources: Light[];
  98381. /** Gets the list of lights affecting that mesh */
  98382. get lightSources(): Light[];
  98383. /** @hidden */
  98384. get _positions(): Nullable<Vector3[]>;
  98385. /** @hidden */
  98386. _waitingData: {
  98387. lods: Nullable<any>;
  98388. actions: Nullable<any>;
  98389. freezeWorldMatrix: Nullable<boolean>;
  98390. };
  98391. /** @hidden */
  98392. _bonesTransformMatrices: Nullable<Float32Array>;
  98393. /** @hidden */
  98394. _transformMatrixTexture: Nullable<RawTexture>;
  98395. /**
  98396. * Gets or sets a skeleton to apply skining transformations
  98397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98398. */
  98399. set skeleton(value: Nullable<Skeleton>);
  98400. get skeleton(): Nullable<Skeleton>;
  98401. /**
  98402. * An event triggered when the mesh is rebuilt.
  98403. */
  98404. onRebuildObservable: Observable<AbstractMesh>;
  98405. /**
  98406. * Creates a new AbstractMesh
  98407. * @param name defines the name of the mesh
  98408. * @param scene defines the hosting scene
  98409. */
  98410. constructor(name: string, scene?: Nullable<Scene>);
  98411. /**
  98412. * Returns the string "AbstractMesh"
  98413. * @returns "AbstractMesh"
  98414. */
  98415. getClassName(): string;
  98416. /**
  98417. * Gets a string representation of the current mesh
  98418. * @param fullDetails defines a boolean indicating if full details must be included
  98419. * @returns a string representation of the current mesh
  98420. */
  98421. toString(fullDetails?: boolean): string;
  98422. /**
  98423. * @hidden
  98424. */
  98425. protected _getEffectiveParent(): Nullable<Node>;
  98426. /** @hidden */
  98427. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98428. /** @hidden */
  98429. _rebuild(): void;
  98430. /** @hidden */
  98431. _resyncLightSources(): void;
  98432. /** @hidden */
  98433. _resyncLightSource(light: Light): void;
  98434. /** @hidden */
  98435. _unBindEffect(): void;
  98436. /** @hidden */
  98437. _removeLightSource(light: Light, dispose: boolean): void;
  98438. private _markSubMeshesAsDirty;
  98439. /** @hidden */
  98440. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98441. /** @hidden */
  98442. _markSubMeshesAsAttributesDirty(): void;
  98443. /** @hidden */
  98444. _markSubMeshesAsMiscDirty(): void;
  98445. /**
  98446. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98447. */
  98448. get scaling(): Vector3;
  98449. set scaling(newScaling: Vector3);
  98450. /**
  98451. * Returns true if the mesh is blocked. Implemented by child classes
  98452. */
  98453. get isBlocked(): boolean;
  98454. /**
  98455. * Returns the mesh itself by default. Implemented by child classes
  98456. * @param camera defines the camera to use to pick the right LOD level
  98457. * @returns the currentAbstractMesh
  98458. */
  98459. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98460. /**
  98461. * Returns 0 by default. Implemented by child classes
  98462. * @returns an integer
  98463. */
  98464. getTotalVertices(): number;
  98465. /**
  98466. * Returns a positive integer : the total number of indices in this mesh geometry.
  98467. * @returns the numner of indices or zero if the mesh has no geometry.
  98468. */
  98469. getTotalIndices(): number;
  98470. /**
  98471. * Returns null by default. Implemented by child classes
  98472. * @returns null
  98473. */
  98474. getIndices(): Nullable<IndicesArray>;
  98475. /**
  98476. * Returns the array of the requested vertex data kind. Implemented by child classes
  98477. * @param kind defines the vertex data kind to use
  98478. * @returns null
  98479. */
  98480. getVerticesData(kind: string): Nullable<FloatArray>;
  98481. /**
  98482. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98483. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98484. * Note that a new underlying VertexBuffer object is created each call.
  98485. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98486. * @param kind defines vertex data kind:
  98487. * * VertexBuffer.PositionKind
  98488. * * VertexBuffer.UVKind
  98489. * * VertexBuffer.UV2Kind
  98490. * * VertexBuffer.UV3Kind
  98491. * * VertexBuffer.UV4Kind
  98492. * * VertexBuffer.UV5Kind
  98493. * * VertexBuffer.UV6Kind
  98494. * * VertexBuffer.ColorKind
  98495. * * VertexBuffer.MatricesIndicesKind
  98496. * * VertexBuffer.MatricesIndicesExtraKind
  98497. * * VertexBuffer.MatricesWeightsKind
  98498. * * VertexBuffer.MatricesWeightsExtraKind
  98499. * @param data defines the data source
  98500. * @param updatable defines if the data must be flagged as updatable (or static)
  98501. * @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
  98502. * @returns the current mesh
  98503. */
  98504. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98505. /**
  98506. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98507. * If the mesh has no geometry, it is simply returned as it is.
  98508. * @param kind defines vertex data kind:
  98509. * * VertexBuffer.PositionKind
  98510. * * VertexBuffer.UVKind
  98511. * * VertexBuffer.UV2Kind
  98512. * * VertexBuffer.UV3Kind
  98513. * * VertexBuffer.UV4Kind
  98514. * * VertexBuffer.UV5Kind
  98515. * * VertexBuffer.UV6Kind
  98516. * * VertexBuffer.ColorKind
  98517. * * VertexBuffer.MatricesIndicesKind
  98518. * * VertexBuffer.MatricesIndicesExtraKind
  98519. * * VertexBuffer.MatricesWeightsKind
  98520. * * VertexBuffer.MatricesWeightsExtraKind
  98521. * @param data defines the data source
  98522. * @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
  98523. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98524. * @returns the current mesh
  98525. */
  98526. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98527. /**
  98528. * Sets the mesh indices,
  98529. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98530. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98531. * @param totalVertices Defines the total number of vertices
  98532. * @returns the current mesh
  98533. */
  98534. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98535. /**
  98536. * Gets a boolean indicating if specific vertex data is present
  98537. * @param kind defines the vertex data kind to use
  98538. * @returns true is data kind is present
  98539. */
  98540. isVerticesDataPresent(kind: string): boolean;
  98541. /**
  98542. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98543. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98544. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98545. * @returns a BoundingInfo
  98546. */
  98547. getBoundingInfo(): BoundingInfo;
  98548. /**
  98549. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98550. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98551. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98552. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98553. * @returns the current mesh
  98554. */
  98555. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98556. /**
  98557. * Overwrite the current bounding info
  98558. * @param boundingInfo defines the new bounding info
  98559. * @returns the current mesh
  98560. */
  98561. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98562. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98563. get useBones(): boolean;
  98564. /** @hidden */
  98565. _preActivate(): void;
  98566. /** @hidden */
  98567. _preActivateForIntermediateRendering(renderId: number): void;
  98568. /** @hidden */
  98569. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98570. /** @hidden */
  98571. _postActivate(): void;
  98572. /** @hidden */
  98573. _freeze(): void;
  98574. /** @hidden */
  98575. _unFreeze(): void;
  98576. /**
  98577. * Gets the current world matrix
  98578. * @returns a Matrix
  98579. */
  98580. getWorldMatrix(): Matrix;
  98581. /** @hidden */
  98582. _getWorldMatrixDeterminant(): number;
  98583. /**
  98584. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98585. */
  98586. get isAnInstance(): boolean;
  98587. /**
  98588. * Gets a boolean indicating if this mesh has instances
  98589. */
  98590. get hasInstances(): boolean;
  98591. /**
  98592. * Perform relative position change from the point of view of behind the front of the mesh.
  98593. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98594. * Supports definition of mesh facing forward or backward
  98595. * @param amountRight defines the distance on the right axis
  98596. * @param amountUp defines the distance on the up axis
  98597. * @param amountForward defines the distance on the forward axis
  98598. * @returns the current mesh
  98599. */
  98600. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98601. /**
  98602. * Calculate relative position change from the point of view of behind the front of the mesh.
  98603. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98604. * Supports definition of mesh facing forward or backward
  98605. * @param amountRight defines the distance on the right axis
  98606. * @param amountUp defines the distance on the up axis
  98607. * @param amountForward defines the distance on the forward axis
  98608. * @returns the new displacement vector
  98609. */
  98610. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98611. /**
  98612. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98613. * Supports definition of mesh facing forward or backward
  98614. * @param flipBack defines the flip
  98615. * @param twirlClockwise defines the twirl
  98616. * @param tiltRight defines the tilt
  98617. * @returns the current mesh
  98618. */
  98619. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98620. /**
  98621. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98622. * Supports definition of mesh facing forward or backward.
  98623. * @param flipBack defines the flip
  98624. * @param twirlClockwise defines the twirl
  98625. * @param tiltRight defines the tilt
  98626. * @returns the new rotation vector
  98627. */
  98628. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98629. /**
  98630. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98631. * This means the mesh underlying bounding box and sphere are recomputed.
  98632. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98633. * @returns the current mesh
  98634. */
  98635. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98636. /** @hidden */
  98637. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98638. /** @hidden */
  98639. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98640. /** @hidden */
  98641. _updateBoundingInfo(): AbstractMesh;
  98642. /** @hidden */
  98643. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98644. /** @hidden */
  98645. protected _afterComputeWorldMatrix(): void;
  98646. /** @hidden */
  98647. get _effectiveMesh(): AbstractMesh;
  98648. /**
  98649. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98650. * A mesh is in the frustum if its bounding box intersects the frustum
  98651. * @param frustumPlanes defines the frustum to test
  98652. * @returns true if the mesh is in the frustum planes
  98653. */
  98654. isInFrustum(frustumPlanes: Plane[]): boolean;
  98655. /**
  98656. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98657. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98658. * @param frustumPlanes defines the frustum to test
  98659. * @returns true if the mesh is completely in the frustum planes
  98660. */
  98661. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98662. /**
  98663. * True if the mesh intersects another mesh or a SolidParticle object
  98664. * @param mesh defines a target mesh or SolidParticle to test
  98665. * @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)
  98666. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98667. * @returns true if there is an intersection
  98668. */
  98669. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98670. /**
  98671. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98672. * @param point defines the point to test
  98673. * @returns true if there is an intersection
  98674. */
  98675. intersectsPoint(point: Vector3): boolean;
  98676. /**
  98677. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98679. */
  98680. get checkCollisions(): boolean;
  98681. set checkCollisions(collisionEnabled: boolean);
  98682. /**
  98683. * Gets Collider object used to compute collisions (not physics)
  98684. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98685. */
  98686. get collider(): Nullable<Collider>;
  98687. /**
  98688. * Move the mesh using collision engine
  98689. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98690. * @param displacement defines the requested displacement vector
  98691. * @returns the current mesh
  98692. */
  98693. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98694. private _onCollisionPositionChange;
  98695. /** @hidden */
  98696. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98697. /** @hidden */
  98698. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98699. /** @hidden */
  98700. _checkCollision(collider: Collider): AbstractMesh;
  98701. /** @hidden */
  98702. _generatePointsArray(): boolean;
  98703. /**
  98704. * Checks if the passed Ray intersects with the mesh
  98705. * @param ray defines the ray to use
  98706. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98707. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98708. * @returns the picking info
  98709. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98710. */
  98711. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98712. /**
  98713. * Clones the current mesh
  98714. * @param name defines the mesh name
  98715. * @param newParent defines the new mesh parent
  98716. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98717. * @returns the new mesh
  98718. */
  98719. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98720. /**
  98721. * Disposes all the submeshes of the current meshnp
  98722. * @returns the current mesh
  98723. */
  98724. releaseSubMeshes(): AbstractMesh;
  98725. /**
  98726. * Releases resources associated with this abstract mesh.
  98727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98729. */
  98730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98731. /**
  98732. * Adds the passed mesh as a child to the current mesh
  98733. * @param mesh defines the child mesh
  98734. * @returns the current mesh
  98735. */
  98736. addChild(mesh: AbstractMesh): AbstractMesh;
  98737. /**
  98738. * Removes the passed mesh from the current mesh children list
  98739. * @param mesh defines the child mesh
  98740. * @returns the current mesh
  98741. */
  98742. removeChild(mesh: AbstractMesh): AbstractMesh;
  98743. /** @hidden */
  98744. private _initFacetData;
  98745. /**
  98746. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98747. * This method can be called within the render loop.
  98748. * 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
  98749. * @returns the current mesh
  98750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98751. */
  98752. updateFacetData(): AbstractMesh;
  98753. /**
  98754. * Returns the facetLocalNormals array.
  98755. * The normals are expressed in the mesh local spac
  98756. * @returns an array of Vector3
  98757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98758. */
  98759. getFacetLocalNormals(): Vector3[];
  98760. /**
  98761. * Returns the facetLocalPositions array.
  98762. * The facet positions are expressed in the mesh local space
  98763. * @returns an array of Vector3
  98764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98765. */
  98766. getFacetLocalPositions(): Vector3[];
  98767. /**
  98768. * Returns the facetLocalPartioning array
  98769. * @returns an array of array of numbers
  98770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98771. */
  98772. getFacetLocalPartitioning(): number[][];
  98773. /**
  98774. * Returns the i-th facet position in the world system.
  98775. * This method allocates a new Vector3 per call
  98776. * @param i defines the facet index
  98777. * @returns a new Vector3
  98778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98779. */
  98780. getFacetPosition(i: number): Vector3;
  98781. /**
  98782. * Sets the reference Vector3 with the i-th facet position in the world system
  98783. * @param i defines the facet index
  98784. * @param ref defines the target vector
  98785. * @returns the current mesh
  98786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98787. */
  98788. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98789. /**
  98790. * Returns the i-th facet normal in the world system.
  98791. * This method allocates a new Vector3 per call
  98792. * @param i defines the facet index
  98793. * @returns a new Vector3
  98794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98795. */
  98796. getFacetNormal(i: number): Vector3;
  98797. /**
  98798. * Sets the reference Vector3 with the i-th facet normal in the world system
  98799. * @param i defines the facet index
  98800. * @param ref defines the target vector
  98801. * @returns the current mesh
  98802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98803. */
  98804. getFacetNormalToRef(i: number, ref: Vector3): this;
  98805. /**
  98806. * 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)
  98807. * @param x defines x coordinate
  98808. * @param y defines y coordinate
  98809. * @param z defines z coordinate
  98810. * @returns the array of facet indexes
  98811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98812. */
  98813. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98814. /**
  98815. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98816. * @param projected sets as the (x,y,z) world projection on the facet
  98817. * @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
  98818. * @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
  98819. * @param x defines x coordinate
  98820. * @param y defines y coordinate
  98821. * @param z defines z coordinate
  98822. * @returns the face index if found (or null instead)
  98823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98824. */
  98825. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98826. /**
  98827. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98828. * @param projected sets as the (x,y,z) local projection on the facet
  98829. * @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
  98830. * @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
  98831. * @param x defines x coordinate
  98832. * @param y defines y coordinate
  98833. * @param z defines z coordinate
  98834. * @returns the face index if found (or null instead)
  98835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98836. */
  98837. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98838. /**
  98839. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98840. * @returns the parameters
  98841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98842. */
  98843. getFacetDataParameters(): any;
  98844. /**
  98845. * Disables the feature FacetData and frees the related memory
  98846. * @returns the current mesh
  98847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98848. */
  98849. disableFacetData(): AbstractMesh;
  98850. /**
  98851. * Updates the AbstractMesh indices array
  98852. * @param indices defines the data source
  98853. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98854. * @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)
  98855. * @returns the current mesh
  98856. */
  98857. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98858. /**
  98859. * Creates new normals data for the mesh
  98860. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98861. * @returns the current mesh
  98862. */
  98863. createNormals(updatable: boolean): AbstractMesh;
  98864. /**
  98865. * Align the mesh with a normal
  98866. * @param normal defines the normal to use
  98867. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98868. * @returns the current mesh
  98869. */
  98870. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98871. /** @hidden */
  98872. _checkOcclusionQuery(): boolean;
  98873. /**
  98874. * Disables the mesh edge rendering mode
  98875. * @returns the currentAbstractMesh
  98876. */
  98877. disableEdgesRendering(): AbstractMesh;
  98878. /**
  98879. * Enables the edge rendering mode on the mesh.
  98880. * This mode makes the mesh edges visible
  98881. * @param epsilon defines the maximal distance between two angles to detect a face
  98882. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98883. * @returns the currentAbstractMesh
  98884. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98885. */
  98886. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98887. }
  98888. }
  98889. declare module BABYLON {
  98890. /**
  98891. * Interface used to define ActionEvent
  98892. */
  98893. export interface IActionEvent {
  98894. /** The mesh or sprite that triggered the action */
  98895. source: any;
  98896. /** The X mouse cursor position at the time of the event */
  98897. pointerX: number;
  98898. /** The Y mouse cursor position at the time of the event */
  98899. pointerY: number;
  98900. /** The mesh that is currently pointed at (can be null) */
  98901. meshUnderPointer: Nullable<AbstractMesh>;
  98902. /** the original (browser) event that triggered the ActionEvent */
  98903. sourceEvent?: any;
  98904. /** additional data for the event */
  98905. additionalData?: any;
  98906. }
  98907. /**
  98908. * ActionEvent is the event being sent when an action is triggered.
  98909. */
  98910. export class ActionEvent implements IActionEvent {
  98911. /** The mesh or sprite that triggered the action */
  98912. source: any;
  98913. /** The X mouse cursor position at the time of the event */
  98914. pointerX: number;
  98915. /** The Y mouse cursor position at the time of the event */
  98916. pointerY: number;
  98917. /** The mesh that is currently pointed at (can be null) */
  98918. meshUnderPointer: Nullable<AbstractMesh>;
  98919. /** the original (browser) event that triggered the ActionEvent */
  98920. sourceEvent?: any;
  98921. /** additional data for the event */
  98922. additionalData?: any;
  98923. /**
  98924. * Creates a new ActionEvent
  98925. * @param source The mesh or sprite that triggered the action
  98926. * @param pointerX The X mouse cursor position at the time of the event
  98927. * @param pointerY The Y mouse cursor position at the time of the event
  98928. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  98929. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  98930. * @param additionalData additional data for the event
  98931. */
  98932. constructor(
  98933. /** The mesh or sprite that triggered the action */
  98934. source: any,
  98935. /** The X mouse cursor position at the time of the event */
  98936. pointerX: number,
  98937. /** The Y mouse cursor position at the time of the event */
  98938. pointerY: number,
  98939. /** The mesh that is currently pointed at (can be null) */
  98940. meshUnderPointer: Nullable<AbstractMesh>,
  98941. /** the original (browser) event that triggered the ActionEvent */
  98942. sourceEvent?: any,
  98943. /** additional data for the event */
  98944. additionalData?: any);
  98945. /**
  98946. * Helper function to auto-create an ActionEvent from a source mesh.
  98947. * @param source The source mesh that triggered the event
  98948. * @param evt The original (browser) event
  98949. * @param additionalData additional data for the event
  98950. * @returns the new ActionEvent
  98951. */
  98952. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  98953. /**
  98954. * Helper function to auto-create an ActionEvent from a source sprite
  98955. * @param source The source sprite that triggered the event
  98956. * @param scene Scene associated with the sprite
  98957. * @param evt The original (browser) event
  98958. * @param additionalData additional data for the event
  98959. * @returns the new ActionEvent
  98960. */
  98961. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  98962. /**
  98963. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  98964. * @param scene the scene where the event occurred
  98965. * @param evt The original (browser) event
  98966. * @returns the new ActionEvent
  98967. */
  98968. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  98969. /**
  98970. * Helper function to auto-create an ActionEvent from a primitive
  98971. * @param prim defines the target primitive
  98972. * @param pointerPos defines the pointer position
  98973. * @param evt The original (browser) event
  98974. * @param additionalData additional data for the event
  98975. * @returns the new ActionEvent
  98976. */
  98977. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  98978. }
  98979. }
  98980. declare module BABYLON {
  98981. /**
  98982. * Abstract class used to decouple action Manager from scene and meshes.
  98983. * Do not instantiate.
  98984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98985. */
  98986. export abstract class AbstractActionManager implements IDisposable {
  98987. /** Gets the list of active triggers */
  98988. static Triggers: {
  98989. [key: string]: number;
  98990. };
  98991. /** Gets the cursor to use when hovering items */
  98992. hoverCursor: string;
  98993. /** Gets the list of actions */
  98994. actions: IAction[];
  98995. /**
  98996. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  98997. */
  98998. isRecursive: boolean;
  98999. /**
  99000. * Releases all associated resources
  99001. */
  99002. abstract dispose(): void;
  99003. /**
  99004. * Does this action manager has pointer triggers
  99005. */
  99006. abstract get hasPointerTriggers(): boolean;
  99007. /**
  99008. * Does this action manager has pick triggers
  99009. */
  99010. abstract get hasPickTriggers(): boolean;
  99011. /**
  99012. * Process a specific trigger
  99013. * @param trigger defines the trigger to process
  99014. * @param evt defines the event details to be processed
  99015. */
  99016. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99017. /**
  99018. * Does this action manager handles actions of any of the given triggers
  99019. * @param triggers defines the triggers to be tested
  99020. * @return a boolean indicating whether one (or more) of the triggers is handled
  99021. */
  99022. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99023. /**
  99024. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99025. * speed.
  99026. * @param triggerA defines the trigger to be tested
  99027. * @param triggerB defines the trigger to be tested
  99028. * @return a boolean indicating whether one (or more) of the triggers is handled
  99029. */
  99030. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99031. /**
  99032. * Does this action manager handles actions of a given trigger
  99033. * @param trigger defines the trigger to be tested
  99034. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99035. * @return whether the trigger is handled
  99036. */
  99037. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99038. /**
  99039. * Serialize this manager to a JSON object
  99040. * @param name defines the property name to store this manager
  99041. * @returns a JSON representation of this manager
  99042. */
  99043. abstract serialize(name: string): any;
  99044. /**
  99045. * Registers an action to this action manager
  99046. * @param action defines the action to be registered
  99047. * @return the action amended (prepared) after registration
  99048. */
  99049. abstract registerAction(action: IAction): Nullable<IAction>;
  99050. /**
  99051. * Unregisters an action to this action manager
  99052. * @param action defines the action to be unregistered
  99053. * @return a boolean indicating whether the action has been unregistered
  99054. */
  99055. abstract unregisterAction(action: IAction): Boolean;
  99056. /**
  99057. * Does exist one action manager with at least one trigger
  99058. **/
  99059. static get HasTriggers(): boolean;
  99060. /**
  99061. * Does exist one action manager with at least one pick trigger
  99062. **/
  99063. static get HasPickTriggers(): boolean;
  99064. /**
  99065. * Does exist one action manager that handles actions of a given trigger
  99066. * @param trigger defines the trigger to be tested
  99067. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99068. **/
  99069. static HasSpecificTrigger(trigger: number): boolean;
  99070. }
  99071. }
  99072. declare module BABYLON {
  99073. /**
  99074. * Defines how a node can be built from a string name.
  99075. */
  99076. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99077. /**
  99078. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99079. */
  99080. export class Node implements IBehaviorAware<Node> {
  99081. /** @hidden */
  99082. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99083. private static _NodeConstructors;
  99084. /**
  99085. * Add a new node constructor
  99086. * @param type defines the type name of the node to construct
  99087. * @param constructorFunc defines the constructor function
  99088. */
  99089. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99090. /**
  99091. * Returns a node constructor based on type name
  99092. * @param type defines the type name
  99093. * @param name defines the new node name
  99094. * @param scene defines the hosting scene
  99095. * @param options defines optional options to transmit to constructors
  99096. * @returns the new constructor or null
  99097. */
  99098. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99099. /**
  99100. * Gets or sets the name of the node
  99101. */
  99102. name: string;
  99103. /**
  99104. * Gets or sets the id of the node
  99105. */
  99106. id: string;
  99107. /**
  99108. * Gets or sets the unique id of the node
  99109. */
  99110. uniqueId: number;
  99111. /**
  99112. * Gets or sets a string used to store user defined state for the node
  99113. */
  99114. state: string;
  99115. /**
  99116. * Gets or sets an object used to store user defined information for the node
  99117. */
  99118. metadata: any;
  99119. /**
  99120. * For internal use only. Please do not use.
  99121. */
  99122. reservedDataStore: any;
  99123. /**
  99124. * List of inspectable custom properties (used by the Inspector)
  99125. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99126. */
  99127. inspectableCustomProperties: IInspectable[];
  99128. private _doNotSerialize;
  99129. /**
  99130. * Gets or sets a boolean used to define if the node must be serialized
  99131. */
  99132. get doNotSerialize(): boolean;
  99133. set doNotSerialize(value: boolean);
  99134. /** @hidden */
  99135. _isDisposed: boolean;
  99136. /**
  99137. * Gets a list of Animations associated with the node
  99138. */
  99139. animations: Animation[];
  99140. protected _ranges: {
  99141. [name: string]: Nullable<AnimationRange>;
  99142. };
  99143. /**
  99144. * Callback raised when the node is ready to be used
  99145. */
  99146. onReady: Nullable<(node: Node) => void>;
  99147. private _isEnabled;
  99148. private _isParentEnabled;
  99149. private _isReady;
  99150. /** @hidden */
  99151. _currentRenderId: number;
  99152. private _parentUpdateId;
  99153. /** @hidden */
  99154. _childUpdateId: number;
  99155. /** @hidden */
  99156. _waitingParentId: Nullable<string>;
  99157. /** @hidden */
  99158. _scene: Scene;
  99159. /** @hidden */
  99160. _cache: any;
  99161. private _parentNode;
  99162. private _children;
  99163. /** @hidden */
  99164. _worldMatrix: Matrix;
  99165. /** @hidden */
  99166. _worldMatrixDeterminant: number;
  99167. /** @hidden */
  99168. _worldMatrixDeterminantIsDirty: boolean;
  99169. /** @hidden */
  99170. private _sceneRootNodesIndex;
  99171. /**
  99172. * Gets a boolean indicating if the node has been disposed
  99173. * @returns true if the node was disposed
  99174. */
  99175. isDisposed(): boolean;
  99176. /**
  99177. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99178. * @see https://doc.babylonjs.com/how_to/parenting
  99179. */
  99180. set parent(parent: Nullable<Node>);
  99181. get parent(): Nullable<Node>;
  99182. /** @hidden */
  99183. _addToSceneRootNodes(): void;
  99184. /** @hidden */
  99185. _removeFromSceneRootNodes(): void;
  99186. private _animationPropertiesOverride;
  99187. /**
  99188. * Gets or sets the animation properties override
  99189. */
  99190. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99191. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99192. /**
  99193. * Gets a string idenfifying the name of the class
  99194. * @returns "Node" string
  99195. */
  99196. getClassName(): string;
  99197. /** @hidden */
  99198. readonly _isNode: boolean;
  99199. /**
  99200. * An event triggered when the mesh is disposed
  99201. */
  99202. onDisposeObservable: Observable<Node>;
  99203. private _onDisposeObserver;
  99204. /**
  99205. * Sets a callback that will be raised when the node will be disposed
  99206. */
  99207. set onDispose(callback: () => void);
  99208. /**
  99209. * Creates a new Node
  99210. * @param name the name and id to be given to this node
  99211. * @param scene the scene this node will be added to
  99212. */
  99213. constructor(name: string, scene?: Nullable<Scene>);
  99214. /**
  99215. * Gets the scene of the node
  99216. * @returns a scene
  99217. */
  99218. getScene(): Scene;
  99219. /**
  99220. * Gets the engine of the node
  99221. * @returns a Engine
  99222. */
  99223. getEngine(): Engine;
  99224. private _behaviors;
  99225. /**
  99226. * Attach a behavior to the node
  99227. * @see http://doc.babylonjs.com/features/behaviour
  99228. * @param behavior defines the behavior to attach
  99229. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99230. * @returns the current Node
  99231. */
  99232. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99233. /**
  99234. * Remove an attached behavior
  99235. * @see http://doc.babylonjs.com/features/behaviour
  99236. * @param behavior defines the behavior to attach
  99237. * @returns the current Node
  99238. */
  99239. removeBehavior(behavior: Behavior<Node>): Node;
  99240. /**
  99241. * Gets the list of attached behaviors
  99242. * @see http://doc.babylonjs.com/features/behaviour
  99243. */
  99244. get behaviors(): Behavior<Node>[];
  99245. /**
  99246. * Gets an attached behavior by name
  99247. * @param name defines the name of the behavior to look for
  99248. * @see http://doc.babylonjs.com/features/behaviour
  99249. * @returns null if behavior was not found else the requested behavior
  99250. */
  99251. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99252. /**
  99253. * Returns the latest update of the World matrix
  99254. * @returns a Matrix
  99255. */
  99256. getWorldMatrix(): Matrix;
  99257. /** @hidden */
  99258. _getWorldMatrixDeterminant(): number;
  99259. /**
  99260. * Returns directly the latest state of the mesh World matrix.
  99261. * A Matrix is returned.
  99262. */
  99263. get worldMatrixFromCache(): Matrix;
  99264. /** @hidden */
  99265. _initCache(): void;
  99266. /** @hidden */
  99267. updateCache(force?: boolean): void;
  99268. /** @hidden */
  99269. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99270. /** @hidden */
  99271. _updateCache(ignoreParentClass?: boolean): void;
  99272. /** @hidden */
  99273. _isSynchronized(): boolean;
  99274. /** @hidden */
  99275. _markSyncedWithParent(): void;
  99276. /** @hidden */
  99277. isSynchronizedWithParent(): boolean;
  99278. /** @hidden */
  99279. isSynchronized(): boolean;
  99280. /**
  99281. * Is this node ready to be used/rendered
  99282. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99283. * @return true if the node is ready
  99284. */
  99285. isReady(completeCheck?: boolean): boolean;
  99286. /**
  99287. * Is this node enabled?
  99288. * 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
  99289. * @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
  99290. * @return whether this node (and its parent) is enabled
  99291. */
  99292. isEnabled(checkAncestors?: boolean): boolean;
  99293. /** @hidden */
  99294. protected _syncParentEnabledState(): void;
  99295. /**
  99296. * Set the enabled state of this node
  99297. * @param value defines the new enabled state
  99298. */
  99299. setEnabled(value: boolean): void;
  99300. /**
  99301. * Is this node a descendant of the given node?
  99302. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99303. * @param ancestor defines the parent node to inspect
  99304. * @returns a boolean indicating if this node is a descendant of the given node
  99305. */
  99306. isDescendantOf(ancestor: Node): boolean;
  99307. /** @hidden */
  99308. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99309. /**
  99310. * Will return all nodes that have this node as ascendant
  99311. * @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
  99312. * @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
  99313. * @return all children nodes of all types
  99314. */
  99315. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99316. /**
  99317. * Get all child-meshes of this node
  99318. * @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)
  99319. * @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
  99320. * @returns an array of AbstractMesh
  99321. */
  99322. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99323. /**
  99324. * Get all direct children of this node
  99325. * @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
  99326. * @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)
  99327. * @returns an array of Node
  99328. */
  99329. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99330. /** @hidden */
  99331. _setReady(state: boolean): void;
  99332. /**
  99333. * Get an animation by name
  99334. * @param name defines the name of the animation to look for
  99335. * @returns null if not found else the requested animation
  99336. */
  99337. getAnimationByName(name: string): Nullable<Animation>;
  99338. /**
  99339. * Creates an animation range for this node
  99340. * @param name defines the name of the range
  99341. * @param from defines the starting key
  99342. * @param to defines the end key
  99343. */
  99344. createAnimationRange(name: string, from: number, to: number): void;
  99345. /**
  99346. * Delete a specific animation range
  99347. * @param name defines the name of the range to delete
  99348. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99349. */
  99350. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99351. /**
  99352. * Get an animation range by name
  99353. * @param name defines the name of the animation range to look for
  99354. * @returns null if not found else the requested animation range
  99355. */
  99356. getAnimationRange(name: string): Nullable<AnimationRange>;
  99357. /**
  99358. * Gets the list of all animation ranges defined on this node
  99359. * @returns an array
  99360. */
  99361. getAnimationRanges(): Nullable<AnimationRange>[];
  99362. /**
  99363. * Will start the animation sequence
  99364. * @param name defines the range frames for animation sequence
  99365. * @param loop defines if the animation should loop (false by default)
  99366. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99367. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99368. * @returns the object created for this animation. If range does not exist, it will return null
  99369. */
  99370. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99371. /**
  99372. * Serialize animation ranges into a JSON compatible object
  99373. * @returns serialization object
  99374. */
  99375. serializeAnimationRanges(): any;
  99376. /**
  99377. * Computes the world matrix of the node
  99378. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99379. * @returns the world matrix
  99380. */
  99381. computeWorldMatrix(force?: boolean): Matrix;
  99382. /**
  99383. * Releases resources associated with this node.
  99384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99386. */
  99387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99388. /**
  99389. * Parse animation range data from a serialization object and store them into a given node
  99390. * @param node defines where to store the animation ranges
  99391. * @param parsedNode defines the serialization object to read data from
  99392. * @param scene defines the hosting scene
  99393. */
  99394. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99395. /**
  99396. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99397. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99398. * @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
  99399. * @returns the new bounding vectors
  99400. */
  99401. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99402. min: Vector3;
  99403. max: Vector3;
  99404. };
  99405. }
  99406. }
  99407. declare module BABYLON {
  99408. /**
  99409. * @hidden
  99410. */
  99411. export class _IAnimationState {
  99412. key: number;
  99413. repeatCount: number;
  99414. workValue?: any;
  99415. loopMode?: number;
  99416. offsetValue?: any;
  99417. highLimitValue?: any;
  99418. }
  99419. /**
  99420. * Class used to store any kind of animation
  99421. */
  99422. export class Animation {
  99423. /**Name of the animation */
  99424. name: string;
  99425. /**Property to animate */
  99426. targetProperty: string;
  99427. /**The frames per second of the animation */
  99428. framePerSecond: number;
  99429. /**The data type of the animation */
  99430. dataType: number;
  99431. /**The loop mode of the animation */
  99432. loopMode?: number | undefined;
  99433. /**Specifies if blending should be enabled */
  99434. enableBlending?: boolean | undefined;
  99435. /**
  99436. * Use matrix interpolation instead of using direct key value when animating matrices
  99437. */
  99438. static AllowMatricesInterpolation: boolean;
  99439. /**
  99440. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99441. */
  99442. static AllowMatrixDecomposeForInterpolation: boolean;
  99443. /**
  99444. * Stores the key frames of the animation
  99445. */
  99446. private _keys;
  99447. /**
  99448. * Stores the easing function of the animation
  99449. */
  99450. private _easingFunction;
  99451. /**
  99452. * @hidden Internal use only
  99453. */
  99454. _runtimeAnimations: RuntimeAnimation[];
  99455. /**
  99456. * The set of event that will be linked to this animation
  99457. */
  99458. private _events;
  99459. /**
  99460. * Stores an array of target property paths
  99461. */
  99462. targetPropertyPath: string[];
  99463. /**
  99464. * Stores the blending speed of the animation
  99465. */
  99466. blendingSpeed: number;
  99467. /**
  99468. * Stores the animation ranges for the animation
  99469. */
  99470. private _ranges;
  99471. /**
  99472. * @hidden Internal use
  99473. */
  99474. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99475. /**
  99476. * Sets up an animation
  99477. * @param property The property to animate
  99478. * @param animationType The animation type to apply
  99479. * @param framePerSecond The frames per second of the animation
  99480. * @param easingFunction The easing function used in the animation
  99481. * @returns The created animation
  99482. */
  99483. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99484. /**
  99485. * Create and start an animation on a node
  99486. * @param name defines the name of the global animation that will be run on all nodes
  99487. * @param node defines the root node where the animation will take place
  99488. * @param targetProperty defines property to animate
  99489. * @param framePerSecond defines the number of frame per second yo use
  99490. * @param totalFrame defines the number of frames in total
  99491. * @param from defines the initial value
  99492. * @param to defines the final value
  99493. * @param loopMode defines which loop mode you want to use (off by default)
  99494. * @param easingFunction defines the easing function to use (linear by default)
  99495. * @param onAnimationEnd defines the callback to call when animation end
  99496. * @returns the animatable created for this animation
  99497. */
  99498. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99499. /**
  99500. * Create and start an animation on a node and its descendants
  99501. * @param name defines the name of the global animation that will be run on all nodes
  99502. * @param node defines the root node where the animation will take place
  99503. * @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
  99504. * @param targetProperty defines property to animate
  99505. * @param framePerSecond defines the number of frame per second to use
  99506. * @param totalFrame defines the number of frames in total
  99507. * @param from defines the initial value
  99508. * @param to defines the final value
  99509. * @param loopMode defines which loop mode you want to use (off by default)
  99510. * @param easingFunction defines the easing function to use (linear by default)
  99511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99512. * @returns the list of animatables created for all nodes
  99513. * @example https://www.babylonjs-playground.com/#MH0VLI
  99514. */
  99515. 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[]>;
  99516. /**
  99517. * Creates a new animation, merges it with the existing animations and starts it
  99518. * @param name Name of the animation
  99519. * @param node Node which contains the scene that begins the animations
  99520. * @param targetProperty Specifies which property to animate
  99521. * @param framePerSecond The frames per second of the animation
  99522. * @param totalFrame The total number of frames
  99523. * @param from The frame at the beginning of the animation
  99524. * @param to The frame at the end of the animation
  99525. * @param loopMode Specifies the loop mode of the animation
  99526. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99527. * @param onAnimationEnd Callback to run once the animation is complete
  99528. * @returns Nullable animation
  99529. */
  99530. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99531. /**
  99532. * Transition property of an host to the target Value
  99533. * @param property The property to transition
  99534. * @param targetValue The target Value of the property
  99535. * @param host The object where the property to animate belongs
  99536. * @param scene Scene used to run the animation
  99537. * @param frameRate Framerate (in frame/s) to use
  99538. * @param transition The transition type we want to use
  99539. * @param duration The duration of the animation, in milliseconds
  99540. * @param onAnimationEnd Callback trigger at the end of the animation
  99541. * @returns Nullable animation
  99542. */
  99543. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99544. /**
  99545. * Return the array of runtime animations currently using this animation
  99546. */
  99547. get runtimeAnimations(): RuntimeAnimation[];
  99548. /**
  99549. * Specifies if any of the runtime animations are currently running
  99550. */
  99551. get hasRunningRuntimeAnimations(): boolean;
  99552. /**
  99553. * Initializes the animation
  99554. * @param name Name of the animation
  99555. * @param targetProperty Property to animate
  99556. * @param framePerSecond The frames per second of the animation
  99557. * @param dataType The data type of the animation
  99558. * @param loopMode The loop mode of the animation
  99559. * @param enableBlending Specifies if blending should be enabled
  99560. */
  99561. constructor(
  99562. /**Name of the animation */
  99563. name: string,
  99564. /**Property to animate */
  99565. targetProperty: string,
  99566. /**The frames per second of the animation */
  99567. framePerSecond: number,
  99568. /**The data type of the animation */
  99569. dataType: number,
  99570. /**The loop mode of the animation */
  99571. loopMode?: number | undefined,
  99572. /**Specifies if blending should be enabled */
  99573. enableBlending?: boolean | undefined);
  99574. /**
  99575. * Converts the animation to a string
  99576. * @param fullDetails support for multiple levels of logging within scene loading
  99577. * @returns String form of the animation
  99578. */
  99579. toString(fullDetails?: boolean): string;
  99580. /**
  99581. * Add an event to this animation
  99582. * @param event Event to add
  99583. */
  99584. addEvent(event: AnimationEvent): void;
  99585. /**
  99586. * Remove all events found at the given frame
  99587. * @param frame The frame to remove events from
  99588. */
  99589. removeEvents(frame: number): void;
  99590. /**
  99591. * Retrieves all the events from the animation
  99592. * @returns Events from the animation
  99593. */
  99594. getEvents(): AnimationEvent[];
  99595. /**
  99596. * Creates an animation range
  99597. * @param name Name of the animation range
  99598. * @param from Starting frame of the animation range
  99599. * @param to Ending frame of the animation
  99600. */
  99601. createRange(name: string, from: number, to: number): void;
  99602. /**
  99603. * Deletes an animation range by name
  99604. * @param name Name of the animation range to delete
  99605. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99606. */
  99607. deleteRange(name: string, deleteFrames?: boolean): void;
  99608. /**
  99609. * Gets the animation range by name, or null if not defined
  99610. * @param name Name of the animation range
  99611. * @returns Nullable animation range
  99612. */
  99613. getRange(name: string): Nullable<AnimationRange>;
  99614. /**
  99615. * Gets the key frames from the animation
  99616. * @returns The key frames of the animation
  99617. */
  99618. getKeys(): Array<IAnimationKey>;
  99619. /**
  99620. * Gets the highest frame rate of the animation
  99621. * @returns Highest frame rate of the animation
  99622. */
  99623. getHighestFrame(): number;
  99624. /**
  99625. * Gets the easing function of the animation
  99626. * @returns Easing function of the animation
  99627. */
  99628. getEasingFunction(): IEasingFunction;
  99629. /**
  99630. * Sets the easing function of the animation
  99631. * @param easingFunction A custom mathematical formula for animation
  99632. */
  99633. setEasingFunction(easingFunction: EasingFunction): void;
  99634. /**
  99635. * Interpolates a scalar linearly
  99636. * @param startValue Start value of the animation curve
  99637. * @param endValue End value of the animation curve
  99638. * @param gradient Scalar amount to interpolate
  99639. * @returns Interpolated scalar value
  99640. */
  99641. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99642. /**
  99643. * Interpolates a scalar cubically
  99644. * @param startValue Start value of the animation curve
  99645. * @param outTangent End tangent of the animation
  99646. * @param endValue End value of the animation curve
  99647. * @param inTangent Start tangent of the animation curve
  99648. * @param gradient Scalar amount to interpolate
  99649. * @returns Interpolated scalar value
  99650. */
  99651. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99652. /**
  99653. * Interpolates a quaternion using a spherical linear interpolation
  99654. * @param startValue Start value of the animation curve
  99655. * @param endValue End value of the animation curve
  99656. * @param gradient Scalar amount to interpolate
  99657. * @returns Interpolated quaternion value
  99658. */
  99659. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99660. /**
  99661. * Interpolates a quaternion cubically
  99662. * @param startValue Start value of the animation curve
  99663. * @param outTangent End tangent of the animation curve
  99664. * @param endValue End value of the animation curve
  99665. * @param inTangent Start tangent of the animation curve
  99666. * @param gradient Scalar amount to interpolate
  99667. * @returns Interpolated quaternion value
  99668. */
  99669. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99670. /**
  99671. * Interpolates a Vector3 linearl
  99672. * @param startValue Start value of the animation curve
  99673. * @param endValue End value of the animation curve
  99674. * @param gradient Scalar amount to interpolate
  99675. * @returns Interpolated scalar value
  99676. */
  99677. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99678. /**
  99679. * Interpolates a Vector3 cubically
  99680. * @param startValue Start value of the animation curve
  99681. * @param outTangent End tangent of the animation
  99682. * @param endValue End value of the animation curve
  99683. * @param inTangent Start tangent of the animation curve
  99684. * @param gradient Scalar amount to interpolate
  99685. * @returns InterpolatedVector3 value
  99686. */
  99687. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99688. /**
  99689. * Interpolates a Vector2 linearly
  99690. * @param startValue Start value of the animation curve
  99691. * @param endValue End value of the animation curve
  99692. * @param gradient Scalar amount to interpolate
  99693. * @returns Interpolated Vector2 value
  99694. */
  99695. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99696. /**
  99697. * Interpolates a Vector2 cubically
  99698. * @param startValue Start value of the animation curve
  99699. * @param outTangent End tangent of the animation
  99700. * @param endValue End value of the animation curve
  99701. * @param inTangent Start tangent of the animation curve
  99702. * @param gradient Scalar amount to interpolate
  99703. * @returns Interpolated Vector2 value
  99704. */
  99705. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99706. /**
  99707. * Interpolates a size linearly
  99708. * @param startValue Start value of the animation curve
  99709. * @param endValue End value of the animation curve
  99710. * @param gradient Scalar amount to interpolate
  99711. * @returns Interpolated Size value
  99712. */
  99713. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99714. /**
  99715. * Interpolates a Color3 linearly
  99716. * @param startValue Start value of the animation curve
  99717. * @param endValue End value of the animation curve
  99718. * @param gradient Scalar amount to interpolate
  99719. * @returns Interpolated Color3 value
  99720. */
  99721. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99722. /**
  99723. * Interpolates a Color4 linearly
  99724. * @param startValue Start value of the animation curve
  99725. * @param endValue End value of the animation curve
  99726. * @param gradient Scalar amount to interpolate
  99727. * @returns Interpolated Color3 value
  99728. */
  99729. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99730. /**
  99731. * @hidden Internal use only
  99732. */
  99733. _getKeyValue(value: any): any;
  99734. /**
  99735. * @hidden Internal use only
  99736. */
  99737. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99738. /**
  99739. * Defines the function to use to interpolate matrices
  99740. * @param startValue defines the start matrix
  99741. * @param endValue defines the end matrix
  99742. * @param gradient defines the gradient between both matrices
  99743. * @param result defines an optional target matrix where to store the interpolation
  99744. * @returns the interpolated matrix
  99745. */
  99746. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99747. /**
  99748. * Makes a copy of the animation
  99749. * @returns Cloned animation
  99750. */
  99751. clone(): Animation;
  99752. /**
  99753. * Sets the key frames of the animation
  99754. * @param values The animation key frames to set
  99755. */
  99756. setKeys(values: Array<IAnimationKey>): void;
  99757. /**
  99758. * Serializes the animation to an object
  99759. * @returns Serialized object
  99760. */
  99761. serialize(): any;
  99762. /**
  99763. * Float animation type
  99764. */
  99765. static readonly ANIMATIONTYPE_FLOAT: number;
  99766. /**
  99767. * Vector3 animation type
  99768. */
  99769. static readonly ANIMATIONTYPE_VECTOR3: number;
  99770. /**
  99771. * Quaternion animation type
  99772. */
  99773. static readonly ANIMATIONTYPE_QUATERNION: number;
  99774. /**
  99775. * Matrix animation type
  99776. */
  99777. static readonly ANIMATIONTYPE_MATRIX: number;
  99778. /**
  99779. * Color3 animation type
  99780. */
  99781. static readonly ANIMATIONTYPE_COLOR3: number;
  99782. /**
  99783. * Color3 animation type
  99784. */
  99785. static readonly ANIMATIONTYPE_COLOR4: number;
  99786. /**
  99787. * Vector2 animation type
  99788. */
  99789. static readonly ANIMATIONTYPE_VECTOR2: number;
  99790. /**
  99791. * Size animation type
  99792. */
  99793. static readonly ANIMATIONTYPE_SIZE: number;
  99794. /**
  99795. * Relative Loop Mode
  99796. */
  99797. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99798. /**
  99799. * Cycle Loop Mode
  99800. */
  99801. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99802. /**
  99803. * Constant Loop Mode
  99804. */
  99805. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99806. /** @hidden */
  99807. static _UniversalLerp(left: any, right: any, amount: number): any;
  99808. /**
  99809. * Parses an animation object and creates an animation
  99810. * @param parsedAnimation Parsed animation object
  99811. * @returns Animation object
  99812. */
  99813. static Parse(parsedAnimation: any): Animation;
  99814. /**
  99815. * Appends the serialized animations from the source animations
  99816. * @param source Source containing the animations
  99817. * @param destination Target to store the animations
  99818. */
  99819. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99820. }
  99821. }
  99822. declare module BABYLON {
  99823. /**
  99824. * Interface containing an array of animations
  99825. */
  99826. export interface IAnimatable {
  99827. /**
  99828. * Array of animations
  99829. */
  99830. animations: Nullable<Array<Animation>>;
  99831. }
  99832. }
  99833. declare module BABYLON {
  99834. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99835. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99836. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99837. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99838. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99839. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99840. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99841. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99842. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99843. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99844. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99845. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99846. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99847. /**
  99848. * Decorator used to define property that can be serialized as reference to a camera
  99849. * @param sourceName defines the name of the property to decorate
  99850. */
  99851. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99852. /**
  99853. * Class used to help serialization objects
  99854. */
  99855. export class SerializationHelper {
  99856. /** @hidden */
  99857. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99858. /** @hidden */
  99859. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99860. /** @hidden */
  99861. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99862. /** @hidden */
  99863. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99864. /**
  99865. * Appends the serialized animations from the source animations
  99866. * @param source Source containing the animations
  99867. * @param destination Target to store the animations
  99868. */
  99869. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99870. /**
  99871. * Static function used to serialized a specific entity
  99872. * @param entity defines the entity to serialize
  99873. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99874. * @returns a JSON compatible object representing the serialization of the entity
  99875. */
  99876. static Serialize<T>(entity: T, serializationObject?: any): any;
  99877. /**
  99878. * Creates a new entity from a serialization data object
  99879. * @param creationFunction defines a function used to instanciated the new entity
  99880. * @param source defines the source serialization data
  99881. * @param scene defines the hosting scene
  99882. * @param rootUrl defines the root url for resources
  99883. * @returns a new entity
  99884. */
  99885. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99886. /**
  99887. * Clones an object
  99888. * @param creationFunction defines the function used to instanciate the new object
  99889. * @param source defines the source object
  99890. * @returns the cloned object
  99891. */
  99892. static Clone<T>(creationFunction: () => T, source: T): T;
  99893. /**
  99894. * Instanciates a new object based on a source one (some data will be shared between both object)
  99895. * @param creationFunction defines the function used to instanciate the new object
  99896. * @param source defines the source object
  99897. * @returns the new object
  99898. */
  99899. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99900. }
  99901. }
  99902. declare module BABYLON {
  99903. /**
  99904. * Class used to manipulate GUIDs
  99905. */
  99906. export class GUID {
  99907. /**
  99908. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99909. * Be aware Math.random() could cause collisions, but:
  99910. * "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"
  99911. * @returns a pseudo random id
  99912. */
  99913. static RandomId(): string;
  99914. }
  99915. }
  99916. declare module BABYLON {
  99917. /**
  99918. * Base class of all the textures in babylon.
  99919. * It groups all the common properties the materials, post process, lights... might need
  99920. * in order to make a correct use of the texture.
  99921. */
  99922. export class BaseTexture implements IAnimatable {
  99923. /**
  99924. * Default anisotropic filtering level for the application.
  99925. * It is set to 4 as a good tradeoff between perf and quality.
  99926. */
  99927. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  99928. /**
  99929. * Gets or sets the unique id of the texture
  99930. */
  99931. uniqueId: number;
  99932. /**
  99933. * Define the name of the texture.
  99934. */
  99935. name: string;
  99936. /**
  99937. * Gets or sets an object used to store user defined information.
  99938. */
  99939. metadata: any;
  99940. /**
  99941. * For internal use only. Please do not use.
  99942. */
  99943. reservedDataStore: any;
  99944. private _hasAlpha;
  99945. /**
  99946. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  99947. */
  99948. set hasAlpha(value: boolean);
  99949. get hasAlpha(): boolean;
  99950. /**
  99951. * Defines if the alpha value should be determined via the rgb values.
  99952. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  99953. */
  99954. getAlphaFromRGB: boolean;
  99955. /**
  99956. * Intensity or strength of the texture.
  99957. * It is commonly used by materials to fine tune the intensity of the texture
  99958. */
  99959. level: number;
  99960. /**
  99961. * Define the UV chanel to use starting from 0 and defaulting to 0.
  99962. * This is part of the texture as textures usually maps to one uv set.
  99963. */
  99964. coordinatesIndex: number;
  99965. private _coordinatesMode;
  99966. /**
  99967. * How a texture is mapped.
  99968. *
  99969. * | Value | Type | Description |
  99970. * | ----- | ----------------------------------- | ----------- |
  99971. * | 0 | EXPLICIT_MODE | |
  99972. * | 1 | SPHERICAL_MODE | |
  99973. * | 2 | PLANAR_MODE | |
  99974. * | 3 | CUBIC_MODE | |
  99975. * | 4 | PROJECTION_MODE | |
  99976. * | 5 | SKYBOX_MODE | |
  99977. * | 6 | INVCUBIC_MODE | |
  99978. * | 7 | EQUIRECTANGULAR_MODE | |
  99979. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  99980. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  99981. */
  99982. set coordinatesMode(value: number);
  99983. get coordinatesMode(): number;
  99984. /**
  99985. * | Value | Type | Description |
  99986. * | ----- | ------------------ | ----------- |
  99987. * | 0 | CLAMP_ADDRESSMODE | |
  99988. * | 1 | WRAP_ADDRESSMODE | |
  99989. * | 2 | MIRROR_ADDRESSMODE | |
  99990. */
  99991. wrapU: number;
  99992. /**
  99993. * | Value | Type | Description |
  99994. * | ----- | ------------------ | ----------- |
  99995. * | 0 | CLAMP_ADDRESSMODE | |
  99996. * | 1 | WRAP_ADDRESSMODE | |
  99997. * | 2 | MIRROR_ADDRESSMODE | |
  99998. */
  99999. wrapV: number;
  100000. /**
  100001. * | Value | Type | Description |
  100002. * | ----- | ------------------ | ----------- |
  100003. * | 0 | CLAMP_ADDRESSMODE | |
  100004. * | 1 | WRAP_ADDRESSMODE | |
  100005. * | 2 | MIRROR_ADDRESSMODE | |
  100006. */
  100007. wrapR: number;
  100008. /**
  100009. * With compliant hardware and browser (supporting anisotropic filtering)
  100010. * this defines the level of anisotropic filtering in the texture.
  100011. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100012. */
  100013. anisotropicFilteringLevel: number;
  100014. /**
  100015. * Define if the texture is a cube texture or if false a 2d texture.
  100016. */
  100017. get isCube(): boolean;
  100018. set isCube(value: boolean);
  100019. /**
  100020. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100021. */
  100022. get is3D(): boolean;
  100023. set is3D(value: boolean);
  100024. /**
  100025. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100026. */
  100027. get is2DArray(): boolean;
  100028. set is2DArray(value: boolean);
  100029. /**
  100030. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100031. * HDR texture are usually stored in linear space.
  100032. * This only impacts the PBR and Background materials
  100033. */
  100034. gammaSpace: boolean;
  100035. /**
  100036. * Gets or sets whether or not the texture contains RGBD data.
  100037. */
  100038. get isRGBD(): boolean;
  100039. set isRGBD(value: boolean);
  100040. /**
  100041. * Is Z inverted in the texture (useful in a cube texture).
  100042. */
  100043. invertZ: boolean;
  100044. /**
  100045. * Are mip maps generated for this texture or not.
  100046. */
  100047. get noMipmap(): boolean;
  100048. /**
  100049. * @hidden
  100050. */
  100051. lodLevelInAlpha: boolean;
  100052. /**
  100053. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100054. */
  100055. get lodGenerationOffset(): number;
  100056. set lodGenerationOffset(value: number);
  100057. /**
  100058. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100059. */
  100060. get lodGenerationScale(): number;
  100061. set lodGenerationScale(value: number);
  100062. /**
  100063. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100064. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100065. * average roughness values.
  100066. */
  100067. get linearSpecularLOD(): boolean;
  100068. set linearSpecularLOD(value: boolean);
  100069. /**
  100070. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100071. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100072. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100073. */
  100074. get irradianceTexture(): Nullable<BaseTexture>;
  100075. set irradianceTexture(value: Nullable<BaseTexture>);
  100076. /**
  100077. * Define if the texture is a render target.
  100078. */
  100079. isRenderTarget: boolean;
  100080. /**
  100081. * Define the unique id of the texture in the scene.
  100082. */
  100083. get uid(): string;
  100084. /**
  100085. * Return a string representation of the texture.
  100086. * @returns the texture as a string
  100087. */
  100088. toString(): string;
  100089. /**
  100090. * Get the class name of the texture.
  100091. * @returns "BaseTexture"
  100092. */
  100093. getClassName(): string;
  100094. /**
  100095. * Define the list of animation attached to the texture.
  100096. */
  100097. animations: Animation[];
  100098. /**
  100099. * An event triggered when the texture is disposed.
  100100. */
  100101. onDisposeObservable: Observable<BaseTexture>;
  100102. private _onDisposeObserver;
  100103. /**
  100104. * Callback triggered when the texture has been disposed.
  100105. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100106. */
  100107. set onDispose(callback: () => void);
  100108. /**
  100109. * Define the current state of the loading sequence when in delayed load mode.
  100110. */
  100111. delayLoadState: number;
  100112. private _scene;
  100113. /** @hidden */
  100114. _texture: Nullable<InternalTexture>;
  100115. private _uid;
  100116. /**
  100117. * Define if the texture is preventinga material to render or not.
  100118. * If not and the texture is not ready, the engine will use a default black texture instead.
  100119. */
  100120. get isBlocking(): boolean;
  100121. /**
  100122. * Instantiates a new BaseTexture.
  100123. * Base class of all the textures in babylon.
  100124. * It groups all the common properties the materials, post process, lights... might need
  100125. * in order to make a correct use of the texture.
  100126. * @param scene Define the scene the texture blongs to
  100127. */
  100128. constructor(scene: Nullable<Scene>);
  100129. /**
  100130. * Get the scene the texture belongs to.
  100131. * @returns the scene or null if undefined
  100132. */
  100133. getScene(): Nullable<Scene>;
  100134. /**
  100135. * Get the texture transform matrix used to offset tile the texture for istance.
  100136. * @returns the transformation matrix
  100137. */
  100138. getTextureMatrix(): Matrix;
  100139. /**
  100140. * Get the texture reflection matrix used to rotate/transform the reflection.
  100141. * @returns the reflection matrix
  100142. */
  100143. getReflectionTextureMatrix(): Matrix;
  100144. /**
  100145. * Get the underlying lower level texture from Babylon.
  100146. * @returns the insternal texture
  100147. */
  100148. getInternalTexture(): Nullable<InternalTexture>;
  100149. /**
  100150. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100151. * @returns true if ready or not blocking
  100152. */
  100153. isReadyOrNotBlocking(): boolean;
  100154. /**
  100155. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100156. * @returns true if fully ready
  100157. */
  100158. isReady(): boolean;
  100159. private _cachedSize;
  100160. /**
  100161. * Get the size of the texture.
  100162. * @returns the texture size.
  100163. */
  100164. getSize(): ISize;
  100165. /**
  100166. * Get the base size of the texture.
  100167. * It can be different from the size if the texture has been resized for POT for instance
  100168. * @returns the base size
  100169. */
  100170. getBaseSize(): ISize;
  100171. /**
  100172. * Update the sampling mode of the texture.
  100173. * Default is Trilinear mode.
  100174. *
  100175. * | Value | Type | Description |
  100176. * | ----- | ------------------ | ----------- |
  100177. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100178. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100179. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100180. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100181. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100182. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100183. * | 7 | NEAREST_LINEAR | |
  100184. * | 8 | NEAREST_NEAREST | |
  100185. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100186. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100187. * | 11 | LINEAR_LINEAR | |
  100188. * | 12 | LINEAR_NEAREST | |
  100189. *
  100190. * > _mag_: magnification filter (close to the viewer)
  100191. * > _min_: minification filter (far from the viewer)
  100192. * > _mip_: filter used between mip map levels
  100193. *@param samplingMode Define the new sampling mode of the texture
  100194. */
  100195. updateSamplingMode(samplingMode: number): void;
  100196. /**
  100197. * Scales the texture if is `canRescale()`
  100198. * @param ratio the resize factor we want to use to rescale
  100199. */
  100200. scale(ratio: number): void;
  100201. /**
  100202. * Get if the texture can rescale.
  100203. */
  100204. get canRescale(): boolean;
  100205. /** @hidden */
  100206. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100207. /** @hidden */
  100208. _rebuild(): void;
  100209. /**
  100210. * Triggers the load sequence in delayed load mode.
  100211. */
  100212. delayLoad(): void;
  100213. /**
  100214. * Clones the texture.
  100215. * @returns the cloned texture
  100216. */
  100217. clone(): Nullable<BaseTexture>;
  100218. /**
  100219. * Get the texture underlying type (INT, FLOAT...)
  100220. */
  100221. get textureType(): number;
  100222. /**
  100223. * Get the texture underlying format (RGB, RGBA...)
  100224. */
  100225. get textureFormat(): number;
  100226. /**
  100227. * Indicates that textures need to be re-calculated for all materials
  100228. */
  100229. protected _markAllSubMeshesAsTexturesDirty(): void;
  100230. /**
  100231. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100232. * This will returns an RGBA array buffer containing either in values (0-255) or
  100233. * float values (0-1) depending of the underlying buffer type.
  100234. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100235. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100236. * @param buffer defines a user defined buffer to fill with data (can be null)
  100237. * @returns The Array buffer containing the pixels data.
  100238. */
  100239. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100240. /**
  100241. * Release and destroy the underlying lower level texture aka internalTexture.
  100242. */
  100243. releaseInternalTexture(): void;
  100244. /** @hidden */
  100245. get _lodTextureHigh(): Nullable<BaseTexture>;
  100246. /** @hidden */
  100247. get _lodTextureMid(): Nullable<BaseTexture>;
  100248. /** @hidden */
  100249. get _lodTextureLow(): Nullable<BaseTexture>;
  100250. /**
  100251. * Dispose the texture and release its associated resources.
  100252. */
  100253. dispose(): void;
  100254. /**
  100255. * Serialize the texture into a JSON representation that can be parsed later on.
  100256. * @returns the JSON representation of the texture
  100257. */
  100258. serialize(): any;
  100259. /**
  100260. * Helper function to be called back once a list of texture contains only ready textures.
  100261. * @param textures Define the list of textures to wait for
  100262. * @param callback Define the callback triggered once the entire list will be ready
  100263. */
  100264. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100265. }
  100266. }
  100267. declare module BABYLON {
  100268. /**
  100269. * Options to be used when creating an effect.
  100270. */
  100271. export interface IEffectCreationOptions {
  100272. /**
  100273. * Atrributes that will be used in the shader.
  100274. */
  100275. attributes: string[];
  100276. /**
  100277. * Uniform varible names that will be set in the shader.
  100278. */
  100279. uniformsNames: string[];
  100280. /**
  100281. * Uniform buffer variable names that will be set in the shader.
  100282. */
  100283. uniformBuffersNames: string[];
  100284. /**
  100285. * Sampler texture variable names that will be set in the shader.
  100286. */
  100287. samplers: string[];
  100288. /**
  100289. * Define statements that will be set in the shader.
  100290. */
  100291. defines: any;
  100292. /**
  100293. * Possible fallbacks for this effect to improve performance when needed.
  100294. */
  100295. fallbacks: Nullable<IEffectFallbacks>;
  100296. /**
  100297. * Callback that will be called when the shader is compiled.
  100298. */
  100299. onCompiled: Nullable<(effect: Effect) => void>;
  100300. /**
  100301. * Callback that will be called if an error occurs during shader compilation.
  100302. */
  100303. onError: Nullable<(effect: Effect, errors: string) => void>;
  100304. /**
  100305. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100306. */
  100307. indexParameters?: any;
  100308. /**
  100309. * Max number of lights that can be used in the shader.
  100310. */
  100311. maxSimultaneousLights?: number;
  100312. /**
  100313. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100314. */
  100315. transformFeedbackVaryings?: Nullable<string[]>;
  100316. }
  100317. /**
  100318. * Effect containing vertex and fragment shader that can be executed on an object.
  100319. */
  100320. export class Effect implements IDisposable {
  100321. /**
  100322. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100323. */
  100324. static ShadersRepository: string;
  100325. /**
  100326. * Name of the effect.
  100327. */
  100328. name: any;
  100329. /**
  100330. * String container all the define statements that should be set on the shader.
  100331. */
  100332. defines: string;
  100333. /**
  100334. * Callback that will be called when the shader is compiled.
  100335. */
  100336. onCompiled: Nullable<(effect: Effect) => void>;
  100337. /**
  100338. * Callback that will be called if an error occurs during shader compilation.
  100339. */
  100340. onError: Nullable<(effect: Effect, errors: string) => void>;
  100341. /**
  100342. * Callback that will be called when effect is bound.
  100343. */
  100344. onBind: Nullable<(effect: Effect) => void>;
  100345. /**
  100346. * Unique ID of the effect.
  100347. */
  100348. uniqueId: number;
  100349. /**
  100350. * Observable that will be called when the shader is compiled.
  100351. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100352. */
  100353. onCompileObservable: Observable<Effect>;
  100354. /**
  100355. * Observable that will be called if an error occurs during shader compilation.
  100356. */
  100357. onErrorObservable: Observable<Effect>;
  100358. /** @hidden */
  100359. _onBindObservable: Nullable<Observable<Effect>>;
  100360. /**
  100361. * Observable that will be called when effect is bound.
  100362. */
  100363. get onBindObservable(): Observable<Effect>;
  100364. /** @hidden */
  100365. _bonesComputationForcedToCPU: boolean;
  100366. private static _uniqueIdSeed;
  100367. private _engine;
  100368. private _uniformBuffersNames;
  100369. private _uniformsNames;
  100370. private _samplerList;
  100371. private _samplers;
  100372. private _isReady;
  100373. private _compilationError;
  100374. private _allFallbacksProcessed;
  100375. private _attributesNames;
  100376. private _attributes;
  100377. private _attributeLocationByName;
  100378. private _uniforms;
  100379. /**
  100380. * Key for the effect.
  100381. * @hidden
  100382. */
  100383. _key: string;
  100384. private _indexParameters;
  100385. private _fallbacks;
  100386. private _vertexSourceCode;
  100387. private _fragmentSourceCode;
  100388. private _vertexSourceCodeOverride;
  100389. private _fragmentSourceCodeOverride;
  100390. private _transformFeedbackVaryings;
  100391. /**
  100392. * Compiled shader to webGL program.
  100393. * @hidden
  100394. */
  100395. _pipelineContext: Nullable<IPipelineContext>;
  100396. private _valueCache;
  100397. private static _baseCache;
  100398. /**
  100399. * Instantiates an effect.
  100400. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100401. * @param baseName Name of the effect.
  100402. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100403. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100404. * @param samplers List of sampler variables that will be passed to the shader.
  100405. * @param engine Engine to be used to render the effect
  100406. * @param defines Define statements to be added to the shader.
  100407. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100408. * @param onCompiled Callback that will be called when the shader is compiled.
  100409. * @param onError Callback that will be called if an error occurs during shader compilation.
  100410. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100411. */
  100412. 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);
  100413. private _useFinalCode;
  100414. /**
  100415. * Unique key for this effect
  100416. */
  100417. get key(): string;
  100418. /**
  100419. * If the effect has been compiled and prepared.
  100420. * @returns if the effect is compiled and prepared.
  100421. */
  100422. isReady(): boolean;
  100423. private _isReadyInternal;
  100424. /**
  100425. * The engine the effect was initialized with.
  100426. * @returns the engine.
  100427. */
  100428. getEngine(): Engine;
  100429. /**
  100430. * The pipeline context for this effect
  100431. * @returns the associated pipeline context
  100432. */
  100433. getPipelineContext(): Nullable<IPipelineContext>;
  100434. /**
  100435. * The set of names of attribute variables for the shader.
  100436. * @returns An array of attribute names.
  100437. */
  100438. getAttributesNames(): string[];
  100439. /**
  100440. * Returns the attribute at the given index.
  100441. * @param index The index of the attribute.
  100442. * @returns The location of the attribute.
  100443. */
  100444. getAttributeLocation(index: number): number;
  100445. /**
  100446. * Returns the attribute based on the name of the variable.
  100447. * @param name of the attribute to look up.
  100448. * @returns the attribute location.
  100449. */
  100450. getAttributeLocationByName(name: string): number;
  100451. /**
  100452. * The number of attributes.
  100453. * @returns the numnber of attributes.
  100454. */
  100455. getAttributesCount(): number;
  100456. /**
  100457. * Gets the index of a uniform variable.
  100458. * @param uniformName of the uniform to look up.
  100459. * @returns the index.
  100460. */
  100461. getUniformIndex(uniformName: string): number;
  100462. /**
  100463. * Returns the attribute based on the name of the variable.
  100464. * @param uniformName of the uniform to look up.
  100465. * @returns the location of the uniform.
  100466. */
  100467. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100468. /**
  100469. * Returns an array of sampler variable names
  100470. * @returns The array of sampler variable neames.
  100471. */
  100472. getSamplers(): string[];
  100473. /**
  100474. * The error from the last compilation.
  100475. * @returns the error string.
  100476. */
  100477. getCompilationError(): string;
  100478. /**
  100479. * Gets a boolean indicating that all fallbacks were used during compilation
  100480. * @returns true if all fallbacks were used
  100481. */
  100482. allFallbacksProcessed(): boolean;
  100483. /**
  100484. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100485. * @param func The callback to be used.
  100486. */
  100487. executeWhenCompiled(func: (effect: Effect) => void): void;
  100488. private _checkIsReady;
  100489. private _loadShader;
  100490. /**
  100491. * Recompiles the webGL program
  100492. * @param vertexSourceCode The source code for the vertex shader.
  100493. * @param fragmentSourceCode The source code for the fragment shader.
  100494. * @param onCompiled Callback called when completed.
  100495. * @param onError Callback called on error.
  100496. * @hidden
  100497. */
  100498. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100499. /**
  100500. * Prepares the effect
  100501. * @hidden
  100502. */
  100503. _prepareEffect(): void;
  100504. private _processCompilationErrors;
  100505. /**
  100506. * Checks if the effect is supported. (Must be called after compilation)
  100507. */
  100508. get isSupported(): boolean;
  100509. /**
  100510. * Binds a texture to the engine to be used as output of the shader.
  100511. * @param channel Name of the output variable.
  100512. * @param texture Texture to bind.
  100513. * @hidden
  100514. */
  100515. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100516. /**
  100517. * Sets a texture on the engine to be used in the shader.
  100518. * @param channel Name of the sampler variable.
  100519. * @param texture Texture to set.
  100520. */
  100521. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100522. /**
  100523. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100524. * @param channel Name of the sampler variable.
  100525. * @param texture Texture to set.
  100526. */
  100527. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100528. /**
  100529. * Sets an array of textures on the engine to be used in the shader.
  100530. * @param channel Name of the variable.
  100531. * @param textures Textures to set.
  100532. */
  100533. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100534. /**
  100535. * 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)
  100536. * @param channel Name of the sampler variable.
  100537. * @param postProcess Post process to get the input texture from.
  100538. */
  100539. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100540. /**
  100541. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100542. * 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)
  100543. * @param channel Name of the sampler variable.
  100544. * @param postProcess Post process to get the output texture from.
  100545. */
  100546. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100547. /** @hidden */
  100548. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100549. /** @hidden */
  100550. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100551. /** @hidden */
  100552. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100553. /** @hidden */
  100554. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100555. /**
  100556. * Binds a buffer to a uniform.
  100557. * @param buffer Buffer to bind.
  100558. * @param name Name of the uniform variable to bind to.
  100559. */
  100560. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100561. /**
  100562. * Binds block to a uniform.
  100563. * @param blockName Name of the block to bind.
  100564. * @param index Index to bind.
  100565. */
  100566. bindUniformBlock(blockName: string, index: number): void;
  100567. /**
  100568. * Sets an interger value on a uniform variable.
  100569. * @param uniformName Name of the variable.
  100570. * @param value Value to be set.
  100571. * @returns this effect.
  100572. */
  100573. setInt(uniformName: string, value: number): Effect;
  100574. /**
  100575. * Sets an int array on a uniform variable.
  100576. * @param uniformName Name of the variable.
  100577. * @param array array to be set.
  100578. * @returns this effect.
  100579. */
  100580. setIntArray(uniformName: string, array: Int32Array): Effect;
  100581. /**
  100582. * 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)
  100583. * @param uniformName Name of the variable.
  100584. * @param array array to be set.
  100585. * @returns this effect.
  100586. */
  100587. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100588. /**
  100589. * 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)
  100590. * @param uniformName Name of the variable.
  100591. * @param array array to be set.
  100592. * @returns this effect.
  100593. */
  100594. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100595. /**
  100596. * 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)
  100597. * @param uniformName Name of the variable.
  100598. * @param array array to be set.
  100599. * @returns this effect.
  100600. */
  100601. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100602. /**
  100603. * Sets an float array on a uniform variable.
  100604. * @param uniformName Name of the variable.
  100605. * @param array array to be set.
  100606. * @returns this effect.
  100607. */
  100608. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100609. /**
  100610. * 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)
  100611. * @param uniformName Name of the variable.
  100612. * @param array array to be set.
  100613. * @returns this effect.
  100614. */
  100615. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100616. /**
  100617. * 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)
  100618. * @param uniformName Name of the variable.
  100619. * @param array array to be set.
  100620. * @returns this effect.
  100621. */
  100622. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100623. /**
  100624. * 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)
  100625. * @param uniformName Name of the variable.
  100626. * @param array array to be set.
  100627. * @returns this effect.
  100628. */
  100629. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100630. /**
  100631. * Sets an array on a uniform variable.
  100632. * @param uniformName Name of the variable.
  100633. * @param array array to be set.
  100634. * @returns this effect.
  100635. */
  100636. setArray(uniformName: string, array: number[]): Effect;
  100637. /**
  100638. * 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)
  100639. * @param uniformName Name of the variable.
  100640. * @param array array to be set.
  100641. * @returns this effect.
  100642. */
  100643. setArray2(uniformName: string, array: number[]): Effect;
  100644. /**
  100645. * 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)
  100646. * @param uniformName Name of the variable.
  100647. * @param array array to be set.
  100648. * @returns this effect.
  100649. */
  100650. setArray3(uniformName: string, array: number[]): Effect;
  100651. /**
  100652. * 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)
  100653. * @param uniformName Name of the variable.
  100654. * @param array array to be set.
  100655. * @returns this effect.
  100656. */
  100657. setArray4(uniformName: string, array: number[]): Effect;
  100658. /**
  100659. * Sets matrices on a uniform variable.
  100660. * @param uniformName Name of the variable.
  100661. * @param matrices matrices to be set.
  100662. * @returns this effect.
  100663. */
  100664. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100665. /**
  100666. * Sets matrix on a uniform variable.
  100667. * @param uniformName Name of the variable.
  100668. * @param matrix matrix to be set.
  100669. * @returns this effect.
  100670. */
  100671. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100672. /**
  100673. * 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)
  100674. * @param uniformName Name of the variable.
  100675. * @param matrix matrix to be set.
  100676. * @returns this effect.
  100677. */
  100678. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100679. /**
  100680. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100681. * @param uniformName Name of the variable.
  100682. * @param matrix matrix to be set.
  100683. * @returns this effect.
  100684. */
  100685. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100686. /**
  100687. * Sets a float on a uniform variable.
  100688. * @param uniformName Name of the variable.
  100689. * @param value value to be set.
  100690. * @returns this effect.
  100691. */
  100692. setFloat(uniformName: string, value: number): Effect;
  100693. /**
  100694. * Sets a boolean on a uniform variable.
  100695. * @param uniformName Name of the variable.
  100696. * @param bool value to be set.
  100697. * @returns this effect.
  100698. */
  100699. setBool(uniformName: string, bool: boolean): Effect;
  100700. /**
  100701. * Sets a Vector2 on a uniform variable.
  100702. * @param uniformName Name of the variable.
  100703. * @param vector2 vector2 to be set.
  100704. * @returns this effect.
  100705. */
  100706. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100707. /**
  100708. * Sets a float2 on a uniform variable.
  100709. * @param uniformName Name of the variable.
  100710. * @param x First float in float2.
  100711. * @param y Second float in float2.
  100712. * @returns this effect.
  100713. */
  100714. setFloat2(uniformName: string, x: number, y: number): Effect;
  100715. /**
  100716. * Sets a Vector3 on a uniform variable.
  100717. * @param uniformName Name of the variable.
  100718. * @param vector3 Value to be set.
  100719. * @returns this effect.
  100720. */
  100721. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100722. /**
  100723. * Sets a float3 on a uniform variable.
  100724. * @param uniformName Name of the variable.
  100725. * @param x First float in float3.
  100726. * @param y Second float in float3.
  100727. * @param z Third float in float3.
  100728. * @returns this effect.
  100729. */
  100730. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100731. /**
  100732. * Sets a Vector4 on a uniform variable.
  100733. * @param uniformName Name of the variable.
  100734. * @param vector4 Value to be set.
  100735. * @returns this effect.
  100736. */
  100737. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100738. /**
  100739. * Sets a float4 on a uniform variable.
  100740. * @param uniformName Name of the variable.
  100741. * @param x First float in float4.
  100742. * @param y Second float in float4.
  100743. * @param z Third float in float4.
  100744. * @param w Fourth float in float4.
  100745. * @returns this effect.
  100746. */
  100747. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100748. /**
  100749. * Sets a Color3 on a uniform variable.
  100750. * @param uniformName Name of the variable.
  100751. * @param color3 Value to be set.
  100752. * @returns this effect.
  100753. */
  100754. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100755. /**
  100756. * Sets a Color4 on a uniform variable.
  100757. * @param uniformName Name of the variable.
  100758. * @param color3 Value to be set.
  100759. * @param alpha Alpha value to be set.
  100760. * @returns this effect.
  100761. */
  100762. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100763. /**
  100764. * Sets a Color4 on a uniform variable
  100765. * @param uniformName defines the name of the variable
  100766. * @param color4 defines the value to be set
  100767. * @returns this effect.
  100768. */
  100769. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100770. /** Release all associated resources */
  100771. dispose(): void;
  100772. /**
  100773. * This function will add a new shader to the shader store
  100774. * @param name the name of the shader
  100775. * @param pixelShader optional pixel shader content
  100776. * @param vertexShader optional vertex shader content
  100777. */
  100778. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100779. /**
  100780. * Store of each shader (The can be looked up using effect.key)
  100781. */
  100782. static ShadersStore: {
  100783. [key: string]: string;
  100784. };
  100785. /**
  100786. * Store of each included file for a shader (The can be looked up using effect.key)
  100787. */
  100788. static IncludesShadersStore: {
  100789. [key: string]: string;
  100790. };
  100791. /**
  100792. * Resets the cache of effects.
  100793. */
  100794. static ResetCache(): void;
  100795. }
  100796. }
  100797. declare module BABYLON {
  100798. /**
  100799. * Interface used to describe the capabilities of the engine relatively to the current browser
  100800. */
  100801. export interface EngineCapabilities {
  100802. /** Maximum textures units per fragment shader */
  100803. maxTexturesImageUnits: number;
  100804. /** Maximum texture units per vertex shader */
  100805. maxVertexTextureImageUnits: number;
  100806. /** Maximum textures units in the entire pipeline */
  100807. maxCombinedTexturesImageUnits: number;
  100808. /** Maximum texture size */
  100809. maxTextureSize: number;
  100810. /** Maximum texture samples */
  100811. maxSamples?: number;
  100812. /** Maximum cube texture size */
  100813. maxCubemapTextureSize: number;
  100814. /** Maximum render texture size */
  100815. maxRenderTextureSize: number;
  100816. /** Maximum number of vertex attributes */
  100817. maxVertexAttribs: number;
  100818. /** Maximum number of varyings */
  100819. maxVaryingVectors: number;
  100820. /** Maximum number of uniforms per vertex shader */
  100821. maxVertexUniformVectors: number;
  100822. /** Maximum number of uniforms per fragment shader */
  100823. maxFragmentUniformVectors: number;
  100824. /** Defines if standard derivates (dx/dy) are supported */
  100825. standardDerivatives: boolean;
  100826. /** Defines if s3tc texture compression is supported */
  100827. s3tc?: WEBGL_compressed_texture_s3tc;
  100828. /** Defines if pvrtc texture compression is supported */
  100829. pvrtc: any;
  100830. /** Defines if etc1 texture compression is supported */
  100831. etc1: any;
  100832. /** Defines if etc2 texture compression is supported */
  100833. etc2: any;
  100834. /** Defines if astc texture compression is supported */
  100835. astc: any;
  100836. /** Defines if float textures are supported */
  100837. textureFloat: boolean;
  100838. /** Defines if vertex array objects are supported */
  100839. vertexArrayObject: boolean;
  100840. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100841. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100842. /** Gets the maximum level of anisotropy supported */
  100843. maxAnisotropy: number;
  100844. /** Defines if instancing is supported */
  100845. instancedArrays: boolean;
  100846. /** Defines if 32 bits indices are supported */
  100847. uintIndices: boolean;
  100848. /** Defines if high precision shaders are supported */
  100849. highPrecisionShaderSupported: boolean;
  100850. /** Defines if depth reading in the fragment shader is supported */
  100851. fragmentDepthSupported: boolean;
  100852. /** Defines if float texture linear filtering is supported*/
  100853. textureFloatLinearFiltering: boolean;
  100854. /** Defines if rendering to float textures is supported */
  100855. textureFloatRender: boolean;
  100856. /** Defines if half float textures are supported*/
  100857. textureHalfFloat: boolean;
  100858. /** Defines if half float texture linear filtering is supported*/
  100859. textureHalfFloatLinearFiltering: boolean;
  100860. /** Defines if rendering to half float textures is supported */
  100861. textureHalfFloatRender: boolean;
  100862. /** Defines if textureLOD shader command is supported */
  100863. textureLOD: boolean;
  100864. /** Defines if draw buffers extension is supported */
  100865. drawBuffersExtension: boolean;
  100866. /** Defines if depth textures are supported */
  100867. depthTextureExtension: boolean;
  100868. /** Defines if float color buffer are supported */
  100869. colorBufferFloat: boolean;
  100870. /** Gets disjoint timer query extension (null if not supported) */
  100871. timerQuery?: EXT_disjoint_timer_query;
  100872. /** Defines if timestamp can be used with timer query */
  100873. canUseTimestampForTimerQuery: boolean;
  100874. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100875. multiview?: any;
  100876. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100877. oculusMultiview?: any;
  100878. /** Function used to let the system compiles shaders in background */
  100879. parallelShaderCompile?: {
  100880. COMPLETION_STATUS_KHR: number;
  100881. };
  100882. /** Max number of texture samples for MSAA */
  100883. maxMSAASamples: number;
  100884. /** Defines if the blend min max extension is supported */
  100885. blendMinMax: boolean;
  100886. }
  100887. }
  100888. declare module BABYLON {
  100889. /**
  100890. * @hidden
  100891. **/
  100892. export class DepthCullingState {
  100893. private _isDepthTestDirty;
  100894. private _isDepthMaskDirty;
  100895. private _isDepthFuncDirty;
  100896. private _isCullFaceDirty;
  100897. private _isCullDirty;
  100898. private _isZOffsetDirty;
  100899. private _isFrontFaceDirty;
  100900. private _depthTest;
  100901. private _depthMask;
  100902. private _depthFunc;
  100903. private _cull;
  100904. private _cullFace;
  100905. private _zOffset;
  100906. private _frontFace;
  100907. /**
  100908. * Initializes the state.
  100909. */
  100910. constructor();
  100911. get isDirty(): boolean;
  100912. get zOffset(): number;
  100913. set zOffset(value: number);
  100914. get cullFace(): Nullable<number>;
  100915. set cullFace(value: Nullable<number>);
  100916. get cull(): Nullable<boolean>;
  100917. set cull(value: Nullable<boolean>);
  100918. get depthFunc(): Nullable<number>;
  100919. set depthFunc(value: Nullable<number>);
  100920. get depthMask(): boolean;
  100921. set depthMask(value: boolean);
  100922. get depthTest(): boolean;
  100923. set depthTest(value: boolean);
  100924. get frontFace(): Nullable<number>;
  100925. set frontFace(value: Nullable<number>);
  100926. reset(): void;
  100927. apply(gl: WebGLRenderingContext): void;
  100928. }
  100929. }
  100930. declare module BABYLON {
  100931. /**
  100932. * @hidden
  100933. **/
  100934. export class StencilState {
  100935. /** 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 */
  100936. static readonly ALWAYS: number;
  100937. /** Passed to stencilOperation to specify that stencil value must be kept */
  100938. static readonly KEEP: number;
  100939. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100940. static readonly REPLACE: number;
  100941. private _isStencilTestDirty;
  100942. private _isStencilMaskDirty;
  100943. private _isStencilFuncDirty;
  100944. private _isStencilOpDirty;
  100945. private _stencilTest;
  100946. private _stencilMask;
  100947. private _stencilFunc;
  100948. private _stencilFuncRef;
  100949. private _stencilFuncMask;
  100950. private _stencilOpStencilFail;
  100951. private _stencilOpDepthFail;
  100952. private _stencilOpStencilDepthPass;
  100953. get isDirty(): boolean;
  100954. get stencilFunc(): number;
  100955. set stencilFunc(value: number);
  100956. get stencilFuncRef(): number;
  100957. set stencilFuncRef(value: number);
  100958. get stencilFuncMask(): number;
  100959. set stencilFuncMask(value: number);
  100960. get stencilOpStencilFail(): number;
  100961. set stencilOpStencilFail(value: number);
  100962. get stencilOpDepthFail(): number;
  100963. set stencilOpDepthFail(value: number);
  100964. get stencilOpStencilDepthPass(): number;
  100965. set stencilOpStencilDepthPass(value: number);
  100966. get stencilMask(): number;
  100967. set stencilMask(value: number);
  100968. get stencilTest(): boolean;
  100969. set stencilTest(value: boolean);
  100970. constructor();
  100971. reset(): void;
  100972. apply(gl: WebGLRenderingContext): void;
  100973. }
  100974. }
  100975. declare module BABYLON {
  100976. /**
  100977. * @hidden
  100978. **/
  100979. export class AlphaState {
  100980. private _isAlphaBlendDirty;
  100981. private _isBlendFunctionParametersDirty;
  100982. private _isBlendEquationParametersDirty;
  100983. private _isBlendConstantsDirty;
  100984. private _alphaBlend;
  100985. private _blendFunctionParameters;
  100986. private _blendEquationParameters;
  100987. private _blendConstants;
  100988. /**
  100989. * Initializes the state.
  100990. */
  100991. constructor();
  100992. get isDirty(): boolean;
  100993. get alphaBlend(): boolean;
  100994. set alphaBlend(value: boolean);
  100995. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  100996. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  100997. setAlphaEquationParameters(rgb: number, alpha: number): void;
  100998. reset(): void;
  100999. apply(gl: WebGLRenderingContext): void;
  101000. }
  101001. }
  101002. declare module BABYLON {
  101003. /** @hidden */
  101004. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101005. attributeProcessor(attribute: string): string;
  101006. varyingProcessor(varying: string, isFragment: boolean): string;
  101007. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101008. }
  101009. }
  101010. declare module BABYLON {
  101011. /**
  101012. * Interface for attribute information associated with buffer instanciation
  101013. */
  101014. export interface InstancingAttributeInfo {
  101015. /**
  101016. * Name of the GLSL attribute
  101017. * if attribute index is not specified, this is used to retrieve the index from the effect
  101018. */
  101019. attributeName: string;
  101020. /**
  101021. * Index/offset of the attribute in the vertex shader
  101022. * if not specified, this will be computes from the name.
  101023. */
  101024. index?: number;
  101025. /**
  101026. * size of the attribute, 1, 2, 3 or 4
  101027. */
  101028. attributeSize: number;
  101029. /**
  101030. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101031. */
  101032. offset: number;
  101033. /**
  101034. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101035. * default to 1
  101036. */
  101037. divisor?: number;
  101038. /**
  101039. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101040. * default is FLOAT
  101041. */
  101042. attributeType?: number;
  101043. /**
  101044. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101045. */
  101046. normalized?: boolean;
  101047. }
  101048. }
  101049. declare module BABYLON {
  101050. interface ThinEngine {
  101051. /**
  101052. * Update a video texture
  101053. * @param texture defines the texture to update
  101054. * @param video defines the video element to use
  101055. * @param invertY defines if data must be stored with Y axis inverted
  101056. */
  101057. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101058. }
  101059. }
  101060. declare module BABYLON {
  101061. /**
  101062. * Settings for finer control over video usage
  101063. */
  101064. export interface VideoTextureSettings {
  101065. /**
  101066. * Applies `autoplay` to video, if specified
  101067. */
  101068. autoPlay?: boolean;
  101069. /**
  101070. * Applies `loop` to video, if specified
  101071. */
  101072. loop?: boolean;
  101073. /**
  101074. * Automatically updates internal texture from video at every frame in the render loop
  101075. */
  101076. autoUpdateTexture: boolean;
  101077. /**
  101078. * Image src displayed during the video loading or until the user interacts with the video.
  101079. */
  101080. poster?: string;
  101081. }
  101082. /**
  101083. * If you want to display a video in your scene, this is the special texture for that.
  101084. * This special texture works similar to other textures, with the exception of a few parameters.
  101085. * @see https://doc.babylonjs.com/how_to/video_texture
  101086. */
  101087. export class VideoTexture extends Texture {
  101088. /**
  101089. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101090. */
  101091. readonly autoUpdateTexture: boolean;
  101092. /**
  101093. * The video instance used by the texture internally
  101094. */
  101095. readonly video: HTMLVideoElement;
  101096. private _onUserActionRequestedObservable;
  101097. /**
  101098. * Event triggerd when a dom action is required by the user to play the video.
  101099. * This happens due to recent changes in browser policies preventing video to auto start.
  101100. */
  101101. get onUserActionRequestedObservable(): Observable<Texture>;
  101102. private _generateMipMaps;
  101103. private _engine;
  101104. private _stillImageCaptured;
  101105. private _displayingPosterTexture;
  101106. private _settings;
  101107. private _createInternalTextureOnEvent;
  101108. private _frameId;
  101109. /**
  101110. * Creates a video texture.
  101111. * If you want to display a video in your scene, this is the special texture for that.
  101112. * This special texture works similar to other textures, with the exception of a few parameters.
  101113. * @see https://doc.babylonjs.com/how_to/video_texture
  101114. * @param name optional name, will detect from video source, if not defined
  101115. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101116. * @param scene is obviously the current scene.
  101117. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101118. * @param invertY is false by default but can be used to invert video on Y axis
  101119. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101120. * @param settings allows finer control over video usage
  101121. */
  101122. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101123. private _getName;
  101124. private _getVideo;
  101125. private _createInternalTexture;
  101126. private reset;
  101127. /**
  101128. * @hidden Internal method to initiate `update`.
  101129. */
  101130. _rebuild(): void;
  101131. /**
  101132. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101133. */
  101134. update(): void;
  101135. /**
  101136. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101137. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101138. */
  101139. updateTexture(isVisible: boolean): void;
  101140. protected _updateInternalTexture: () => void;
  101141. /**
  101142. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101143. * @param url New url.
  101144. */
  101145. updateURL(url: string): void;
  101146. /**
  101147. * Dispose the texture and release its associated resources.
  101148. */
  101149. dispose(): void;
  101150. /**
  101151. * Creates a video texture straight from a stream.
  101152. * @param scene Define the scene the texture should be created in
  101153. * @param stream Define the stream the texture should be created from
  101154. * @returns The created video texture as a promise
  101155. */
  101156. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101157. /**
  101158. * Creates a video texture straight from your WebCam video feed.
  101159. * @param scene Define the scene the texture should be created in
  101160. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101161. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101162. * @returns The created video texture as a promise
  101163. */
  101164. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101165. minWidth: number;
  101166. maxWidth: number;
  101167. minHeight: number;
  101168. maxHeight: number;
  101169. deviceId: string;
  101170. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101171. /**
  101172. * Creates a video texture straight from your WebCam video feed.
  101173. * @param scene Define the scene the texture should be created in
  101174. * @param onReady Define a callback to triggered once the texture will be ready
  101175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101177. */
  101178. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101179. minWidth: number;
  101180. maxWidth: number;
  101181. minHeight: number;
  101182. maxHeight: number;
  101183. deviceId: string;
  101184. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * Defines the interface used by objects working like Scene
  101190. * @hidden
  101191. */
  101192. interface ISceneLike {
  101193. _addPendingData(data: any): void;
  101194. _removePendingData(data: any): void;
  101195. offlineProvider: IOfflineProvider;
  101196. }
  101197. /** Interface defining initialization parameters for Engine class */
  101198. export interface EngineOptions extends WebGLContextAttributes {
  101199. /**
  101200. * Defines if the engine should no exceed a specified device ratio
  101201. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101202. */
  101203. limitDeviceRatio?: number;
  101204. /**
  101205. * Defines if webvr should be enabled automatically
  101206. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101207. */
  101208. autoEnableWebVR?: boolean;
  101209. /**
  101210. * Defines if webgl2 should be turned off even if supported
  101211. * @see http://doc.babylonjs.com/features/webgl2
  101212. */
  101213. disableWebGL2Support?: boolean;
  101214. /**
  101215. * Defines if webaudio should be initialized as well
  101216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101217. */
  101218. audioEngine?: boolean;
  101219. /**
  101220. * Defines if animations should run using a deterministic lock step
  101221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101222. */
  101223. deterministicLockstep?: boolean;
  101224. /** Defines the maximum steps to use with deterministic lock step mode */
  101225. lockstepMaxSteps?: number;
  101226. /** Defines the seconds between each deterministic lock step */
  101227. timeStep?: number;
  101228. /**
  101229. * Defines that engine should ignore context lost events
  101230. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101231. */
  101232. doNotHandleContextLost?: boolean;
  101233. /**
  101234. * Defines that engine should ignore modifying touch action attribute and style
  101235. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101236. */
  101237. doNotHandleTouchAction?: boolean;
  101238. /**
  101239. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101240. */
  101241. useHighPrecisionFloats?: boolean;
  101242. }
  101243. /**
  101244. * The base engine class (root of all engines)
  101245. */
  101246. export class ThinEngine {
  101247. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101248. static ExceptionList: ({
  101249. key: string;
  101250. capture: string;
  101251. captureConstraint: number;
  101252. targets: string[];
  101253. } | {
  101254. key: string;
  101255. capture: null;
  101256. captureConstraint: null;
  101257. targets: string[];
  101258. })[];
  101259. /** @hidden */
  101260. static _TextureLoaders: IInternalTextureLoader[];
  101261. /**
  101262. * Returns the current npm package of the sdk
  101263. */
  101264. static get NpmPackage(): string;
  101265. /**
  101266. * Returns the current version of the framework
  101267. */
  101268. static get Version(): string;
  101269. /**
  101270. * Returns a string describing the current engine
  101271. */
  101272. get description(): string;
  101273. /**
  101274. * Gets or sets the epsilon value used by collision engine
  101275. */
  101276. static CollisionsEpsilon: number;
  101277. /**
  101278. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101279. */
  101280. static get ShadersRepository(): string;
  101281. static set ShadersRepository(value: string);
  101282. /**
  101283. * Gets or sets the textures that the engine should not attempt to load as compressed
  101284. */
  101285. protected _excludedCompressedTextures: string[];
  101286. /**
  101287. * Filters the compressed texture formats to only include
  101288. * files that are not included in the skippable list
  101289. *
  101290. * @param url the current extension
  101291. * @param textureFormatInUse the current compressed texture format
  101292. * @returns "format" string
  101293. */
  101294. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101295. /** @hidden */
  101296. _shaderProcessor: IShaderProcessor;
  101297. /**
  101298. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101299. */
  101300. forcePOTTextures: boolean;
  101301. /**
  101302. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101303. */
  101304. isFullscreen: boolean;
  101305. /**
  101306. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101307. */
  101308. cullBackFaces: boolean;
  101309. /**
  101310. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101311. */
  101312. renderEvenInBackground: boolean;
  101313. /**
  101314. * Gets or sets a boolean indicating that cache can be kept between frames
  101315. */
  101316. preventCacheWipeBetweenFrames: boolean;
  101317. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101318. validateShaderPrograms: boolean;
  101319. /**
  101320. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101321. * This can provide greater z depth for distant objects.
  101322. */
  101323. useReverseDepthBuffer: boolean;
  101324. /**
  101325. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101326. */
  101327. disableUniformBuffers: boolean;
  101328. /** @hidden */
  101329. _uniformBuffers: UniformBuffer[];
  101330. /**
  101331. * Gets a boolean indicating that the engine supports uniform buffers
  101332. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101333. */
  101334. get supportsUniformBuffers(): boolean;
  101335. /** @hidden */
  101336. _gl: WebGLRenderingContext;
  101337. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101338. protected _windowIsBackground: boolean;
  101339. protected _webGLVersion: number;
  101340. protected _creationOptions: EngineOptions;
  101341. protected _highPrecisionShadersAllowed: boolean;
  101342. /** @hidden */
  101343. get _shouldUseHighPrecisionShader(): boolean;
  101344. /**
  101345. * Gets a boolean indicating that only power of 2 textures are supported
  101346. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101347. */
  101348. get needPOTTextures(): boolean;
  101349. /** @hidden */
  101350. _badOS: boolean;
  101351. /** @hidden */
  101352. _badDesktopOS: boolean;
  101353. private _hardwareScalingLevel;
  101354. /** @hidden */
  101355. _caps: EngineCapabilities;
  101356. private _isStencilEnable;
  101357. private _glVersion;
  101358. private _glRenderer;
  101359. private _glVendor;
  101360. /** @hidden */
  101361. _videoTextureSupported: boolean;
  101362. protected _renderingQueueLaunched: boolean;
  101363. protected _activeRenderLoops: (() => void)[];
  101364. /**
  101365. * Observable signaled when a context lost event is raised
  101366. */
  101367. onContextLostObservable: Observable<ThinEngine>;
  101368. /**
  101369. * Observable signaled when a context restored event is raised
  101370. */
  101371. onContextRestoredObservable: Observable<ThinEngine>;
  101372. private _onContextLost;
  101373. private _onContextRestored;
  101374. protected _contextWasLost: boolean;
  101375. /** @hidden */
  101376. _doNotHandleContextLost: boolean;
  101377. /**
  101378. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101380. */
  101381. get doNotHandleContextLost(): boolean;
  101382. set doNotHandleContextLost(value: boolean);
  101383. /**
  101384. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101385. */
  101386. disableVertexArrayObjects: boolean;
  101387. /** @hidden */
  101388. protected _colorWrite: boolean;
  101389. /** @hidden */
  101390. protected _colorWriteChanged: boolean;
  101391. /** @hidden */
  101392. protected _depthCullingState: DepthCullingState;
  101393. /** @hidden */
  101394. protected _stencilState: StencilState;
  101395. /** @hidden */
  101396. _alphaState: AlphaState;
  101397. /** @hidden */
  101398. _alphaMode: number;
  101399. /** @hidden */
  101400. _alphaEquation: number;
  101401. /** @hidden */
  101402. _internalTexturesCache: InternalTexture[];
  101403. /** @hidden */
  101404. protected _activeChannel: number;
  101405. private _currentTextureChannel;
  101406. /** @hidden */
  101407. protected _boundTexturesCache: {
  101408. [key: string]: Nullable<InternalTexture>;
  101409. };
  101410. /** @hidden */
  101411. protected _currentEffect: Nullable<Effect>;
  101412. /** @hidden */
  101413. protected _currentProgram: Nullable<WebGLProgram>;
  101414. private _compiledEffects;
  101415. private _vertexAttribArraysEnabled;
  101416. /** @hidden */
  101417. protected _cachedViewport: Nullable<IViewportLike>;
  101418. private _cachedVertexArrayObject;
  101419. /** @hidden */
  101420. protected _cachedVertexBuffers: any;
  101421. /** @hidden */
  101422. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101423. /** @hidden */
  101424. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101425. /** @hidden */
  101426. _currentRenderTarget: Nullable<InternalTexture>;
  101427. private _uintIndicesCurrentlySet;
  101428. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101429. /** @hidden */
  101430. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101431. private _currentBufferPointers;
  101432. private _currentInstanceLocations;
  101433. private _currentInstanceBuffers;
  101434. private _textureUnits;
  101435. /** @hidden */
  101436. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101437. /** @hidden */
  101438. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101439. /** @hidden */
  101440. _boundRenderFunction: any;
  101441. private _vaoRecordInProgress;
  101442. private _mustWipeVertexAttributes;
  101443. private _emptyTexture;
  101444. private _emptyCubeTexture;
  101445. private _emptyTexture3D;
  101446. private _emptyTexture2DArray;
  101447. /** @hidden */
  101448. _frameHandler: number;
  101449. private _nextFreeTextureSlots;
  101450. private _maxSimultaneousTextures;
  101451. private _activeRequests;
  101452. protected _texturesSupported: string[];
  101453. /** @hidden */
  101454. _textureFormatInUse: Nullable<string>;
  101455. protected get _supportsHardwareTextureRescaling(): boolean;
  101456. /**
  101457. * Gets the list of texture formats supported
  101458. */
  101459. get texturesSupported(): Array<string>;
  101460. /**
  101461. * Gets the list of texture formats in use
  101462. */
  101463. get textureFormatInUse(): Nullable<string>;
  101464. /**
  101465. * Gets the current viewport
  101466. */
  101467. get currentViewport(): Nullable<IViewportLike>;
  101468. /**
  101469. * Gets the default empty texture
  101470. */
  101471. get emptyTexture(): InternalTexture;
  101472. /**
  101473. * Gets the default empty 3D texture
  101474. */
  101475. get emptyTexture3D(): InternalTexture;
  101476. /**
  101477. * Gets the default empty 2D array texture
  101478. */
  101479. get emptyTexture2DArray(): InternalTexture;
  101480. /**
  101481. * Gets the default empty cube texture
  101482. */
  101483. get emptyCubeTexture(): InternalTexture;
  101484. /**
  101485. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101486. */
  101487. readonly premultipliedAlpha: boolean;
  101488. /**
  101489. * Observable event triggered before each texture is initialized
  101490. */
  101491. onBeforeTextureInitObservable: Observable<Texture>;
  101492. /**
  101493. * Creates a new engine
  101494. * @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
  101495. * @param antialias defines enable antialiasing (default: false)
  101496. * @param options defines further options to be sent to the getContext() function
  101497. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101498. */
  101499. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101500. private _rebuildInternalTextures;
  101501. private _rebuildEffects;
  101502. /**
  101503. * Gets a boolean indicating if all created effects are ready
  101504. * @returns true if all effects are ready
  101505. */
  101506. areAllEffectsReady(): boolean;
  101507. protected _rebuildBuffers(): void;
  101508. private _initGLContext;
  101509. /**
  101510. * Gets version of the current webGL context
  101511. */
  101512. get webGLVersion(): number;
  101513. /**
  101514. * Gets a string idenfifying the name of the class
  101515. * @returns "Engine" string
  101516. */
  101517. getClassName(): string;
  101518. /**
  101519. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101520. */
  101521. get isStencilEnable(): boolean;
  101522. /** @hidden */
  101523. _prepareWorkingCanvas(): void;
  101524. /**
  101525. * Reset the texture cache to empty state
  101526. */
  101527. resetTextureCache(): void;
  101528. /**
  101529. * Gets an object containing information about the current webGL context
  101530. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101531. */
  101532. getGlInfo(): {
  101533. vendor: string;
  101534. renderer: string;
  101535. version: string;
  101536. };
  101537. /**
  101538. * Defines the hardware scaling level.
  101539. * By default the hardware scaling level is computed from the window device ratio.
  101540. * 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.
  101541. * @param level defines the level to use
  101542. */
  101543. setHardwareScalingLevel(level: number): void;
  101544. /**
  101545. * Gets the current hardware scaling level.
  101546. * By default the hardware scaling level is computed from the window device ratio.
  101547. * 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.
  101548. * @returns a number indicating the current hardware scaling level
  101549. */
  101550. getHardwareScalingLevel(): number;
  101551. /**
  101552. * Gets the list of loaded textures
  101553. * @returns an array containing all loaded textures
  101554. */
  101555. getLoadedTexturesCache(): InternalTexture[];
  101556. /**
  101557. * Gets the object containing all engine capabilities
  101558. * @returns the EngineCapabilities object
  101559. */
  101560. getCaps(): EngineCapabilities;
  101561. /**
  101562. * stop executing a render loop function and remove it from the execution array
  101563. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101564. */
  101565. stopRenderLoop(renderFunction?: () => void): void;
  101566. /** @hidden */
  101567. _renderLoop(): void;
  101568. /**
  101569. * Gets the HTML canvas attached with the current webGL context
  101570. * @returns a HTML canvas
  101571. */
  101572. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101573. /**
  101574. * Gets host window
  101575. * @returns the host window object
  101576. */
  101577. getHostWindow(): Nullable<Window>;
  101578. /**
  101579. * Gets the current render width
  101580. * @param useScreen defines if screen size must be used (or the current render target if any)
  101581. * @returns a number defining the current render width
  101582. */
  101583. getRenderWidth(useScreen?: boolean): number;
  101584. /**
  101585. * Gets the current render height
  101586. * @param useScreen defines if screen size must be used (or the current render target if any)
  101587. * @returns a number defining the current render height
  101588. */
  101589. getRenderHeight(useScreen?: boolean): number;
  101590. /**
  101591. * Can be used to override the current requestAnimationFrame requester.
  101592. * @hidden
  101593. */
  101594. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101595. /**
  101596. * Register and execute a render loop. The engine can have more than one render function
  101597. * @param renderFunction defines the function to continuously execute
  101598. */
  101599. runRenderLoop(renderFunction: () => void): void;
  101600. /**
  101601. * Clear the current render buffer or the current render target (if any is set up)
  101602. * @param color defines the color to use
  101603. * @param backBuffer defines if the back buffer must be cleared
  101604. * @param depth defines if the depth buffer must be cleared
  101605. * @param stencil defines if the stencil buffer must be cleared
  101606. */
  101607. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101608. private _viewportCached;
  101609. /** @hidden */
  101610. _viewport(x: number, y: number, width: number, height: number): void;
  101611. /**
  101612. * Set the WebGL's viewport
  101613. * @param viewport defines the viewport element to be used
  101614. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101615. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101616. */
  101617. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101618. /**
  101619. * Begin a new frame
  101620. */
  101621. beginFrame(): void;
  101622. /**
  101623. * Enf the current frame
  101624. */
  101625. endFrame(): void;
  101626. /**
  101627. * Resize the view according to the canvas' size
  101628. */
  101629. resize(): void;
  101630. /**
  101631. * Force a specific size of the canvas
  101632. * @param width defines the new canvas' width
  101633. * @param height defines the new canvas' height
  101634. */
  101635. setSize(width: number, height: number): void;
  101636. /**
  101637. * Binds the frame buffer to the specified texture.
  101638. * @param texture The texture to render to or null for the default canvas
  101639. * @param faceIndex The face of the texture to render to in case of cube texture
  101640. * @param requiredWidth The width of the target to render to
  101641. * @param requiredHeight The height of the target to render to
  101642. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101643. * @param depthStencilTexture The depth stencil texture to use to render
  101644. * @param lodLevel defines le lod level to bind to the frame buffer
  101645. */
  101646. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101647. /** @hidden */
  101648. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101649. /**
  101650. * Unbind the current render target texture from the webGL context
  101651. * @param texture defines the render target texture to unbind
  101652. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101653. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101654. */
  101655. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101656. /**
  101657. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101658. */
  101659. flushFramebuffer(): void;
  101660. /**
  101661. * Unbind the current render target and bind the default framebuffer
  101662. */
  101663. restoreDefaultFramebuffer(): void;
  101664. /** @hidden */
  101665. protected _resetVertexBufferBinding(): void;
  101666. /**
  101667. * Creates a vertex buffer
  101668. * @param data the data for the vertex buffer
  101669. * @returns the new WebGL static buffer
  101670. */
  101671. createVertexBuffer(data: DataArray): DataBuffer;
  101672. private _createVertexBuffer;
  101673. /**
  101674. * Creates a dynamic vertex buffer
  101675. * @param data the data for the dynamic vertex buffer
  101676. * @returns the new WebGL dynamic buffer
  101677. */
  101678. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101679. protected _resetIndexBufferBinding(): void;
  101680. /**
  101681. * Creates a new index buffer
  101682. * @param indices defines the content of the index buffer
  101683. * @param updatable defines if the index buffer must be updatable
  101684. * @returns a new webGL buffer
  101685. */
  101686. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101687. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101688. /**
  101689. * Bind a webGL buffer to the webGL context
  101690. * @param buffer defines the buffer to bind
  101691. */
  101692. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101693. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101694. private bindBuffer;
  101695. /**
  101696. * update the bound buffer with the given data
  101697. * @param data defines the data to update
  101698. */
  101699. updateArrayBuffer(data: Float32Array): void;
  101700. private _vertexAttribPointer;
  101701. private _bindIndexBufferWithCache;
  101702. private _bindVertexBuffersAttributes;
  101703. /**
  101704. * Records a vertex array object
  101705. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101706. * @param vertexBuffers defines the list of vertex buffers to store
  101707. * @param indexBuffer defines the index buffer to store
  101708. * @param effect defines the effect to store
  101709. * @returns the new vertex array object
  101710. */
  101711. recordVertexArrayObject(vertexBuffers: {
  101712. [key: string]: VertexBuffer;
  101713. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101714. /**
  101715. * Bind a specific vertex array object
  101716. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101717. * @param vertexArrayObject defines the vertex array object to bind
  101718. * @param indexBuffer defines the index buffer to bind
  101719. */
  101720. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101721. /**
  101722. * Bind webGl buffers directly to the webGL context
  101723. * @param vertexBuffer defines the vertex buffer to bind
  101724. * @param indexBuffer defines the index buffer to bind
  101725. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101726. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101727. * @param effect defines the effect associated with the vertex buffer
  101728. */
  101729. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101730. private _unbindVertexArrayObject;
  101731. /**
  101732. * Bind a list of vertex buffers to the webGL context
  101733. * @param vertexBuffers defines the list of vertex buffers to bind
  101734. * @param indexBuffer defines the index buffer to bind
  101735. * @param effect defines the effect associated with the vertex buffers
  101736. */
  101737. bindBuffers(vertexBuffers: {
  101738. [key: string]: Nullable<VertexBuffer>;
  101739. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101740. /**
  101741. * Unbind all instance attributes
  101742. */
  101743. unbindInstanceAttributes(): void;
  101744. /**
  101745. * Release and free the memory of a vertex array object
  101746. * @param vao defines the vertex array object to delete
  101747. */
  101748. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101749. /** @hidden */
  101750. _releaseBuffer(buffer: DataBuffer): boolean;
  101751. protected _deleteBuffer(buffer: DataBuffer): void;
  101752. /**
  101753. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101754. * @param instancesBuffer defines the webGL buffer to update and bind
  101755. * @param data defines the data to store in the buffer
  101756. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101757. */
  101758. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101759. /**
  101760. * Bind the content of a webGL buffer used with instanciation
  101761. * @param instancesBuffer defines the webGL buffer to bind
  101762. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101763. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101764. */
  101765. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101766. /**
  101767. * Disable the instance attribute corresponding to the name in parameter
  101768. * @param name defines the name of the attribute to disable
  101769. */
  101770. disableInstanceAttributeByName(name: string): void;
  101771. /**
  101772. * Disable the instance attribute corresponding to the location in parameter
  101773. * @param attributeLocation defines the attribute location of the attribute to disable
  101774. */
  101775. disableInstanceAttribute(attributeLocation: number): void;
  101776. /**
  101777. * Disable the attribute corresponding to the location in parameter
  101778. * @param attributeLocation defines the attribute location of the attribute to disable
  101779. */
  101780. disableAttributeByIndex(attributeLocation: number): void;
  101781. /**
  101782. * Send a draw order
  101783. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101784. * @param indexStart defines the starting index
  101785. * @param indexCount defines the number of index to draw
  101786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101787. */
  101788. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101789. /**
  101790. * Draw a list of points
  101791. * @param verticesStart defines the index of first vertex to draw
  101792. * @param verticesCount defines the count of vertices to draw
  101793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101794. */
  101795. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101796. /**
  101797. * Draw a list of unindexed primitives
  101798. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101799. * @param verticesStart defines the index of first vertex to draw
  101800. * @param verticesCount defines the count of vertices to draw
  101801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101802. */
  101803. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101804. /**
  101805. * Draw a list of indexed primitives
  101806. * @param fillMode defines the primitive to use
  101807. * @param indexStart defines the starting index
  101808. * @param indexCount defines the number of index to draw
  101809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101810. */
  101811. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101812. /**
  101813. * Draw a list of unindexed primitives
  101814. * @param fillMode defines the primitive to use
  101815. * @param verticesStart defines the index of first vertex to draw
  101816. * @param verticesCount defines the count of vertices to draw
  101817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101818. */
  101819. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101820. private _drawMode;
  101821. /** @hidden */
  101822. protected _reportDrawCall(): void;
  101823. /** @hidden */
  101824. _releaseEffect(effect: Effect): void;
  101825. /** @hidden */
  101826. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101827. /**
  101828. * Create a new effect (used to store vertex/fragment shaders)
  101829. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101830. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101831. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101832. * @param samplers defines an array of string used to represent textures
  101833. * @param defines defines the string containing the defines to use to compile the shaders
  101834. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101835. * @param onCompiled defines a function to call when the effect creation is successful
  101836. * @param onError defines a function to call when the effect creation has failed
  101837. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101838. * @returns the new Effect
  101839. */
  101840. 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;
  101841. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101842. private _compileShader;
  101843. private _compileRawShader;
  101844. /**
  101845. * Directly creates a webGL program
  101846. * @param pipelineContext defines the pipeline context to attach to
  101847. * @param vertexCode defines the vertex shader code to use
  101848. * @param fragmentCode defines the fragment shader code to use
  101849. * @param context defines the webGL context to use (if not set, the current one will be used)
  101850. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101851. * @returns the new webGL program
  101852. */
  101853. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101854. /**
  101855. * Creates a webGL program
  101856. * @param pipelineContext defines the pipeline context to attach to
  101857. * @param vertexCode defines the vertex shader code to use
  101858. * @param fragmentCode defines the fragment shader code to use
  101859. * @param defines defines the string containing the defines to use to compile the shaders
  101860. * @param context defines the webGL context to use (if not set, the current one will be used)
  101861. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101862. * @returns the new webGL program
  101863. */
  101864. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101865. /**
  101866. * Creates a new pipeline context
  101867. * @returns the new pipeline
  101868. */
  101869. createPipelineContext(): IPipelineContext;
  101870. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101871. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101872. /** @hidden */
  101873. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101874. /** @hidden */
  101875. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101876. /** @hidden */
  101877. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101878. /**
  101879. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101880. * @param pipelineContext defines the pipeline context to use
  101881. * @param uniformsNames defines the list of uniform names
  101882. * @returns an array of webGL uniform locations
  101883. */
  101884. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101885. /**
  101886. * Gets the lsit of active attributes for a given webGL program
  101887. * @param pipelineContext defines the pipeline context to use
  101888. * @param attributesNames defines the list of attribute names to get
  101889. * @returns an array of indices indicating the offset of each attribute
  101890. */
  101891. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101892. /**
  101893. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101894. * @param effect defines the effect to activate
  101895. */
  101896. enableEffect(effect: Nullable<Effect>): void;
  101897. /**
  101898. * Set the value of an uniform to a number (int)
  101899. * @param uniform defines the webGL uniform location where to store the value
  101900. * @param value defines the int number to store
  101901. */
  101902. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101903. /**
  101904. * Set the value of an uniform to an array of int32
  101905. * @param uniform defines the webGL uniform location where to store the value
  101906. * @param array defines the array of int32 to store
  101907. */
  101908. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101909. /**
  101910. * Set the value of an uniform to an array of int32 (stored as vec2)
  101911. * @param uniform defines the webGL uniform location where to store the value
  101912. * @param array defines the array of int32 to store
  101913. */
  101914. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101915. /**
  101916. * Set the value of an uniform to an array of int32 (stored as vec3)
  101917. * @param uniform defines the webGL uniform location where to store the value
  101918. * @param array defines the array of int32 to store
  101919. */
  101920. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101921. /**
  101922. * Set the value of an uniform to an array of int32 (stored as vec4)
  101923. * @param uniform defines the webGL uniform location where to store the value
  101924. * @param array defines the array of int32 to store
  101925. */
  101926. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101927. /**
  101928. * Set the value of an uniform to an array of number
  101929. * @param uniform defines the webGL uniform location where to store the value
  101930. * @param array defines the array of number to store
  101931. */
  101932. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101933. /**
  101934. * Set the value of an uniform to an array of number (stored as vec2)
  101935. * @param uniform defines the webGL uniform location where to store the value
  101936. * @param array defines the array of number to store
  101937. */
  101938. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101939. /**
  101940. * Set the value of an uniform to an array of number (stored as vec3)
  101941. * @param uniform defines the webGL uniform location where to store the value
  101942. * @param array defines the array of number to store
  101943. */
  101944. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101945. /**
  101946. * Set the value of an uniform to an array of number (stored as vec4)
  101947. * @param uniform defines the webGL uniform location where to store the value
  101948. * @param array defines the array of number to store
  101949. */
  101950. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101951. /**
  101952. * Set the value of an uniform to an array of float32 (stored as matrices)
  101953. * @param uniform defines the webGL uniform location where to store the value
  101954. * @param matrices defines the array of float32 to store
  101955. */
  101956. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  101957. /**
  101958. * Set the value of an uniform to a matrix (3x3)
  101959. * @param uniform defines the webGL uniform location where to store the value
  101960. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  101961. */
  101962. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101963. /**
  101964. * Set the value of an uniform to a matrix (2x2)
  101965. * @param uniform defines the webGL uniform location where to store the value
  101966. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  101967. */
  101968. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101969. /**
  101970. * Set the value of an uniform to a number (float)
  101971. * @param uniform defines the webGL uniform location where to store the value
  101972. * @param value defines the float number to store
  101973. */
  101974. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101975. /**
  101976. * Set the value of an uniform to a vec2
  101977. * @param uniform defines the webGL uniform location where to store the value
  101978. * @param x defines the 1st component of the value
  101979. * @param y defines the 2nd component of the value
  101980. */
  101981. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  101982. /**
  101983. * Set the value of an uniform to a vec3
  101984. * @param uniform defines the webGL uniform location where to store the value
  101985. * @param x defines the 1st component of the value
  101986. * @param y defines the 2nd component of the value
  101987. * @param z defines the 3rd component of the value
  101988. */
  101989. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  101990. /**
  101991. * Set the value of an uniform to a vec4
  101992. * @param uniform defines the webGL uniform location where to store the value
  101993. * @param x defines the 1st component of the value
  101994. * @param y defines the 2nd component of the value
  101995. * @param z defines the 3rd component of the value
  101996. * @param w defines the 4th component of the value
  101997. */
  101998. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  101999. /**
  102000. * Apply all cached states (depth, culling, stencil and alpha)
  102001. */
  102002. applyStates(): void;
  102003. /**
  102004. * Enable or disable color writing
  102005. * @param enable defines the state to set
  102006. */
  102007. setColorWrite(enable: boolean): void;
  102008. /**
  102009. * Gets a boolean indicating if color writing is enabled
  102010. * @returns the current color writing state
  102011. */
  102012. getColorWrite(): boolean;
  102013. /**
  102014. * Gets the depth culling state manager
  102015. */
  102016. get depthCullingState(): DepthCullingState;
  102017. /**
  102018. * Gets the alpha state manager
  102019. */
  102020. get alphaState(): AlphaState;
  102021. /**
  102022. * Gets the stencil state manager
  102023. */
  102024. get stencilState(): StencilState;
  102025. /**
  102026. * Clears the list of texture accessible through engine.
  102027. * This can help preventing texture load conflict due to name collision.
  102028. */
  102029. clearInternalTexturesCache(): void;
  102030. /**
  102031. * Force the entire cache to be cleared
  102032. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102033. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102034. */
  102035. wipeCaches(bruteForce?: boolean): void;
  102036. /** @hidden */
  102037. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102038. min: number;
  102039. mag: number;
  102040. };
  102041. /** @hidden */
  102042. _createTexture(): WebGLTexture;
  102043. /**
  102044. * Usually called from Texture.ts.
  102045. * Passed information to create a WebGLTexture
  102046. * @param urlArg defines a value which contains one of the following:
  102047. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102048. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102049. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102050. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102051. * @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)
  102052. * @param scene needed for loading to the correct scene
  102053. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102054. * @param onLoad optional callback to be called upon successful completion
  102055. * @param onError optional callback to be called upon failure
  102056. * @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
  102057. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102058. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102059. * @param forcedExtension defines the extension to use to pick the right loader
  102060. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102061. * @param mimeType defines an optional mime type
  102062. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102063. */
  102064. 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;
  102065. /**
  102066. * @hidden
  102067. */
  102068. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102069. /**
  102070. * Creates a raw texture
  102071. * @param data defines the data to store in the texture
  102072. * @param width defines the width of the texture
  102073. * @param height defines the height of the texture
  102074. * @param format defines the format of the data
  102075. * @param generateMipMaps defines if the engine should generate the mip levels
  102076. * @param invertY defines if data must be stored with Y axis inverted
  102077. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102078. * @param compression defines the compression used (null by default)
  102079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102080. * @returns the raw texture inside an InternalTexture
  102081. */
  102082. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102083. /**
  102084. * Creates a new raw cube texture
  102085. * @param data defines the array of data to use to create each face
  102086. * @param size defines the size of the textures
  102087. * @param format defines the format of the data
  102088. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102089. * @param generateMipMaps defines if the engine should generate the mip levels
  102090. * @param invertY defines if data must be stored with Y axis inverted
  102091. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102092. * @param compression defines the compression used (null by default)
  102093. * @returns the cube texture as an InternalTexture
  102094. */
  102095. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102096. /**
  102097. * Creates a new raw 3D texture
  102098. * @param data defines the data used to create the texture
  102099. * @param width defines the width of the texture
  102100. * @param height defines the height of the texture
  102101. * @param depth defines the depth of the texture
  102102. * @param format defines the format of the texture
  102103. * @param generateMipMaps defines if the engine must generate mip levels
  102104. * @param invertY defines if data must be stored with Y axis inverted
  102105. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102106. * @param compression defines the compressed used (can be null)
  102107. * @param textureType defines the compressed used (can be null)
  102108. * @returns a new raw 3D texture (stored in an InternalTexture)
  102109. */
  102110. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102111. /**
  102112. * Creates a new raw 2D array texture
  102113. * @param data defines the data used to create the texture
  102114. * @param width defines the width of the texture
  102115. * @param height defines the height of the texture
  102116. * @param depth defines the number of layers of the texture
  102117. * @param format defines the format of the texture
  102118. * @param generateMipMaps defines if the engine must generate mip levels
  102119. * @param invertY defines if data must be stored with Y axis inverted
  102120. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102121. * @param compression defines the compressed used (can be null)
  102122. * @param textureType defines the compressed used (can be null)
  102123. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102124. */
  102125. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102126. private _unpackFlipYCached;
  102127. /**
  102128. * In case you are sharing the context with other applications, it might
  102129. * be interested to not cache the unpack flip y state to ensure a consistent
  102130. * value would be set.
  102131. */
  102132. enableUnpackFlipYCached: boolean;
  102133. /** @hidden */
  102134. _unpackFlipY(value: boolean): void;
  102135. /** @hidden */
  102136. _getUnpackAlignement(): number;
  102137. private _getTextureTarget;
  102138. /**
  102139. * Update the sampling mode of a given texture
  102140. * @param samplingMode defines the required sampling mode
  102141. * @param texture defines the texture to update
  102142. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102143. */
  102144. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102145. /**
  102146. * Update the sampling mode of a given texture
  102147. * @param texture defines the texture to update
  102148. * @param wrapU defines the texture wrap mode of the u coordinates
  102149. * @param wrapV defines the texture wrap mode of the v coordinates
  102150. * @param wrapR defines the texture wrap mode of the r coordinates
  102151. */
  102152. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102153. /** @hidden */
  102154. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102155. width: number;
  102156. height: number;
  102157. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102158. /** @hidden */
  102159. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102160. /** @hidden */
  102161. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102162. /** @hidden */
  102163. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102164. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102165. private _prepareWebGLTexture;
  102166. /** @hidden */
  102167. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102168. private _getDepthStencilBuffer;
  102169. /** @hidden */
  102170. _releaseFramebufferObjects(texture: InternalTexture): void;
  102171. /** @hidden */
  102172. _releaseTexture(texture: InternalTexture): void;
  102173. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102174. protected _setProgram(program: WebGLProgram): void;
  102175. protected _boundUniforms: {
  102176. [key: number]: WebGLUniformLocation;
  102177. };
  102178. /**
  102179. * Binds an effect to the webGL context
  102180. * @param effect defines the effect to bind
  102181. */
  102182. bindSamplers(effect: Effect): void;
  102183. private _activateCurrentTexture;
  102184. /** @hidden */
  102185. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102186. /** @hidden */
  102187. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102188. /**
  102189. * Unbind all textures from the webGL context
  102190. */
  102191. unbindAllTextures(): void;
  102192. /**
  102193. * Sets a texture to the according uniform.
  102194. * @param channel The texture channel
  102195. * @param uniform The uniform to set
  102196. * @param texture The texture to apply
  102197. */
  102198. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102199. private _bindSamplerUniformToChannel;
  102200. private _getTextureWrapMode;
  102201. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102202. /**
  102203. * Sets an array of texture to the webGL context
  102204. * @param channel defines the channel where the texture array must be set
  102205. * @param uniform defines the associated uniform location
  102206. * @param textures defines the array of textures to bind
  102207. */
  102208. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102209. /** @hidden */
  102210. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  102211. private _setTextureParameterFloat;
  102212. private _setTextureParameterInteger;
  102213. /**
  102214. * Unbind all vertex attributes from the webGL context
  102215. */
  102216. unbindAllAttributes(): void;
  102217. /**
  102218. * 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
  102219. */
  102220. releaseEffects(): void;
  102221. /**
  102222. * Dispose and release all associated resources
  102223. */
  102224. dispose(): void;
  102225. /**
  102226. * Attach a new callback raised when context lost event is fired
  102227. * @param callback defines the callback to call
  102228. */
  102229. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102230. /**
  102231. * Attach a new callback raised when context restored event is fired
  102232. * @param callback defines the callback to call
  102233. */
  102234. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102235. /**
  102236. * Get the current error code of the webGL context
  102237. * @returns the error code
  102238. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102239. */
  102240. getError(): number;
  102241. private _canRenderToFloatFramebuffer;
  102242. private _canRenderToHalfFloatFramebuffer;
  102243. private _canRenderToFramebuffer;
  102244. /** @hidden */
  102245. _getWebGLTextureType(type: number): number;
  102246. /** @hidden */
  102247. _getInternalFormat(format: number): number;
  102248. /** @hidden */
  102249. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102250. /** @hidden */
  102251. _getRGBAMultiSampleBufferFormat(type: number): number;
  102252. /** @hidden */
  102253. _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;
  102254. /**
  102255. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102256. * @param x defines the x coordinate of the rectangle where pixels must be read
  102257. * @param y defines the y coordinate of the rectangle where pixels must be read
  102258. * @param width defines the width of the rectangle where pixels must be read
  102259. * @param height defines the height of the rectangle where pixels must be read
  102260. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102261. * @returns a Uint8Array containing RGBA colors
  102262. */
  102263. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102264. private static _isSupported;
  102265. /**
  102266. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102267. * @returns true if the engine can be created
  102268. * @ignorenaming
  102269. */
  102270. static isSupported(): boolean;
  102271. /**
  102272. * Find the next highest power of two.
  102273. * @param x Number to start search from.
  102274. * @return Next highest power of two.
  102275. */
  102276. static CeilingPOT(x: number): number;
  102277. /**
  102278. * Find the next lowest power of two.
  102279. * @param x Number to start search from.
  102280. * @return Next lowest power of two.
  102281. */
  102282. static FloorPOT(x: number): number;
  102283. /**
  102284. * Find the nearest power of two.
  102285. * @param x Number to start search from.
  102286. * @return Next nearest power of two.
  102287. */
  102288. static NearestPOT(x: number): number;
  102289. /**
  102290. * Get the closest exponent of two
  102291. * @param value defines the value to approximate
  102292. * @param max defines the maximum value to return
  102293. * @param mode defines how to define the closest value
  102294. * @returns closest exponent of two of the given value
  102295. */
  102296. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102297. /**
  102298. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102299. * @param func - the function to be called
  102300. * @param requester - the object that will request the next frame. Falls back to window.
  102301. * @returns frame number
  102302. */
  102303. static QueueNewFrame(func: () => void, requester?: any): number;
  102304. /**
  102305. * Gets host document
  102306. * @returns the host document object
  102307. */
  102308. getHostDocument(): Nullable<Document>;
  102309. }
  102310. }
  102311. declare module BABYLON {
  102312. /**
  102313. * Class representing spherical harmonics coefficients to the 3rd degree
  102314. */
  102315. export class SphericalHarmonics {
  102316. /**
  102317. * Defines whether or not the harmonics have been prescaled for rendering.
  102318. */
  102319. preScaled: boolean;
  102320. /**
  102321. * The l0,0 coefficients of the spherical harmonics
  102322. */
  102323. l00: Vector3;
  102324. /**
  102325. * The l1,-1 coefficients of the spherical harmonics
  102326. */
  102327. l1_1: Vector3;
  102328. /**
  102329. * The l1,0 coefficients of the spherical harmonics
  102330. */
  102331. l10: Vector3;
  102332. /**
  102333. * The l1,1 coefficients of the spherical harmonics
  102334. */
  102335. l11: Vector3;
  102336. /**
  102337. * The l2,-2 coefficients of the spherical harmonics
  102338. */
  102339. l2_2: Vector3;
  102340. /**
  102341. * The l2,-1 coefficients of the spherical harmonics
  102342. */
  102343. l2_1: Vector3;
  102344. /**
  102345. * The l2,0 coefficients of the spherical harmonics
  102346. */
  102347. l20: Vector3;
  102348. /**
  102349. * The l2,1 coefficients of the spherical harmonics
  102350. */
  102351. l21: Vector3;
  102352. /**
  102353. * The l2,2 coefficients of the spherical harmonics
  102354. */
  102355. l22: Vector3;
  102356. /**
  102357. * Adds a light to the spherical harmonics
  102358. * @param direction the direction of the light
  102359. * @param color the color of the light
  102360. * @param deltaSolidAngle the delta solid angle of the light
  102361. */
  102362. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102363. /**
  102364. * Scales the spherical harmonics by the given amount
  102365. * @param scale the amount to scale
  102366. */
  102367. scaleInPlace(scale: number): void;
  102368. /**
  102369. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102370. *
  102371. * ```
  102372. * E_lm = A_l * L_lm
  102373. * ```
  102374. *
  102375. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102376. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102377. * the scaling factors are given in equation 9.
  102378. */
  102379. convertIncidentRadianceToIrradiance(): void;
  102380. /**
  102381. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102382. *
  102383. * ```
  102384. * L = (1/pi) * E * rho
  102385. * ```
  102386. *
  102387. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102388. */
  102389. convertIrradianceToLambertianRadiance(): void;
  102390. /**
  102391. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102392. * required operations at run time.
  102393. *
  102394. * This is simply done by scaling back the SH with Ylm constants parameter.
  102395. * The trigonometric part being applied by the shader at run time.
  102396. */
  102397. preScaleForRendering(): void;
  102398. /**
  102399. * Constructs a spherical harmonics from an array.
  102400. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102401. * @returns the spherical harmonics
  102402. */
  102403. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102404. /**
  102405. * Gets the spherical harmonics from polynomial
  102406. * @param polynomial the spherical polynomial
  102407. * @returns the spherical harmonics
  102408. */
  102409. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102410. }
  102411. /**
  102412. * Class representing spherical polynomial coefficients to the 3rd degree
  102413. */
  102414. export class SphericalPolynomial {
  102415. private _harmonics;
  102416. /**
  102417. * The spherical harmonics used to create the polynomials.
  102418. */
  102419. get preScaledHarmonics(): SphericalHarmonics;
  102420. /**
  102421. * The x coefficients of the spherical polynomial
  102422. */
  102423. x: Vector3;
  102424. /**
  102425. * The y coefficients of the spherical polynomial
  102426. */
  102427. y: Vector3;
  102428. /**
  102429. * The z coefficients of the spherical polynomial
  102430. */
  102431. z: Vector3;
  102432. /**
  102433. * The xx coefficients of the spherical polynomial
  102434. */
  102435. xx: Vector3;
  102436. /**
  102437. * The yy coefficients of the spherical polynomial
  102438. */
  102439. yy: Vector3;
  102440. /**
  102441. * The zz coefficients of the spherical polynomial
  102442. */
  102443. zz: Vector3;
  102444. /**
  102445. * The xy coefficients of the spherical polynomial
  102446. */
  102447. xy: Vector3;
  102448. /**
  102449. * The yz coefficients of the spherical polynomial
  102450. */
  102451. yz: Vector3;
  102452. /**
  102453. * The zx coefficients of the spherical polynomial
  102454. */
  102455. zx: Vector3;
  102456. /**
  102457. * Adds an ambient color to the spherical polynomial
  102458. * @param color the color to add
  102459. */
  102460. addAmbient(color: Color3): void;
  102461. /**
  102462. * Scales the spherical polynomial by the given amount
  102463. * @param scale the amount to scale
  102464. */
  102465. scaleInPlace(scale: number): void;
  102466. /**
  102467. * Gets the spherical polynomial from harmonics
  102468. * @param harmonics the spherical harmonics
  102469. * @returns the spherical polynomial
  102470. */
  102471. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102472. /**
  102473. * Constructs a spherical polynomial from an array.
  102474. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102475. * @returns the spherical polynomial
  102476. */
  102477. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Defines the source of the internal texture
  102483. */
  102484. export enum InternalTextureSource {
  102485. /**
  102486. * The source of the texture data is unknown
  102487. */
  102488. Unknown = 0,
  102489. /**
  102490. * Texture data comes from an URL
  102491. */
  102492. Url = 1,
  102493. /**
  102494. * Texture data is only used for temporary storage
  102495. */
  102496. Temp = 2,
  102497. /**
  102498. * Texture data comes from raw data (ArrayBuffer)
  102499. */
  102500. Raw = 3,
  102501. /**
  102502. * Texture content is dynamic (video or dynamic texture)
  102503. */
  102504. Dynamic = 4,
  102505. /**
  102506. * Texture content is generated by rendering to it
  102507. */
  102508. RenderTarget = 5,
  102509. /**
  102510. * Texture content is part of a multi render target process
  102511. */
  102512. MultiRenderTarget = 6,
  102513. /**
  102514. * Texture data comes from a cube data file
  102515. */
  102516. Cube = 7,
  102517. /**
  102518. * Texture data comes from a raw cube data
  102519. */
  102520. CubeRaw = 8,
  102521. /**
  102522. * Texture data come from a prefiltered cube data file
  102523. */
  102524. CubePrefiltered = 9,
  102525. /**
  102526. * Texture content is raw 3D data
  102527. */
  102528. Raw3D = 10,
  102529. /**
  102530. * Texture content is raw 2D array data
  102531. */
  102532. Raw2DArray = 11,
  102533. /**
  102534. * Texture content is a depth texture
  102535. */
  102536. Depth = 12,
  102537. /**
  102538. * Texture data comes from a raw cube data encoded with RGBD
  102539. */
  102540. CubeRawRGBD = 13
  102541. }
  102542. /**
  102543. * Class used to store data associated with WebGL texture data for the engine
  102544. * This class should not be used directly
  102545. */
  102546. export class InternalTexture {
  102547. /** @hidden */
  102548. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102549. /**
  102550. * Defines if the texture is ready
  102551. */
  102552. isReady: boolean;
  102553. /**
  102554. * Defines if the texture is a cube texture
  102555. */
  102556. isCube: boolean;
  102557. /**
  102558. * Defines if the texture contains 3D data
  102559. */
  102560. is3D: boolean;
  102561. /**
  102562. * Defines if the texture contains 2D array data
  102563. */
  102564. is2DArray: boolean;
  102565. /**
  102566. * Defines if the texture contains multiview data
  102567. */
  102568. isMultiview: boolean;
  102569. /**
  102570. * Gets the URL used to load this texture
  102571. */
  102572. url: string;
  102573. /**
  102574. * Gets the sampling mode of the texture
  102575. */
  102576. samplingMode: number;
  102577. /**
  102578. * Gets a boolean indicating if the texture needs mipmaps generation
  102579. */
  102580. generateMipMaps: boolean;
  102581. /**
  102582. * Gets the number of samples used by the texture (WebGL2+ only)
  102583. */
  102584. samples: number;
  102585. /**
  102586. * Gets the type of the texture (int, float...)
  102587. */
  102588. type: number;
  102589. /**
  102590. * Gets the format of the texture (RGB, RGBA...)
  102591. */
  102592. format: number;
  102593. /**
  102594. * Observable called when the texture is loaded
  102595. */
  102596. onLoadedObservable: Observable<InternalTexture>;
  102597. /**
  102598. * Gets the width of the texture
  102599. */
  102600. width: number;
  102601. /**
  102602. * Gets the height of the texture
  102603. */
  102604. height: number;
  102605. /**
  102606. * Gets the depth of the texture
  102607. */
  102608. depth: number;
  102609. /**
  102610. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102611. */
  102612. baseWidth: number;
  102613. /**
  102614. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102615. */
  102616. baseHeight: number;
  102617. /**
  102618. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102619. */
  102620. baseDepth: number;
  102621. /**
  102622. * Gets a boolean indicating if the texture is inverted on Y axis
  102623. */
  102624. invertY: boolean;
  102625. /** @hidden */
  102626. _invertVScale: boolean;
  102627. /** @hidden */
  102628. _associatedChannel: number;
  102629. /** @hidden */
  102630. _source: InternalTextureSource;
  102631. /** @hidden */
  102632. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102633. /** @hidden */
  102634. _bufferView: Nullable<ArrayBufferView>;
  102635. /** @hidden */
  102636. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102637. /** @hidden */
  102638. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102639. /** @hidden */
  102640. _size: number;
  102641. /** @hidden */
  102642. _extension: string;
  102643. /** @hidden */
  102644. _files: Nullable<string[]>;
  102645. /** @hidden */
  102646. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102647. /** @hidden */
  102648. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102649. /** @hidden */
  102650. _framebuffer: Nullable<WebGLFramebuffer>;
  102651. /** @hidden */
  102652. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102653. /** @hidden */
  102654. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102655. /** @hidden */
  102656. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102657. /** @hidden */
  102658. _attachments: Nullable<number[]>;
  102659. /** @hidden */
  102660. _cachedCoordinatesMode: Nullable<number>;
  102661. /** @hidden */
  102662. _cachedWrapU: Nullable<number>;
  102663. /** @hidden */
  102664. _cachedWrapV: Nullable<number>;
  102665. /** @hidden */
  102666. _cachedWrapR: Nullable<number>;
  102667. /** @hidden */
  102668. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102669. /** @hidden */
  102670. _isDisabled: boolean;
  102671. /** @hidden */
  102672. _compression: Nullable<string>;
  102673. /** @hidden */
  102674. _generateStencilBuffer: boolean;
  102675. /** @hidden */
  102676. _generateDepthBuffer: boolean;
  102677. /** @hidden */
  102678. _comparisonFunction: number;
  102679. /** @hidden */
  102680. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102681. /** @hidden */
  102682. _lodGenerationScale: number;
  102683. /** @hidden */
  102684. _lodGenerationOffset: number;
  102685. /** @hidden */
  102686. _colorTextureArray: Nullable<WebGLTexture>;
  102687. /** @hidden */
  102688. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102689. /** @hidden */
  102690. _lodTextureHigh: Nullable<BaseTexture>;
  102691. /** @hidden */
  102692. _lodTextureMid: Nullable<BaseTexture>;
  102693. /** @hidden */
  102694. _lodTextureLow: Nullable<BaseTexture>;
  102695. /** @hidden */
  102696. _isRGBD: boolean;
  102697. /** @hidden */
  102698. _linearSpecularLOD: boolean;
  102699. /** @hidden */
  102700. _irradianceTexture: Nullable<BaseTexture>;
  102701. /** @hidden */
  102702. _webGLTexture: Nullable<WebGLTexture>;
  102703. /** @hidden */
  102704. _references: number;
  102705. private _engine;
  102706. /**
  102707. * Gets the Engine the texture belongs to.
  102708. * @returns The babylon engine
  102709. */
  102710. getEngine(): ThinEngine;
  102711. /**
  102712. * Gets the data source type of the texture
  102713. */
  102714. get source(): InternalTextureSource;
  102715. /**
  102716. * Creates a new InternalTexture
  102717. * @param engine defines the engine to use
  102718. * @param source defines the type of data that will be used
  102719. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102720. */
  102721. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102722. /**
  102723. * Increments the number of references (ie. the number of Texture that point to it)
  102724. */
  102725. incrementReferences(): void;
  102726. /**
  102727. * Change the size of the texture (not the size of the content)
  102728. * @param width defines the new width
  102729. * @param height defines the new height
  102730. * @param depth defines the new depth (1 by default)
  102731. */
  102732. updateSize(width: int, height: int, depth?: int): void;
  102733. /** @hidden */
  102734. _rebuild(): void;
  102735. /** @hidden */
  102736. _swapAndDie(target: InternalTexture): void;
  102737. /**
  102738. * Dispose the current allocated resources
  102739. */
  102740. dispose(): void;
  102741. }
  102742. }
  102743. declare module BABYLON {
  102744. /**
  102745. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102747. */
  102748. export class Analyser {
  102749. /**
  102750. * Gets or sets the smoothing
  102751. * @ignorenaming
  102752. */
  102753. SMOOTHING: number;
  102754. /**
  102755. * Gets or sets the FFT table size
  102756. * @ignorenaming
  102757. */
  102758. FFT_SIZE: number;
  102759. /**
  102760. * Gets or sets the bar graph amplitude
  102761. * @ignorenaming
  102762. */
  102763. BARGRAPHAMPLITUDE: number;
  102764. /**
  102765. * Gets or sets the position of the debug canvas
  102766. * @ignorenaming
  102767. */
  102768. DEBUGCANVASPOS: {
  102769. x: number;
  102770. y: number;
  102771. };
  102772. /**
  102773. * Gets or sets the debug canvas size
  102774. * @ignorenaming
  102775. */
  102776. DEBUGCANVASSIZE: {
  102777. width: number;
  102778. height: number;
  102779. };
  102780. private _byteFreqs;
  102781. private _byteTime;
  102782. private _floatFreqs;
  102783. private _webAudioAnalyser;
  102784. private _debugCanvas;
  102785. private _debugCanvasContext;
  102786. private _scene;
  102787. private _registerFunc;
  102788. private _audioEngine;
  102789. /**
  102790. * Creates a new analyser
  102791. * @param scene defines hosting scene
  102792. */
  102793. constructor(scene: Scene);
  102794. /**
  102795. * Get the number of data values you will have to play with for the visualization
  102796. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102797. * @returns a number
  102798. */
  102799. getFrequencyBinCount(): number;
  102800. /**
  102801. * Gets the current frequency data as a byte array
  102802. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102803. * @returns a Uint8Array
  102804. */
  102805. getByteFrequencyData(): Uint8Array;
  102806. /**
  102807. * Gets the current waveform as a byte array
  102808. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102809. * @returns a Uint8Array
  102810. */
  102811. getByteTimeDomainData(): Uint8Array;
  102812. /**
  102813. * Gets the current frequency data as a float array
  102814. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102815. * @returns a Float32Array
  102816. */
  102817. getFloatFrequencyData(): Float32Array;
  102818. /**
  102819. * Renders the debug canvas
  102820. */
  102821. drawDebugCanvas(): void;
  102822. /**
  102823. * Stops rendering the debug canvas and removes it
  102824. */
  102825. stopDebugCanvas(): void;
  102826. /**
  102827. * Connects two audio nodes
  102828. * @param inputAudioNode defines first node to connect
  102829. * @param outputAudioNode defines second node to connect
  102830. */
  102831. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102832. /**
  102833. * Releases all associated resources
  102834. */
  102835. dispose(): void;
  102836. }
  102837. }
  102838. declare module BABYLON {
  102839. /**
  102840. * This represents an audio engine and it is responsible
  102841. * to play, synchronize and analyse sounds throughout the application.
  102842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102843. */
  102844. export interface IAudioEngine extends IDisposable {
  102845. /**
  102846. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102847. */
  102848. readonly canUseWebAudio: boolean;
  102849. /**
  102850. * Gets the current AudioContext if available.
  102851. */
  102852. readonly audioContext: Nullable<AudioContext>;
  102853. /**
  102854. * The master gain node defines the global audio volume of your audio engine.
  102855. */
  102856. readonly masterGain: GainNode;
  102857. /**
  102858. * Gets whether or not mp3 are supported by your browser.
  102859. */
  102860. readonly isMP3supported: boolean;
  102861. /**
  102862. * Gets whether or not ogg are supported by your browser.
  102863. */
  102864. readonly isOGGsupported: boolean;
  102865. /**
  102866. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102867. * @ignoreNaming
  102868. */
  102869. WarnedWebAudioUnsupported: boolean;
  102870. /**
  102871. * Defines if the audio engine relies on a custom unlocked button.
  102872. * In this case, the embedded button will not be displayed.
  102873. */
  102874. useCustomUnlockedButton: boolean;
  102875. /**
  102876. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102877. */
  102878. readonly unlocked: boolean;
  102879. /**
  102880. * Event raised when audio has been unlocked on the browser.
  102881. */
  102882. onAudioUnlockedObservable: Observable<AudioEngine>;
  102883. /**
  102884. * Event raised when audio has been locked on the browser.
  102885. */
  102886. onAudioLockedObservable: Observable<AudioEngine>;
  102887. /**
  102888. * Flags the audio engine in Locked state.
  102889. * This happens due to new browser policies preventing audio to autoplay.
  102890. */
  102891. lock(): void;
  102892. /**
  102893. * Unlocks the audio engine once a user action has been done on the dom.
  102894. * This is helpful to resume play once browser policies have been satisfied.
  102895. */
  102896. unlock(): void;
  102897. }
  102898. /**
  102899. * This represents the default audio engine used in babylon.
  102900. * It is responsible to play, synchronize and analyse sounds throughout the application.
  102901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102902. */
  102903. export class AudioEngine implements IAudioEngine {
  102904. private _audioContext;
  102905. private _audioContextInitialized;
  102906. private _muteButton;
  102907. private _hostElement;
  102908. /**
  102909. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102910. */
  102911. canUseWebAudio: boolean;
  102912. /**
  102913. * The master gain node defines the global audio volume of your audio engine.
  102914. */
  102915. masterGain: GainNode;
  102916. /**
  102917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102918. * @ignoreNaming
  102919. */
  102920. WarnedWebAudioUnsupported: boolean;
  102921. /**
  102922. * Gets whether or not mp3 are supported by your browser.
  102923. */
  102924. isMP3supported: boolean;
  102925. /**
  102926. * Gets whether or not ogg are supported by your browser.
  102927. */
  102928. isOGGsupported: boolean;
  102929. /**
  102930. * Gets whether audio has been unlocked on the device.
  102931. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  102932. * a user interaction has happened.
  102933. */
  102934. unlocked: boolean;
  102935. /**
  102936. * Defines if the audio engine relies on a custom unlocked button.
  102937. * In this case, the embedded button will not be displayed.
  102938. */
  102939. useCustomUnlockedButton: boolean;
  102940. /**
  102941. * Event raised when audio has been unlocked on the browser.
  102942. */
  102943. onAudioUnlockedObservable: Observable<AudioEngine>;
  102944. /**
  102945. * Event raised when audio has been locked on the browser.
  102946. */
  102947. onAudioLockedObservable: Observable<AudioEngine>;
  102948. /**
  102949. * Gets the current AudioContext if available.
  102950. */
  102951. get audioContext(): Nullable<AudioContext>;
  102952. private _connectedAnalyser;
  102953. /**
  102954. * Instantiates a new audio engine.
  102955. *
  102956. * There should be only one per page as some browsers restrict the number
  102957. * of audio contexts you can create.
  102958. * @param hostElement defines the host element where to display the mute icon if necessary
  102959. */
  102960. constructor(hostElement?: Nullable<HTMLElement>);
  102961. /**
  102962. * Flags the audio engine in Locked state.
  102963. * This happens due to new browser policies preventing audio to autoplay.
  102964. */
  102965. lock(): void;
  102966. /**
  102967. * Unlocks the audio engine once a user action has been done on the dom.
  102968. * This is helpful to resume play once browser policies have been satisfied.
  102969. */
  102970. unlock(): void;
  102971. private _resumeAudioContext;
  102972. private _initializeAudioContext;
  102973. private _tryToRun;
  102974. private _triggerRunningState;
  102975. private _triggerSuspendedState;
  102976. private _displayMuteButton;
  102977. private _moveButtonToTopLeft;
  102978. private _onResize;
  102979. private _hideMuteButton;
  102980. /**
  102981. * Destroy and release the resources associated with the audio ccontext.
  102982. */
  102983. dispose(): void;
  102984. /**
  102985. * Gets the global volume sets on the master gain.
  102986. * @returns the global volume if set or -1 otherwise
  102987. */
  102988. getGlobalVolume(): number;
  102989. /**
  102990. * Sets the global volume of your experience (sets on the master gain).
  102991. * @param newVolume Defines the new global volume of the application
  102992. */
  102993. setGlobalVolume(newVolume: number): void;
  102994. /**
  102995. * Connect the audio engine to an audio analyser allowing some amazing
  102996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102998. * @param analyser The analyser to connect to the engine
  102999. */
  103000. connectToAnalyser(analyser: Analyser): void;
  103001. }
  103002. }
  103003. declare module BABYLON {
  103004. /**
  103005. * Interface used to present a loading screen while loading a scene
  103006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103007. */
  103008. export interface ILoadingScreen {
  103009. /**
  103010. * Function called to display the loading screen
  103011. */
  103012. displayLoadingUI: () => void;
  103013. /**
  103014. * Function called to hide the loading screen
  103015. */
  103016. hideLoadingUI: () => void;
  103017. /**
  103018. * Gets or sets the color to use for the background
  103019. */
  103020. loadingUIBackgroundColor: string;
  103021. /**
  103022. * Gets or sets the text to display while loading
  103023. */
  103024. loadingUIText: string;
  103025. }
  103026. /**
  103027. * Class used for the default loading screen
  103028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103029. */
  103030. export class DefaultLoadingScreen implements ILoadingScreen {
  103031. private _renderingCanvas;
  103032. private _loadingText;
  103033. private _loadingDivBackgroundColor;
  103034. private _loadingDiv;
  103035. private _loadingTextDiv;
  103036. /** Gets or sets the logo url to use for the default loading screen */
  103037. static DefaultLogoUrl: string;
  103038. /** Gets or sets the spinner url to use for the default loading screen */
  103039. static DefaultSpinnerUrl: string;
  103040. /**
  103041. * Creates a new default loading screen
  103042. * @param _renderingCanvas defines the canvas used to render the scene
  103043. * @param _loadingText defines the default text to display
  103044. * @param _loadingDivBackgroundColor defines the default background color
  103045. */
  103046. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103047. /**
  103048. * Function called to display the loading screen
  103049. */
  103050. displayLoadingUI(): void;
  103051. /**
  103052. * Function called to hide the loading screen
  103053. */
  103054. hideLoadingUI(): void;
  103055. /**
  103056. * Gets or sets the text to display while loading
  103057. */
  103058. set loadingUIText(text: string);
  103059. get loadingUIText(): string;
  103060. /**
  103061. * Gets or sets the color to use for the background
  103062. */
  103063. get loadingUIBackgroundColor(): string;
  103064. set loadingUIBackgroundColor(color: string);
  103065. private _resizeLoadingUI;
  103066. }
  103067. }
  103068. declare module BABYLON {
  103069. /**
  103070. * Interface for any object that can request an animation frame
  103071. */
  103072. export interface ICustomAnimationFrameRequester {
  103073. /**
  103074. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103075. */
  103076. renderFunction?: Function;
  103077. /**
  103078. * Called to request the next frame to render to
  103079. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103080. */
  103081. requestAnimationFrame: Function;
  103082. /**
  103083. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103084. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103085. */
  103086. requestID?: number;
  103087. }
  103088. }
  103089. declare module BABYLON {
  103090. /**
  103091. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103092. */
  103093. export class PerformanceMonitor {
  103094. private _enabled;
  103095. private _rollingFrameTime;
  103096. private _lastFrameTimeMs;
  103097. /**
  103098. * constructor
  103099. * @param frameSampleSize The number of samples required to saturate the sliding window
  103100. */
  103101. constructor(frameSampleSize?: number);
  103102. /**
  103103. * Samples current frame
  103104. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103105. */
  103106. sampleFrame(timeMs?: number): void;
  103107. /**
  103108. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103109. */
  103110. get averageFrameTime(): number;
  103111. /**
  103112. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103113. */
  103114. get averageFrameTimeVariance(): number;
  103115. /**
  103116. * Returns the frame time of the most recent frame
  103117. */
  103118. get instantaneousFrameTime(): number;
  103119. /**
  103120. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103121. */
  103122. get averageFPS(): number;
  103123. /**
  103124. * Returns the average framerate in frames per second using the most recent frame time
  103125. */
  103126. get instantaneousFPS(): number;
  103127. /**
  103128. * Returns true if enough samples have been taken to completely fill the sliding window
  103129. */
  103130. get isSaturated(): boolean;
  103131. /**
  103132. * Enables contributions to the sliding window sample set
  103133. */
  103134. enable(): void;
  103135. /**
  103136. * Disables contributions to the sliding window sample set
  103137. * Samples will not be interpolated over the disabled period
  103138. */
  103139. disable(): void;
  103140. /**
  103141. * Returns true if sampling is enabled
  103142. */
  103143. get isEnabled(): boolean;
  103144. /**
  103145. * Resets performance monitor
  103146. */
  103147. reset(): void;
  103148. }
  103149. /**
  103150. * RollingAverage
  103151. *
  103152. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103153. */
  103154. export class RollingAverage {
  103155. /**
  103156. * Current average
  103157. */
  103158. average: number;
  103159. /**
  103160. * Current variance
  103161. */
  103162. variance: number;
  103163. protected _samples: Array<number>;
  103164. protected _sampleCount: number;
  103165. protected _pos: number;
  103166. protected _m2: number;
  103167. /**
  103168. * constructor
  103169. * @param length The number of samples required to saturate the sliding window
  103170. */
  103171. constructor(length: number);
  103172. /**
  103173. * Adds a sample to the sample set
  103174. * @param v The sample value
  103175. */
  103176. add(v: number): void;
  103177. /**
  103178. * Returns previously added values or null if outside of history or outside the sliding window domain
  103179. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103180. * @return Value previously recorded with add() or null if outside of range
  103181. */
  103182. history(i: number): number;
  103183. /**
  103184. * Returns true if enough samples have been taken to completely fill the sliding window
  103185. * @return true if sample-set saturated
  103186. */
  103187. isSaturated(): boolean;
  103188. /**
  103189. * Resets the rolling average (equivalent to 0 samples taken so far)
  103190. */
  103191. reset(): void;
  103192. /**
  103193. * Wraps a value around the sample range boundaries
  103194. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103195. * @return Wrapped position in sample range
  103196. */
  103197. protected _wrapPosition(i: number): number;
  103198. }
  103199. }
  103200. declare module BABYLON {
  103201. /**
  103202. * This class is used to track a performance counter which is number based.
  103203. * The user has access to many properties which give statistics of different nature.
  103204. *
  103205. * The implementer can track two kinds of Performance Counter: time and count.
  103206. * 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.
  103207. * 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.
  103208. */
  103209. export class PerfCounter {
  103210. /**
  103211. * Gets or sets a global boolean to turn on and off all the counters
  103212. */
  103213. static Enabled: boolean;
  103214. /**
  103215. * Returns the smallest value ever
  103216. */
  103217. get min(): number;
  103218. /**
  103219. * Returns the biggest value ever
  103220. */
  103221. get max(): number;
  103222. /**
  103223. * Returns the average value since the performance counter is running
  103224. */
  103225. get average(): number;
  103226. /**
  103227. * Returns the average value of the last second the counter was monitored
  103228. */
  103229. get lastSecAverage(): number;
  103230. /**
  103231. * Returns the current value
  103232. */
  103233. get current(): number;
  103234. /**
  103235. * Gets the accumulated total
  103236. */
  103237. get total(): number;
  103238. /**
  103239. * Gets the total value count
  103240. */
  103241. get count(): number;
  103242. /**
  103243. * Creates a new counter
  103244. */
  103245. constructor();
  103246. /**
  103247. * Call this method to start monitoring a new frame.
  103248. * 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.
  103249. */
  103250. fetchNewFrame(): void;
  103251. /**
  103252. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103253. * @param newCount the count value to add to the monitored count
  103254. * @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.
  103255. */
  103256. addCount(newCount: number, fetchResult: boolean): void;
  103257. /**
  103258. * Start monitoring this performance counter
  103259. */
  103260. beginMonitoring(): void;
  103261. /**
  103262. * Compute the time lapsed since the previous beginMonitoring() call.
  103263. * @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
  103264. */
  103265. endMonitoring(newFrame?: boolean): void;
  103266. private _fetchResult;
  103267. private _startMonitoringTime;
  103268. private _min;
  103269. private _max;
  103270. private _average;
  103271. private _current;
  103272. private _totalValueCount;
  103273. private _totalAccumulated;
  103274. private _lastSecAverage;
  103275. private _lastSecAccumulated;
  103276. private _lastSecTime;
  103277. private _lastSecValueCount;
  103278. }
  103279. }
  103280. declare module BABYLON {
  103281. interface ThinEngine {
  103282. /**
  103283. * Sets alpha constants used by some alpha blending modes
  103284. * @param r defines the red component
  103285. * @param g defines the green component
  103286. * @param b defines the blue component
  103287. * @param a defines the alpha component
  103288. */
  103289. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103290. /**
  103291. * Sets the current alpha mode
  103292. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103293. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103294. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103295. */
  103296. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103297. /**
  103298. * Gets the current alpha mode
  103299. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103300. * @returns the current alpha mode
  103301. */
  103302. getAlphaMode(): number;
  103303. /**
  103304. * Sets the current alpha equation
  103305. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103306. */
  103307. setAlphaEquation(equation: number): void;
  103308. /**
  103309. * Gets the current alpha equation.
  103310. * @returns the current alpha equation
  103311. */
  103312. getAlphaEquation(): number;
  103313. }
  103314. }
  103315. declare module BABYLON {
  103316. /**
  103317. * Defines the interface used by display changed events
  103318. */
  103319. export interface IDisplayChangedEventArgs {
  103320. /** Gets the vrDisplay object (if any) */
  103321. vrDisplay: Nullable<any>;
  103322. /** Gets a boolean indicating if webVR is supported */
  103323. vrSupported: boolean;
  103324. }
  103325. /**
  103326. * Defines the interface used by objects containing a viewport (like a camera)
  103327. */
  103328. interface IViewportOwnerLike {
  103329. /**
  103330. * Gets or sets the viewport
  103331. */
  103332. viewport: IViewportLike;
  103333. }
  103334. /**
  103335. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103336. */
  103337. export class Engine extends ThinEngine {
  103338. /** Defines that alpha blending is disabled */
  103339. static readonly ALPHA_DISABLE: number;
  103340. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103341. static readonly ALPHA_ADD: number;
  103342. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103343. static readonly ALPHA_COMBINE: number;
  103344. /** Defines that alpha blending to DEST - SRC * DEST */
  103345. static readonly ALPHA_SUBTRACT: number;
  103346. /** Defines that alpha blending to SRC * DEST */
  103347. static readonly ALPHA_MULTIPLY: number;
  103348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103349. static readonly ALPHA_MAXIMIZED: number;
  103350. /** Defines that alpha blending to SRC + DEST */
  103351. static readonly ALPHA_ONEONE: number;
  103352. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103353. static readonly ALPHA_PREMULTIPLIED: number;
  103354. /**
  103355. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103356. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103357. */
  103358. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103359. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103360. static readonly ALPHA_INTERPOLATE: number;
  103361. /**
  103362. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103363. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103364. */
  103365. static readonly ALPHA_SCREENMODE: number;
  103366. /** Defines that the ressource is not delayed*/
  103367. static readonly DELAYLOADSTATE_NONE: number;
  103368. /** Defines that the ressource was successfully delay loaded */
  103369. static readonly DELAYLOADSTATE_LOADED: number;
  103370. /** Defines that the ressource is currently delay loading */
  103371. static readonly DELAYLOADSTATE_LOADING: number;
  103372. /** Defines that the ressource is delayed and has not started loading */
  103373. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103375. static readonly NEVER: number;
  103376. /** 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 */
  103377. static readonly ALWAYS: number;
  103378. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103379. static readonly LESS: number;
  103380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103381. static readonly EQUAL: number;
  103382. /** 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 */
  103383. static readonly LEQUAL: number;
  103384. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103385. static readonly GREATER: number;
  103386. /** 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 */
  103387. static readonly GEQUAL: number;
  103388. /** 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 */
  103389. static readonly NOTEQUAL: number;
  103390. /** Passed to stencilOperation to specify that stencil value must be kept */
  103391. static readonly KEEP: number;
  103392. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103393. static readonly REPLACE: number;
  103394. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103395. static readonly INCR: number;
  103396. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103397. static readonly DECR: number;
  103398. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103399. static readonly INVERT: number;
  103400. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103401. static readonly INCR_WRAP: number;
  103402. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103403. static readonly DECR_WRAP: number;
  103404. /** Texture is not repeating outside of 0..1 UVs */
  103405. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103406. /** Texture is repeating outside of 0..1 UVs */
  103407. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103408. /** Texture is repeating and mirrored */
  103409. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103410. /** ALPHA */
  103411. static readonly TEXTUREFORMAT_ALPHA: number;
  103412. /** LUMINANCE */
  103413. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103414. /** LUMINANCE_ALPHA */
  103415. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103416. /** RGB */
  103417. static readonly TEXTUREFORMAT_RGB: number;
  103418. /** RGBA */
  103419. static readonly TEXTUREFORMAT_RGBA: number;
  103420. /** RED */
  103421. static readonly TEXTUREFORMAT_RED: number;
  103422. /** RED (2nd reference) */
  103423. static readonly TEXTUREFORMAT_R: number;
  103424. /** RG */
  103425. static readonly TEXTUREFORMAT_RG: number;
  103426. /** RED_INTEGER */
  103427. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103428. /** RED_INTEGER (2nd reference) */
  103429. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103430. /** RG_INTEGER */
  103431. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103432. /** RGB_INTEGER */
  103433. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103434. /** RGBA_INTEGER */
  103435. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103436. /** UNSIGNED_BYTE */
  103437. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103438. /** UNSIGNED_BYTE (2nd reference) */
  103439. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103440. /** FLOAT */
  103441. static readonly TEXTURETYPE_FLOAT: number;
  103442. /** HALF_FLOAT */
  103443. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103444. /** BYTE */
  103445. static readonly TEXTURETYPE_BYTE: number;
  103446. /** SHORT */
  103447. static readonly TEXTURETYPE_SHORT: number;
  103448. /** UNSIGNED_SHORT */
  103449. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103450. /** INT */
  103451. static readonly TEXTURETYPE_INT: number;
  103452. /** UNSIGNED_INT */
  103453. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103454. /** UNSIGNED_SHORT_4_4_4_4 */
  103455. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103456. /** UNSIGNED_SHORT_5_5_5_1 */
  103457. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103458. /** UNSIGNED_SHORT_5_6_5 */
  103459. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103460. /** UNSIGNED_INT_2_10_10_10_REV */
  103461. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103462. /** UNSIGNED_INT_24_8 */
  103463. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103464. /** UNSIGNED_INT_10F_11F_11F_REV */
  103465. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103466. /** UNSIGNED_INT_5_9_9_9_REV */
  103467. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103468. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103469. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103470. /** nearest is mag = nearest and min = nearest and mip = linear */
  103471. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103472. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103473. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103474. /** Trilinear is mag = linear and min = linear and mip = linear */
  103475. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103476. /** nearest is mag = nearest and min = nearest and mip = linear */
  103477. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103478. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103479. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103480. /** Trilinear is mag = linear and min = linear and mip = linear */
  103481. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103482. /** mag = nearest and min = nearest and mip = nearest */
  103483. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103484. /** mag = nearest and min = linear and mip = nearest */
  103485. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103486. /** mag = nearest and min = linear and mip = linear */
  103487. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103488. /** mag = nearest and min = linear and mip = none */
  103489. static readonly TEXTURE_NEAREST_LINEAR: number;
  103490. /** mag = nearest and min = nearest and mip = none */
  103491. static readonly TEXTURE_NEAREST_NEAREST: number;
  103492. /** mag = linear and min = nearest and mip = nearest */
  103493. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103494. /** mag = linear and min = nearest and mip = linear */
  103495. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103496. /** mag = linear and min = linear and mip = none */
  103497. static readonly TEXTURE_LINEAR_LINEAR: number;
  103498. /** mag = linear and min = nearest and mip = none */
  103499. static readonly TEXTURE_LINEAR_NEAREST: number;
  103500. /** Explicit coordinates mode */
  103501. static readonly TEXTURE_EXPLICIT_MODE: number;
  103502. /** Spherical coordinates mode */
  103503. static readonly TEXTURE_SPHERICAL_MODE: number;
  103504. /** Planar coordinates mode */
  103505. static readonly TEXTURE_PLANAR_MODE: number;
  103506. /** Cubic coordinates mode */
  103507. static readonly TEXTURE_CUBIC_MODE: number;
  103508. /** Projection coordinates mode */
  103509. static readonly TEXTURE_PROJECTION_MODE: number;
  103510. /** Skybox coordinates mode */
  103511. static readonly TEXTURE_SKYBOX_MODE: number;
  103512. /** Inverse Cubic coordinates mode */
  103513. static readonly TEXTURE_INVCUBIC_MODE: number;
  103514. /** Equirectangular coordinates mode */
  103515. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103516. /** Equirectangular Fixed coordinates mode */
  103517. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103518. /** Equirectangular Fixed Mirrored coordinates mode */
  103519. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103520. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103521. static readonly SCALEMODE_FLOOR: number;
  103522. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103523. static readonly SCALEMODE_NEAREST: number;
  103524. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103525. static readonly SCALEMODE_CEILING: number;
  103526. /**
  103527. * Returns the current npm package of the sdk
  103528. */
  103529. static get NpmPackage(): string;
  103530. /**
  103531. * Returns the current version of the framework
  103532. */
  103533. static get Version(): string;
  103534. /** Gets the list of created engines */
  103535. static get Instances(): Engine[];
  103536. /**
  103537. * Gets the latest created engine
  103538. */
  103539. static get LastCreatedEngine(): Nullable<Engine>;
  103540. /**
  103541. * Gets the latest created scene
  103542. */
  103543. static get LastCreatedScene(): Nullable<Scene>;
  103544. /**
  103545. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103546. * @param flag defines which part of the materials must be marked as dirty
  103547. * @param predicate defines a predicate used to filter which materials should be affected
  103548. */
  103549. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103550. /**
  103551. * Method called to create the default loading screen.
  103552. * This can be overriden in your own app.
  103553. * @param canvas The rendering canvas element
  103554. * @returns The loading screen
  103555. */
  103556. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103557. /**
  103558. * Method called to create the default rescale post process on each engine.
  103559. */
  103560. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103561. /**
  103562. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103563. **/
  103564. enableOfflineSupport: boolean;
  103565. /**
  103566. * 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)
  103567. **/
  103568. disableManifestCheck: boolean;
  103569. /**
  103570. * Gets the list of created scenes
  103571. */
  103572. scenes: Scene[];
  103573. /**
  103574. * Event raised when a new scene is created
  103575. */
  103576. onNewSceneAddedObservable: Observable<Scene>;
  103577. /**
  103578. * Gets the list of created postprocesses
  103579. */
  103580. postProcesses: PostProcess[];
  103581. /**
  103582. * Gets a boolean indicating if the pointer is currently locked
  103583. */
  103584. isPointerLock: boolean;
  103585. /**
  103586. * Observable event triggered each time the rendering canvas is resized
  103587. */
  103588. onResizeObservable: Observable<Engine>;
  103589. /**
  103590. * Observable event triggered each time the canvas loses focus
  103591. */
  103592. onCanvasBlurObservable: Observable<Engine>;
  103593. /**
  103594. * Observable event triggered each time the canvas gains focus
  103595. */
  103596. onCanvasFocusObservable: Observable<Engine>;
  103597. /**
  103598. * Observable event triggered each time the canvas receives pointerout event
  103599. */
  103600. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103601. /**
  103602. * Observable raised when the engine begins a new frame
  103603. */
  103604. onBeginFrameObservable: Observable<Engine>;
  103605. /**
  103606. * If set, will be used to request the next animation frame for the render loop
  103607. */
  103608. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103609. /**
  103610. * Observable raised when the engine ends the current frame
  103611. */
  103612. onEndFrameObservable: Observable<Engine>;
  103613. /**
  103614. * Observable raised when the engine is about to compile a shader
  103615. */
  103616. onBeforeShaderCompilationObservable: Observable<Engine>;
  103617. /**
  103618. * Observable raised when the engine has jsut compiled a shader
  103619. */
  103620. onAfterShaderCompilationObservable: Observable<Engine>;
  103621. /**
  103622. * Gets the audio engine
  103623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103624. * @ignorenaming
  103625. */
  103626. static audioEngine: IAudioEngine;
  103627. /**
  103628. * Default AudioEngine factory responsible of creating the Audio Engine.
  103629. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103630. */
  103631. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103632. /**
  103633. * Default offline support factory responsible of creating a tool used to store data locally.
  103634. * By default, this will create a Database object if the workload has been embedded.
  103635. */
  103636. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103637. private _loadingScreen;
  103638. private _pointerLockRequested;
  103639. private _dummyFramebuffer;
  103640. private _rescalePostProcess;
  103641. private _deterministicLockstep;
  103642. private _lockstepMaxSteps;
  103643. private _timeStep;
  103644. protected get _supportsHardwareTextureRescaling(): boolean;
  103645. private _fps;
  103646. private _deltaTime;
  103647. /** @hidden */
  103648. _drawCalls: PerfCounter;
  103649. /**
  103650. * Turn this value on if you want to pause FPS computation when in background
  103651. */
  103652. disablePerformanceMonitorInBackground: boolean;
  103653. private _performanceMonitor;
  103654. /**
  103655. * Gets the performance monitor attached to this engine
  103656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103657. */
  103658. get performanceMonitor(): PerformanceMonitor;
  103659. private _onFocus;
  103660. private _onBlur;
  103661. private _onCanvasPointerOut;
  103662. private _onCanvasBlur;
  103663. private _onCanvasFocus;
  103664. private _onFullscreenChange;
  103665. private _onPointerLockChange;
  103666. /**
  103667. * Gets the HTML element used to attach event listeners
  103668. * @returns a HTML element
  103669. */
  103670. getInputElement(): Nullable<HTMLElement>;
  103671. /**
  103672. * Creates a new engine
  103673. * @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
  103674. * @param antialias defines enable antialiasing (default: false)
  103675. * @param options defines further options to be sent to the getContext() function
  103676. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103677. */
  103678. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103679. /**
  103680. * Gets current aspect ratio
  103681. * @param viewportOwner defines the camera to use to get the aspect ratio
  103682. * @param useScreen defines if screen size must be used (or the current render target if any)
  103683. * @returns a number defining the aspect ratio
  103684. */
  103685. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103686. /**
  103687. * Gets current screen aspect ratio
  103688. * @returns a number defining the aspect ratio
  103689. */
  103690. getScreenAspectRatio(): number;
  103691. /**
  103692. * Gets the client rect of the HTML canvas attached with the current webGL context
  103693. * @returns a client rectanglee
  103694. */
  103695. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103696. /**
  103697. * Gets the client rect of the HTML element used for events
  103698. * @returns a client rectanglee
  103699. */
  103700. getInputElementClientRect(): Nullable<ClientRect>;
  103701. /**
  103702. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103704. * @returns true if engine is in deterministic lock step mode
  103705. */
  103706. isDeterministicLockStep(): boolean;
  103707. /**
  103708. * Gets the max steps when engine is running in deterministic lock step
  103709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103710. * @returns the max steps
  103711. */
  103712. getLockstepMaxSteps(): number;
  103713. /**
  103714. * Returns the time in ms between steps when using deterministic lock step.
  103715. * @returns time step in (ms)
  103716. */
  103717. getTimeStep(): number;
  103718. /**
  103719. * Force the mipmap generation for the given render target texture
  103720. * @param texture defines the render target texture to use
  103721. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103722. */
  103723. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103724. /** States */
  103725. /**
  103726. * Set various states to the webGL context
  103727. * @param culling defines backface culling state
  103728. * @param zOffset defines the value to apply to zOffset (0 by default)
  103729. * @param force defines if states must be applied even if cache is up to date
  103730. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103731. */
  103732. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103733. /**
  103734. * Set the z offset to apply to current rendering
  103735. * @param value defines the offset to apply
  103736. */
  103737. setZOffset(value: number): void;
  103738. /**
  103739. * Gets the current value of the zOffset
  103740. * @returns the current zOffset state
  103741. */
  103742. getZOffset(): number;
  103743. /**
  103744. * Enable or disable depth buffering
  103745. * @param enable defines the state to set
  103746. */
  103747. setDepthBuffer(enable: boolean): void;
  103748. /**
  103749. * Gets a boolean indicating if depth writing is enabled
  103750. * @returns the current depth writing state
  103751. */
  103752. getDepthWrite(): boolean;
  103753. /**
  103754. * Enable or disable depth writing
  103755. * @param enable defines the state to set
  103756. */
  103757. setDepthWrite(enable: boolean): void;
  103758. /**
  103759. * Gets a boolean indicating if stencil buffer is enabled
  103760. * @returns the current stencil buffer state
  103761. */
  103762. getStencilBuffer(): boolean;
  103763. /**
  103764. * Enable or disable the stencil buffer
  103765. * @param enable defines if the stencil buffer must be enabled or disabled
  103766. */
  103767. setStencilBuffer(enable: boolean): void;
  103768. /**
  103769. * Gets the current stencil mask
  103770. * @returns a number defining the new stencil mask to use
  103771. */
  103772. getStencilMask(): number;
  103773. /**
  103774. * Sets the current stencil mask
  103775. * @param mask defines the new stencil mask to use
  103776. */
  103777. setStencilMask(mask: number): void;
  103778. /**
  103779. * Gets the current stencil function
  103780. * @returns a number defining the stencil function to use
  103781. */
  103782. getStencilFunction(): number;
  103783. /**
  103784. * Gets the current stencil reference value
  103785. * @returns a number defining the stencil reference value to use
  103786. */
  103787. getStencilFunctionReference(): number;
  103788. /**
  103789. * Gets the current stencil mask
  103790. * @returns a number defining the stencil mask to use
  103791. */
  103792. getStencilFunctionMask(): number;
  103793. /**
  103794. * Sets the current stencil function
  103795. * @param stencilFunc defines the new stencil function to use
  103796. */
  103797. setStencilFunction(stencilFunc: number): void;
  103798. /**
  103799. * Sets the current stencil reference
  103800. * @param reference defines the new stencil reference to use
  103801. */
  103802. setStencilFunctionReference(reference: number): void;
  103803. /**
  103804. * Sets the current stencil mask
  103805. * @param mask defines the new stencil mask to use
  103806. */
  103807. setStencilFunctionMask(mask: number): void;
  103808. /**
  103809. * Gets the current stencil operation when stencil fails
  103810. * @returns a number defining stencil operation to use when stencil fails
  103811. */
  103812. getStencilOperationFail(): number;
  103813. /**
  103814. * Gets the current stencil operation when depth fails
  103815. * @returns a number defining stencil operation to use when depth fails
  103816. */
  103817. getStencilOperationDepthFail(): number;
  103818. /**
  103819. * Gets the current stencil operation when stencil passes
  103820. * @returns a number defining stencil operation to use when stencil passes
  103821. */
  103822. getStencilOperationPass(): number;
  103823. /**
  103824. * Sets the stencil operation to use when stencil fails
  103825. * @param operation defines the stencil operation to use when stencil fails
  103826. */
  103827. setStencilOperationFail(operation: number): void;
  103828. /**
  103829. * Sets the stencil operation to use when depth fails
  103830. * @param operation defines the stencil operation to use when depth fails
  103831. */
  103832. setStencilOperationDepthFail(operation: number): void;
  103833. /**
  103834. * Sets the stencil operation to use when stencil passes
  103835. * @param operation defines the stencil operation to use when stencil passes
  103836. */
  103837. setStencilOperationPass(operation: number): void;
  103838. /**
  103839. * Sets a boolean indicating if the dithering state is enabled or disabled
  103840. * @param value defines the dithering state
  103841. */
  103842. setDitheringState(value: boolean): void;
  103843. /**
  103844. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103845. * @param value defines the rasterizer state
  103846. */
  103847. setRasterizerState(value: boolean): void;
  103848. /**
  103849. * Gets the current depth function
  103850. * @returns a number defining the depth function
  103851. */
  103852. getDepthFunction(): Nullable<number>;
  103853. /**
  103854. * Sets the current depth function
  103855. * @param depthFunc defines the function to use
  103856. */
  103857. setDepthFunction(depthFunc: number): void;
  103858. /**
  103859. * Sets the current depth function to GREATER
  103860. */
  103861. setDepthFunctionToGreater(): void;
  103862. /**
  103863. * Sets the current depth function to GEQUAL
  103864. */
  103865. setDepthFunctionToGreaterOrEqual(): void;
  103866. /**
  103867. * Sets the current depth function to LESS
  103868. */
  103869. setDepthFunctionToLess(): void;
  103870. /**
  103871. * Sets the current depth function to LEQUAL
  103872. */
  103873. setDepthFunctionToLessOrEqual(): void;
  103874. private _cachedStencilBuffer;
  103875. private _cachedStencilFunction;
  103876. private _cachedStencilMask;
  103877. private _cachedStencilOperationPass;
  103878. private _cachedStencilOperationFail;
  103879. private _cachedStencilOperationDepthFail;
  103880. private _cachedStencilReference;
  103881. /**
  103882. * Caches the the state of the stencil buffer
  103883. */
  103884. cacheStencilState(): void;
  103885. /**
  103886. * Restores the state of the stencil buffer
  103887. */
  103888. restoreStencilState(): void;
  103889. /**
  103890. * Directly set the WebGL Viewport
  103891. * @param x defines the x coordinate of the viewport (in screen space)
  103892. * @param y defines the y coordinate of the viewport (in screen space)
  103893. * @param width defines the width of the viewport (in screen space)
  103894. * @param height defines the height of the viewport (in screen space)
  103895. * @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
  103896. */
  103897. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  103898. /**
  103899. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  103900. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103901. * @param y defines the y-coordinate of the corner of the clear rectangle
  103902. * @param width defines the width of the clear rectangle
  103903. * @param height defines the height of the clear rectangle
  103904. * @param clearColor defines the clear color
  103905. */
  103906. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  103907. /**
  103908. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  103909. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103910. * @param y defines the y-coordinate of the corner of the clear rectangle
  103911. * @param width defines the width of the clear rectangle
  103912. * @param height defines the height of the clear rectangle
  103913. */
  103914. enableScissor(x: number, y: number, width: number, height: number): void;
  103915. /**
  103916. * Disable previously set scissor test rectangle
  103917. */
  103918. disableScissor(): void;
  103919. protected _reportDrawCall(): void;
  103920. /**
  103921. * Initializes a webVR display and starts listening to display change events
  103922. * The onVRDisplayChangedObservable will be notified upon these changes
  103923. * @returns The onVRDisplayChangedObservable
  103924. */
  103925. initWebVR(): Observable<IDisplayChangedEventArgs>;
  103926. /** @hidden */
  103927. _prepareVRComponent(): void;
  103928. /** @hidden */
  103929. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  103930. /** @hidden */
  103931. _submitVRFrame(): void;
  103932. /**
  103933. * Call this function to leave webVR mode
  103934. * Will do nothing if webVR is not supported or if there is no webVR device
  103935. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103936. */
  103937. disableVR(): void;
  103938. /**
  103939. * Gets a boolean indicating that the system is in VR mode and is presenting
  103940. * @returns true if VR mode is engaged
  103941. */
  103942. isVRPresenting(): boolean;
  103943. /** @hidden */
  103944. _requestVRFrame(): void;
  103945. /** @hidden */
  103946. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103947. /**
  103948. * Gets the source code of the vertex shader associated with a specific webGL program
  103949. * @param program defines the program to use
  103950. * @returns a string containing the source code of the vertex shader associated with the program
  103951. */
  103952. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  103953. /**
  103954. * Gets the source code of the fragment shader associated with a specific webGL program
  103955. * @param program defines the program to use
  103956. * @returns a string containing the source code of the fragment shader associated with the program
  103957. */
  103958. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  103959. /**
  103960. * Sets a depth stencil texture from a render target to the according uniform.
  103961. * @param channel The texture channel
  103962. * @param uniform The uniform to set
  103963. * @param texture The render target texture containing the depth stencil texture to apply
  103964. */
  103965. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  103966. /**
  103967. * Sets a texture to the webGL context from a postprocess
  103968. * @param channel defines the channel to use
  103969. * @param postProcess defines the source postprocess
  103970. */
  103971. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  103972. /**
  103973. * Binds the output of the passed in post process to the texture channel specified
  103974. * @param channel The channel the texture should be bound to
  103975. * @param postProcess The post process which's output should be bound
  103976. */
  103977. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  103978. /** @hidden */
  103979. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  103980. protected _rebuildBuffers(): void;
  103981. /** @hidden */
  103982. _renderFrame(): void;
  103983. _renderLoop(): void;
  103984. /** @hidden */
  103985. _renderViews(): boolean;
  103986. /**
  103987. * Toggle full screen mode
  103988. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103989. */
  103990. switchFullscreen(requestPointerLock: boolean): void;
  103991. /**
  103992. * Enters full screen mode
  103993. * @param requestPointerLock defines if a pointer lock should be requested from the user
  103994. */
  103995. enterFullscreen(requestPointerLock: boolean): void;
  103996. /**
  103997. * Exits full screen mode
  103998. */
  103999. exitFullscreen(): void;
  104000. /**
  104001. * Enters Pointerlock mode
  104002. */
  104003. enterPointerlock(): void;
  104004. /**
  104005. * Exits Pointerlock mode
  104006. */
  104007. exitPointerlock(): void;
  104008. /**
  104009. * Begin a new frame
  104010. */
  104011. beginFrame(): void;
  104012. /**
  104013. * Enf the current frame
  104014. */
  104015. endFrame(): void;
  104016. resize(): void;
  104017. /**
  104018. * Set the compressed texture format to use, based on the formats you have, and the formats
  104019. * supported by the hardware / browser.
  104020. *
  104021. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104022. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104023. * to API arguments needed to compressed textures. This puts the burden on the container
  104024. * generator to house the arcane code for determining these for current & future formats.
  104025. *
  104026. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104027. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104028. *
  104029. * Note: The result of this call is not taken into account when a texture is base64.
  104030. *
  104031. * @param formatsAvailable defines the list of those format families you have created
  104032. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104033. *
  104034. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104035. * @returns The extension selected.
  104036. */
  104037. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104038. /**
  104039. * Set the compressed texture extensions or file names to skip.
  104040. *
  104041. * @param skippedFiles defines the list of those texture files you want to skip
  104042. * Example: [".dds", ".env", "myfile.png"]
  104043. */
  104044. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104045. /**
  104046. * Force a specific size of the canvas
  104047. * @param width defines the new canvas' width
  104048. * @param height defines the new canvas' height
  104049. */
  104050. setSize(width: number, height: number): void;
  104051. /**
  104052. * Updates a dynamic vertex buffer.
  104053. * @param vertexBuffer the vertex buffer to update
  104054. * @param data the data used to update the vertex buffer
  104055. * @param byteOffset the byte offset of the data
  104056. * @param byteLength the byte length of the data
  104057. */
  104058. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104060. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104061. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104062. _releaseTexture(texture: InternalTexture): void;
  104063. /**
  104064. * @hidden
  104065. * Rescales a texture
  104066. * @param source input texutre
  104067. * @param destination destination texture
  104068. * @param scene scene to use to render the resize
  104069. * @param internalFormat format to use when resizing
  104070. * @param onComplete callback to be called when resize has completed
  104071. */
  104072. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104073. /**
  104074. * Gets the current framerate
  104075. * @returns a number representing the framerate
  104076. */
  104077. getFps(): number;
  104078. /**
  104079. * Gets the time spent between current and previous frame
  104080. * @returns a number representing the delta time in ms
  104081. */
  104082. getDeltaTime(): number;
  104083. private _measureFps;
  104084. /** @hidden */
  104085. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104086. /**
  104087. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104088. * @param renderTarget The render target to set the frame buffer for
  104089. */
  104090. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104091. /**
  104092. * Update a dynamic index buffer
  104093. * @param indexBuffer defines the target index buffer
  104094. * @param indices defines the data to update
  104095. * @param offset defines the offset in the target index buffer where update should start
  104096. */
  104097. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104098. /**
  104099. * Updates the sample count of a render target texture
  104100. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104101. * @param texture defines the texture to update
  104102. * @param samples defines the sample count to set
  104103. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104104. */
  104105. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104106. /**
  104107. * Updates a depth texture Comparison Mode and Function.
  104108. * If the comparison Function is equal to 0, the mode will be set to none.
  104109. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104110. * @param texture The texture to set the comparison function for
  104111. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104112. */
  104113. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104114. /**
  104115. * Creates a webGL buffer to use with instanciation
  104116. * @param capacity defines the size of the buffer
  104117. * @returns the webGL buffer
  104118. */
  104119. createInstancesBuffer(capacity: number): DataBuffer;
  104120. /**
  104121. * Delete a webGL buffer used with instanciation
  104122. * @param buffer defines the webGL buffer to delete
  104123. */
  104124. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104125. /** @hidden */
  104126. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104127. dispose(): void;
  104128. private _disableTouchAction;
  104129. /**
  104130. * Display the loading screen
  104131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104132. */
  104133. displayLoadingUI(): void;
  104134. /**
  104135. * Hide the loading screen
  104136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104137. */
  104138. hideLoadingUI(): void;
  104139. /**
  104140. * Gets the current loading screen object
  104141. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104142. */
  104143. get loadingScreen(): ILoadingScreen;
  104144. /**
  104145. * Sets the current loading screen object
  104146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104147. */
  104148. set loadingScreen(loadingScreen: ILoadingScreen);
  104149. /**
  104150. * Sets the current loading screen text
  104151. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104152. */
  104153. set loadingUIText(text: string);
  104154. /**
  104155. * Sets the current loading screen background color
  104156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104157. */
  104158. set loadingUIBackgroundColor(color: string);
  104159. /** Pointerlock and fullscreen */
  104160. /**
  104161. * Ask the browser to promote the current element to pointerlock mode
  104162. * @param element defines the DOM element to promote
  104163. */
  104164. static _RequestPointerlock(element: HTMLElement): void;
  104165. /**
  104166. * Asks the browser to exit pointerlock mode
  104167. */
  104168. static _ExitPointerlock(): void;
  104169. /**
  104170. * Ask the browser to promote the current element to fullscreen rendering mode
  104171. * @param element defines the DOM element to promote
  104172. */
  104173. static _RequestFullscreen(element: HTMLElement): void;
  104174. /**
  104175. * Asks the browser to exit fullscreen mode
  104176. */
  104177. static _ExitFullscreen(): void;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104183. * during the life time of the application.
  104184. */
  104185. export class EngineStore {
  104186. /** Gets the list of created engines */
  104187. static Instances: Engine[];
  104188. /** @hidden */
  104189. static _LastCreatedScene: Nullable<Scene>;
  104190. /**
  104191. * Gets the latest created engine
  104192. */
  104193. static get LastCreatedEngine(): Nullable<Engine>;
  104194. /**
  104195. * Gets the latest created scene
  104196. */
  104197. static get LastCreatedScene(): Nullable<Scene>;
  104198. /**
  104199. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104200. * @ignorenaming
  104201. */
  104202. static UseFallbackTexture: boolean;
  104203. /**
  104204. * Texture content used if a texture cannot loaded
  104205. * @ignorenaming
  104206. */
  104207. static FallbackTexture: string;
  104208. }
  104209. }
  104210. declare module BABYLON {
  104211. /**
  104212. * Helper class that provides a small promise polyfill
  104213. */
  104214. export class PromisePolyfill {
  104215. /**
  104216. * Static function used to check if the polyfill is required
  104217. * If this is the case then the function will inject the polyfill to window.Promise
  104218. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104219. */
  104220. static Apply(force?: boolean): void;
  104221. }
  104222. }
  104223. declare module BABYLON {
  104224. /**
  104225. * Interface for screenshot methods with describe argument called `size` as object with options
  104226. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104227. */
  104228. export interface IScreenshotSize {
  104229. /**
  104230. * number in pixels for canvas height
  104231. */
  104232. height?: number;
  104233. /**
  104234. * multiplier allowing render at a higher or lower resolution
  104235. * If value is defined then height and width will be ignored and taken from camera
  104236. */
  104237. precision?: number;
  104238. /**
  104239. * number in pixels for canvas width
  104240. */
  104241. width?: number;
  104242. }
  104243. }
  104244. declare module BABYLON {
  104245. interface IColor4Like {
  104246. r: float;
  104247. g: float;
  104248. b: float;
  104249. a: float;
  104250. }
  104251. /**
  104252. * Class containing a set of static utilities functions
  104253. */
  104254. export class Tools {
  104255. /**
  104256. * Gets or sets the base URL to use to load assets
  104257. */
  104258. static get BaseUrl(): string;
  104259. static set BaseUrl(value: string);
  104260. /**
  104261. * Enable/Disable Custom HTTP Request Headers globally.
  104262. * default = false
  104263. * @see CustomRequestHeaders
  104264. */
  104265. static UseCustomRequestHeaders: boolean;
  104266. /**
  104267. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104268. * i.e. when loading files, where the server/service expects an Authorization header
  104269. */
  104270. static CustomRequestHeaders: {
  104271. [key: string]: string;
  104272. };
  104273. /**
  104274. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104275. */
  104276. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104277. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104278. /**
  104279. * Default behaviour for cors in the application.
  104280. * It can be a string if the expected behavior is identical in the entire app.
  104281. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104282. */
  104283. static CorsBehavior: string | ((url: string | string[]) => string);
  104284. /**
  104285. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104286. * @ignorenaming
  104287. */
  104288. static get UseFallbackTexture(): boolean;
  104289. static set UseFallbackTexture(value: boolean);
  104290. /**
  104291. * Use this object to register external classes like custom textures or material
  104292. * to allow the laoders to instantiate them
  104293. */
  104294. static get RegisteredExternalClasses(): {
  104295. [key: string]: Object;
  104296. };
  104297. static set RegisteredExternalClasses(classes: {
  104298. [key: string]: Object;
  104299. });
  104300. /**
  104301. * Texture content used if a texture cannot loaded
  104302. * @ignorenaming
  104303. */
  104304. static get fallbackTexture(): string;
  104305. static set fallbackTexture(value: string);
  104306. /**
  104307. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104308. * @param u defines the coordinate on X axis
  104309. * @param v defines the coordinate on Y axis
  104310. * @param width defines the width of the source data
  104311. * @param height defines the height of the source data
  104312. * @param pixels defines the source byte array
  104313. * @param color defines the output color
  104314. */
  104315. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104316. /**
  104317. * Interpolates between a and b via alpha
  104318. * @param a The lower value (returned when alpha = 0)
  104319. * @param b The upper value (returned when alpha = 1)
  104320. * @param alpha The interpolation-factor
  104321. * @return The mixed value
  104322. */
  104323. static Mix(a: number, b: number, alpha: number): number;
  104324. /**
  104325. * Tries to instantiate a new object from a given class name
  104326. * @param className defines the class name to instantiate
  104327. * @returns the new object or null if the system was not able to do the instantiation
  104328. */
  104329. static Instantiate(className: string): any;
  104330. /**
  104331. * Provides a slice function that will work even on IE
  104332. * @param data defines the array to slice
  104333. * @param start defines the start of the data (optional)
  104334. * @param end defines the end of the data (optional)
  104335. * @returns the new sliced array
  104336. */
  104337. static Slice<T>(data: T, start?: number, end?: number): T;
  104338. /**
  104339. * Polyfill for setImmediate
  104340. * @param action defines the action to execute after the current execution block
  104341. */
  104342. static SetImmediate(action: () => void): void;
  104343. /**
  104344. * Function indicating if a number is an exponent of 2
  104345. * @param value defines the value to test
  104346. * @returns true if the value is an exponent of 2
  104347. */
  104348. static IsExponentOfTwo(value: number): boolean;
  104349. private static _tmpFloatArray;
  104350. /**
  104351. * Returns the nearest 32-bit single precision float representation of a Number
  104352. * @param value A Number. If the parameter is of a different type, it will get converted
  104353. * to a number or to NaN if it cannot be converted
  104354. * @returns number
  104355. */
  104356. static FloatRound(value: number): number;
  104357. /**
  104358. * Extracts the filename from a path
  104359. * @param path defines the path to use
  104360. * @returns the filename
  104361. */
  104362. static GetFilename(path: string): string;
  104363. /**
  104364. * Extracts the "folder" part of a path (everything before the filename).
  104365. * @param uri The URI to extract the info from
  104366. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104367. * @returns The "folder" part of the path
  104368. */
  104369. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104370. /**
  104371. * Extracts text content from a DOM element hierarchy
  104372. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104373. */
  104374. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104375. /**
  104376. * Convert an angle in radians to degrees
  104377. * @param angle defines the angle to convert
  104378. * @returns the angle in degrees
  104379. */
  104380. static ToDegrees(angle: number): number;
  104381. /**
  104382. * Convert an angle in degrees to radians
  104383. * @param angle defines the angle to convert
  104384. * @returns the angle in radians
  104385. */
  104386. static ToRadians(angle: number): number;
  104387. /**
  104388. * Returns an array if obj is not an array
  104389. * @param obj defines the object to evaluate as an array
  104390. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104391. * @returns either obj directly if obj is an array or a new array containing obj
  104392. */
  104393. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104394. /**
  104395. * Gets the pointer prefix to use
  104396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104397. */
  104398. static GetPointerPrefix(): string;
  104399. /**
  104400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104401. * @param url define the url we are trying
  104402. * @param element define the dom element where to configure the cors policy
  104403. */
  104404. static SetCorsBehavior(url: string | string[], element: {
  104405. crossOrigin: string | null;
  104406. }): void;
  104407. /**
  104408. * Removes unwanted characters from an url
  104409. * @param url defines the url to clean
  104410. * @returns the cleaned url
  104411. */
  104412. static CleanUrl(url: string): string;
  104413. /**
  104414. * Gets or sets a function used to pre-process url before using them to load assets
  104415. */
  104416. static get PreprocessUrl(): (url: string) => string;
  104417. static set PreprocessUrl(processor: (url: string) => string);
  104418. /**
  104419. * Loads an image as an HTMLImageElement.
  104420. * @param input url string, ArrayBuffer, or Blob to load
  104421. * @param onLoad callback called when the image successfully loads
  104422. * @param onError callback called when the image fails to load
  104423. * @param offlineProvider offline provider for caching
  104424. * @param mimeType optional mime type
  104425. * @returns the HTMLImageElement of the loaded image
  104426. */
  104427. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104428. /**
  104429. * Loads a file from a url
  104430. * @param url url string, ArrayBuffer, or Blob to load
  104431. * @param onSuccess callback called when the file successfully loads
  104432. * @param onProgress callback called while file is loading (if the server supports this mode)
  104433. * @param offlineProvider defines the offline provider for caching
  104434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104435. * @param onError callback called when the file fails to load
  104436. * @returns a file request object
  104437. */
  104438. 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;
  104439. /**
  104440. * Loads a file from a url
  104441. * @param url the file url to load
  104442. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104443. */
  104444. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104445. /**
  104446. * Load a script (identified by an url). When the url returns, the
  104447. * content of this file is added into a new script element, attached to the DOM (body element)
  104448. * @param scriptUrl defines the url of the script to laod
  104449. * @param onSuccess defines the callback called when the script is loaded
  104450. * @param onError defines the callback to call if an error occurs
  104451. * @param scriptId defines the id of the script element
  104452. */
  104453. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104454. /**
  104455. * Load an asynchronous script (identified by an url). When the url returns, the
  104456. * content of this file is added into a new script element, attached to the DOM (body element)
  104457. * @param scriptUrl defines the url of the script to laod
  104458. * @param scriptId defines the id of the script element
  104459. * @returns a promise request object
  104460. */
  104461. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  104462. /**
  104463. * Loads a file from a blob
  104464. * @param fileToLoad defines the blob to use
  104465. * @param callback defines the callback to call when data is loaded
  104466. * @param progressCallback defines the callback to call during loading process
  104467. * @returns a file request object
  104468. */
  104469. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104470. /**
  104471. * Reads a file from a File object
  104472. * @param file defines the file to load
  104473. * @param onSuccess defines the callback to call when data is loaded
  104474. * @param onProgress defines the callback to call during loading process
  104475. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104476. * @param onError defines the callback to call when an error occurs
  104477. * @returns a file request object
  104478. */
  104479. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104480. /**
  104481. * Creates a data url from a given string content
  104482. * @param content defines the content to convert
  104483. * @returns the new data url link
  104484. */
  104485. static FileAsURL(content: string): string;
  104486. /**
  104487. * Format the given number to a specific decimal format
  104488. * @param value defines the number to format
  104489. * @param decimals defines the number of decimals to use
  104490. * @returns the formatted string
  104491. */
  104492. static Format(value: number, decimals?: number): string;
  104493. /**
  104494. * Tries to copy an object by duplicating every property
  104495. * @param source defines the source object
  104496. * @param destination defines the target object
  104497. * @param doNotCopyList defines a list of properties to avoid
  104498. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104499. */
  104500. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104501. /**
  104502. * Gets a boolean indicating if the given object has no own property
  104503. * @param obj defines the object to test
  104504. * @returns true if object has no own property
  104505. */
  104506. static IsEmpty(obj: any): boolean;
  104507. /**
  104508. * Function used to register events at window level
  104509. * @param windowElement defines the Window object to use
  104510. * @param events defines the events to register
  104511. */
  104512. static RegisterTopRootEvents(windowElement: Window, events: {
  104513. name: string;
  104514. handler: Nullable<(e: FocusEvent) => any>;
  104515. }[]): void;
  104516. /**
  104517. * Function used to unregister events from window level
  104518. * @param windowElement defines the Window object to use
  104519. * @param events defines the events to unregister
  104520. */
  104521. static UnregisterTopRootEvents(windowElement: Window, events: {
  104522. name: string;
  104523. handler: Nullable<(e: FocusEvent) => any>;
  104524. }[]): void;
  104525. /**
  104526. * @ignore
  104527. */
  104528. static _ScreenshotCanvas: HTMLCanvasElement;
  104529. /**
  104530. * Dumps the current bound framebuffer
  104531. * @param width defines the rendering width
  104532. * @param height defines the rendering height
  104533. * @param engine defines the hosting engine
  104534. * @param successCallback defines the callback triggered once the data are available
  104535. * @param mimeType defines the mime type of the result
  104536. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104537. */
  104538. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104539. /**
  104540. * Converts the canvas data to blob.
  104541. * This acts as a polyfill for browsers not supporting the to blob function.
  104542. * @param canvas Defines the canvas to extract the data from
  104543. * @param successCallback Defines the callback triggered once the data are available
  104544. * @param mimeType Defines the mime type of the result
  104545. */
  104546. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104547. /**
  104548. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104549. * @param successCallback defines the callback triggered once the data are available
  104550. * @param mimeType defines the mime type of the result
  104551. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104552. */
  104553. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104554. /**
  104555. * Downloads a blob in the browser
  104556. * @param blob defines the blob to download
  104557. * @param fileName defines the name of the downloaded file
  104558. */
  104559. static Download(blob: Blob, fileName: string): void;
  104560. /**
  104561. * Captures a screenshot of the current rendering
  104562. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104563. * @param engine defines the rendering engine
  104564. * @param camera defines the source camera
  104565. * @param size This parameter can be set to a single number or to an object with the
  104566. * following (optional) properties: precision, width, height. If a single number is passed,
  104567. * it will be used for both width and height. If an object is passed, the screenshot size
  104568. * will be derived from the parameters. The precision property is a multiplier allowing
  104569. * rendering at a higher or lower resolution
  104570. * @param successCallback defines the callback receives a single parameter which contains the
  104571. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104572. * src parameter of an <img> to display it
  104573. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104574. * Check your browser for supported MIME types
  104575. */
  104576. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104577. /**
  104578. * Captures a screenshot of the current rendering
  104579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104580. * @param engine defines the rendering engine
  104581. * @param camera defines the source camera
  104582. * @param size This parameter can be set to a single number or to an object with the
  104583. * following (optional) properties: precision, width, height. If a single number is passed,
  104584. * it will be used for both width and height. If an object is passed, the screenshot size
  104585. * will be derived from the parameters. The precision property is a multiplier allowing
  104586. * rendering at a higher or lower resolution
  104587. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104588. * Check your browser for supported MIME types
  104589. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104590. * to the src parameter of an <img> to display it
  104591. */
  104592. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104593. /**
  104594. * Generates an image screenshot from the specified camera.
  104595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104596. * @param engine The engine to use for rendering
  104597. * @param camera The camera to use for rendering
  104598. * @param size This parameter can be set to a single number or to an object with the
  104599. * following (optional) properties: precision, width, height. If a single number is passed,
  104600. * it will be used for both width and height. If an object is passed, the screenshot size
  104601. * will be derived from the parameters. The precision property is a multiplier allowing
  104602. * rendering at a higher or lower resolution
  104603. * @param successCallback The callback receives a single parameter which contains the
  104604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104605. * src parameter of an <img> to display it
  104606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104607. * Check your browser for supported MIME types
  104608. * @param samples Texture samples (default: 1)
  104609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104610. * @param fileName A name for for the downloaded file.
  104611. */
  104612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104613. /**
  104614. * Generates an image screenshot from the specified camera.
  104615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104616. * @param engine The engine to use for rendering
  104617. * @param camera The camera to use for rendering
  104618. * @param size This parameter can be set to a single number or to an object with the
  104619. * following (optional) properties: precision, width, height. If a single number is passed,
  104620. * it will be used for both width and height. If an object is passed, the screenshot size
  104621. * will be derived from the parameters. The precision property is a multiplier allowing
  104622. * rendering at a higher or lower resolution
  104623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104624. * Check your browser for supported MIME types
  104625. * @param samples Texture samples (default: 1)
  104626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104627. * @param fileName A name for for the downloaded file.
  104628. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104629. * to the src parameter of an <img> to display it
  104630. */
  104631. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104632. /**
  104633. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104634. * Be aware Math.random() could cause collisions, but:
  104635. * "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"
  104636. * @returns a pseudo random id
  104637. */
  104638. static RandomId(): string;
  104639. /**
  104640. * Test if the given uri is a base64 string
  104641. * @param uri The uri to test
  104642. * @return True if the uri is a base64 string or false otherwise
  104643. */
  104644. static IsBase64(uri: string): boolean;
  104645. /**
  104646. * Decode the given base64 uri.
  104647. * @param uri The uri to decode
  104648. * @return The decoded base64 data.
  104649. */
  104650. static DecodeBase64(uri: string): ArrayBuffer;
  104651. /**
  104652. * Gets the absolute url.
  104653. * @param url the input url
  104654. * @return the absolute url
  104655. */
  104656. static GetAbsoluteUrl(url: string): string;
  104657. /**
  104658. * No log
  104659. */
  104660. static readonly NoneLogLevel: number;
  104661. /**
  104662. * Only message logs
  104663. */
  104664. static readonly MessageLogLevel: number;
  104665. /**
  104666. * Only warning logs
  104667. */
  104668. static readonly WarningLogLevel: number;
  104669. /**
  104670. * Only error logs
  104671. */
  104672. static readonly ErrorLogLevel: number;
  104673. /**
  104674. * All logs
  104675. */
  104676. static readonly AllLogLevel: number;
  104677. /**
  104678. * Gets a value indicating the number of loading errors
  104679. * @ignorenaming
  104680. */
  104681. static get errorsCount(): number;
  104682. /**
  104683. * Callback called when a new log is added
  104684. */
  104685. static OnNewCacheEntry: (entry: string) => void;
  104686. /**
  104687. * Log a message to the console
  104688. * @param message defines the message to log
  104689. */
  104690. static Log(message: string): void;
  104691. /**
  104692. * Write a warning message to the console
  104693. * @param message defines the message to log
  104694. */
  104695. static Warn(message: string): void;
  104696. /**
  104697. * Write an error message to the console
  104698. * @param message defines the message to log
  104699. */
  104700. static Error(message: string): void;
  104701. /**
  104702. * Gets current log cache (list of logs)
  104703. */
  104704. static get LogCache(): string;
  104705. /**
  104706. * Clears the log cache
  104707. */
  104708. static ClearLogCache(): void;
  104709. /**
  104710. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104711. */
  104712. static set LogLevels(level: number);
  104713. /**
  104714. * Checks if the window object exists
  104715. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104716. */
  104717. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104718. /**
  104719. * No performance log
  104720. */
  104721. static readonly PerformanceNoneLogLevel: number;
  104722. /**
  104723. * Use user marks to log performance
  104724. */
  104725. static readonly PerformanceUserMarkLogLevel: number;
  104726. /**
  104727. * Log performance to the console
  104728. */
  104729. static readonly PerformanceConsoleLogLevel: number;
  104730. private static _performance;
  104731. /**
  104732. * Sets the current performance log level
  104733. */
  104734. static set PerformanceLogLevel(level: number);
  104735. private static _StartPerformanceCounterDisabled;
  104736. private static _EndPerformanceCounterDisabled;
  104737. private static _StartUserMark;
  104738. private static _EndUserMark;
  104739. private static _StartPerformanceConsole;
  104740. private static _EndPerformanceConsole;
  104741. /**
  104742. * Starts a performance counter
  104743. */
  104744. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104745. /**
  104746. * Ends a specific performance coutner
  104747. */
  104748. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104749. /**
  104750. * Gets either window.performance.now() if supported or Date.now() else
  104751. */
  104752. static get Now(): number;
  104753. /**
  104754. * This method will return the name of the class used to create the instance of the given object.
  104755. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104756. * @param object the object to get the class name from
  104757. * @param isType defines if the object is actually a type
  104758. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104759. */
  104760. static GetClassName(object: any, isType?: boolean): string;
  104761. /**
  104762. * Gets the first element of an array satisfying a given predicate
  104763. * @param array defines the array to browse
  104764. * @param predicate defines the predicate to use
  104765. * @returns null if not found or the element
  104766. */
  104767. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104768. /**
  104769. * This method will return the name of the full name of the class, including its owning module (if any).
  104770. * 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).
  104771. * @param object the object to get the class name from
  104772. * @param isType defines if the object is actually a type
  104773. * @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.
  104774. * @ignorenaming
  104775. */
  104776. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104777. /**
  104778. * Returns a promise that resolves after the given amount of time.
  104779. * @param delay Number of milliseconds to delay
  104780. * @returns Promise that resolves after the given amount of time
  104781. */
  104782. static DelayAsync(delay: number): Promise<void>;
  104783. }
  104784. /**
  104785. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104786. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104787. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104788. * @param name The name of the class, case should be preserved
  104789. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104790. */
  104791. export function className(name: string, module?: string): (target: Object) => void;
  104792. /**
  104793. * An implementation of a loop for asynchronous functions.
  104794. */
  104795. export class AsyncLoop {
  104796. /**
  104797. * Defines the number of iterations for the loop
  104798. */
  104799. iterations: number;
  104800. /**
  104801. * Defines the current index of the loop.
  104802. */
  104803. index: number;
  104804. private _done;
  104805. private _fn;
  104806. private _successCallback;
  104807. /**
  104808. * Constructor.
  104809. * @param iterations the number of iterations.
  104810. * @param func the function to run each iteration
  104811. * @param successCallback the callback that will be called upon succesful execution
  104812. * @param offset starting offset.
  104813. */
  104814. constructor(
  104815. /**
  104816. * Defines the number of iterations for the loop
  104817. */
  104818. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104819. /**
  104820. * Execute the next iteration. Must be called after the last iteration was finished.
  104821. */
  104822. executeNext(): void;
  104823. /**
  104824. * Break the loop and run the success callback.
  104825. */
  104826. breakLoop(): void;
  104827. /**
  104828. * Create and run an async loop.
  104829. * @param iterations the number of iterations.
  104830. * @param fn the function to run each iteration
  104831. * @param successCallback the callback that will be called upon succesful execution
  104832. * @param offset starting offset.
  104833. * @returns the created async loop object
  104834. */
  104835. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104836. /**
  104837. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104838. * @param iterations total number of iterations
  104839. * @param syncedIterations number of synchronous iterations in each async iteration.
  104840. * @param fn the function to call each iteration.
  104841. * @param callback a success call back that will be called when iterating stops.
  104842. * @param breakFunction a break condition (optional)
  104843. * @param timeout timeout settings for the setTimeout function. default - 0.
  104844. * @returns the created async loop object
  104845. */
  104846. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104847. }
  104848. }
  104849. declare module BABYLON {
  104850. /**
  104851. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104852. * The underlying implementation relies on an associative array to ensure the best performances.
  104853. * The value can be anything including 'null' but except 'undefined'
  104854. */
  104855. export class StringDictionary<T> {
  104856. /**
  104857. * This will clear this dictionary and copy the content from the 'source' one.
  104858. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104859. * @param source the dictionary to take the content from and copy to this dictionary
  104860. */
  104861. copyFrom(source: StringDictionary<T>): void;
  104862. /**
  104863. * Get a value based from its key
  104864. * @param key the given key to get the matching value from
  104865. * @return the value if found, otherwise undefined is returned
  104866. */
  104867. get(key: string): T | undefined;
  104868. /**
  104869. * Get a value from its key or add it if it doesn't exist.
  104870. * This method will ensure you that a given key/data will be present in the dictionary.
  104871. * @param key the given key to get the matching value from
  104872. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104873. * The factory will only be invoked if there's no data for the given key.
  104874. * @return the value corresponding to the key.
  104875. */
  104876. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104877. /**
  104878. * Get a value from its key if present in the dictionary otherwise add it
  104879. * @param key the key to get the value from
  104880. * @param val if there's no such key/value pair in the dictionary add it with this value
  104881. * @return the value corresponding to the key
  104882. */
  104883. getOrAdd(key: string, val: T): T;
  104884. /**
  104885. * Check if there's a given key in the dictionary
  104886. * @param key the key to check for
  104887. * @return true if the key is present, false otherwise
  104888. */
  104889. contains(key: string): boolean;
  104890. /**
  104891. * Add a new key and its corresponding value
  104892. * @param key the key to add
  104893. * @param value the value corresponding to the key
  104894. * @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
  104895. */
  104896. add(key: string, value: T): boolean;
  104897. /**
  104898. * Update a specific value associated to a key
  104899. * @param key defines the key to use
  104900. * @param value defines the value to store
  104901. * @returns true if the value was updated (or false if the key was not found)
  104902. */
  104903. set(key: string, value: T): boolean;
  104904. /**
  104905. * Get the element of the given key and remove it from the dictionary
  104906. * @param key defines the key to search
  104907. * @returns the value associated with the key or null if not found
  104908. */
  104909. getAndRemove(key: string): Nullable<T>;
  104910. /**
  104911. * Remove a key/value from the dictionary.
  104912. * @param key the key to remove
  104913. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104914. */
  104915. remove(key: string): boolean;
  104916. /**
  104917. * Clear the whole content of the dictionary
  104918. */
  104919. clear(): void;
  104920. /**
  104921. * Gets the current count
  104922. */
  104923. get count(): number;
  104924. /**
  104925. * Execute a callback on each key/val of the dictionary.
  104926. * Note that you can remove any element in this dictionary in the callback implementation
  104927. * @param callback the callback to execute on a given key/value pair
  104928. */
  104929. forEach(callback: (key: string, val: T) => void): void;
  104930. /**
  104931. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104932. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104933. * Note that you can remove any element in this dictionary in the callback implementation
  104934. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104935. * @returns the first item
  104936. */
  104937. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  104938. private _count;
  104939. private _data;
  104940. }
  104941. }
  104942. declare module BABYLON {
  104943. /** @hidden */
  104944. export interface ICollisionCoordinator {
  104945. createCollider(): Collider;
  104946. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104947. init(scene: Scene): void;
  104948. }
  104949. /** @hidden */
  104950. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  104951. private _scene;
  104952. private _scaledPosition;
  104953. private _scaledVelocity;
  104954. private _finalPosition;
  104955. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104956. createCollider(): Collider;
  104957. init(scene: Scene): void;
  104958. private _collideWithWorld;
  104959. }
  104960. }
  104961. declare module BABYLON {
  104962. /**
  104963. * Class used to manage all inputs for the scene.
  104964. */
  104965. export class InputManager {
  104966. /** The distance in pixel that you have to move to prevent some events */
  104967. static DragMovementThreshold: number;
  104968. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  104969. static LongPressDelay: number;
  104970. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  104971. static DoubleClickDelay: number;
  104972. /** If you need to check double click without raising a single click at first click, enable this flag */
  104973. static ExclusiveDoubleClickMode: boolean;
  104974. private _wheelEventName;
  104975. private _onPointerMove;
  104976. private _onPointerDown;
  104977. private _onPointerUp;
  104978. private _initClickEvent;
  104979. private _initActionManager;
  104980. private _delayedSimpleClick;
  104981. private _delayedSimpleClickTimeout;
  104982. private _previousDelayedSimpleClickTimeout;
  104983. private _meshPickProceed;
  104984. private _previousButtonPressed;
  104985. private _currentPickResult;
  104986. private _previousPickResult;
  104987. private _totalPointersPressed;
  104988. private _doubleClickOccured;
  104989. private _pointerOverMesh;
  104990. private _pickedDownMesh;
  104991. private _pickedUpMesh;
  104992. private _pointerX;
  104993. private _pointerY;
  104994. private _unTranslatedPointerX;
  104995. private _unTranslatedPointerY;
  104996. private _startingPointerPosition;
  104997. private _previousStartingPointerPosition;
  104998. private _startingPointerTime;
  104999. private _previousStartingPointerTime;
  105000. private _pointerCaptures;
  105001. private _onKeyDown;
  105002. private _onKeyUp;
  105003. private _onCanvasFocusObserver;
  105004. private _onCanvasBlurObserver;
  105005. private _scene;
  105006. /**
  105007. * Creates a new InputManager
  105008. * @param scene defines the hosting scene
  105009. */
  105010. constructor(scene: Scene);
  105011. /**
  105012. * Gets the mesh that is currently under the pointer
  105013. */
  105014. get meshUnderPointer(): Nullable<AbstractMesh>;
  105015. /**
  105016. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105017. */
  105018. get unTranslatedPointer(): Vector2;
  105019. /**
  105020. * Gets or sets the current on-screen X position of the pointer
  105021. */
  105022. get pointerX(): number;
  105023. set pointerX(value: number);
  105024. /**
  105025. * Gets or sets the current on-screen Y position of the pointer
  105026. */
  105027. get pointerY(): number;
  105028. set pointerY(value: number);
  105029. private _updatePointerPosition;
  105030. private _processPointerMove;
  105031. private _setRayOnPointerInfo;
  105032. private _checkPrePointerObservable;
  105033. /**
  105034. * Use this method to simulate a pointer move on a mesh
  105035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105038. */
  105039. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105040. /**
  105041. * Use this method to simulate a pointer down on a mesh
  105042. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105043. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105044. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105045. */
  105046. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105047. private _processPointerDown;
  105048. /** @hidden */
  105049. _isPointerSwiping(): boolean;
  105050. /**
  105051. * Use this method to simulate a pointer up on a mesh
  105052. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105053. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105054. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105055. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105056. */
  105057. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105058. private _processPointerUp;
  105059. /**
  105060. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105061. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105062. * @returns true if the pointer was captured
  105063. */
  105064. isPointerCaptured(pointerId?: number): boolean;
  105065. /**
  105066. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105067. * @param attachUp defines if you want to attach events to pointerup
  105068. * @param attachDown defines if you want to attach events to pointerdown
  105069. * @param attachMove defines if you want to attach events to pointermove
  105070. */
  105071. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105072. /**
  105073. * Detaches all event handlers
  105074. */
  105075. detachControl(): void;
  105076. /**
  105077. * Force the value of meshUnderPointer
  105078. * @param mesh defines the mesh to use
  105079. */
  105080. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105081. /**
  105082. * Gets the mesh under the pointer
  105083. * @returns a Mesh or null if no mesh is under the pointer
  105084. */
  105085. getPointerOverMesh(): Nullable<AbstractMesh>;
  105086. }
  105087. }
  105088. declare module BABYLON {
  105089. /**
  105090. * Helper class used to generate session unique ID
  105091. */
  105092. export class UniqueIdGenerator {
  105093. private static _UniqueIdCounter;
  105094. /**
  105095. * Gets an unique (relatively to the current scene) Id
  105096. */
  105097. static get UniqueId(): number;
  105098. }
  105099. }
  105100. declare module BABYLON {
  105101. /**
  105102. * This class defines the direct association between an animation and a target
  105103. */
  105104. export class TargetedAnimation {
  105105. /**
  105106. * Animation to perform
  105107. */
  105108. animation: Animation;
  105109. /**
  105110. * Target to animate
  105111. */
  105112. target: any;
  105113. /**
  105114. * Serialize the object
  105115. * @returns the JSON object representing the current entity
  105116. */
  105117. serialize(): any;
  105118. }
  105119. /**
  105120. * Use this class to create coordinated animations on multiple targets
  105121. */
  105122. export class AnimationGroup implements IDisposable {
  105123. /** The name of the animation group */
  105124. name: string;
  105125. private _scene;
  105126. private _targetedAnimations;
  105127. private _animatables;
  105128. private _from;
  105129. private _to;
  105130. private _isStarted;
  105131. private _isPaused;
  105132. private _speedRatio;
  105133. private _loopAnimation;
  105134. /**
  105135. * Gets or sets the unique id of the node
  105136. */
  105137. uniqueId: number;
  105138. /**
  105139. * This observable will notify when one animation have ended
  105140. */
  105141. onAnimationEndObservable: Observable<TargetedAnimation>;
  105142. /**
  105143. * Observer raised when one animation loops
  105144. */
  105145. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105146. /**
  105147. * Observer raised when all animations have looped
  105148. */
  105149. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105150. /**
  105151. * This observable will notify when all animations have ended.
  105152. */
  105153. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105154. /**
  105155. * This observable will notify when all animations have paused.
  105156. */
  105157. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105158. /**
  105159. * This observable will notify when all animations are playing.
  105160. */
  105161. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105162. /**
  105163. * Gets the first frame
  105164. */
  105165. get from(): number;
  105166. /**
  105167. * Gets the last frame
  105168. */
  105169. get to(): number;
  105170. /**
  105171. * Define if the animations are started
  105172. */
  105173. get isStarted(): boolean;
  105174. /**
  105175. * Gets a value indicating that the current group is playing
  105176. */
  105177. get isPlaying(): boolean;
  105178. /**
  105179. * Gets or sets the speed ratio to use for all animations
  105180. */
  105181. get speedRatio(): number;
  105182. /**
  105183. * Gets or sets the speed ratio to use for all animations
  105184. */
  105185. set speedRatio(value: number);
  105186. /**
  105187. * Gets or sets if all animations should loop or not
  105188. */
  105189. get loopAnimation(): boolean;
  105190. set loopAnimation(value: boolean);
  105191. /**
  105192. * Gets the targeted animations for this animation group
  105193. */
  105194. get targetedAnimations(): Array<TargetedAnimation>;
  105195. /**
  105196. * returning the list of animatables controlled by this animation group.
  105197. */
  105198. get animatables(): Array<Animatable>;
  105199. /**
  105200. * Instantiates a new Animation Group.
  105201. * This helps managing several animations at once.
  105202. * @see http://doc.babylonjs.com/how_to/group
  105203. * @param name Defines the name of the group
  105204. * @param scene Defines the scene the group belongs to
  105205. */
  105206. constructor(
  105207. /** The name of the animation group */
  105208. name: string, scene?: Nullable<Scene>);
  105209. /**
  105210. * Add an animation (with its target) in the group
  105211. * @param animation defines the animation we want to add
  105212. * @param target defines the target of the animation
  105213. * @returns the TargetedAnimation object
  105214. */
  105215. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105216. /**
  105217. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105218. * It can add constant keys at begin or end
  105219. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105220. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105221. * @returns the animation group
  105222. */
  105223. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105224. private _animationLoopCount;
  105225. private _animationLoopFlags;
  105226. private _processLoop;
  105227. /**
  105228. * Start all animations on given targets
  105229. * @param loop defines if animations must loop
  105230. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105231. * @param from defines the from key (optional)
  105232. * @param to defines the to key (optional)
  105233. * @returns the current animation group
  105234. */
  105235. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105236. /**
  105237. * Pause all animations
  105238. * @returns the animation group
  105239. */
  105240. pause(): AnimationGroup;
  105241. /**
  105242. * Play all animations to initial state
  105243. * This function will start() the animations if they were not started or will restart() them if they were paused
  105244. * @param loop defines if animations must loop
  105245. * @returns the animation group
  105246. */
  105247. play(loop?: boolean): AnimationGroup;
  105248. /**
  105249. * Reset all animations to initial state
  105250. * @returns the animation group
  105251. */
  105252. reset(): AnimationGroup;
  105253. /**
  105254. * Restart animations from key 0
  105255. * @returns the animation group
  105256. */
  105257. restart(): AnimationGroup;
  105258. /**
  105259. * Stop all animations
  105260. * @returns the animation group
  105261. */
  105262. stop(): AnimationGroup;
  105263. /**
  105264. * Set animation weight for all animatables
  105265. * @param weight defines the weight to use
  105266. * @return the animationGroup
  105267. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105268. */
  105269. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105270. /**
  105271. * Synchronize and normalize all animatables with a source animatable
  105272. * @param root defines the root animatable to synchronize with
  105273. * @return the animationGroup
  105274. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105275. */
  105276. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105277. /**
  105278. * Goes to a specific frame in this animation group
  105279. * @param frame the frame number to go to
  105280. * @return the animationGroup
  105281. */
  105282. goToFrame(frame: number): AnimationGroup;
  105283. /**
  105284. * Dispose all associated resources
  105285. */
  105286. dispose(): void;
  105287. private _checkAnimationGroupEnded;
  105288. /**
  105289. * Clone the current animation group and returns a copy
  105290. * @param newName defines the name of the new group
  105291. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105292. * @returns the new aniamtion group
  105293. */
  105294. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105295. /**
  105296. * Serializes the animationGroup to an object
  105297. * @returns Serialized object
  105298. */
  105299. serialize(): any;
  105300. /**
  105301. * Returns a new AnimationGroup object parsed from the source provided.
  105302. * @param parsedAnimationGroup defines the source
  105303. * @param scene defines the scene that will receive the animationGroup
  105304. * @returns a new AnimationGroup
  105305. */
  105306. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105307. /**
  105308. * Returns the string "AnimationGroup"
  105309. * @returns "AnimationGroup"
  105310. */
  105311. getClassName(): string;
  105312. /**
  105313. * Creates a detailled string about the object
  105314. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105315. * @returns a string representing the object
  105316. */
  105317. toString(fullDetails?: boolean): string;
  105318. }
  105319. }
  105320. declare module BABYLON {
  105321. /**
  105322. * Define an interface for all classes that will hold resources
  105323. */
  105324. export interface IDisposable {
  105325. /**
  105326. * Releases all held resources
  105327. */
  105328. dispose(): void;
  105329. }
  105330. /** Interface defining initialization parameters for Scene class */
  105331. export interface SceneOptions {
  105332. /**
  105333. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105334. * It will improve performance when the number of geometries becomes important.
  105335. */
  105336. useGeometryUniqueIdsMap?: boolean;
  105337. /**
  105338. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105339. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105340. */
  105341. useMaterialMeshMap?: boolean;
  105342. /**
  105343. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105344. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105345. */
  105346. useClonedMeshhMap?: boolean;
  105347. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105348. virtual?: boolean;
  105349. }
  105350. /**
  105351. * Represents a scene to be rendered by the engine.
  105352. * @see http://doc.babylonjs.com/features/scene
  105353. */
  105354. export class Scene extends AbstractScene implements IAnimatable {
  105355. /** The fog is deactivated */
  105356. static readonly FOGMODE_NONE: number;
  105357. /** The fog density is following an exponential function */
  105358. static readonly FOGMODE_EXP: number;
  105359. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105360. static readonly FOGMODE_EXP2: number;
  105361. /** The fog density is following a linear function. */
  105362. static readonly FOGMODE_LINEAR: number;
  105363. /**
  105364. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105366. */
  105367. static MinDeltaTime: number;
  105368. /**
  105369. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105370. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105371. */
  105372. static MaxDeltaTime: number;
  105373. /**
  105374. * Factory used to create the default material.
  105375. * @param name The name of the material to create
  105376. * @param scene The scene to create the material for
  105377. * @returns The default material
  105378. */
  105379. static DefaultMaterialFactory(scene: Scene): Material;
  105380. /**
  105381. * Factory used to create the a collision coordinator.
  105382. * @returns The collision coordinator
  105383. */
  105384. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105385. /** @hidden */
  105386. _inputManager: InputManager;
  105387. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105388. cameraToUseForPointers: Nullable<Camera>;
  105389. /** @hidden */
  105390. readonly _isScene: boolean;
  105391. /**
  105392. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105393. */
  105394. autoClear: boolean;
  105395. /**
  105396. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105397. */
  105398. autoClearDepthAndStencil: boolean;
  105399. /**
  105400. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105401. */
  105402. clearColor: Color4;
  105403. /**
  105404. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105405. */
  105406. ambientColor: Color3;
  105407. /**
  105408. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105409. * It should only be one of the following (if not the default embedded one):
  105410. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105411. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105412. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105413. * The material properties need to be setup according to the type of texture in use.
  105414. */
  105415. environmentBRDFTexture: BaseTexture;
  105416. /** @hidden */
  105417. protected _environmentTexture: Nullable<BaseTexture>;
  105418. /**
  105419. * Texture used in all pbr material as the reflection texture.
  105420. * As in the majority of the scene they are the same (exception for multi room and so on),
  105421. * this is easier to reference from here than from all the materials.
  105422. */
  105423. get environmentTexture(): Nullable<BaseTexture>;
  105424. /**
  105425. * Texture used in all pbr material as the reflection texture.
  105426. * As in the majority of the scene they are the same (exception for multi room and so on),
  105427. * this is easier to set here than in all the materials.
  105428. */
  105429. set environmentTexture(value: Nullable<BaseTexture>);
  105430. /** @hidden */
  105431. protected _environmentIntensity: number;
  105432. /**
  105433. * Intensity of the environment in all pbr material.
  105434. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105435. * As in the majority of the scene they are the same (exception for multi room and so on),
  105436. * this is easier to reference from here than from all the materials.
  105437. */
  105438. get environmentIntensity(): number;
  105439. /**
  105440. * Intensity of the environment in all pbr material.
  105441. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105442. * As in the majority of the scene they are the same (exception for multi room and so on),
  105443. * this is easier to set here than in all the materials.
  105444. */
  105445. set environmentIntensity(value: number);
  105446. /** @hidden */
  105447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105448. /**
  105449. * Default image processing configuration used either in the rendering
  105450. * Forward main pass or through the imageProcessingPostProcess if present.
  105451. * As in the majority of the scene they are the same (exception for multi camera),
  105452. * this is easier to reference from here than from all the materials and post process.
  105453. *
  105454. * No setter as we it is a shared configuration, you can set the values instead.
  105455. */
  105456. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105457. private _forceWireframe;
  105458. /**
  105459. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105460. */
  105461. set forceWireframe(value: boolean);
  105462. get forceWireframe(): boolean;
  105463. private _forcePointsCloud;
  105464. /**
  105465. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105466. */
  105467. set forcePointsCloud(value: boolean);
  105468. get forcePointsCloud(): boolean;
  105469. /**
  105470. * Gets or sets the active clipplane 1
  105471. */
  105472. clipPlane: Nullable<Plane>;
  105473. /**
  105474. * Gets or sets the active clipplane 2
  105475. */
  105476. clipPlane2: Nullable<Plane>;
  105477. /**
  105478. * Gets or sets the active clipplane 3
  105479. */
  105480. clipPlane3: Nullable<Plane>;
  105481. /**
  105482. * Gets or sets the active clipplane 4
  105483. */
  105484. clipPlane4: Nullable<Plane>;
  105485. /**
  105486. * Gets or sets a boolean indicating if animations are enabled
  105487. */
  105488. animationsEnabled: boolean;
  105489. private _animationPropertiesOverride;
  105490. /**
  105491. * Gets or sets the animation properties override
  105492. */
  105493. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105494. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105495. /**
  105496. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105497. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105498. */
  105499. useConstantAnimationDeltaTime: boolean;
  105500. /**
  105501. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105502. * Please note that it requires to run a ray cast through the scene on every frame
  105503. */
  105504. constantlyUpdateMeshUnderPointer: boolean;
  105505. /**
  105506. * Defines the HTML cursor to use when hovering over interactive elements
  105507. */
  105508. hoverCursor: string;
  105509. /**
  105510. * Defines the HTML default cursor to use (empty by default)
  105511. */
  105512. defaultCursor: string;
  105513. /**
  105514. * Defines wether cursors are handled by the scene.
  105515. */
  105516. doNotHandleCursors: boolean;
  105517. /**
  105518. * This is used to call preventDefault() on pointer down
  105519. * in order to block unwanted artifacts like system double clicks
  105520. */
  105521. preventDefaultOnPointerDown: boolean;
  105522. /**
  105523. * This is used to call preventDefault() on pointer up
  105524. * in order to block unwanted artifacts like system double clicks
  105525. */
  105526. preventDefaultOnPointerUp: boolean;
  105527. /**
  105528. * Gets or sets user defined metadata
  105529. */
  105530. metadata: any;
  105531. /**
  105532. * For internal use only. Please do not use.
  105533. */
  105534. reservedDataStore: any;
  105535. /**
  105536. * Gets the name of the plugin used to load this scene (null by default)
  105537. */
  105538. loadingPluginName: string;
  105539. /**
  105540. * Use this array to add regular expressions used to disable offline support for specific urls
  105541. */
  105542. disableOfflineSupportExceptionRules: RegExp[];
  105543. /**
  105544. * An event triggered when the scene is disposed.
  105545. */
  105546. onDisposeObservable: Observable<Scene>;
  105547. private _onDisposeObserver;
  105548. /** Sets a function to be executed when this scene is disposed. */
  105549. set onDispose(callback: () => void);
  105550. /**
  105551. * An event triggered before rendering the scene (right after animations and physics)
  105552. */
  105553. onBeforeRenderObservable: Observable<Scene>;
  105554. private _onBeforeRenderObserver;
  105555. /** Sets a function to be executed before rendering this scene */
  105556. set beforeRender(callback: Nullable<() => void>);
  105557. /**
  105558. * An event triggered after rendering the scene
  105559. */
  105560. onAfterRenderObservable: Observable<Scene>;
  105561. /**
  105562. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105563. */
  105564. onAfterRenderCameraObservable: Observable<Camera>;
  105565. private _onAfterRenderObserver;
  105566. /** Sets a function to be executed after rendering this scene */
  105567. set afterRender(callback: Nullable<() => void>);
  105568. /**
  105569. * An event triggered before animating the scene
  105570. */
  105571. onBeforeAnimationsObservable: Observable<Scene>;
  105572. /**
  105573. * An event triggered after animations processing
  105574. */
  105575. onAfterAnimationsObservable: Observable<Scene>;
  105576. /**
  105577. * An event triggered before draw calls are ready to be sent
  105578. */
  105579. onBeforeDrawPhaseObservable: Observable<Scene>;
  105580. /**
  105581. * An event triggered after draw calls have been sent
  105582. */
  105583. onAfterDrawPhaseObservable: Observable<Scene>;
  105584. /**
  105585. * An event triggered when the scene is ready
  105586. */
  105587. onReadyObservable: Observable<Scene>;
  105588. /**
  105589. * An event triggered before rendering a camera
  105590. */
  105591. onBeforeCameraRenderObservable: Observable<Camera>;
  105592. private _onBeforeCameraRenderObserver;
  105593. /** Sets a function to be executed before rendering a camera*/
  105594. set beforeCameraRender(callback: () => void);
  105595. /**
  105596. * An event triggered after rendering a camera
  105597. */
  105598. onAfterCameraRenderObservable: Observable<Camera>;
  105599. private _onAfterCameraRenderObserver;
  105600. /** Sets a function to be executed after rendering a camera*/
  105601. set afterCameraRender(callback: () => void);
  105602. /**
  105603. * An event triggered when active meshes evaluation is about to start
  105604. */
  105605. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105606. /**
  105607. * An event triggered when active meshes evaluation is done
  105608. */
  105609. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105610. /**
  105611. * An event triggered when particles rendering is about to start
  105612. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105613. */
  105614. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105615. /**
  105616. * An event triggered when particles rendering is done
  105617. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105618. */
  105619. onAfterParticlesRenderingObservable: Observable<Scene>;
  105620. /**
  105621. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105622. */
  105623. onDataLoadedObservable: Observable<Scene>;
  105624. /**
  105625. * An event triggered when a camera is created
  105626. */
  105627. onNewCameraAddedObservable: Observable<Camera>;
  105628. /**
  105629. * An event triggered when a camera is removed
  105630. */
  105631. onCameraRemovedObservable: Observable<Camera>;
  105632. /**
  105633. * An event triggered when a light is created
  105634. */
  105635. onNewLightAddedObservable: Observable<Light>;
  105636. /**
  105637. * An event triggered when a light is removed
  105638. */
  105639. onLightRemovedObservable: Observable<Light>;
  105640. /**
  105641. * An event triggered when a geometry is created
  105642. */
  105643. onNewGeometryAddedObservable: Observable<Geometry>;
  105644. /**
  105645. * An event triggered when a geometry is removed
  105646. */
  105647. onGeometryRemovedObservable: Observable<Geometry>;
  105648. /**
  105649. * An event triggered when a transform node is created
  105650. */
  105651. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105652. /**
  105653. * An event triggered when a transform node is removed
  105654. */
  105655. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105656. /**
  105657. * An event triggered when a mesh is created
  105658. */
  105659. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105660. /**
  105661. * An event triggered when a mesh is removed
  105662. */
  105663. onMeshRemovedObservable: Observable<AbstractMesh>;
  105664. /**
  105665. * An event triggered when a skeleton is created
  105666. */
  105667. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105668. /**
  105669. * An event triggered when a skeleton is removed
  105670. */
  105671. onSkeletonRemovedObservable: Observable<Skeleton>;
  105672. /**
  105673. * An event triggered when a material is created
  105674. */
  105675. onNewMaterialAddedObservable: Observable<Material>;
  105676. /**
  105677. * An event triggered when a material is removed
  105678. */
  105679. onMaterialRemovedObservable: Observable<Material>;
  105680. /**
  105681. * An event triggered when a texture is created
  105682. */
  105683. onNewTextureAddedObservable: Observable<BaseTexture>;
  105684. /**
  105685. * An event triggered when a texture is removed
  105686. */
  105687. onTextureRemovedObservable: Observable<BaseTexture>;
  105688. /**
  105689. * An event triggered when render targets are about to be rendered
  105690. * Can happen multiple times per frame.
  105691. */
  105692. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105693. /**
  105694. * An event triggered when render targets were rendered.
  105695. * Can happen multiple times per frame.
  105696. */
  105697. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105698. /**
  105699. * An event triggered before calculating deterministic simulation step
  105700. */
  105701. onBeforeStepObservable: Observable<Scene>;
  105702. /**
  105703. * An event triggered after calculating deterministic simulation step
  105704. */
  105705. onAfterStepObservable: Observable<Scene>;
  105706. /**
  105707. * An event triggered when the activeCamera property is updated
  105708. */
  105709. onActiveCameraChanged: Observable<Scene>;
  105710. /**
  105711. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105712. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105713. * 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)
  105714. */
  105715. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105716. /**
  105717. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105718. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105719. * 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)
  105720. */
  105721. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105722. /**
  105723. * This Observable will when a mesh has been imported into the scene.
  105724. */
  105725. onMeshImportedObservable: Observable<AbstractMesh>;
  105726. /**
  105727. * This Observable will when an animation file has been imported into the scene.
  105728. */
  105729. onAnimationFileImportedObservable: Observable<Scene>;
  105730. /**
  105731. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105732. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105733. */
  105734. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105735. /** @hidden */
  105736. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105737. /**
  105738. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105739. */
  105740. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105741. /**
  105742. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105743. */
  105744. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105745. /**
  105746. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105747. */
  105748. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105749. /** Callback called when a pointer move is detected */
  105750. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105751. /** Callback called when a pointer down is detected */
  105752. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105753. /** Callback called when a pointer up is detected */
  105754. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105755. /** Callback called when a pointer pick is detected */
  105756. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105757. /**
  105758. * 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).
  105759. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105760. */
  105761. onPrePointerObservable: Observable<PointerInfoPre>;
  105762. /**
  105763. * Observable event triggered each time an input event is received from the rendering canvas
  105764. */
  105765. onPointerObservable: Observable<PointerInfo>;
  105766. /**
  105767. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105768. */
  105769. get unTranslatedPointer(): Vector2;
  105770. /**
  105771. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105772. */
  105773. static get DragMovementThreshold(): number;
  105774. static set DragMovementThreshold(value: number);
  105775. /**
  105776. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105777. */
  105778. static get LongPressDelay(): number;
  105779. static set LongPressDelay(value: number);
  105780. /**
  105781. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105782. */
  105783. static get DoubleClickDelay(): number;
  105784. static set DoubleClickDelay(value: number);
  105785. /** If you need to check double click without raising a single click at first click, enable this flag */
  105786. static get ExclusiveDoubleClickMode(): boolean;
  105787. static set ExclusiveDoubleClickMode(value: boolean);
  105788. /** @hidden */
  105789. _mirroredCameraPosition: Nullable<Vector3>;
  105790. /**
  105791. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105792. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105793. */
  105794. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105795. /**
  105796. * Observable event triggered each time an keyboard event is received from the hosting window
  105797. */
  105798. onKeyboardObservable: Observable<KeyboardInfo>;
  105799. private _useRightHandedSystem;
  105800. /**
  105801. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105802. */
  105803. set useRightHandedSystem(value: boolean);
  105804. get useRightHandedSystem(): boolean;
  105805. private _timeAccumulator;
  105806. private _currentStepId;
  105807. private _currentInternalStep;
  105808. /**
  105809. * Sets the step Id used by deterministic lock step
  105810. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105811. * @param newStepId defines the step Id
  105812. */
  105813. setStepId(newStepId: number): void;
  105814. /**
  105815. * Gets the step Id used by deterministic lock step
  105816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105817. * @returns the step Id
  105818. */
  105819. getStepId(): number;
  105820. /**
  105821. * Gets the internal step used by deterministic lock step
  105822. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105823. * @returns the internal step
  105824. */
  105825. getInternalStep(): number;
  105826. private _fogEnabled;
  105827. /**
  105828. * Gets or sets a boolean indicating if fog is enabled on this scene
  105829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105830. * (Default is true)
  105831. */
  105832. set fogEnabled(value: boolean);
  105833. get fogEnabled(): boolean;
  105834. private _fogMode;
  105835. /**
  105836. * Gets or sets the fog mode to use
  105837. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105838. * | mode | value |
  105839. * | --- | --- |
  105840. * | FOGMODE_NONE | 0 |
  105841. * | FOGMODE_EXP | 1 |
  105842. * | FOGMODE_EXP2 | 2 |
  105843. * | FOGMODE_LINEAR | 3 |
  105844. */
  105845. set fogMode(value: number);
  105846. get fogMode(): number;
  105847. /**
  105848. * Gets or sets the fog color to use
  105849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105850. * (Default is Color3(0.2, 0.2, 0.3))
  105851. */
  105852. fogColor: Color3;
  105853. /**
  105854. * Gets or sets the fog density to use
  105855. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105856. * (Default is 0.1)
  105857. */
  105858. fogDensity: number;
  105859. /**
  105860. * Gets or sets the fog start distance to use
  105861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105862. * (Default is 0)
  105863. */
  105864. fogStart: number;
  105865. /**
  105866. * Gets or sets the fog end distance to use
  105867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105868. * (Default is 1000)
  105869. */
  105870. fogEnd: number;
  105871. private _shadowsEnabled;
  105872. /**
  105873. * Gets or sets a boolean indicating if shadows are enabled on this scene
  105874. */
  105875. set shadowsEnabled(value: boolean);
  105876. get shadowsEnabled(): boolean;
  105877. private _lightsEnabled;
  105878. /**
  105879. * Gets or sets a boolean indicating if lights are enabled on this scene
  105880. */
  105881. set lightsEnabled(value: boolean);
  105882. get lightsEnabled(): boolean;
  105883. /** All of the active cameras added to this scene. */
  105884. activeCameras: Camera[];
  105885. /** @hidden */
  105886. _activeCamera: Nullable<Camera>;
  105887. /** Gets or sets the current active camera */
  105888. get activeCamera(): Nullable<Camera>;
  105889. set activeCamera(value: Nullable<Camera>);
  105890. private _defaultMaterial;
  105891. /** The default material used on meshes when no material is affected */
  105892. get defaultMaterial(): Material;
  105893. /** The default material used on meshes when no material is affected */
  105894. set defaultMaterial(value: Material);
  105895. private _texturesEnabled;
  105896. /**
  105897. * Gets or sets a boolean indicating if textures are enabled on this scene
  105898. */
  105899. set texturesEnabled(value: boolean);
  105900. get texturesEnabled(): boolean;
  105901. /**
  105902. * Gets or sets a boolean indicating if particles are enabled on this scene
  105903. */
  105904. particlesEnabled: boolean;
  105905. /**
  105906. * Gets or sets a boolean indicating if sprites are enabled on this scene
  105907. */
  105908. spritesEnabled: boolean;
  105909. private _skeletonsEnabled;
  105910. /**
  105911. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  105912. */
  105913. set skeletonsEnabled(value: boolean);
  105914. get skeletonsEnabled(): boolean;
  105915. /**
  105916. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  105917. */
  105918. lensFlaresEnabled: boolean;
  105919. /**
  105920. * Gets or sets a boolean indicating if collisions are enabled on this scene
  105921. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105922. */
  105923. collisionsEnabled: boolean;
  105924. private _collisionCoordinator;
  105925. /** @hidden */
  105926. get collisionCoordinator(): ICollisionCoordinator;
  105927. /**
  105928. * Defines the gravity applied to this scene (used only for collisions)
  105929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105930. */
  105931. gravity: Vector3;
  105932. /**
  105933. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  105934. */
  105935. postProcessesEnabled: boolean;
  105936. /**
  105937. * The list of postprocesses added to the scene
  105938. */
  105939. postProcesses: PostProcess[];
  105940. /**
  105941. * Gets the current postprocess manager
  105942. */
  105943. postProcessManager: PostProcessManager;
  105944. /**
  105945. * Gets or sets a boolean indicating if render targets are enabled on this scene
  105946. */
  105947. renderTargetsEnabled: boolean;
  105948. /**
  105949. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  105950. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  105951. */
  105952. dumpNextRenderTargets: boolean;
  105953. /**
  105954. * The list of user defined render targets added to the scene
  105955. */
  105956. customRenderTargets: RenderTargetTexture[];
  105957. /**
  105958. * Defines if texture loading must be delayed
  105959. * If true, textures will only be loaded when they need to be rendered
  105960. */
  105961. useDelayedTextureLoading: boolean;
  105962. /**
  105963. * Gets the list of meshes imported to the scene through SceneLoader
  105964. */
  105965. importedMeshesFiles: String[];
  105966. /**
  105967. * Gets or sets a boolean indicating if probes are enabled on this scene
  105968. */
  105969. probesEnabled: boolean;
  105970. /**
  105971. * Gets or sets the current offline provider to use to store scene data
  105972. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105973. */
  105974. offlineProvider: IOfflineProvider;
  105975. /**
  105976. * Gets or sets the action manager associated with the scene
  105977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105978. */
  105979. actionManager: AbstractActionManager;
  105980. private _meshesForIntersections;
  105981. /**
  105982. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  105983. */
  105984. proceduralTexturesEnabled: boolean;
  105985. private _engine;
  105986. private _totalVertices;
  105987. /** @hidden */
  105988. _activeIndices: PerfCounter;
  105989. /** @hidden */
  105990. _activeParticles: PerfCounter;
  105991. /** @hidden */
  105992. _activeBones: PerfCounter;
  105993. private _animationRatio;
  105994. /** @hidden */
  105995. _animationTimeLast: number;
  105996. /** @hidden */
  105997. _animationTime: number;
  105998. /**
  105999. * Gets or sets a general scale for animation speed
  106000. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106001. */
  106002. animationTimeScale: number;
  106003. /** @hidden */
  106004. _cachedMaterial: Nullable<Material>;
  106005. /** @hidden */
  106006. _cachedEffect: Nullable<Effect>;
  106007. /** @hidden */
  106008. _cachedVisibility: Nullable<number>;
  106009. private _renderId;
  106010. private _frameId;
  106011. private _executeWhenReadyTimeoutId;
  106012. private _intermediateRendering;
  106013. private _viewUpdateFlag;
  106014. private _projectionUpdateFlag;
  106015. /** @hidden */
  106016. _toBeDisposed: Nullable<IDisposable>[];
  106017. private _activeRequests;
  106018. /** @hidden */
  106019. _pendingData: any[];
  106020. private _isDisposed;
  106021. /**
  106022. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106023. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106024. */
  106025. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106026. private _activeMeshes;
  106027. private _processedMaterials;
  106028. private _renderTargets;
  106029. /** @hidden */
  106030. _activeParticleSystems: SmartArray<IParticleSystem>;
  106031. private _activeSkeletons;
  106032. private _softwareSkinnedMeshes;
  106033. private _renderingManager;
  106034. /** @hidden */
  106035. _activeAnimatables: Animatable[];
  106036. private _transformMatrix;
  106037. private _sceneUbo;
  106038. /** @hidden */
  106039. _viewMatrix: Matrix;
  106040. private _projectionMatrix;
  106041. /** @hidden */
  106042. _forcedViewPosition: Nullable<Vector3>;
  106043. /** @hidden */
  106044. _frustumPlanes: Plane[];
  106045. /**
  106046. * Gets the list of frustum planes (built from the active camera)
  106047. */
  106048. get frustumPlanes(): Plane[];
  106049. /**
  106050. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106051. * This is useful if there are more lights that the maximum simulteanous authorized
  106052. */
  106053. requireLightSorting: boolean;
  106054. /** @hidden */
  106055. readonly useMaterialMeshMap: boolean;
  106056. /** @hidden */
  106057. readonly useClonedMeshhMap: boolean;
  106058. private _externalData;
  106059. private _uid;
  106060. /**
  106061. * @hidden
  106062. * Backing store of defined scene components.
  106063. */
  106064. _components: ISceneComponent[];
  106065. /**
  106066. * @hidden
  106067. * Backing store of defined scene components.
  106068. */
  106069. _serializableComponents: ISceneSerializableComponent[];
  106070. /**
  106071. * List of components to register on the next registration step.
  106072. */
  106073. private _transientComponents;
  106074. /**
  106075. * Registers the transient components if needed.
  106076. */
  106077. private _registerTransientComponents;
  106078. /**
  106079. * @hidden
  106080. * Add a component to the scene.
  106081. * Note that the ccomponent could be registered on th next frame if this is called after
  106082. * the register component stage.
  106083. * @param component Defines the component to add to the scene
  106084. */
  106085. _addComponent(component: ISceneComponent): void;
  106086. /**
  106087. * @hidden
  106088. * Gets a component from the scene.
  106089. * @param name defines the name of the component to retrieve
  106090. * @returns the component or null if not present
  106091. */
  106092. _getComponent(name: string): Nullable<ISceneComponent>;
  106093. /**
  106094. * @hidden
  106095. * Defines the actions happening before camera updates.
  106096. */
  106097. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106098. /**
  106099. * @hidden
  106100. * Defines the actions happening before clear the canvas.
  106101. */
  106102. _beforeClearStage: Stage<SimpleStageAction>;
  106103. /**
  106104. * @hidden
  106105. * Defines the actions when collecting render targets for the frame.
  106106. */
  106107. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106108. /**
  106109. * @hidden
  106110. * Defines the actions happening for one camera in the frame.
  106111. */
  106112. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106113. /**
  106114. * @hidden
  106115. * Defines the actions happening during the per mesh ready checks.
  106116. */
  106117. _isReadyForMeshStage: Stage<MeshStageAction>;
  106118. /**
  106119. * @hidden
  106120. * Defines the actions happening before evaluate active mesh checks.
  106121. */
  106122. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106123. /**
  106124. * @hidden
  106125. * Defines the actions happening during the evaluate sub mesh checks.
  106126. */
  106127. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106128. /**
  106129. * @hidden
  106130. * Defines the actions happening during the active mesh stage.
  106131. */
  106132. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106133. /**
  106134. * @hidden
  106135. * Defines the actions happening during the per camera render target step.
  106136. */
  106137. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106138. /**
  106139. * @hidden
  106140. * Defines the actions happening just before the active camera is drawing.
  106141. */
  106142. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106143. /**
  106144. * @hidden
  106145. * Defines the actions happening just before a render target is drawing.
  106146. */
  106147. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106148. /**
  106149. * @hidden
  106150. * Defines the actions happening just before a rendering group is drawing.
  106151. */
  106152. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106153. /**
  106154. * @hidden
  106155. * Defines the actions happening just before a mesh is drawing.
  106156. */
  106157. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106158. /**
  106159. * @hidden
  106160. * Defines the actions happening just after a mesh has been drawn.
  106161. */
  106162. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106163. /**
  106164. * @hidden
  106165. * Defines the actions happening just after a rendering group has been drawn.
  106166. */
  106167. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106168. /**
  106169. * @hidden
  106170. * Defines the actions happening just after the active camera has been drawn.
  106171. */
  106172. _afterCameraDrawStage: Stage<CameraStageAction>;
  106173. /**
  106174. * @hidden
  106175. * Defines the actions happening just after a render target has been drawn.
  106176. */
  106177. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106178. /**
  106179. * @hidden
  106180. * Defines the actions happening just after rendering all cameras and computing intersections.
  106181. */
  106182. _afterRenderStage: Stage<SimpleStageAction>;
  106183. /**
  106184. * @hidden
  106185. * Defines the actions happening when a pointer move event happens.
  106186. */
  106187. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106188. /**
  106189. * @hidden
  106190. * Defines the actions happening when a pointer down event happens.
  106191. */
  106192. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106193. /**
  106194. * @hidden
  106195. * Defines the actions happening when a pointer up event happens.
  106196. */
  106197. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106198. /**
  106199. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106200. */
  106201. private geometriesByUniqueId;
  106202. /**
  106203. * Creates a new Scene
  106204. * @param engine defines the engine to use to render this scene
  106205. * @param options defines the scene options
  106206. */
  106207. constructor(engine: Engine, options?: SceneOptions);
  106208. /**
  106209. * Gets a string idenfifying the name of the class
  106210. * @returns "Scene" string
  106211. */
  106212. getClassName(): string;
  106213. private _defaultMeshCandidates;
  106214. /**
  106215. * @hidden
  106216. */
  106217. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106218. private _defaultSubMeshCandidates;
  106219. /**
  106220. * @hidden
  106221. */
  106222. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106223. /**
  106224. * Sets the default candidate providers for the scene.
  106225. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106226. * and getCollidingSubMeshCandidates to their default function
  106227. */
  106228. setDefaultCandidateProviders(): void;
  106229. /**
  106230. * Gets the mesh that is currently under the pointer
  106231. */
  106232. get meshUnderPointer(): Nullable<AbstractMesh>;
  106233. /**
  106234. * Gets or sets the current on-screen X position of the pointer
  106235. */
  106236. get pointerX(): number;
  106237. set pointerX(value: number);
  106238. /**
  106239. * Gets or sets the current on-screen Y position of the pointer
  106240. */
  106241. get pointerY(): number;
  106242. set pointerY(value: number);
  106243. /**
  106244. * Gets the cached material (ie. the latest rendered one)
  106245. * @returns the cached material
  106246. */
  106247. getCachedMaterial(): Nullable<Material>;
  106248. /**
  106249. * Gets the cached effect (ie. the latest rendered one)
  106250. * @returns the cached effect
  106251. */
  106252. getCachedEffect(): Nullable<Effect>;
  106253. /**
  106254. * Gets the cached visibility state (ie. the latest rendered one)
  106255. * @returns the cached visibility state
  106256. */
  106257. getCachedVisibility(): Nullable<number>;
  106258. /**
  106259. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106260. * @param material defines the current material
  106261. * @param effect defines the current effect
  106262. * @param visibility defines the current visibility state
  106263. * @returns true if one parameter is not cached
  106264. */
  106265. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106266. /**
  106267. * Gets the engine associated with the scene
  106268. * @returns an Engine
  106269. */
  106270. getEngine(): Engine;
  106271. /**
  106272. * Gets the total number of vertices rendered per frame
  106273. * @returns the total number of vertices rendered per frame
  106274. */
  106275. getTotalVertices(): number;
  106276. /**
  106277. * Gets the performance counter for total vertices
  106278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106279. */
  106280. get totalVerticesPerfCounter(): PerfCounter;
  106281. /**
  106282. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106283. * @returns the total number of active indices rendered per frame
  106284. */
  106285. getActiveIndices(): number;
  106286. /**
  106287. * Gets the performance counter for active indices
  106288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106289. */
  106290. get totalActiveIndicesPerfCounter(): PerfCounter;
  106291. /**
  106292. * Gets the total number of active particles rendered per frame
  106293. * @returns the total number of active particles rendered per frame
  106294. */
  106295. getActiveParticles(): number;
  106296. /**
  106297. * Gets the performance counter for active particles
  106298. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106299. */
  106300. get activeParticlesPerfCounter(): PerfCounter;
  106301. /**
  106302. * Gets the total number of active bones rendered per frame
  106303. * @returns the total number of active bones rendered per frame
  106304. */
  106305. getActiveBones(): number;
  106306. /**
  106307. * Gets the performance counter for active bones
  106308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106309. */
  106310. get activeBonesPerfCounter(): PerfCounter;
  106311. /**
  106312. * Gets the array of active meshes
  106313. * @returns an array of AbstractMesh
  106314. */
  106315. getActiveMeshes(): SmartArray<AbstractMesh>;
  106316. /**
  106317. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106318. * @returns a number
  106319. */
  106320. getAnimationRatio(): number;
  106321. /**
  106322. * Gets an unique Id for the current render phase
  106323. * @returns a number
  106324. */
  106325. getRenderId(): number;
  106326. /**
  106327. * Gets an unique Id for the current frame
  106328. * @returns a number
  106329. */
  106330. getFrameId(): number;
  106331. /** Call this function if you want to manually increment the render Id*/
  106332. incrementRenderId(): void;
  106333. private _createUbo;
  106334. /**
  106335. * Use this method to simulate a pointer move on a mesh
  106336. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106337. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106338. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106339. * @returns the current scene
  106340. */
  106341. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106342. /**
  106343. * Use this method to simulate a pointer down on a mesh
  106344. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106345. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106346. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106347. * @returns the current scene
  106348. */
  106349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106350. /**
  106351. * Use this method to simulate a pointer up on a mesh
  106352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106356. * @returns the current scene
  106357. */
  106358. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106359. /**
  106360. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106361. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106362. * @returns true if the pointer was captured
  106363. */
  106364. isPointerCaptured(pointerId?: number): boolean;
  106365. /**
  106366. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106367. * @param attachUp defines if you want to attach events to pointerup
  106368. * @param attachDown defines if you want to attach events to pointerdown
  106369. * @param attachMove defines if you want to attach events to pointermove
  106370. */
  106371. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106372. /** Detaches all event handlers*/
  106373. detachControl(): void;
  106374. /**
  106375. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106376. * Delay loaded resources are not taking in account
  106377. * @return true if all required resources are ready
  106378. */
  106379. isReady(): boolean;
  106380. /** Resets all cached information relative to material (including effect and visibility) */
  106381. resetCachedMaterial(): void;
  106382. /**
  106383. * Registers a function to be called before every frame render
  106384. * @param func defines the function to register
  106385. */
  106386. registerBeforeRender(func: () => void): void;
  106387. /**
  106388. * Unregisters a function called before every frame render
  106389. * @param func defines the function to unregister
  106390. */
  106391. unregisterBeforeRender(func: () => void): void;
  106392. /**
  106393. * Registers a function to be called after every frame render
  106394. * @param func defines the function to register
  106395. */
  106396. registerAfterRender(func: () => void): void;
  106397. /**
  106398. * Unregisters a function called after every frame render
  106399. * @param func defines the function to unregister
  106400. */
  106401. unregisterAfterRender(func: () => void): void;
  106402. private _executeOnceBeforeRender;
  106403. /**
  106404. * The provided function will run before render once and will be disposed afterwards.
  106405. * A timeout delay can be provided so that the function will be executed in N ms.
  106406. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106407. * @param func The function to be executed.
  106408. * @param timeout optional delay in ms
  106409. */
  106410. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106411. /** @hidden */
  106412. _addPendingData(data: any): void;
  106413. /** @hidden */
  106414. _removePendingData(data: any): void;
  106415. /**
  106416. * Returns the number of items waiting to be loaded
  106417. * @returns the number of items waiting to be loaded
  106418. */
  106419. getWaitingItemsCount(): number;
  106420. /**
  106421. * Returns a boolean indicating if the scene is still loading data
  106422. */
  106423. get isLoading(): boolean;
  106424. /**
  106425. * Registers a function to be executed when the scene is ready
  106426. * @param {Function} func - the function to be executed
  106427. */
  106428. executeWhenReady(func: () => void): void;
  106429. /**
  106430. * Returns a promise that resolves when the scene is ready
  106431. * @returns A promise that resolves when the scene is ready
  106432. */
  106433. whenReadyAsync(): Promise<void>;
  106434. /** @hidden */
  106435. _checkIsReady(): void;
  106436. /**
  106437. * Gets all animatable attached to the scene
  106438. */
  106439. get animatables(): Animatable[];
  106440. /**
  106441. * Resets the last animation time frame.
  106442. * Useful to override when animations start running when loading a scene for the first time.
  106443. */
  106444. resetLastAnimationTimeFrame(): void;
  106445. /**
  106446. * Gets the current view matrix
  106447. * @returns a Matrix
  106448. */
  106449. getViewMatrix(): Matrix;
  106450. /**
  106451. * Gets the current projection matrix
  106452. * @returns a Matrix
  106453. */
  106454. getProjectionMatrix(): Matrix;
  106455. /**
  106456. * Gets the current transform matrix
  106457. * @returns a Matrix made of View * Projection
  106458. */
  106459. getTransformMatrix(): Matrix;
  106460. /**
  106461. * Sets the current transform matrix
  106462. * @param viewL defines the View matrix to use
  106463. * @param projectionL defines the Projection matrix to use
  106464. * @param viewR defines the right View matrix to use (if provided)
  106465. * @param projectionR defines the right Projection matrix to use (if provided)
  106466. */
  106467. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106468. /**
  106469. * Gets the uniform buffer used to store scene data
  106470. * @returns a UniformBuffer
  106471. */
  106472. getSceneUniformBuffer(): UniformBuffer;
  106473. /**
  106474. * Gets an unique (relatively to the current scene) Id
  106475. * @returns an unique number for the scene
  106476. */
  106477. getUniqueId(): number;
  106478. /**
  106479. * Add a mesh to the list of scene's meshes
  106480. * @param newMesh defines the mesh to add
  106481. * @param recursive if all child meshes should also be added to the scene
  106482. */
  106483. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106484. /**
  106485. * Remove a mesh for the list of scene's meshes
  106486. * @param toRemove defines the mesh to remove
  106487. * @param recursive if all child meshes should also be removed from the scene
  106488. * @returns the index where the mesh was in the mesh list
  106489. */
  106490. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106491. /**
  106492. * Add a transform node to the list of scene's transform nodes
  106493. * @param newTransformNode defines the transform node to add
  106494. */
  106495. addTransformNode(newTransformNode: TransformNode): void;
  106496. /**
  106497. * Remove a transform node for the list of scene's transform nodes
  106498. * @param toRemove defines the transform node to remove
  106499. * @returns the index where the transform node was in the transform node list
  106500. */
  106501. removeTransformNode(toRemove: TransformNode): number;
  106502. /**
  106503. * Remove a skeleton for the list of scene's skeletons
  106504. * @param toRemove defines the skeleton to remove
  106505. * @returns the index where the skeleton was in the skeleton list
  106506. */
  106507. removeSkeleton(toRemove: Skeleton): number;
  106508. /**
  106509. * Remove a morph target for the list of scene's morph targets
  106510. * @param toRemove defines the morph target to remove
  106511. * @returns the index where the morph target was in the morph target list
  106512. */
  106513. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106514. /**
  106515. * Remove a light for the list of scene's lights
  106516. * @param toRemove defines the light to remove
  106517. * @returns the index where the light was in the light list
  106518. */
  106519. removeLight(toRemove: Light): number;
  106520. /**
  106521. * Remove a camera for the list of scene's cameras
  106522. * @param toRemove defines the camera to remove
  106523. * @returns the index where the camera was in the camera list
  106524. */
  106525. removeCamera(toRemove: Camera): number;
  106526. /**
  106527. * Remove a particle system for the list of scene's particle systems
  106528. * @param toRemove defines the particle system to remove
  106529. * @returns the index where the particle system was in the particle system list
  106530. */
  106531. removeParticleSystem(toRemove: IParticleSystem): number;
  106532. /**
  106533. * Remove a animation for the list of scene's animations
  106534. * @param toRemove defines the animation to remove
  106535. * @returns the index where the animation was in the animation list
  106536. */
  106537. removeAnimation(toRemove: Animation): number;
  106538. /**
  106539. * Will stop the animation of the given target
  106540. * @param target - the target
  106541. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106542. * @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)
  106543. */
  106544. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106545. /**
  106546. * Removes the given animation group from this scene.
  106547. * @param toRemove The animation group to remove
  106548. * @returns The index of the removed animation group
  106549. */
  106550. removeAnimationGroup(toRemove: AnimationGroup): number;
  106551. /**
  106552. * Removes the given multi-material from this scene.
  106553. * @param toRemove The multi-material to remove
  106554. * @returns The index of the removed multi-material
  106555. */
  106556. removeMultiMaterial(toRemove: MultiMaterial): number;
  106557. /**
  106558. * Removes the given material from this scene.
  106559. * @param toRemove The material to remove
  106560. * @returns The index of the removed material
  106561. */
  106562. removeMaterial(toRemove: Material): number;
  106563. /**
  106564. * Removes the given action manager from this scene.
  106565. * @param toRemove The action manager to remove
  106566. * @returns The index of the removed action manager
  106567. */
  106568. removeActionManager(toRemove: AbstractActionManager): number;
  106569. /**
  106570. * Removes the given texture from this scene.
  106571. * @param toRemove The texture to remove
  106572. * @returns The index of the removed texture
  106573. */
  106574. removeTexture(toRemove: BaseTexture): number;
  106575. /**
  106576. * Adds the given light to this scene
  106577. * @param newLight The light to add
  106578. */
  106579. addLight(newLight: Light): void;
  106580. /**
  106581. * Sorts the list list based on light priorities
  106582. */
  106583. sortLightsByPriority(): void;
  106584. /**
  106585. * Adds the given camera to this scene
  106586. * @param newCamera The camera to add
  106587. */
  106588. addCamera(newCamera: Camera): void;
  106589. /**
  106590. * Adds the given skeleton to this scene
  106591. * @param newSkeleton The skeleton to add
  106592. */
  106593. addSkeleton(newSkeleton: Skeleton): void;
  106594. /**
  106595. * Adds the given particle system to this scene
  106596. * @param newParticleSystem The particle system to add
  106597. */
  106598. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106599. /**
  106600. * Adds the given animation to this scene
  106601. * @param newAnimation The animation to add
  106602. */
  106603. addAnimation(newAnimation: Animation): void;
  106604. /**
  106605. * Adds the given animation group to this scene.
  106606. * @param newAnimationGroup The animation group to add
  106607. */
  106608. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106609. /**
  106610. * Adds the given multi-material to this scene
  106611. * @param newMultiMaterial The multi-material to add
  106612. */
  106613. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106614. /**
  106615. * Adds the given material to this scene
  106616. * @param newMaterial The material to add
  106617. */
  106618. addMaterial(newMaterial: Material): void;
  106619. /**
  106620. * Adds the given morph target to this scene
  106621. * @param newMorphTargetManager The morph target to add
  106622. */
  106623. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106624. /**
  106625. * Adds the given geometry to this scene
  106626. * @param newGeometry The geometry to add
  106627. */
  106628. addGeometry(newGeometry: Geometry): void;
  106629. /**
  106630. * Adds the given action manager to this scene
  106631. * @param newActionManager The action manager to add
  106632. */
  106633. addActionManager(newActionManager: AbstractActionManager): void;
  106634. /**
  106635. * Adds the given texture to this scene.
  106636. * @param newTexture The texture to add
  106637. */
  106638. addTexture(newTexture: BaseTexture): void;
  106639. /**
  106640. * Switch active camera
  106641. * @param newCamera defines the new active camera
  106642. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106643. */
  106644. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106645. /**
  106646. * sets the active camera of the scene using its ID
  106647. * @param id defines the camera's ID
  106648. * @return the new active camera or null if none found.
  106649. */
  106650. setActiveCameraByID(id: string): Nullable<Camera>;
  106651. /**
  106652. * sets the active camera of the scene using its name
  106653. * @param name defines the camera's name
  106654. * @returns the new active camera or null if none found.
  106655. */
  106656. setActiveCameraByName(name: string): Nullable<Camera>;
  106657. /**
  106658. * get an animation group using its name
  106659. * @param name defines the material's name
  106660. * @return the animation group or null if none found.
  106661. */
  106662. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106663. /**
  106664. * Get a material using its unique id
  106665. * @param uniqueId defines the material's unique id
  106666. * @return the material or null if none found.
  106667. */
  106668. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106669. /**
  106670. * get a material using its id
  106671. * @param id defines the material's ID
  106672. * @return the material or null if none found.
  106673. */
  106674. getMaterialByID(id: string): Nullable<Material>;
  106675. /**
  106676. * Gets a the last added material using a given id
  106677. * @param id defines the material's ID
  106678. * @return the last material with the given id or null if none found.
  106679. */
  106680. getLastMaterialByID(id: string): Nullable<Material>;
  106681. /**
  106682. * Gets a material using its name
  106683. * @param name defines the material's name
  106684. * @return the material or null if none found.
  106685. */
  106686. getMaterialByName(name: string): Nullable<Material>;
  106687. /**
  106688. * Get a texture using its unique id
  106689. * @param uniqueId defines the texture's unique id
  106690. * @return the texture or null if none found.
  106691. */
  106692. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106693. /**
  106694. * Gets a camera using its id
  106695. * @param id defines the id to look for
  106696. * @returns the camera or null if not found
  106697. */
  106698. getCameraByID(id: string): Nullable<Camera>;
  106699. /**
  106700. * Gets a camera using its unique id
  106701. * @param uniqueId defines the unique id to look for
  106702. * @returns the camera or null if not found
  106703. */
  106704. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106705. /**
  106706. * Gets a camera using its name
  106707. * @param name defines the camera's name
  106708. * @return the camera or null if none found.
  106709. */
  106710. getCameraByName(name: string): Nullable<Camera>;
  106711. /**
  106712. * Gets a bone using its id
  106713. * @param id defines the bone's id
  106714. * @return the bone or null if not found
  106715. */
  106716. getBoneByID(id: string): Nullable<Bone>;
  106717. /**
  106718. * Gets a bone using its id
  106719. * @param name defines the bone's name
  106720. * @return the bone or null if not found
  106721. */
  106722. getBoneByName(name: string): Nullable<Bone>;
  106723. /**
  106724. * Gets a light node using its name
  106725. * @param name defines the the light's name
  106726. * @return the light or null if none found.
  106727. */
  106728. getLightByName(name: string): Nullable<Light>;
  106729. /**
  106730. * Gets a light node using its id
  106731. * @param id defines the light's id
  106732. * @return the light or null if none found.
  106733. */
  106734. getLightByID(id: string): Nullable<Light>;
  106735. /**
  106736. * Gets a light node using its scene-generated unique ID
  106737. * @param uniqueId defines the light's unique id
  106738. * @return the light or null if none found.
  106739. */
  106740. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106741. /**
  106742. * Gets a particle system by id
  106743. * @param id defines the particle system id
  106744. * @return the corresponding system or null if none found
  106745. */
  106746. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106747. /**
  106748. * Gets a geometry using its ID
  106749. * @param id defines the geometry's id
  106750. * @return the geometry or null if none found.
  106751. */
  106752. getGeometryByID(id: string): Nullable<Geometry>;
  106753. private _getGeometryByUniqueID;
  106754. /**
  106755. * Add a new geometry to this scene
  106756. * @param geometry defines the geometry to be added to the scene.
  106757. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106758. * @return a boolean defining if the geometry was added or not
  106759. */
  106760. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106761. /**
  106762. * Removes an existing geometry
  106763. * @param geometry defines the geometry to be removed from the scene
  106764. * @return a boolean defining if the geometry was removed or not
  106765. */
  106766. removeGeometry(geometry: Geometry): boolean;
  106767. /**
  106768. * Gets the list of geometries attached to the scene
  106769. * @returns an array of Geometry
  106770. */
  106771. getGeometries(): Geometry[];
  106772. /**
  106773. * Gets the first added mesh found of a given ID
  106774. * @param id defines the id to search for
  106775. * @return the mesh found or null if not found at all
  106776. */
  106777. getMeshByID(id: string): Nullable<AbstractMesh>;
  106778. /**
  106779. * Gets a list of meshes using their id
  106780. * @param id defines the id to search for
  106781. * @returns a list of meshes
  106782. */
  106783. getMeshesByID(id: string): Array<AbstractMesh>;
  106784. /**
  106785. * Gets the first added transform node found of a given ID
  106786. * @param id defines the id to search for
  106787. * @return the found transform node or null if not found at all.
  106788. */
  106789. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106790. /**
  106791. * Gets a transform node with its auto-generated unique id
  106792. * @param uniqueId efines the unique id to search for
  106793. * @return the found transform node or null if not found at all.
  106794. */
  106795. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106796. /**
  106797. * Gets a list of transform nodes using their id
  106798. * @param id defines the id to search for
  106799. * @returns a list of transform nodes
  106800. */
  106801. getTransformNodesByID(id: string): Array<TransformNode>;
  106802. /**
  106803. * Gets a mesh with its auto-generated unique id
  106804. * @param uniqueId defines the unique id to search for
  106805. * @return the found mesh or null if not found at all.
  106806. */
  106807. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106808. /**
  106809. * Gets a the last added mesh using a given id
  106810. * @param id defines the id to search for
  106811. * @return the found mesh or null if not found at all.
  106812. */
  106813. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106814. /**
  106815. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106816. * @param id defines the id to search for
  106817. * @return the found node or null if not found at all
  106818. */
  106819. getLastEntryByID(id: string): Nullable<Node>;
  106820. /**
  106821. * Gets a node (Mesh, Camera, Light) using a given id
  106822. * @param id defines the id to search for
  106823. * @return the found node or null if not found at all
  106824. */
  106825. getNodeByID(id: string): Nullable<Node>;
  106826. /**
  106827. * Gets a node (Mesh, Camera, Light) using a given name
  106828. * @param name defines the name to search for
  106829. * @return the found node or null if not found at all.
  106830. */
  106831. getNodeByName(name: string): Nullable<Node>;
  106832. /**
  106833. * Gets a mesh using a given name
  106834. * @param name defines the name to search for
  106835. * @return the found mesh or null if not found at all.
  106836. */
  106837. getMeshByName(name: string): Nullable<AbstractMesh>;
  106838. /**
  106839. * Gets a transform node using a given name
  106840. * @param name defines the name to search for
  106841. * @return the found transform node or null if not found at all.
  106842. */
  106843. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106844. /**
  106845. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106846. * @param id defines the id to search for
  106847. * @return the found skeleton or null if not found at all.
  106848. */
  106849. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106850. /**
  106851. * Gets a skeleton using a given auto generated unique id
  106852. * @param uniqueId defines the unique id to search for
  106853. * @return the found skeleton or null if not found at all.
  106854. */
  106855. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106856. /**
  106857. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106858. * @param id defines the id to search for
  106859. * @return the found skeleton or null if not found at all.
  106860. */
  106861. getSkeletonById(id: string): Nullable<Skeleton>;
  106862. /**
  106863. * Gets a skeleton using a given name
  106864. * @param name defines the name to search for
  106865. * @return the found skeleton or null if not found at all.
  106866. */
  106867. getSkeletonByName(name: string): Nullable<Skeleton>;
  106868. /**
  106869. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  106870. * @param id defines the id to search for
  106871. * @return the found morph target manager or null if not found at all.
  106872. */
  106873. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  106874. /**
  106875. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  106876. * @param id defines the id to search for
  106877. * @return the found morph target or null if not found at all.
  106878. */
  106879. getMorphTargetById(id: string): Nullable<MorphTarget>;
  106880. /**
  106881. * Gets a boolean indicating if the given mesh is active
  106882. * @param mesh defines the mesh to look for
  106883. * @returns true if the mesh is in the active list
  106884. */
  106885. isActiveMesh(mesh: AbstractMesh): boolean;
  106886. /**
  106887. * Return a unique id as a string which can serve as an identifier for the scene
  106888. */
  106889. get uid(): string;
  106890. /**
  106891. * Add an externaly attached data from its key.
  106892. * This method call will fail and return false, if such key already exists.
  106893. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  106894. * @param key the unique key that identifies the data
  106895. * @param data the data object to associate to the key for this Engine instance
  106896. * @return true if no such key were already present and the data was added successfully, false otherwise
  106897. */
  106898. addExternalData<T>(key: string, data: T): boolean;
  106899. /**
  106900. * Get an externaly attached data from its key
  106901. * @param key the unique key that identifies the data
  106902. * @return the associated data, if present (can be null), or undefined if not present
  106903. */
  106904. getExternalData<T>(key: string): Nullable<T>;
  106905. /**
  106906. * Get an externaly attached data from its key, create it using a factory if it's not already present
  106907. * @param key the unique key that identifies the data
  106908. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  106909. * @return the associated data, can be null if the factory returned null.
  106910. */
  106911. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  106912. /**
  106913. * Remove an externaly attached data from the Engine instance
  106914. * @param key the unique key that identifies the data
  106915. * @return true if the data was successfully removed, false if it doesn't exist
  106916. */
  106917. removeExternalData(key: string): boolean;
  106918. private _evaluateSubMesh;
  106919. /**
  106920. * Clear the processed materials smart array preventing retention point in material dispose.
  106921. */
  106922. freeProcessedMaterials(): void;
  106923. private _preventFreeActiveMeshesAndRenderingGroups;
  106924. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  106925. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  106926. * when disposing several meshes in a row or a hierarchy of meshes.
  106927. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  106928. */
  106929. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  106930. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  106931. /**
  106932. * Clear the active meshes smart array preventing retention point in mesh dispose.
  106933. */
  106934. freeActiveMeshes(): void;
  106935. /**
  106936. * Clear the info related to rendering groups preventing retention points during dispose.
  106937. */
  106938. freeRenderingGroups(): void;
  106939. /** @hidden */
  106940. _isInIntermediateRendering(): boolean;
  106941. /**
  106942. * Lambda returning the list of potentially active meshes.
  106943. */
  106944. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  106945. /**
  106946. * Lambda returning the list of potentially active sub meshes.
  106947. */
  106948. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  106949. /**
  106950. * Lambda returning the list of potentially intersecting sub meshes.
  106951. */
  106952. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  106953. /**
  106954. * Lambda returning the list of potentially colliding sub meshes.
  106955. */
  106956. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  106957. private _activeMeshesFrozen;
  106958. private _skipEvaluateActiveMeshesCompletely;
  106959. /**
  106960. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  106961. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  106962. * @returns the current scene
  106963. */
  106964. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  106965. /**
  106966. * Use this function to restart evaluating active meshes on every frame
  106967. * @returns the current scene
  106968. */
  106969. unfreezeActiveMeshes(): Scene;
  106970. private _evaluateActiveMeshes;
  106971. private _activeMesh;
  106972. /**
  106973. * Update the transform matrix to update from the current active camera
  106974. * @param force defines a boolean used to force the update even if cache is up to date
  106975. */
  106976. updateTransformMatrix(force?: boolean): void;
  106977. private _bindFrameBuffer;
  106978. /** @hidden */
  106979. _allowPostProcessClearColor: boolean;
  106980. /** @hidden */
  106981. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  106982. private _processSubCameras;
  106983. private _checkIntersections;
  106984. /** @hidden */
  106985. _advancePhysicsEngineStep(step: number): void;
  106986. /**
  106987. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  106988. */
  106989. getDeterministicFrameTime: () => number;
  106990. /** @hidden */
  106991. _animate(): void;
  106992. /** Execute all animations (for a frame) */
  106993. animate(): void;
  106994. /**
  106995. * Render the scene
  106996. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  106997. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  106998. */
  106999. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107000. /**
  107001. * Freeze all materials
  107002. * A frozen material will not be updatable but should be faster to render
  107003. */
  107004. freezeMaterials(): void;
  107005. /**
  107006. * Unfreeze all materials
  107007. * A frozen material will not be updatable but should be faster to render
  107008. */
  107009. unfreezeMaterials(): void;
  107010. /**
  107011. * Releases all held ressources
  107012. */
  107013. dispose(): void;
  107014. /**
  107015. * Gets if the scene is already disposed
  107016. */
  107017. get isDisposed(): boolean;
  107018. /**
  107019. * Call this function to reduce memory footprint of the scene.
  107020. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107021. */
  107022. clearCachedVertexData(): void;
  107023. /**
  107024. * This function will remove the local cached buffer data from texture.
  107025. * It will save memory but will prevent the texture from being rebuilt
  107026. */
  107027. cleanCachedTextureBuffer(): void;
  107028. /**
  107029. * Get the world extend vectors with an optional filter
  107030. *
  107031. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107032. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107033. */
  107034. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107035. min: Vector3;
  107036. max: Vector3;
  107037. };
  107038. /**
  107039. * Creates a ray that can be used to pick in the scene
  107040. * @param x defines the x coordinate of the origin (on-screen)
  107041. * @param y defines the y coordinate of the origin (on-screen)
  107042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107043. * @param camera defines the camera to use for the picking
  107044. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107045. * @returns a Ray
  107046. */
  107047. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107048. /**
  107049. * Creates a ray that can be used to pick in the scene
  107050. * @param x defines the x coordinate of the origin (on-screen)
  107051. * @param y defines the y coordinate of the origin (on-screen)
  107052. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107053. * @param result defines the ray where to store the picking ray
  107054. * @param camera defines the camera to use for the picking
  107055. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107056. * @returns the current scene
  107057. */
  107058. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107059. /**
  107060. * Creates a ray that can be used to pick in the scene
  107061. * @param x defines the x coordinate of the origin (on-screen)
  107062. * @param y defines the y coordinate of the origin (on-screen)
  107063. * @param camera defines the camera to use for the picking
  107064. * @returns a Ray
  107065. */
  107066. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107067. /**
  107068. * Creates a ray that can be used to pick in the scene
  107069. * @param x defines the x coordinate of the origin (on-screen)
  107070. * @param y defines the y coordinate of the origin (on-screen)
  107071. * @param result defines the ray where to store the picking ray
  107072. * @param camera defines the camera to use for the picking
  107073. * @returns the current scene
  107074. */
  107075. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107076. /** Launch a ray to try to pick a mesh in the scene
  107077. * @param x position on screen
  107078. * @param y position on screen
  107079. * @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
  107080. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107083. * @returns a PickingInfo
  107084. */
  107085. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107086. /** Use the given ray to pick a mesh in the scene
  107087. * @param ray The ray to use to pick meshes
  107088. * @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
  107089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107090. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107091. * @returns a PickingInfo
  107092. */
  107093. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107094. /**
  107095. * Launch a ray to try to pick a mesh in the scene
  107096. * @param x X position on screen
  107097. * @param y Y position on screen
  107098. * @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
  107099. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107101. * @returns an array of PickingInfo
  107102. */
  107103. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107104. /**
  107105. * Launch a ray to try to pick a mesh in the scene
  107106. * @param ray Ray to use
  107107. * @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
  107108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107109. * @returns an array of PickingInfo
  107110. */
  107111. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107112. /**
  107113. * Force the value of meshUnderPointer
  107114. * @param mesh defines the mesh to use
  107115. */
  107116. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107117. /**
  107118. * Gets the mesh under the pointer
  107119. * @returns a Mesh or null if no mesh is under the pointer
  107120. */
  107121. getPointerOverMesh(): Nullable<AbstractMesh>;
  107122. /** @hidden */
  107123. _rebuildGeometries(): void;
  107124. /** @hidden */
  107125. _rebuildTextures(): void;
  107126. private _getByTags;
  107127. /**
  107128. * Get a list of meshes by tags
  107129. * @param tagsQuery defines the tags query to use
  107130. * @param forEach defines a predicate used to filter results
  107131. * @returns an array of Mesh
  107132. */
  107133. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107134. /**
  107135. * Get a list of cameras by tags
  107136. * @param tagsQuery defines the tags query to use
  107137. * @param forEach defines a predicate used to filter results
  107138. * @returns an array of Camera
  107139. */
  107140. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107141. /**
  107142. * Get a list of lights by tags
  107143. * @param tagsQuery defines the tags query to use
  107144. * @param forEach defines a predicate used to filter results
  107145. * @returns an array of Light
  107146. */
  107147. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107148. /**
  107149. * Get a list of materials by tags
  107150. * @param tagsQuery defines the tags query to use
  107151. * @param forEach defines a predicate used to filter results
  107152. * @returns an array of Material
  107153. */
  107154. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107155. /**
  107156. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107157. * This allowed control for front to back rendering or reversly depending of the special needs.
  107158. *
  107159. * @param renderingGroupId The rendering group id corresponding to its index
  107160. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107161. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107162. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107163. */
  107164. 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;
  107165. /**
  107166. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107167. *
  107168. * @param renderingGroupId The rendering group id corresponding to its index
  107169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107170. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107171. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107172. */
  107173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107174. /**
  107175. * Gets the current auto clear configuration for one rendering group of the rendering
  107176. * manager.
  107177. * @param index the rendering group index to get the information for
  107178. * @returns The auto clear setup for the requested rendering group
  107179. */
  107180. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107181. private _blockMaterialDirtyMechanism;
  107182. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107183. get blockMaterialDirtyMechanism(): boolean;
  107184. set blockMaterialDirtyMechanism(value: boolean);
  107185. /**
  107186. * Will flag all materials as dirty to trigger new shader compilation
  107187. * @param flag defines the flag used to specify which material part must be marked as dirty
  107188. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107189. */
  107190. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107191. /** @hidden */
  107192. _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;
  107193. /** @hidden */
  107194. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107195. /** @hidden */
  107196. _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;
  107197. /** @hidden */
  107198. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107199. /** @hidden */
  107200. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107201. /** @hidden */
  107202. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107203. }
  107204. }
  107205. declare module BABYLON {
  107206. /**
  107207. * Set of assets to keep when moving a scene into an asset container.
  107208. */
  107209. export class KeepAssets extends AbstractScene {
  107210. }
  107211. /**
  107212. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107213. */
  107214. export class InstantiatedEntries {
  107215. /**
  107216. * List of new root nodes (eg. nodes with no parent)
  107217. */
  107218. rootNodes: TransformNode[];
  107219. /**
  107220. * List of new skeletons
  107221. */
  107222. skeletons: Skeleton[];
  107223. /**
  107224. * List of new animation groups
  107225. */
  107226. animationGroups: AnimationGroup[];
  107227. }
  107228. /**
  107229. * Container with a set of assets that can be added or removed from a scene.
  107230. */
  107231. export class AssetContainer extends AbstractScene {
  107232. /**
  107233. * The scene the AssetContainer belongs to.
  107234. */
  107235. scene: Scene;
  107236. /**
  107237. * Instantiates an AssetContainer.
  107238. * @param scene The scene the AssetContainer belongs to.
  107239. */
  107240. constructor(scene: Scene);
  107241. /**
  107242. * Instantiate or clone all meshes and add the new ones to the scene.
  107243. * Skeletons and animation groups will all be cloned
  107244. * @param nameFunction defines an optional function used to get new names for clones
  107245. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107246. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107247. */
  107248. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107249. /**
  107250. * Adds all the assets from the container to the scene.
  107251. */
  107252. addAllToScene(): void;
  107253. /**
  107254. * Removes all the assets in the container from the scene
  107255. */
  107256. removeAllFromScene(): void;
  107257. /**
  107258. * Disposes all the assets in the container
  107259. */
  107260. dispose(): void;
  107261. private _moveAssets;
  107262. /**
  107263. * Removes all the assets contained in the scene and adds them to the container.
  107264. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107265. */
  107266. moveAllFromScene(keepAssets?: KeepAssets): void;
  107267. /**
  107268. * 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.
  107269. * @returns the root mesh
  107270. */
  107271. createRootMesh(): Mesh;
  107272. /**
  107273. * Merge animations from this asset container into a scene
  107274. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107275. * @param animatables set of animatables to retarget to a node from the scene
  107276. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107277. */
  107278. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /**
  107283. * Defines how the parser contract is defined.
  107284. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107285. */
  107286. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107287. /**
  107288. * Defines how the individual parser contract is defined.
  107289. * These parser can parse an individual asset
  107290. */
  107291. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107292. /**
  107293. * Base class of the scene acting as a container for the different elements composing a scene.
  107294. * This class is dynamically extended by the different components of the scene increasing
  107295. * flexibility and reducing coupling
  107296. */
  107297. export abstract class AbstractScene {
  107298. /**
  107299. * Stores the list of available parsers in the application.
  107300. */
  107301. private static _BabylonFileParsers;
  107302. /**
  107303. * Stores the list of available individual parsers in the application.
  107304. */
  107305. private static _IndividualBabylonFileParsers;
  107306. /**
  107307. * Adds a parser in the list of available ones
  107308. * @param name Defines the name of the parser
  107309. * @param parser Defines the parser to add
  107310. */
  107311. static AddParser(name: string, parser: BabylonFileParser): void;
  107312. /**
  107313. * Gets a general parser from the list of avaialble ones
  107314. * @param name Defines the name of the parser
  107315. * @returns the requested parser or null
  107316. */
  107317. static GetParser(name: string): Nullable<BabylonFileParser>;
  107318. /**
  107319. * Adds n individual parser in the list of available ones
  107320. * @param name Defines the name of the parser
  107321. * @param parser Defines the parser to add
  107322. */
  107323. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107324. /**
  107325. * Gets an individual parser from the list of avaialble ones
  107326. * @param name Defines the name of the parser
  107327. * @returns the requested parser or null
  107328. */
  107329. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107330. /**
  107331. * Parser json data and populate both a scene and its associated container object
  107332. * @param jsonData Defines the data to parse
  107333. * @param scene Defines the scene to parse the data for
  107334. * @param container Defines the container attached to the parsing sequence
  107335. * @param rootUrl Defines the root url of the data
  107336. */
  107337. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107338. /**
  107339. * Gets the list of root nodes (ie. nodes with no parent)
  107340. */
  107341. rootNodes: Node[];
  107342. /** All of the cameras added to this scene
  107343. * @see http://doc.babylonjs.com/babylon101/cameras
  107344. */
  107345. cameras: Camera[];
  107346. /**
  107347. * All of the lights added to this scene
  107348. * @see http://doc.babylonjs.com/babylon101/lights
  107349. */
  107350. lights: Light[];
  107351. /**
  107352. * All of the (abstract) meshes added to this scene
  107353. */
  107354. meshes: AbstractMesh[];
  107355. /**
  107356. * The list of skeletons added to the scene
  107357. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107358. */
  107359. skeletons: Skeleton[];
  107360. /**
  107361. * All of the particle systems added to this scene
  107362. * @see http://doc.babylonjs.com/babylon101/particles
  107363. */
  107364. particleSystems: IParticleSystem[];
  107365. /**
  107366. * Gets a list of Animations associated with the scene
  107367. */
  107368. animations: Animation[];
  107369. /**
  107370. * All of the animation groups added to this scene
  107371. * @see http://doc.babylonjs.com/how_to/group
  107372. */
  107373. animationGroups: AnimationGroup[];
  107374. /**
  107375. * All of the multi-materials added to this scene
  107376. * @see http://doc.babylonjs.com/how_to/multi_materials
  107377. */
  107378. multiMaterials: MultiMaterial[];
  107379. /**
  107380. * All of the materials added to this scene
  107381. * In the context of a Scene, it is not supposed to be modified manually.
  107382. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107383. * Note also that the order of the Material within the array is not significant and might change.
  107384. * @see http://doc.babylonjs.com/babylon101/materials
  107385. */
  107386. materials: Material[];
  107387. /**
  107388. * The list of morph target managers added to the scene
  107389. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107390. */
  107391. morphTargetManagers: MorphTargetManager[];
  107392. /**
  107393. * The list of geometries used in the scene.
  107394. */
  107395. geometries: Geometry[];
  107396. /**
  107397. * All of the tranform nodes added to this scene
  107398. * In the context of a Scene, it is not supposed to be modified manually.
  107399. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107400. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107401. * @see http://doc.babylonjs.com/how_to/transformnode
  107402. */
  107403. transformNodes: TransformNode[];
  107404. /**
  107405. * ActionManagers available on the scene.
  107406. */
  107407. actionManagers: AbstractActionManager[];
  107408. /**
  107409. * Textures to keep.
  107410. */
  107411. textures: BaseTexture[];
  107412. /**
  107413. * Environment texture for the scene
  107414. */
  107415. environmentTexture: Nullable<BaseTexture>;
  107416. /**
  107417. * @returns all meshes, lights, cameras, transformNodes and bones
  107418. */
  107419. getNodes(): Array<Node>;
  107420. }
  107421. }
  107422. declare module BABYLON {
  107423. /**
  107424. * Interface used to define options for Sound class
  107425. */
  107426. export interface ISoundOptions {
  107427. /**
  107428. * Does the sound autoplay once loaded.
  107429. */
  107430. autoplay?: boolean;
  107431. /**
  107432. * Does the sound loop after it finishes playing once.
  107433. */
  107434. loop?: boolean;
  107435. /**
  107436. * Sound's volume
  107437. */
  107438. volume?: number;
  107439. /**
  107440. * Is it a spatial sound?
  107441. */
  107442. spatialSound?: boolean;
  107443. /**
  107444. * Maximum distance to hear that sound
  107445. */
  107446. maxDistance?: number;
  107447. /**
  107448. * Uses user defined attenuation function
  107449. */
  107450. useCustomAttenuation?: boolean;
  107451. /**
  107452. * Define the roll off factor of spatial sounds.
  107453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107454. */
  107455. rolloffFactor?: number;
  107456. /**
  107457. * Define the reference distance the sound should be heard perfectly.
  107458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107459. */
  107460. refDistance?: number;
  107461. /**
  107462. * Define the distance attenuation model the sound will follow.
  107463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107464. */
  107465. distanceModel?: string;
  107466. /**
  107467. * Defines the playback speed (1 by default)
  107468. */
  107469. playbackRate?: number;
  107470. /**
  107471. * Defines if the sound is from a streaming source
  107472. */
  107473. streaming?: boolean;
  107474. /**
  107475. * Defines an optional length (in seconds) inside the sound file
  107476. */
  107477. length?: number;
  107478. /**
  107479. * Defines an optional offset (in seconds) inside the sound file
  107480. */
  107481. offset?: number;
  107482. /**
  107483. * If true, URLs will not be required to state the audio file codec to use.
  107484. */
  107485. skipCodecCheck?: boolean;
  107486. }
  107487. /**
  107488. * Defines a sound that can be played in the application.
  107489. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107491. */
  107492. export class Sound {
  107493. /**
  107494. * The name of the sound in the scene.
  107495. */
  107496. name: string;
  107497. /**
  107498. * Does the sound autoplay once loaded.
  107499. */
  107500. autoplay: boolean;
  107501. /**
  107502. * Does the sound loop after it finishes playing once.
  107503. */
  107504. loop: boolean;
  107505. /**
  107506. * Does the sound use a custom attenuation curve to simulate the falloff
  107507. * happening when the source gets further away from the camera.
  107508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107509. */
  107510. useCustomAttenuation: boolean;
  107511. /**
  107512. * The sound track id this sound belongs to.
  107513. */
  107514. soundTrackId: number;
  107515. /**
  107516. * Is this sound currently played.
  107517. */
  107518. isPlaying: boolean;
  107519. /**
  107520. * Is this sound currently paused.
  107521. */
  107522. isPaused: boolean;
  107523. /**
  107524. * Does this sound enables spatial sound.
  107525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107526. */
  107527. spatialSound: boolean;
  107528. /**
  107529. * Define the reference distance the sound should be heard perfectly.
  107530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107531. */
  107532. refDistance: number;
  107533. /**
  107534. * Define the roll off factor of spatial sounds.
  107535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107536. */
  107537. rolloffFactor: number;
  107538. /**
  107539. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107541. */
  107542. maxDistance: number;
  107543. /**
  107544. * Define the distance attenuation model the sound will follow.
  107545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107546. */
  107547. distanceModel: string;
  107548. /**
  107549. * @hidden
  107550. * Back Compat
  107551. **/
  107552. onended: () => any;
  107553. /**
  107554. * Observable event when the current playing sound finishes.
  107555. */
  107556. onEndedObservable: Observable<Sound>;
  107557. private _panningModel;
  107558. private _playbackRate;
  107559. private _streaming;
  107560. private _startTime;
  107561. private _startOffset;
  107562. private _position;
  107563. /** @hidden */
  107564. _positionInEmitterSpace: boolean;
  107565. private _localDirection;
  107566. private _volume;
  107567. private _isReadyToPlay;
  107568. private _isDirectional;
  107569. private _readyToPlayCallback;
  107570. private _audioBuffer;
  107571. private _soundSource;
  107572. private _streamingSource;
  107573. private _soundPanner;
  107574. private _soundGain;
  107575. private _inputAudioNode;
  107576. private _outputAudioNode;
  107577. private _coneInnerAngle;
  107578. private _coneOuterAngle;
  107579. private _coneOuterGain;
  107580. private _scene;
  107581. private _connectedTransformNode;
  107582. private _customAttenuationFunction;
  107583. private _registerFunc;
  107584. private _isOutputConnected;
  107585. private _htmlAudioElement;
  107586. private _urlType;
  107587. private _length?;
  107588. private _offset?;
  107589. /** @hidden */
  107590. static _SceneComponentInitialization: (scene: Scene) => void;
  107591. /**
  107592. * Create a sound and attach it to a scene
  107593. * @param name Name of your sound
  107594. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107595. * @param scene defines the scene the sound belongs to
  107596. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107597. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107598. */
  107599. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107600. /**
  107601. * Release the sound and its associated resources
  107602. */
  107603. dispose(): void;
  107604. /**
  107605. * Gets if the sounds is ready to be played or not.
  107606. * @returns true if ready, otherwise false
  107607. */
  107608. isReady(): boolean;
  107609. private _soundLoaded;
  107610. /**
  107611. * Sets the data of the sound from an audiobuffer
  107612. * @param audioBuffer The audioBuffer containing the data
  107613. */
  107614. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107615. /**
  107616. * Updates the current sounds options such as maxdistance, loop...
  107617. * @param options A JSON object containing values named as the object properties
  107618. */
  107619. updateOptions(options: ISoundOptions): void;
  107620. private _createSpatialParameters;
  107621. private _updateSpatialParameters;
  107622. /**
  107623. * Switch the panning model to HRTF:
  107624. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107626. */
  107627. switchPanningModelToHRTF(): void;
  107628. /**
  107629. * Switch the panning model to Equal Power:
  107630. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107632. */
  107633. switchPanningModelToEqualPower(): void;
  107634. private _switchPanningModel;
  107635. /**
  107636. * Connect this sound to a sound track audio node like gain...
  107637. * @param soundTrackAudioNode the sound track audio node to connect to
  107638. */
  107639. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107640. /**
  107641. * Transform this sound into a directional source
  107642. * @param coneInnerAngle Size of the inner cone in degree
  107643. * @param coneOuterAngle Size of the outer cone in degree
  107644. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107645. */
  107646. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107647. /**
  107648. * Gets or sets the inner angle for the directional cone.
  107649. */
  107650. get directionalConeInnerAngle(): number;
  107651. /**
  107652. * Gets or sets the inner angle for the directional cone.
  107653. */
  107654. set directionalConeInnerAngle(value: number);
  107655. /**
  107656. * Gets or sets the outer angle for the directional cone.
  107657. */
  107658. get directionalConeOuterAngle(): number;
  107659. /**
  107660. * Gets or sets the outer angle for the directional cone.
  107661. */
  107662. set directionalConeOuterAngle(value: number);
  107663. /**
  107664. * Sets the position of the emitter if spatial sound is enabled
  107665. * @param newPosition Defines the new posisiton
  107666. */
  107667. setPosition(newPosition: Vector3): void;
  107668. /**
  107669. * Sets the local direction of the emitter if spatial sound is enabled
  107670. * @param newLocalDirection Defines the new local direction
  107671. */
  107672. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107673. private _updateDirection;
  107674. /** @hidden */
  107675. updateDistanceFromListener(): void;
  107676. /**
  107677. * Sets a new custom attenuation function for the sound.
  107678. * @param callback Defines the function used for the attenuation
  107679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107680. */
  107681. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107682. /**
  107683. * Play the sound
  107684. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107685. * @param offset (optional) Start the sound at a specific time in seconds
  107686. * @param length (optional) Sound duration (in seconds)
  107687. */
  107688. play(time?: number, offset?: number, length?: number): void;
  107689. private _onended;
  107690. /**
  107691. * Stop the sound
  107692. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107693. */
  107694. stop(time?: number): void;
  107695. /**
  107696. * Put the sound in pause
  107697. */
  107698. pause(): void;
  107699. /**
  107700. * Sets a dedicated volume for this sounds
  107701. * @param newVolume Define the new volume of the sound
  107702. * @param time Define time for gradual change to new volume
  107703. */
  107704. setVolume(newVolume: number, time?: number): void;
  107705. /**
  107706. * Set the sound play back rate
  107707. * @param newPlaybackRate Define the playback rate the sound should be played at
  107708. */
  107709. setPlaybackRate(newPlaybackRate: number): void;
  107710. /**
  107711. * Gets the volume of the sound.
  107712. * @returns the volume of the sound
  107713. */
  107714. getVolume(): number;
  107715. /**
  107716. * Attach the sound to a dedicated mesh
  107717. * @param transformNode The transform node to connect the sound with
  107718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107719. */
  107720. attachToMesh(transformNode: TransformNode): void;
  107721. /**
  107722. * Detach the sound from the previously attached mesh
  107723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107724. */
  107725. detachFromMesh(): void;
  107726. private _onRegisterAfterWorldMatrixUpdate;
  107727. /**
  107728. * Clone the current sound in the scene.
  107729. * @returns the new sound clone
  107730. */
  107731. clone(): Nullable<Sound>;
  107732. /**
  107733. * Gets the current underlying audio buffer containing the data
  107734. * @returns the audio buffer
  107735. */
  107736. getAudioBuffer(): Nullable<AudioBuffer>;
  107737. /**
  107738. * Serializes the Sound in a JSON representation
  107739. * @returns the JSON representation of the sound
  107740. */
  107741. serialize(): any;
  107742. /**
  107743. * Parse a JSON representation of a sound to innstantiate in a given scene
  107744. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107745. * @param scene Define the scene the new parsed sound should be created in
  107746. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107747. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107748. * @returns the newly parsed sound
  107749. */
  107750. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107751. }
  107752. }
  107753. declare module BABYLON {
  107754. /**
  107755. * This defines an action helpful to play a defined sound on a triggered action.
  107756. */
  107757. export class PlaySoundAction extends Action {
  107758. private _sound;
  107759. /**
  107760. * Instantiate the action
  107761. * @param triggerOptions defines the trigger options
  107762. * @param sound defines the sound to play
  107763. * @param condition defines the trigger related conditions
  107764. */
  107765. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107766. /** @hidden */
  107767. _prepare(): void;
  107768. /**
  107769. * Execute the action and play the sound.
  107770. */
  107771. execute(): void;
  107772. /**
  107773. * Serializes the actions and its related information.
  107774. * @param parent defines the object to serialize in
  107775. * @returns the serialized object
  107776. */
  107777. serialize(parent: any): any;
  107778. }
  107779. /**
  107780. * This defines an action helpful to stop a defined sound on a triggered action.
  107781. */
  107782. export class StopSoundAction extends Action {
  107783. private _sound;
  107784. /**
  107785. * Instantiate the action
  107786. * @param triggerOptions defines the trigger options
  107787. * @param sound defines the sound to stop
  107788. * @param condition defines the trigger related conditions
  107789. */
  107790. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107791. /** @hidden */
  107792. _prepare(): void;
  107793. /**
  107794. * Execute the action and stop the sound.
  107795. */
  107796. execute(): void;
  107797. /**
  107798. * Serializes the actions and its related information.
  107799. * @param parent defines the object to serialize in
  107800. * @returns the serialized object
  107801. */
  107802. serialize(parent: any): any;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /**
  107807. * This defines an action responsible to change the value of a property
  107808. * by interpolating between its current value and the newly set one once triggered.
  107809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107810. */
  107811. export class InterpolateValueAction extends Action {
  107812. /**
  107813. * Defines the path of the property where the value should be interpolated
  107814. */
  107815. propertyPath: string;
  107816. /**
  107817. * Defines the target value at the end of the interpolation.
  107818. */
  107819. value: any;
  107820. /**
  107821. * Defines the time it will take for the property to interpolate to the value.
  107822. */
  107823. duration: number;
  107824. /**
  107825. * Defines if the other scene animations should be stopped when the action has been triggered
  107826. */
  107827. stopOtherAnimations?: boolean;
  107828. /**
  107829. * Defines a callback raised once the interpolation animation has been done.
  107830. */
  107831. onInterpolationDone?: () => void;
  107832. /**
  107833. * Observable triggered once the interpolation animation has been done.
  107834. */
  107835. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107836. private _target;
  107837. private _effectiveTarget;
  107838. private _property;
  107839. /**
  107840. * Instantiate the action
  107841. * @param triggerOptions defines the trigger options
  107842. * @param target defines the object containing the value to interpolate
  107843. * @param propertyPath defines the path to the property in the target object
  107844. * @param value defines the target value at the end of the interpolation
  107845. * @param duration deines the time it will take for the property to interpolate to the value.
  107846. * @param condition defines the trigger related conditions
  107847. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107848. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107849. */
  107850. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107851. /** @hidden */
  107852. _prepare(): void;
  107853. /**
  107854. * Execute the action starts the value interpolation.
  107855. */
  107856. execute(): void;
  107857. /**
  107858. * Serializes the actions and its related information.
  107859. * @param parent defines the object to serialize in
  107860. * @returns the serialized object
  107861. */
  107862. serialize(parent: any): any;
  107863. }
  107864. }
  107865. declare module BABYLON {
  107866. /**
  107867. * Options allowed during the creation of a sound track.
  107868. */
  107869. export interface ISoundTrackOptions {
  107870. /**
  107871. * The volume the sound track should take during creation
  107872. */
  107873. volume?: number;
  107874. /**
  107875. * Define if the sound track is the main sound track of the scene
  107876. */
  107877. mainTrack?: boolean;
  107878. }
  107879. /**
  107880. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  107881. * It will be also used in a future release to apply effects on a specific track.
  107882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107883. */
  107884. export class SoundTrack {
  107885. /**
  107886. * The unique identifier of the sound track in the scene.
  107887. */
  107888. id: number;
  107889. /**
  107890. * The list of sounds included in the sound track.
  107891. */
  107892. soundCollection: Array<Sound>;
  107893. private _outputAudioNode;
  107894. private _scene;
  107895. private _connectedAnalyser;
  107896. private _options;
  107897. private _isInitialized;
  107898. /**
  107899. * Creates a new sound track.
  107900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107901. * @param scene Define the scene the sound track belongs to
  107902. * @param options
  107903. */
  107904. constructor(scene: Scene, options?: ISoundTrackOptions);
  107905. private _initializeSoundTrackAudioGraph;
  107906. /**
  107907. * Release the sound track and its associated resources
  107908. */
  107909. dispose(): void;
  107910. /**
  107911. * Adds a sound to this sound track
  107912. * @param sound define the cound to add
  107913. * @ignoreNaming
  107914. */
  107915. AddSound(sound: Sound): void;
  107916. /**
  107917. * Removes a sound to this sound track
  107918. * @param sound define the cound to remove
  107919. * @ignoreNaming
  107920. */
  107921. RemoveSound(sound: Sound): void;
  107922. /**
  107923. * Set a global volume for the full sound track.
  107924. * @param newVolume Define the new volume of the sound track
  107925. */
  107926. setVolume(newVolume: number): void;
  107927. /**
  107928. * Switch the panning model to HRTF:
  107929. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107931. */
  107932. switchPanningModelToHRTF(): void;
  107933. /**
  107934. * Switch the panning model to Equal Power:
  107935. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107937. */
  107938. switchPanningModelToEqualPower(): void;
  107939. /**
  107940. * Connect the sound track to an audio analyser allowing some amazing
  107941. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107943. * @param analyser The analyser to connect to the engine
  107944. */
  107945. connectToAnalyser(analyser: Analyser): void;
  107946. }
  107947. }
  107948. declare module BABYLON {
  107949. interface AbstractScene {
  107950. /**
  107951. * The list of sounds used in the scene.
  107952. */
  107953. sounds: Nullable<Array<Sound>>;
  107954. }
  107955. interface Scene {
  107956. /**
  107957. * @hidden
  107958. * Backing field
  107959. */
  107960. _mainSoundTrack: SoundTrack;
  107961. /**
  107962. * The main sound track played by the scene.
  107963. * It cotains your primary collection of sounds.
  107964. */
  107965. mainSoundTrack: SoundTrack;
  107966. /**
  107967. * The list of sound tracks added to the scene
  107968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107969. */
  107970. soundTracks: Nullable<Array<SoundTrack>>;
  107971. /**
  107972. * Gets a sound using a given name
  107973. * @param name defines the name to search for
  107974. * @return the found sound or null if not found at all.
  107975. */
  107976. getSoundByName(name: string): Nullable<Sound>;
  107977. /**
  107978. * Gets or sets if audio support is enabled
  107979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107980. */
  107981. audioEnabled: boolean;
  107982. /**
  107983. * Gets or sets if audio will be output to headphones
  107984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107985. */
  107986. headphone: boolean;
  107987. /**
  107988. * Gets or sets custom audio listener position provider
  107989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107990. */
  107991. audioListenerPositionProvider: Nullable<() => Vector3>;
  107992. /**
  107993. * Gets or sets a refresh rate when using 3D audio positioning
  107994. */
  107995. audioPositioningRefreshRate: number;
  107996. }
  107997. /**
  107998. * Defines the sound scene component responsible to manage any sounds
  107999. * in a given scene.
  108000. */
  108001. export class AudioSceneComponent implements ISceneSerializableComponent {
  108002. /**
  108003. * The component name helpfull to identify the component in the list of scene components.
  108004. */
  108005. readonly name: string;
  108006. /**
  108007. * The scene the component belongs to.
  108008. */
  108009. scene: Scene;
  108010. private _audioEnabled;
  108011. /**
  108012. * Gets whether audio is enabled or not.
  108013. * Please use related enable/disable method to switch state.
  108014. */
  108015. get audioEnabled(): boolean;
  108016. private _headphone;
  108017. /**
  108018. * Gets whether audio is outputing to headphone or not.
  108019. * Please use the according Switch methods to change output.
  108020. */
  108021. get headphone(): boolean;
  108022. /**
  108023. * Gets or sets a refresh rate when using 3D audio positioning
  108024. */
  108025. audioPositioningRefreshRate: number;
  108026. private _audioListenerPositionProvider;
  108027. /**
  108028. * Gets the current audio listener position provider
  108029. */
  108030. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108031. /**
  108032. * Sets a custom listener position for all sounds in the scene
  108033. * By default, this is the position of the first active camera
  108034. */
  108035. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108036. /**
  108037. * Creates a new instance of the component for the given scene
  108038. * @param scene Defines the scene to register the component in
  108039. */
  108040. constructor(scene: Scene);
  108041. /**
  108042. * Registers the component in a given scene
  108043. */
  108044. register(): void;
  108045. /**
  108046. * Rebuilds the elements related to this component in case of
  108047. * context lost for instance.
  108048. */
  108049. rebuild(): void;
  108050. /**
  108051. * Serializes the component data to the specified json object
  108052. * @param serializationObject The object to serialize to
  108053. */
  108054. serialize(serializationObject: any): void;
  108055. /**
  108056. * Adds all the elements from the container to the scene
  108057. * @param container the container holding the elements
  108058. */
  108059. addFromContainer(container: AbstractScene): void;
  108060. /**
  108061. * Removes all the elements in the container from the scene
  108062. * @param container contains the elements to remove
  108063. * @param dispose if the removed element should be disposed (default: false)
  108064. */
  108065. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108066. /**
  108067. * Disposes the component and the associated ressources.
  108068. */
  108069. dispose(): void;
  108070. /**
  108071. * Disables audio in the associated scene.
  108072. */
  108073. disableAudio(): void;
  108074. /**
  108075. * Enables audio in the associated scene.
  108076. */
  108077. enableAudio(): void;
  108078. /**
  108079. * Switch audio to headphone output.
  108080. */
  108081. switchAudioModeForHeadphones(): void;
  108082. /**
  108083. * Switch audio to normal speakers.
  108084. */
  108085. switchAudioModeForNormalSpeakers(): void;
  108086. private _cachedCameraDirection;
  108087. private _cachedCameraPosition;
  108088. private _lastCheck;
  108089. private _afterRender;
  108090. }
  108091. }
  108092. declare module BABYLON {
  108093. /**
  108094. * Wraps one or more Sound objects and selects one with random weight for playback.
  108095. */
  108096. export class WeightedSound {
  108097. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108098. loop: boolean;
  108099. private _coneInnerAngle;
  108100. private _coneOuterAngle;
  108101. private _volume;
  108102. /** A Sound is currently playing. */
  108103. isPlaying: boolean;
  108104. /** A Sound is currently paused. */
  108105. isPaused: boolean;
  108106. private _sounds;
  108107. private _weights;
  108108. private _currentIndex?;
  108109. /**
  108110. * Creates a new WeightedSound from the list of sounds given.
  108111. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108112. * @param sounds Array of Sounds that will be selected from.
  108113. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108114. */
  108115. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108116. /**
  108117. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108118. */
  108119. get directionalConeInnerAngle(): number;
  108120. /**
  108121. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108122. */
  108123. set directionalConeInnerAngle(value: number);
  108124. /**
  108125. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108126. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108127. */
  108128. get directionalConeOuterAngle(): number;
  108129. /**
  108130. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108131. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108132. */
  108133. set directionalConeOuterAngle(value: number);
  108134. /**
  108135. * Playback volume.
  108136. */
  108137. get volume(): number;
  108138. /**
  108139. * Playback volume.
  108140. */
  108141. set volume(value: number);
  108142. private _onended;
  108143. /**
  108144. * Suspend playback
  108145. */
  108146. pause(): void;
  108147. /**
  108148. * Stop playback
  108149. */
  108150. stop(): void;
  108151. /**
  108152. * Start playback.
  108153. * @param startOffset Position the clip head at a specific time in seconds.
  108154. */
  108155. play(startOffset?: number): void;
  108156. }
  108157. }
  108158. declare module BABYLON {
  108159. /**
  108160. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108162. */
  108163. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108164. /**
  108165. * Gets the name of the behavior.
  108166. */
  108167. get name(): string;
  108168. /**
  108169. * The easing function used by animations
  108170. */
  108171. static EasingFunction: BackEase;
  108172. /**
  108173. * The easing mode used by animations
  108174. */
  108175. static EasingMode: number;
  108176. /**
  108177. * The duration of the animation, in milliseconds
  108178. */
  108179. transitionDuration: number;
  108180. /**
  108181. * Length of the distance animated by the transition when lower radius is reached
  108182. */
  108183. lowerRadiusTransitionRange: number;
  108184. /**
  108185. * Length of the distance animated by the transition when upper radius is reached
  108186. */
  108187. upperRadiusTransitionRange: number;
  108188. private _autoTransitionRange;
  108189. /**
  108190. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108191. */
  108192. get autoTransitionRange(): boolean;
  108193. /**
  108194. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108195. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108196. */
  108197. set autoTransitionRange(value: boolean);
  108198. private _attachedCamera;
  108199. private _onAfterCheckInputsObserver;
  108200. private _onMeshTargetChangedObserver;
  108201. /**
  108202. * Initializes the behavior.
  108203. */
  108204. init(): void;
  108205. /**
  108206. * Attaches the behavior to its arc rotate camera.
  108207. * @param camera Defines the camera to attach the behavior to
  108208. */
  108209. attach(camera: ArcRotateCamera): void;
  108210. /**
  108211. * Detaches the behavior from its current arc rotate camera.
  108212. */
  108213. detach(): void;
  108214. private _radiusIsAnimating;
  108215. private _radiusBounceTransition;
  108216. private _animatables;
  108217. private _cachedWheelPrecision;
  108218. /**
  108219. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108220. * @param radiusLimit The limit to check against.
  108221. * @return Bool to indicate if at limit.
  108222. */
  108223. private _isRadiusAtLimit;
  108224. /**
  108225. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108226. * @param radiusDelta The delta by which to animate to. Can be negative.
  108227. */
  108228. private _applyBoundRadiusAnimation;
  108229. /**
  108230. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108231. */
  108232. protected _clearAnimationLocks(): void;
  108233. /**
  108234. * Stops and removes all animations that have been applied to the camera
  108235. */
  108236. stopAllAnimations(): void;
  108237. }
  108238. }
  108239. declare module BABYLON {
  108240. /**
  108241. * 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.
  108242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108243. */
  108244. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108245. /**
  108246. * Gets the name of the behavior.
  108247. */
  108248. get name(): string;
  108249. private _mode;
  108250. private _radiusScale;
  108251. private _positionScale;
  108252. private _defaultElevation;
  108253. private _elevationReturnTime;
  108254. private _elevationReturnWaitTime;
  108255. private _zoomStopsAnimation;
  108256. private _framingTime;
  108257. /**
  108258. * The easing function used by animations
  108259. */
  108260. static EasingFunction: ExponentialEase;
  108261. /**
  108262. * The easing mode used by animations
  108263. */
  108264. static EasingMode: number;
  108265. /**
  108266. * Sets the current mode used by the behavior
  108267. */
  108268. set mode(mode: number);
  108269. /**
  108270. * Gets current mode used by the behavior.
  108271. */
  108272. get mode(): number;
  108273. /**
  108274. * Sets the scale applied to the radius (1 by default)
  108275. */
  108276. set radiusScale(radius: number);
  108277. /**
  108278. * Gets the scale applied to the radius
  108279. */
  108280. get radiusScale(): number;
  108281. /**
  108282. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108283. */
  108284. set positionScale(scale: number);
  108285. /**
  108286. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108287. */
  108288. get positionScale(): number;
  108289. /**
  108290. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108291. * behaviour is triggered, in radians.
  108292. */
  108293. set defaultElevation(elevation: number);
  108294. /**
  108295. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108296. * behaviour is triggered, in radians.
  108297. */
  108298. get defaultElevation(): number;
  108299. /**
  108300. * Sets the time (in milliseconds) taken to return to the default beta position.
  108301. * Negative value indicates camera should not return to default.
  108302. */
  108303. set elevationReturnTime(speed: number);
  108304. /**
  108305. * Gets the time (in milliseconds) taken to return to the default beta position.
  108306. * Negative value indicates camera should not return to default.
  108307. */
  108308. get elevationReturnTime(): number;
  108309. /**
  108310. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108311. */
  108312. set elevationReturnWaitTime(time: number);
  108313. /**
  108314. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108315. */
  108316. get elevationReturnWaitTime(): number;
  108317. /**
  108318. * Sets the flag that indicates if user zooming should stop animation.
  108319. */
  108320. set zoomStopsAnimation(flag: boolean);
  108321. /**
  108322. * Gets the flag that indicates if user zooming should stop animation.
  108323. */
  108324. get zoomStopsAnimation(): boolean;
  108325. /**
  108326. * Sets the transition time when framing the mesh, in milliseconds
  108327. */
  108328. set framingTime(time: number);
  108329. /**
  108330. * Gets the transition time when framing the mesh, in milliseconds
  108331. */
  108332. get framingTime(): number;
  108333. /**
  108334. * Define if the behavior should automatically change the configured
  108335. * camera limits and sensibilities.
  108336. */
  108337. autoCorrectCameraLimitsAndSensibility: boolean;
  108338. private _onPrePointerObservableObserver;
  108339. private _onAfterCheckInputsObserver;
  108340. private _onMeshTargetChangedObserver;
  108341. private _attachedCamera;
  108342. private _isPointerDown;
  108343. private _lastInteractionTime;
  108344. /**
  108345. * Initializes the behavior.
  108346. */
  108347. init(): void;
  108348. /**
  108349. * Attaches the behavior to its arc rotate camera.
  108350. * @param camera Defines the camera to attach the behavior to
  108351. */
  108352. attach(camera: ArcRotateCamera): void;
  108353. /**
  108354. * Detaches the behavior from its current arc rotate camera.
  108355. */
  108356. detach(): void;
  108357. private _animatables;
  108358. private _betaIsAnimating;
  108359. private _betaTransition;
  108360. private _radiusTransition;
  108361. private _vectorTransition;
  108362. /**
  108363. * Targets the given mesh and updates zoom level accordingly.
  108364. * @param mesh The mesh to target.
  108365. * @param radius Optional. If a cached radius position already exists, overrides default.
  108366. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108367. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108368. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108369. */
  108370. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108371. /**
  108372. * Targets the given mesh with its children and updates zoom level accordingly.
  108373. * @param mesh The mesh to target.
  108374. * @param radius Optional. If a cached radius position already exists, overrides default.
  108375. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108376. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108377. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108378. */
  108379. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108380. /**
  108381. * Targets the given meshes with their children and updates zoom level accordingly.
  108382. * @param meshes The mesh to target.
  108383. * @param radius Optional. If a cached radius position already exists, overrides default.
  108384. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108385. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108386. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108387. */
  108388. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108389. /**
  108390. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108391. * @param minimumWorld Determines the smaller position of the bounding box extend
  108392. * @param maximumWorld Determines the bigger position of the bounding box extend
  108393. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108394. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108395. */
  108396. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108397. /**
  108398. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108399. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108400. * frustum width.
  108401. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108402. * to fully enclose the mesh in the viewing frustum.
  108403. */
  108404. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108405. /**
  108406. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108407. * is automatically returned to its default position (expected to be above ground plane).
  108408. */
  108409. private _maintainCameraAboveGround;
  108410. /**
  108411. * Returns the frustum slope based on the canvas ratio and camera FOV
  108412. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108413. */
  108414. private _getFrustumSlope;
  108415. /**
  108416. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108417. */
  108418. private _clearAnimationLocks;
  108419. /**
  108420. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108421. */
  108422. private _applyUserInteraction;
  108423. /**
  108424. * Stops and removes all animations that have been applied to the camera
  108425. */
  108426. stopAllAnimations(): void;
  108427. /**
  108428. * Gets a value indicating if the user is moving the camera
  108429. */
  108430. get isUserIsMoving(): boolean;
  108431. /**
  108432. * The camera can move all the way towards the mesh.
  108433. */
  108434. static IgnoreBoundsSizeMode: number;
  108435. /**
  108436. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108437. */
  108438. static FitFrustumSidesMode: number;
  108439. }
  108440. }
  108441. declare module BABYLON {
  108442. /**
  108443. * Base class for Camera Pointer Inputs.
  108444. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108445. * for example usage.
  108446. */
  108447. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108448. /**
  108449. * Defines the camera the input is attached to.
  108450. */
  108451. abstract camera: Camera;
  108452. /**
  108453. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108454. */
  108455. protected _altKey: boolean;
  108456. protected _ctrlKey: boolean;
  108457. protected _metaKey: boolean;
  108458. protected _shiftKey: boolean;
  108459. /**
  108460. * Which mouse buttons were pressed at time of last mouse event.
  108461. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108462. */
  108463. protected _buttonsPressed: number;
  108464. /**
  108465. * Defines the buttons associated with the input to handle camera move.
  108466. */
  108467. buttons: number[];
  108468. /**
  108469. * Attach the input controls to a specific dom element to get the input from.
  108470. * @param element Defines the element the controls should be listened from
  108471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108472. */
  108473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108474. /**
  108475. * Detach the current controls from the specified dom element.
  108476. * @param element Defines the element to stop listening the inputs from
  108477. */
  108478. detachControl(element: Nullable<HTMLElement>): void;
  108479. /**
  108480. * Gets the class name of the current input.
  108481. * @returns the class name
  108482. */
  108483. getClassName(): string;
  108484. /**
  108485. * Get the friendly name associated with the input class.
  108486. * @returns the input friendly name
  108487. */
  108488. getSimpleName(): string;
  108489. /**
  108490. * Called on pointer POINTERDOUBLETAP event.
  108491. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108492. */
  108493. protected onDoubleTap(type: string): void;
  108494. /**
  108495. * Called on pointer POINTERMOVE event if only a single touch is active.
  108496. * Override this method to provide functionality.
  108497. */
  108498. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108499. /**
  108500. * Called on pointer POINTERMOVE event if multiple touches are active.
  108501. * Override this method to provide functionality.
  108502. */
  108503. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108504. /**
  108505. * Called on JS contextmenu event.
  108506. * Override this method to provide functionality.
  108507. */
  108508. protected onContextMenu(evt: PointerEvent): void;
  108509. /**
  108510. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108511. * press.
  108512. * Override this method to provide functionality.
  108513. */
  108514. protected onButtonDown(evt: PointerEvent): void;
  108515. /**
  108516. * Called each time a new POINTERUP event occurs. Ie, for each button
  108517. * release.
  108518. * Override this method to provide functionality.
  108519. */
  108520. protected onButtonUp(evt: PointerEvent): void;
  108521. /**
  108522. * Called when window becomes inactive.
  108523. * Override this method to provide functionality.
  108524. */
  108525. protected onLostFocus(): void;
  108526. private _pointerInput;
  108527. private _observer;
  108528. private _onLostFocus;
  108529. private pointA;
  108530. private pointB;
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * Manage the pointers inputs to control an arc rotate camera.
  108536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108537. */
  108538. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108539. /**
  108540. * Defines the camera the input is attached to.
  108541. */
  108542. camera: ArcRotateCamera;
  108543. /**
  108544. * Gets the class name of the current input.
  108545. * @returns the class name
  108546. */
  108547. getClassName(): string;
  108548. /**
  108549. * Defines the buttons associated with the input to handle camera move.
  108550. */
  108551. buttons: number[];
  108552. /**
  108553. * Defines the pointer angular sensibility along the X axis or how fast is
  108554. * the camera rotating.
  108555. */
  108556. angularSensibilityX: number;
  108557. /**
  108558. * Defines the pointer angular sensibility along the Y axis or how fast is
  108559. * the camera rotating.
  108560. */
  108561. angularSensibilityY: number;
  108562. /**
  108563. * Defines the pointer pinch precision or how fast is the camera zooming.
  108564. */
  108565. pinchPrecision: number;
  108566. /**
  108567. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108568. * from 0.
  108569. * It defines the percentage of current camera.radius to use as delta when
  108570. * pinch zoom is used.
  108571. */
  108572. pinchDeltaPercentage: number;
  108573. /**
  108574. * Defines the pointer panning sensibility or how fast is the camera moving.
  108575. */
  108576. panningSensibility: number;
  108577. /**
  108578. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108579. */
  108580. multiTouchPanning: boolean;
  108581. /**
  108582. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108583. * zoom (pinch) through multitouch.
  108584. */
  108585. multiTouchPanAndZoom: boolean;
  108586. /**
  108587. * Revers pinch action direction.
  108588. */
  108589. pinchInwards: boolean;
  108590. private _isPanClick;
  108591. private _twoFingerActivityCount;
  108592. private _isPinching;
  108593. /**
  108594. * Called on pointer POINTERMOVE event if only a single touch is active.
  108595. */
  108596. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108597. /**
  108598. * Called on pointer POINTERDOUBLETAP event.
  108599. */
  108600. protected onDoubleTap(type: string): void;
  108601. /**
  108602. * Called on pointer POINTERMOVE event if multiple touches are active.
  108603. */
  108604. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108605. /**
  108606. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108607. * press.
  108608. */
  108609. protected onButtonDown(evt: PointerEvent): void;
  108610. /**
  108611. * Called each time a new POINTERUP event occurs. Ie, for each button
  108612. * release.
  108613. */
  108614. protected onButtonUp(evt: PointerEvent): void;
  108615. /**
  108616. * Called when window becomes inactive.
  108617. */
  108618. protected onLostFocus(): void;
  108619. }
  108620. }
  108621. declare module BABYLON {
  108622. /**
  108623. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108624. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108625. */
  108626. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108627. /**
  108628. * Defines the camera the input is attached to.
  108629. */
  108630. camera: ArcRotateCamera;
  108631. /**
  108632. * Defines the list of key codes associated with the up action (increase alpha)
  108633. */
  108634. keysUp: number[];
  108635. /**
  108636. * Defines the list of key codes associated with the down action (decrease alpha)
  108637. */
  108638. keysDown: number[];
  108639. /**
  108640. * Defines the list of key codes associated with the left action (increase beta)
  108641. */
  108642. keysLeft: number[];
  108643. /**
  108644. * Defines the list of key codes associated with the right action (decrease beta)
  108645. */
  108646. keysRight: number[];
  108647. /**
  108648. * Defines the list of key codes associated with the reset action.
  108649. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108650. */
  108651. keysReset: number[];
  108652. /**
  108653. * Defines the panning sensibility of the inputs.
  108654. * (How fast is the camera paning)
  108655. */
  108656. panningSensibility: number;
  108657. /**
  108658. * Defines the zooming sensibility of the inputs.
  108659. * (How fast is the camera zooming)
  108660. */
  108661. zoomingSensibility: number;
  108662. /**
  108663. * Defines wether maintaining the alt key down switch the movement mode from
  108664. * orientation to zoom.
  108665. */
  108666. useAltToZoom: boolean;
  108667. /**
  108668. * Rotation speed of the camera
  108669. */
  108670. angularSpeed: number;
  108671. private _keys;
  108672. private _ctrlPressed;
  108673. private _altPressed;
  108674. private _onCanvasBlurObserver;
  108675. private _onKeyboardObserver;
  108676. private _engine;
  108677. private _scene;
  108678. /**
  108679. * Attach the input controls to a specific dom element to get the input from.
  108680. * @param element Defines the element the controls should be listened from
  108681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108682. */
  108683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108684. /**
  108685. * Detach the current controls from the specified dom element.
  108686. * @param element Defines the element to stop listening the inputs from
  108687. */
  108688. detachControl(element: Nullable<HTMLElement>): void;
  108689. /**
  108690. * Update the current camera state depending on the inputs that have been used this frame.
  108691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108692. */
  108693. checkInputs(): void;
  108694. /**
  108695. * Gets the class name of the current intput.
  108696. * @returns the class name
  108697. */
  108698. getClassName(): string;
  108699. /**
  108700. * Get the friendly name associated with the input class.
  108701. * @returns the input friendly name
  108702. */
  108703. getSimpleName(): string;
  108704. }
  108705. }
  108706. declare module BABYLON {
  108707. /**
  108708. * Manage the mouse wheel inputs to control an arc rotate camera.
  108709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108710. */
  108711. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108712. /**
  108713. * Defines the camera the input is attached to.
  108714. */
  108715. camera: ArcRotateCamera;
  108716. /**
  108717. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108718. */
  108719. wheelPrecision: number;
  108720. /**
  108721. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108722. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108723. */
  108724. wheelDeltaPercentage: number;
  108725. private _wheel;
  108726. private _observer;
  108727. private computeDeltaFromMouseWheelLegacyEvent;
  108728. /**
  108729. * Attach the input controls to a specific dom element to get the input from.
  108730. * @param element Defines the element the controls should be listened from
  108731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108732. */
  108733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108734. /**
  108735. * Detach the current controls from the specified dom element.
  108736. * @param element Defines the element to stop listening the inputs from
  108737. */
  108738. detachControl(element: Nullable<HTMLElement>): void;
  108739. /**
  108740. * Gets the class name of the current intput.
  108741. * @returns the class name
  108742. */
  108743. getClassName(): string;
  108744. /**
  108745. * Get the friendly name associated with the input class.
  108746. * @returns the input friendly name
  108747. */
  108748. getSimpleName(): string;
  108749. }
  108750. }
  108751. declare module BABYLON {
  108752. /**
  108753. * Default Inputs manager for the ArcRotateCamera.
  108754. * It groups all the default supported inputs for ease of use.
  108755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108756. */
  108757. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108758. /**
  108759. * Instantiates a new ArcRotateCameraInputsManager.
  108760. * @param camera Defines the camera the inputs belong to
  108761. */
  108762. constructor(camera: ArcRotateCamera);
  108763. /**
  108764. * Add mouse wheel input support to the input manager.
  108765. * @returns the current input manager
  108766. */
  108767. addMouseWheel(): ArcRotateCameraInputsManager;
  108768. /**
  108769. * Add pointers input support to the input manager.
  108770. * @returns the current input manager
  108771. */
  108772. addPointers(): ArcRotateCameraInputsManager;
  108773. /**
  108774. * Add keyboard input support to the input manager.
  108775. * @returns the current input manager
  108776. */
  108777. addKeyboard(): ArcRotateCameraInputsManager;
  108778. }
  108779. }
  108780. declare module BABYLON {
  108781. /**
  108782. * This represents an orbital type of camera.
  108783. *
  108784. * 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.
  108785. * 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.
  108786. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108787. */
  108788. export class ArcRotateCamera extends TargetCamera {
  108789. /**
  108790. * Defines the rotation angle of the camera along the longitudinal axis.
  108791. */
  108792. alpha: number;
  108793. /**
  108794. * Defines the rotation angle of the camera along the latitudinal axis.
  108795. */
  108796. beta: number;
  108797. /**
  108798. * Defines the radius of the camera from it s target point.
  108799. */
  108800. radius: number;
  108801. protected _target: Vector3;
  108802. protected _targetHost: Nullable<AbstractMesh>;
  108803. /**
  108804. * Defines the target point of the camera.
  108805. * The camera looks towards it form the radius distance.
  108806. */
  108807. get target(): Vector3;
  108808. set target(value: Vector3);
  108809. /**
  108810. * Define the current local position of the camera in the scene
  108811. */
  108812. get position(): Vector3;
  108813. set position(newPosition: Vector3);
  108814. protected _upVector: Vector3;
  108815. protected _upToYMatrix: Matrix;
  108816. protected _YToUpMatrix: Matrix;
  108817. /**
  108818. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108819. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108820. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108821. */
  108822. set upVector(vec: Vector3);
  108823. get upVector(): Vector3;
  108824. /**
  108825. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108826. */
  108827. setMatUp(): void;
  108828. /**
  108829. * Current inertia value on the longitudinal axis.
  108830. * The bigger this number the longer it will take for the camera to stop.
  108831. */
  108832. inertialAlphaOffset: number;
  108833. /**
  108834. * Current inertia value on the latitudinal axis.
  108835. * The bigger this number the longer it will take for the camera to stop.
  108836. */
  108837. inertialBetaOffset: number;
  108838. /**
  108839. * Current inertia value on the radius axis.
  108840. * The bigger this number the longer it will take for the camera to stop.
  108841. */
  108842. inertialRadiusOffset: number;
  108843. /**
  108844. * Minimum allowed angle on the longitudinal axis.
  108845. * This can help limiting how the Camera is able to move in the scene.
  108846. */
  108847. lowerAlphaLimit: Nullable<number>;
  108848. /**
  108849. * Maximum allowed angle on the longitudinal axis.
  108850. * This can help limiting how the Camera is able to move in the scene.
  108851. */
  108852. upperAlphaLimit: Nullable<number>;
  108853. /**
  108854. * Minimum allowed angle on the latitudinal axis.
  108855. * This can help limiting how the Camera is able to move in the scene.
  108856. */
  108857. lowerBetaLimit: number;
  108858. /**
  108859. * Maximum allowed angle on the latitudinal axis.
  108860. * This can help limiting how the Camera is able to move in the scene.
  108861. */
  108862. upperBetaLimit: number;
  108863. /**
  108864. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  108865. * This can help limiting how the Camera is able to move in the scene.
  108866. */
  108867. lowerRadiusLimit: Nullable<number>;
  108868. /**
  108869. * Maximum allowed distance of the camera to the target (The camera can not get further).
  108870. * This can help limiting how the Camera is able to move in the scene.
  108871. */
  108872. upperRadiusLimit: Nullable<number>;
  108873. /**
  108874. * Defines the current inertia value used during panning of the camera along the X axis.
  108875. */
  108876. inertialPanningX: number;
  108877. /**
  108878. * Defines the current inertia value used during panning of the camera along the Y axis.
  108879. */
  108880. inertialPanningY: number;
  108881. /**
  108882. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  108883. * Basically if your fingers moves away from more than this distance you will be considered
  108884. * in pinch mode.
  108885. */
  108886. pinchToPanMaxDistance: number;
  108887. /**
  108888. * Defines the maximum distance the camera can pan.
  108889. * This could help keeping the cammera always in your scene.
  108890. */
  108891. panningDistanceLimit: Nullable<number>;
  108892. /**
  108893. * Defines the target of the camera before paning.
  108894. */
  108895. panningOriginTarget: Vector3;
  108896. /**
  108897. * Defines the value of the inertia used during panning.
  108898. * 0 would mean stop inertia and one would mean no decelleration at all.
  108899. */
  108900. panningInertia: number;
  108901. /**
  108902. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  108903. */
  108904. get angularSensibilityX(): number;
  108905. set angularSensibilityX(value: number);
  108906. /**
  108907. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  108908. */
  108909. get angularSensibilityY(): number;
  108910. set angularSensibilityY(value: number);
  108911. /**
  108912. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  108913. */
  108914. get pinchPrecision(): number;
  108915. set pinchPrecision(value: number);
  108916. /**
  108917. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  108918. * It will be used instead of pinchDeltaPrecision if different from 0.
  108919. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108920. */
  108921. get pinchDeltaPercentage(): number;
  108922. set pinchDeltaPercentage(value: number);
  108923. /**
  108924. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  108925. */
  108926. get panningSensibility(): number;
  108927. set panningSensibility(value: number);
  108928. /**
  108929. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  108930. */
  108931. get keysUp(): number[];
  108932. set keysUp(value: number[]);
  108933. /**
  108934. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  108935. */
  108936. get keysDown(): number[];
  108937. set keysDown(value: number[]);
  108938. /**
  108939. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  108940. */
  108941. get keysLeft(): number[];
  108942. set keysLeft(value: number[]);
  108943. /**
  108944. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  108945. */
  108946. get keysRight(): number[];
  108947. set keysRight(value: number[]);
  108948. /**
  108949. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108950. */
  108951. get wheelPrecision(): number;
  108952. set wheelPrecision(value: number);
  108953. /**
  108954. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  108955. * It will be used instead of pinchDeltaPrecision if different from 0.
  108956. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108957. */
  108958. get wheelDeltaPercentage(): number;
  108959. set wheelDeltaPercentage(value: number);
  108960. /**
  108961. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  108962. */
  108963. zoomOnFactor: number;
  108964. /**
  108965. * Defines a screen offset for the camera position.
  108966. */
  108967. targetScreenOffset: Vector2;
  108968. /**
  108969. * Allows the camera to be completely reversed.
  108970. * If false the camera can not arrive upside down.
  108971. */
  108972. allowUpsideDown: boolean;
  108973. /**
  108974. * Define if double tap/click is used to restore the previously saved state of the camera.
  108975. */
  108976. useInputToRestoreState: boolean;
  108977. /** @hidden */
  108978. _viewMatrix: Matrix;
  108979. /** @hidden */
  108980. _useCtrlForPanning: boolean;
  108981. /** @hidden */
  108982. _panningMouseButton: number;
  108983. /**
  108984. * Defines the input associated to the camera.
  108985. */
  108986. inputs: ArcRotateCameraInputsManager;
  108987. /** @hidden */
  108988. _reset: () => void;
  108989. /**
  108990. * Defines the allowed panning axis.
  108991. */
  108992. panningAxis: Vector3;
  108993. protected _localDirection: Vector3;
  108994. protected _transformedDirection: Vector3;
  108995. private _bouncingBehavior;
  108996. /**
  108997. * Gets the bouncing behavior of the camera if it has been enabled.
  108998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108999. */
  109000. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109001. /**
  109002. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109003. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109004. */
  109005. get useBouncingBehavior(): boolean;
  109006. set useBouncingBehavior(value: boolean);
  109007. private _framingBehavior;
  109008. /**
  109009. * Gets the framing behavior of the camera if it has been enabled.
  109010. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109011. */
  109012. get framingBehavior(): Nullable<FramingBehavior>;
  109013. /**
  109014. * Defines if the framing behavior of the camera is enabled on the camera.
  109015. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109016. */
  109017. get useFramingBehavior(): boolean;
  109018. set useFramingBehavior(value: boolean);
  109019. private _autoRotationBehavior;
  109020. /**
  109021. * Gets the auto rotation behavior of the camera if it has been enabled.
  109022. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109023. */
  109024. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109025. /**
  109026. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109028. */
  109029. get useAutoRotationBehavior(): boolean;
  109030. set useAutoRotationBehavior(value: boolean);
  109031. /**
  109032. * Observable triggered when the mesh target has been changed on the camera.
  109033. */
  109034. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109035. /**
  109036. * Event raised when the camera is colliding with a mesh.
  109037. */
  109038. onCollide: (collidedMesh: AbstractMesh) => void;
  109039. /**
  109040. * Defines whether the camera should check collision with the objects oh the scene.
  109041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109042. */
  109043. checkCollisions: boolean;
  109044. /**
  109045. * Defines the collision radius of the camera.
  109046. * This simulates a sphere around the camera.
  109047. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109048. */
  109049. collisionRadius: Vector3;
  109050. protected _collider: Collider;
  109051. protected _previousPosition: Vector3;
  109052. protected _collisionVelocity: Vector3;
  109053. protected _newPosition: Vector3;
  109054. protected _previousAlpha: number;
  109055. protected _previousBeta: number;
  109056. protected _previousRadius: number;
  109057. protected _collisionTriggered: boolean;
  109058. protected _targetBoundingCenter: Nullable<Vector3>;
  109059. private _computationVector;
  109060. /**
  109061. * Instantiates a new ArcRotateCamera in a given scene
  109062. * @param name Defines the name of the camera
  109063. * @param alpha Defines the camera rotation along the logitudinal axis
  109064. * @param beta Defines the camera rotation along the latitudinal axis
  109065. * @param radius Defines the camera distance from its target
  109066. * @param target Defines the camera target
  109067. * @param scene Defines the scene the camera belongs to
  109068. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109069. */
  109070. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109071. /** @hidden */
  109072. _initCache(): void;
  109073. /** @hidden */
  109074. _updateCache(ignoreParentClass?: boolean): void;
  109075. protected _getTargetPosition(): Vector3;
  109076. private _storedAlpha;
  109077. private _storedBeta;
  109078. private _storedRadius;
  109079. private _storedTarget;
  109080. private _storedTargetScreenOffset;
  109081. /**
  109082. * Stores the current state of the camera (alpha, beta, radius and target)
  109083. * @returns the camera itself
  109084. */
  109085. storeState(): Camera;
  109086. /**
  109087. * @hidden
  109088. * Restored camera state. You must call storeState() first
  109089. */
  109090. _restoreStateValues(): boolean;
  109091. /** @hidden */
  109092. _isSynchronizedViewMatrix(): boolean;
  109093. /**
  109094. * Attached controls to the current camera.
  109095. * @param element Defines the element the controls should be listened from
  109096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109097. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109098. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109099. */
  109100. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109101. /**
  109102. * Detach the current controls from the camera.
  109103. * The camera will stop reacting to inputs.
  109104. * @param element Defines the element to stop listening the inputs from
  109105. */
  109106. detachControl(element: HTMLElement): void;
  109107. /** @hidden */
  109108. _checkInputs(): void;
  109109. protected _checkLimits(): void;
  109110. /**
  109111. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109112. */
  109113. rebuildAnglesAndRadius(): void;
  109114. /**
  109115. * Use a position to define the current camera related information like alpha, beta and radius
  109116. * @param position Defines the position to set the camera at
  109117. */
  109118. setPosition(position: Vector3): void;
  109119. /**
  109120. * Defines the target the camera should look at.
  109121. * This will automatically adapt alpha beta and radius to fit within the new target.
  109122. * @param target Defines the new target as a Vector or a mesh
  109123. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109124. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109125. */
  109126. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109127. /** @hidden */
  109128. _getViewMatrix(): Matrix;
  109129. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109130. /**
  109131. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109132. * @param meshes Defines the mesh to zoom on
  109133. * @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)
  109134. */
  109135. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109136. /**
  109137. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109138. * The target will be changed but the radius
  109139. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109140. * @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)
  109141. */
  109142. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109143. min: Vector3;
  109144. max: Vector3;
  109145. distance: number;
  109146. }, doNotUpdateMaxZ?: boolean): void;
  109147. /**
  109148. * @override
  109149. * Override Camera.createRigCamera
  109150. */
  109151. createRigCamera(name: string, cameraIndex: number): Camera;
  109152. /**
  109153. * @hidden
  109154. * @override
  109155. * Override Camera._updateRigCameras
  109156. */
  109157. _updateRigCameras(): void;
  109158. /**
  109159. * Destroy the camera and release the current resources hold by it.
  109160. */
  109161. dispose(): void;
  109162. /**
  109163. * Gets the current object class name.
  109164. * @return the class name
  109165. */
  109166. getClassName(): string;
  109167. }
  109168. }
  109169. declare module BABYLON {
  109170. /**
  109171. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109173. */
  109174. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109175. /**
  109176. * Gets the name of the behavior.
  109177. */
  109178. get name(): string;
  109179. private _zoomStopsAnimation;
  109180. private _idleRotationSpeed;
  109181. private _idleRotationWaitTime;
  109182. private _idleRotationSpinupTime;
  109183. /**
  109184. * Sets the flag that indicates if user zooming should stop animation.
  109185. */
  109186. set zoomStopsAnimation(flag: boolean);
  109187. /**
  109188. * Gets the flag that indicates if user zooming should stop animation.
  109189. */
  109190. get zoomStopsAnimation(): boolean;
  109191. /**
  109192. * Sets the default speed at which the camera rotates around the model.
  109193. */
  109194. set idleRotationSpeed(speed: number);
  109195. /**
  109196. * Gets the default speed at which the camera rotates around the model.
  109197. */
  109198. get idleRotationSpeed(): number;
  109199. /**
  109200. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109201. */
  109202. set idleRotationWaitTime(time: number);
  109203. /**
  109204. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109205. */
  109206. get idleRotationWaitTime(): number;
  109207. /**
  109208. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109209. */
  109210. set idleRotationSpinupTime(time: number);
  109211. /**
  109212. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109213. */
  109214. get idleRotationSpinupTime(): number;
  109215. /**
  109216. * Gets a value indicating if the camera is currently rotating because of this behavior
  109217. */
  109218. get rotationInProgress(): boolean;
  109219. private _onPrePointerObservableObserver;
  109220. private _onAfterCheckInputsObserver;
  109221. private _attachedCamera;
  109222. private _isPointerDown;
  109223. private _lastFrameTime;
  109224. private _lastInteractionTime;
  109225. private _cameraRotationSpeed;
  109226. /**
  109227. * Initializes the behavior.
  109228. */
  109229. init(): void;
  109230. /**
  109231. * Attaches the behavior to its arc rotate camera.
  109232. * @param camera Defines the camera to attach the behavior to
  109233. */
  109234. attach(camera: ArcRotateCamera): void;
  109235. /**
  109236. * Detaches the behavior from its current arc rotate camera.
  109237. */
  109238. detach(): void;
  109239. /**
  109240. * Returns true if user is scrolling.
  109241. * @return true if user is scrolling.
  109242. */
  109243. private _userIsZooming;
  109244. private _lastFrameRadius;
  109245. private _shouldAnimationStopForInteraction;
  109246. /**
  109247. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109248. */
  109249. private _applyUserInteraction;
  109250. private _userIsMoving;
  109251. }
  109252. }
  109253. declare module BABYLON {
  109254. /**
  109255. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109256. */
  109257. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109258. private ui;
  109259. /**
  109260. * The name of the behavior
  109261. */
  109262. name: string;
  109263. /**
  109264. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109265. */
  109266. distanceAwayFromFace: number;
  109267. /**
  109268. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109269. */
  109270. distanceAwayFromBottomOfFace: number;
  109271. private _faceVectors;
  109272. private _target;
  109273. private _scene;
  109274. private _onRenderObserver;
  109275. private _tmpMatrix;
  109276. private _tmpVector;
  109277. /**
  109278. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109279. * @param ui The transform node that should be attched to the mesh
  109280. */
  109281. constructor(ui: TransformNode);
  109282. /**
  109283. * Initializes the behavior
  109284. */
  109285. init(): void;
  109286. private _closestFace;
  109287. private _zeroVector;
  109288. private _lookAtTmpMatrix;
  109289. private _lookAtToRef;
  109290. /**
  109291. * Attaches the AttachToBoxBehavior to the passed in mesh
  109292. * @param target The mesh that the specified node will be attached to
  109293. */
  109294. attach(target: Mesh): void;
  109295. /**
  109296. * Detaches the behavior from the mesh
  109297. */
  109298. detach(): void;
  109299. }
  109300. }
  109301. declare module BABYLON {
  109302. /**
  109303. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109304. */
  109305. export class FadeInOutBehavior implements Behavior<Mesh> {
  109306. /**
  109307. * Time in milliseconds to delay before fading in (Default: 0)
  109308. */
  109309. delay: number;
  109310. /**
  109311. * Time in milliseconds for the mesh to fade in (Default: 300)
  109312. */
  109313. fadeInTime: number;
  109314. private _millisecondsPerFrame;
  109315. private _hovered;
  109316. private _hoverValue;
  109317. private _ownerNode;
  109318. /**
  109319. * Instatiates the FadeInOutBehavior
  109320. */
  109321. constructor();
  109322. /**
  109323. * The name of the behavior
  109324. */
  109325. get name(): string;
  109326. /**
  109327. * Initializes the behavior
  109328. */
  109329. init(): void;
  109330. /**
  109331. * Attaches the fade behavior on the passed in mesh
  109332. * @param ownerNode The mesh that will be faded in/out once attached
  109333. */
  109334. attach(ownerNode: Mesh): void;
  109335. /**
  109336. * Detaches the behavior from the mesh
  109337. */
  109338. detach(): void;
  109339. /**
  109340. * Triggers the mesh to begin fading in or out
  109341. * @param value if the object should fade in or out (true to fade in)
  109342. */
  109343. fadeIn(value: boolean): void;
  109344. private _update;
  109345. private _setAllVisibility;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /**
  109350. * Class containing a set of static utilities functions for managing Pivots
  109351. * @hidden
  109352. */
  109353. export class PivotTools {
  109354. private static _PivotCached;
  109355. private static _OldPivotPoint;
  109356. private static _PivotTranslation;
  109357. private static _PivotTmpVector;
  109358. /** @hidden */
  109359. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109360. /** @hidden */
  109361. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109362. }
  109363. }
  109364. declare module BABYLON {
  109365. /**
  109366. * Class containing static functions to help procedurally build meshes
  109367. */
  109368. export class PlaneBuilder {
  109369. /**
  109370. * Creates a plane mesh
  109371. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109372. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109373. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109377. * @param name defines the name of the mesh
  109378. * @param options defines the options used to create the mesh
  109379. * @param scene defines the hosting scene
  109380. * @returns the plane mesh
  109381. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109382. */
  109383. static CreatePlane(name: string, options: {
  109384. size?: number;
  109385. width?: number;
  109386. height?: number;
  109387. sideOrientation?: number;
  109388. frontUVs?: Vector4;
  109389. backUVs?: Vector4;
  109390. updatable?: boolean;
  109391. sourcePlane?: Plane;
  109392. }, scene?: Nullable<Scene>): Mesh;
  109393. }
  109394. }
  109395. declare module BABYLON {
  109396. /**
  109397. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109398. */
  109399. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109400. private static _AnyMouseID;
  109401. /**
  109402. * Abstract mesh the behavior is set on
  109403. */
  109404. attachedNode: AbstractMesh;
  109405. private _dragPlane;
  109406. private _scene;
  109407. private _pointerObserver;
  109408. private _beforeRenderObserver;
  109409. private static _planeScene;
  109410. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109411. /**
  109412. * 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)
  109413. */
  109414. maxDragAngle: number;
  109415. /**
  109416. * @hidden
  109417. */
  109418. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109419. /**
  109420. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109421. */
  109422. currentDraggingPointerID: number;
  109423. /**
  109424. * The last position where the pointer hit the drag plane in world space
  109425. */
  109426. lastDragPosition: Vector3;
  109427. /**
  109428. * If the behavior is currently in a dragging state
  109429. */
  109430. dragging: boolean;
  109431. /**
  109432. * 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)
  109433. */
  109434. dragDeltaRatio: number;
  109435. /**
  109436. * If the drag plane orientation should be updated during the dragging (Default: true)
  109437. */
  109438. updateDragPlane: boolean;
  109439. private _debugMode;
  109440. private _moving;
  109441. /**
  109442. * Fires each time the attached mesh is dragged with the pointer
  109443. * * delta between last drag position and current drag position in world space
  109444. * * dragDistance along the drag axis
  109445. * * dragPlaneNormal normal of the current drag plane used during the drag
  109446. * * dragPlanePoint in world space where the drag intersects the drag plane
  109447. */
  109448. onDragObservable: Observable<{
  109449. delta: Vector3;
  109450. dragPlanePoint: Vector3;
  109451. dragPlaneNormal: Vector3;
  109452. dragDistance: number;
  109453. pointerId: number;
  109454. }>;
  109455. /**
  109456. * Fires each time a drag begins (eg. mouse down on mesh)
  109457. */
  109458. onDragStartObservable: Observable<{
  109459. dragPlanePoint: Vector3;
  109460. pointerId: number;
  109461. }>;
  109462. /**
  109463. * Fires each time a drag ends (eg. mouse release after drag)
  109464. */
  109465. onDragEndObservable: Observable<{
  109466. dragPlanePoint: Vector3;
  109467. pointerId: number;
  109468. }>;
  109469. /**
  109470. * If the attached mesh should be moved when dragged
  109471. */
  109472. moveAttached: boolean;
  109473. /**
  109474. * If the drag behavior will react to drag events (Default: true)
  109475. */
  109476. enabled: boolean;
  109477. /**
  109478. * If pointer events should start and release the drag (Default: true)
  109479. */
  109480. startAndReleaseDragOnPointerEvents: boolean;
  109481. /**
  109482. * If camera controls should be detached during the drag
  109483. */
  109484. detachCameraControls: boolean;
  109485. /**
  109486. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109487. */
  109488. useObjectOrienationForDragging: boolean;
  109489. private _options;
  109490. /**
  109491. * Gets the options used by the behavior
  109492. */
  109493. get options(): {
  109494. dragAxis?: Vector3;
  109495. dragPlaneNormal?: Vector3;
  109496. };
  109497. /**
  109498. * Sets the options used by the behavior
  109499. */
  109500. set options(options: {
  109501. dragAxis?: Vector3;
  109502. dragPlaneNormal?: Vector3;
  109503. });
  109504. /**
  109505. * Creates a pointer drag behavior that can be attached to a mesh
  109506. * @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)
  109507. */
  109508. constructor(options?: {
  109509. dragAxis?: Vector3;
  109510. dragPlaneNormal?: Vector3;
  109511. });
  109512. /**
  109513. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109514. */
  109515. validateDrag: (targetPosition: Vector3) => boolean;
  109516. /**
  109517. * The name of the behavior
  109518. */
  109519. get name(): string;
  109520. /**
  109521. * Initializes the behavior
  109522. */
  109523. init(): void;
  109524. private _tmpVector;
  109525. private _alternatePickedPoint;
  109526. private _worldDragAxis;
  109527. private _targetPosition;
  109528. private _attachedElement;
  109529. /**
  109530. * Attaches the drag behavior the passed in mesh
  109531. * @param ownerNode The mesh that will be dragged around once attached
  109532. * @param predicate Predicate to use for pick filtering
  109533. */
  109534. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109535. /**
  109536. * Force relase the drag action by code.
  109537. */
  109538. releaseDrag(): void;
  109539. private _startDragRay;
  109540. private _lastPointerRay;
  109541. /**
  109542. * Simulates the start of a pointer drag event on the behavior
  109543. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109544. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109545. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109546. */
  109547. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109548. private _startDrag;
  109549. private _dragDelta;
  109550. private _moveDrag;
  109551. private _pickWithRayOnDragPlane;
  109552. private _pointA;
  109553. private _pointB;
  109554. private _pointC;
  109555. private _lineA;
  109556. private _lineB;
  109557. private _localAxis;
  109558. private _lookAt;
  109559. private _updateDragPlanePosition;
  109560. /**
  109561. * Detaches the behavior from the mesh
  109562. */
  109563. detach(): void;
  109564. }
  109565. }
  109566. declare module BABYLON {
  109567. /**
  109568. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109569. */
  109570. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109571. private _dragBehaviorA;
  109572. private _dragBehaviorB;
  109573. private _startDistance;
  109574. private _initialScale;
  109575. private _targetScale;
  109576. private _ownerNode;
  109577. private _sceneRenderObserver;
  109578. /**
  109579. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109580. */
  109581. constructor();
  109582. /**
  109583. * The name of the behavior
  109584. */
  109585. get name(): string;
  109586. /**
  109587. * Initializes the behavior
  109588. */
  109589. init(): void;
  109590. private _getCurrentDistance;
  109591. /**
  109592. * Attaches the scale behavior the passed in mesh
  109593. * @param ownerNode The mesh that will be scaled around once attached
  109594. */
  109595. attach(ownerNode: Mesh): void;
  109596. /**
  109597. * Detaches the behavior from the mesh
  109598. */
  109599. detach(): void;
  109600. }
  109601. }
  109602. declare module BABYLON {
  109603. /**
  109604. * 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
  109605. */
  109606. export class SixDofDragBehavior implements Behavior<Mesh> {
  109607. private static _virtualScene;
  109608. private _ownerNode;
  109609. private _sceneRenderObserver;
  109610. private _scene;
  109611. private _targetPosition;
  109612. private _virtualOriginMesh;
  109613. private _virtualDragMesh;
  109614. private _pointerObserver;
  109615. private _moving;
  109616. private _startingOrientation;
  109617. /**
  109618. * 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)
  109619. */
  109620. private zDragFactor;
  109621. /**
  109622. * If the object should rotate to face the drag origin
  109623. */
  109624. rotateDraggedObject: boolean;
  109625. /**
  109626. * If the behavior is currently in a dragging state
  109627. */
  109628. dragging: boolean;
  109629. /**
  109630. * 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)
  109631. */
  109632. dragDeltaRatio: number;
  109633. /**
  109634. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109635. */
  109636. currentDraggingPointerID: number;
  109637. /**
  109638. * If camera controls should be detached during the drag
  109639. */
  109640. detachCameraControls: boolean;
  109641. /**
  109642. * Fires each time a drag starts
  109643. */
  109644. onDragStartObservable: Observable<{}>;
  109645. /**
  109646. * Fires each time a drag ends (eg. mouse release after drag)
  109647. */
  109648. onDragEndObservable: Observable<{}>;
  109649. /**
  109650. * 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
  109651. */
  109652. constructor();
  109653. /**
  109654. * The name of the behavior
  109655. */
  109656. get name(): string;
  109657. /**
  109658. * Initializes the behavior
  109659. */
  109660. init(): void;
  109661. /**
  109662. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109663. */
  109664. private get _pointerCamera();
  109665. /**
  109666. * Attaches the scale behavior the passed in mesh
  109667. * @param ownerNode The mesh that will be scaled around once attached
  109668. */
  109669. attach(ownerNode: Mesh): void;
  109670. /**
  109671. * Detaches the behavior from the mesh
  109672. */
  109673. detach(): void;
  109674. }
  109675. }
  109676. declare module BABYLON {
  109677. /**
  109678. * Class used to apply inverse kinematics to bones
  109679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109680. */
  109681. export class BoneIKController {
  109682. private static _tmpVecs;
  109683. private static _tmpQuat;
  109684. private static _tmpMats;
  109685. /**
  109686. * Gets or sets the target mesh
  109687. */
  109688. targetMesh: AbstractMesh;
  109689. /** Gets or sets the mesh used as pole */
  109690. poleTargetMesh: AbstractMesh;
  109691. /**
  109692. * Gets or sets the bone used as pole
  109693. */
  109694. poleTargetBone: Nullable<Bone>;
  109695. /**
  109696. * Gets or sets the target position
  109697. */
  109698. targetPosition: Vector3;
  109699. /**
  109700. * Gets or sets the pole target position
  109701. */
  109702. poleTargetPosition: Vector3;
  109703. /**
  109704. * Gets or sets the pole target local offset
  109705. */
  109706. poleTargetLocalOffset: Vector3;
  109707. /**
  109708. * Gets or sets the pole angle
  109709. */
  109710. poleAngle: number;
  109711. /**
  109712. * Gets or sets the mesh associated with the controller
  109713. */
  109714. mesh: AbstractMesh;
  109715. /**
  109716. * 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)
  109717. */
  109718. slerpAmount: number;
  109719. private _bone1Quat;
  109720. private _bone1Mat;
  109721. private _bone2Ang;
  109722. private _bone1;
  109723. private _bone2;
  109724. private _bone1Length;
  109725. private _bone2Length;
  109726. private _maxAngle;
  109727. private _maxReach;
  109728. private _rightHandedSystem;
  109729. private _bendAxis;
  109730. private _slerping;
  109731. private _adjustRoll;
  109732. /**
  109733. * Gets or sets maximum allowed angle
  109734. */
  109735. get maxAngle(): number;
  109736. set maxAngle(value: number);
  109737. /**
  109738. * Creates a new BoneIKController
  109739. * @param mesh defines the mesh to control
  109740. * @param bone defines the bone to control
  109741. * @param options defines options to set up the controller
  109742. */
  109743. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109744. targetMesh?: AbstractMesh;
  109745. poleTargetMesh?: AbstractMesh;
  109746. poleTargetBone?: Bone;
  109747. poleTargetLocalOffset?: Vector3;
  109748. poleAngle?: number;
  109749. bendAxis?: Vector3;
  109750. maxAngle?: number;
  109751. slerpAmount?: number;
  109752. });
  109753. private _setMaxAngle;
  109754. /**
  109755. * Force the controller to update the bones
  109756. */
  109757. update(): void;
  109758. }
  109759. }
  109760. declare module BABYLON {
  109761. /**
  109762. * Class used to make a bone look toward a point in space
  109763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109764. */
  109765. export class BoneLookController {
  109766. private static _tmpVecs;
  109767. private static _tmpQuat;
  109768. private static _tmpMats;
  109769. /**
  109770. * The target Vector3 that the bone will look at
  109771. */
  109772. target: Vector3;
  109773. /**
  109774. * The mesh that the bone is attached to
  109775. */
  109776. mesh: AbstractMesh;
  109777. /**
  109778. * The bone that will be looking to the target
  109779. */
  109780. bone: Bone;
  109781. /**
  109782. * The up axis of the coordinate system that is used when the bone is rotated
  109783. */
  109784. upAxis: Vector3;
  109785. /**
  109786. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109787. */
  109788. upAxisSpace: Space;
  109789. /**
  109790. * Used to make an adjustment to the yaw of the bone
  109791. */
  109792. adjustYaw: number;
  109793. /**
  109794. * Used to make an adjustment to the pitch of the bone
  109795. */
  109796. adjustPitch: number;
  109797. /**
  109798. * Used to make an adjustment to the roll of the bone
  109799. */
  109800. adjustRoll: number;
  109801. /**
  109802. * 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)
  109803. */
  109804. slerpAmount: number;
  109805. private _minYaw;
  109806. private _maxYaw;
  109807. private _minPitch;
  109808. private _maxPitch;
  109809. private _minYawSin;
  109810. private _minYawCos;
  109811. private _maxYawSin;
  109812. private _maxYawCos;
  109813. private _midYawConstraint;
  109814. private _minPitchTan;
  109815. private _maxPitchTan;
  109816. private _boneQuat;
  109817. private _slerping;
  109818. private _transformYawPitch;
  109819. private _transformYawPitchInv;
  109820. private _firstFrameSkipped;
  109821. private _yawRange;
  109822. private _fowardAxis;
  109823. /**
  109824. * Gets or sets the minimum yaw angle that the bone can look to
  109825. */
  109826. get minYaw(): number;
  109827. set minYaw(value: number);
  109828. /**
  109829. * Gets or sets the maximum yaw angle that the bone can look to
  109830. */
  109831. get maxYaw(): number;
  109832. set maxYaw(value: number);
  109833. /**
  109834. * Gets or sets the minimum pitch angle that the bone can look to
  109835. */
  109836. get minPitch(): number;
  109837. set minPitch(value: number);
  109838. /**
  109839. * Gets or sets the maximum pitch angle that the bone can look to
  109840. */
  109841. get maxPitch(): number;
  109842. set maxPitch(value: number);
  109843. /**
  109844. * Create a BoneLookController
  109845. * @param mesh the mesh that the bone belongs to
  109846. * @param bone the bone that will be looking to the target
  109847. * @param target the target Vector3 to look at
  109848. * @param options optional settings:
  109849. * * maxYaw: the maximum angle the bone will yaw to
  109850. * * minYaw: the minimum angle the bone will yaw to
  109851. * * maxPitch: the maximum angle the bone will pitch to
  109852. * * minPitch: the minimum angle the bone will yaw to
  109853. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109854. * * upAxis: the up axis of the coordinate system
  109855. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109856. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109857. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109858. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109859. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109860. * * adjustRoll: used to make an adjustment to the roll of the bone
  109861. **/
  109862. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109863. maxYaw?: number;
  109864. minYaw?: number;
  109865. maxPitch?: number;
  109866. minPitch?: number;
  109867. slerpAmount?: number;
  109868. upAxis?: Vector3;
  109869. upAxisSpace?: Space;
  109870. yawAxis?: Vector3;
  109871. pitchAxis?: Vector3;
  109872. adjustYaw?: number;
  109873. adjustPitch?: number;
  109874. adjustRoll?: number;
  109875. });
  109876. /**
  109877. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  109878. */
  109879. update(): void;
  109880. private _getAngleDiff;
  109881. private _getAngleBetween;
  109882. private _isAngleBetween;
  109883. }
  109884. }
  109885. declare module BABYLON {
  109886. /**
  109887. * Manage the gamepad inputs to control an arc rotate camera.
  109888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109889. */
  109890. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  109891. /**
  109892. * Defines the camera the input is attached to.
  109893. */
  109894. camera: ArcRotateCamera;
  109895. /**
  109896. * Defines the gamepad the input is gathering event from.
  109897. */
  109898. gamepad: Nullable<Gamepad>;
  109899. /**
  109900. * Defines the gamepad rotation sensiblity.
  109901. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109902. */
  109903. gamepadRotationSensibility: number;
  109904. /**
  109905. * Defines the gamepad move sensiblity.
  109906. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109907. */
  109908. gamepadMoveSensibility: number;
  109909. private _yAxisScale;
  109910. /**
  109911. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109912. */
  109913. get invertYAxis(): boolean;
  109914. set invertYAxis(value: boolean);
  109915. private _onGamepadConnectedObserver;
  109916. private _onGamepadDisconnectedObserver;
  109917. /**
  109918. * Attach the input controls to a specific dom element to get the input from.
  109919. * @param element Defines the element the controls should be listened from
  109920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109921. */
  109922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109923. /**
  109924. * Detach the current controls from the specified dom element.
  109925. * @param element Defines the element to stop listening the inputs from
  109926. */
  109927. detachControl(element: Nullable<HTMLElement>): void;
  109928. /**
  109929. * Update the current camera state depending on the inputs that have been used this frame.
  109930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109931. */
  109932. checkInputs(): void;
  109933. /**
  109934. * Gets the class name of the current intput.
  109935. * @returns the class name
  109936. */
  109937. getClassName(): string;
  109938. /**
  109939. * Get the friendly name associated with the input class.
  109940. * @returns the input friendly name
  109941. */
  109942. getSimpleName(): string;
  109943. }
  109944. }
  109945. declare module BABYLON {
  109946. interface ArcRotateCameraInputsManager {
  109947. /**
  109948. * Add orientation input support to the input manager.
  109949. * @returns the current input manager
  109950. */
  109951. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  109952. }
  109953. /**
  109954. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  109955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109956. */
  109957. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  109958. /**
  109959. * Defines the camera the input is attached to.
  109960. */
  109961. camera: ArcRotateCamera;
  109962. /**
  109963. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  109964. */
  109965. alphaCorrection: number;
  109966. /**
  109967. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  109968. */
  109969. gammaCorrection: number;
  109970. private _alpha;
  109971. private _gamma;
  109972. private _dirty;
  109973. private _deviceOrientationHandler;
  109974. /**
  109975. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  109976. */
  109977. constructor();
  109978. /**
  109979. * Attach the input controls to a specific dom element to get the input from.
  109980. * @param element Defines the element the controls should be listened from
  109981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109982. */
  109983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109984. /** @hidden */
  109985. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  109986. /**
  109987. * Update the current camera state depending on the inputs that have been used this frame.
  109988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109989. */
  109990. checkInputs(): void;
  109991. /**
  109992. * Detach the current controls from the specified dom element.
  109993. * @param element Defines the element to stop listening the inputs from
  109994. */
  109995. detachControl(element: Nullable<HTMLElement>): void;
  109996. /**
  109997. * Gets the class name of the current intput.
  109998. * @returns the class name
  109999. */
  110000. getClassName(): string;
  110001. /**
  110002. * Get the friendly name associated with the input class.
  110003. * @returns the input friendly name
  110004. */
  110005. getSimpleName(): string;
  110006. }
  110007. }
  110008. declare module BABYLON {
  110009. /**
  110010. * Listen to mouse events to control the camera.
  110011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110012. */
  110013. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110014. /**
  110015. * Defines the camera the input is attached to.
  110016. */
  110017. camera: FlyCamera;
  110018. /**
  110019. * Defines if touch is enabled. (Default is true.)
  110020. */
  110021. touchEnabled: boolean;
  110022. /**
  110023. * Defines the buttons associated with the input to handle camera rotation.
  110024. */
  110025. buttons: number[];
  110026. /**
  110027. * Assign buttons for Yaw control.
  110028. */
  110029. buttonsYaw: number[];
  110030. /**
  110031. * Assign buttons for Pitch control.
  110032. */
  110033. buttonsPitch: number[];
  110034. /**
  110035. * Assign buttons for Roll control.
  110036. */
  110037. buttonsRoll: number[];
  110038. /**
  110039. * Detect if any button is being pressed while mouse is moved.
  110040. * -1 = Mouse locked.
  110041. * 0 = Left button.
  110042. * 1 = Middle Button.
  110043. * 2 = Right Button.
  110044. */
  110045. activeButton: number;
  110046. /**
  110047. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110048. * Higher values reduce its sensitivity.
  110049. */
  110050. angularSensibility: number;
  110051. private _mousemoveCallback;
  110052. private _observer;
  110053. private _rollObserver;
  110054. private previousPosition;
  110055. private noPreventDefault;
  110056. private element;
  110057. /**
  110058. * Listen to mouse events to control the camera.
  110059. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110061. */
  110062. constructor(touchEnabled?: boolean);
  110063. /**
  110064. * Attach the mouse control to the HTML DOM element.
  110065. * @param element Defines the element that listens to the input events.
  110066. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110067. */
  110068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110069. /**
  110070. * Detach the current controls from the specified dom element.
  110071. * @param element Defines the element to stop listening the inputs from
  110072. */
  110073. detachControl(element: Nullable<HTMLElement>): void;
  110074. /**
  110075. * Gets the class name of the current input.
  110076. * @returns the class name.
  110077. */
  110078. getClassName(): string;
  110079. /**
  110080. * Get the friendly name associated with the input class.
  110081. * @returns the input's friendly name.
  110082. */
  110083. getSimpleName(): string;
  110084. private _pointerInput;
  110085. private _onMouseMove;
  110086. /**
  110087. * Rotate camera by mouse offset.
  110088. */
  110089. private rotateCamera;
  110090. }
  110091. }
  110092. declare module BABYLON {
  110093. /**
  110094. * Default Inputs manager for the FlyCamera.
  110095. * It groups all the default supported inputs for ease of use.
  110096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110097. */
  110098. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110099. /**
  110100. * Instantiates a new FlyCameraInputsManager.
  110101. * @param camera Defines the camera the inputs belong to.
  110102. */
  110103. constructor(camera: FlyCamera);
  110104. /**
  110105. * Add keyboard input support to the input manager.
  110106. * @returns the new FlyCameraKeyboardMoveInput().
  110107. */
  110108. addKeyboard(): FlyCameraInputsManager;
  110109. /**
  110110. * Add mouse input support to the input manager.
  110111. * @param touchEnabled Enable touch screen support.
  110112. * @returns the new FlyCameraMouseInput().
  110113. */
  110114. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110115. }
  110116. }
  110117. declare module BABYLON {
  110118. /**
  110119. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110120. * such as in a 3D Space Shooter or a Flight Simulator.
  110121. */
  110122. export class FlyCamera extends TargetCamera {
  110123. /**
  110124. * Define the collision ellipsoid of the camera.
  110125. * This is helpful for simulating a camera body, like a player's body.
  110126. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110127. */
  110128. ellipsoid: Vector3;
  110129. /**
  110130. * Define an offset for the position of the ellipsoid around the camera.
  110131. * This can be helpful if the camera is attached away from the player's body center,
  110132. * such as at its head.
  110133. */
  110134. ellipsoidOffset: Vector3;
  110135. /**
  110136. * Enable or disable collisions of the camera with the rest of the scene objects.
  110137. */
  110138. checkCollisions: boolean;
  110139. /**
  110140. * Enable or disable gravity on the camera.
  110141. */
  110142. applyGravity: boolean;
  110143. /**
  110144. * Define the current direction the camera is moving to.
  110145. */
  110146. cameraDirection: Vector3;
  110147. /**
  110148. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110149. * This overrides and empties cameraRotation.
  110150. */
  110151. rotationQuaternion: Quaternion;
  110152. /**
  110153. * Track Roll to maintain the wanted Rolling when looking around.
  110154. */
  110155. _trackRoll: number;
  110156. /**
  110157. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110158. */
  110159. rollCorrect: number;
  110160. /**
  110161. * Mimic a banked turn, Rolling the camera when Yawing.
  110162. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110163. */
  110164. bankedTurn: boolean;
  110165. /**
  110166. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110167. */
  110168. bankedTurnLimit: number;
  110169. /**
  110170. * Value of 0 disables the banked Roll.
  110171. * Value of 1 is equal to the Yaw angle in radians.
  110172. */
  110173. bankedTurnMultiplier: number;
  110174. /**
  110175. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110176. */
  110177. inputs: FlyCameraInputsManager;
  110178. /**
  110179. * Gets the input sensibility for mouse input.
  110180. * Higher values reduce sensitivity.
  110181. */
  110182. get angularSensibility(): number;
  110183. /**
  110184. * Sets the input sensibility for a mouse input.
  110185. * Higher values reduce sensitivity.
  110186. */
  110187. set angularSensibility(value: number);
  110188. /**
  110189. * Get the keys for camera movement forward.
  110190. */
  110191. get keysForward(): number[];
  110192. /**
  110193. * Set the keys for camera movement forward.
  110194. */
  110195. set keysForward(value: number[]);
  110196. /**
  110197. * Get the keys for camera movement backward.
  110198. */
  110199. get keysBackward(): number[];
  110200. set keysBackward(value: number[]);
  110201. /**
  110202. * Get the keys for camera movement up.
  110203. */
  110204. get keysUp(): number[];
  110205. /**
  110206. * Set the keys for camera movement up.
  110207. */
  110208. set keysUp(value: number[]);
  110209. /**
  110210. * Get the keys for camera movement down.
  110211. */
  110212. get keysDown(): number[];
  110213. /**
  110214. * Set the keys for camera movement down.
  110215. */
  110216. set keysDown(value: number[]);
  110217. /**
  110218. * Get the keys for camera movement left.
  110219. */
  110220. get keysLeft(): number[];
  110221. /**
  110222. * Set the keys for camera movement left.
  110223. */
  110224. set keysLeft(value: number[]);
  110225. /**
  110226. * Set the keys for camera movement right.
  110227. */
  110228. get keysRight(): number[];
  110229. /**
  110230. * Set the keys for camera movement right.
  110231. */
  110232. set keysRight(value: number[]);
  110233. /**
  110234. * Event raised when the camera collides with a mesh in the scene.
  110235. */
  110236. onCollide: (collidedMesh: AbstractMesh) => void;
  110237. private _collider;
  110238. private _needMoveForGravity;
  110239. private _oldPosition;
  110240. private _diffPosition;
  110241. private _newPosition;
  110242. /** @hidden */
  110243. _localDirection: Vector3;
  110244. /** @hidden */
  110245. _transformedDirection: Vector3;
  110246. /**
  110247. * Instantiates a FlyCamera.
  110248. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110249. * such as in a 3D Space Shooter or a Flight Simulator.
  110250. * @param name Define the name of the camera in the scene.
  110251. * @param position Define the starting position of the camera in the scene.
  110252. * @param scene Define the scene the camera belongs to.
  110253. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110254. */
  110255. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110256. /**
  110257. * Attach a control to the HTML DOM element.
  110258. * @param element Defines the element that listens to the input events.
  110259. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110260. */
  110261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110262. /**
  110263. * Detach a control from the HTML DOM element.
  110264. * The camera will stop reacting to that input.
  110265. * @param element Defines the element that listens to the input events.
  110266. */
  110267. detachControl(element: HTMLElement): void;
  110268. private _collisionMask;
  110269. /**
  110270. * Get the mask that the camera ignores in collision events.
  110271. */
  110272. get collisionMask(): number;
  110273. /**
  110274. * Set the mask that the camera ignores in collision events.
  110275. */
  110276. set collisionMask(mask: number);
  110277. /** @hidden */
  110278. _collideWithWorld(displacement: Vector3): void;
  110279. /** @hidden */
  110280. private _onCollisionPositionChange;
  110281. /** @hidden */
  110282. _checkInputs(): void;
  110283. /** @hidden */
  110284. _decideIfNeedsToMove(): boolean;
  110285. /** @hidden */
  110286. _updatePosition(): void;
  110287. /**
  110288. * Restore the Roll to its target value at the rate specified.
  110289. * @param rate - Higher means slower restoring.
  110290. * @hidden
  110291. */
  110292. restoreRoll(rate: number): void;
  110293. /**
  110294. * Destroy the camera and release the current resources held by it.
  110295. */
  110296. dispose(): void;
  110297. /**
  110298. * Get the current object class name.
  110299. * @returns the class name.
  110300. */
  110301. getClassName(): string;
  110302. }
  110303. }
  110304. declare module BABYLON {
  110305. /**
  110306. * Listen to keyboard events to control the camera.
  110307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110308. */
  110309. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110310. /**
  110311. * Defines the camera the input is attached to.
  110312. */
  110313. camera: FlyCamera;
  110314. /**
  110315. * The list of keyboard keys used to control the forward move of the camera.
  110316. */
  110317. keysForward: number[];
  110318. /**
  110319. * The list of keyboard keys used to control the backward move of the camera.
  110320. */
  110321. keysBackward: number[];
  110322. /**
  110323. * The list of keyboard keys used to control the forward move of the camera.
  110324. */
  110325. keysUp: number[];
  110326. /**
  110327. * The list of keyboard keys used to control the backward move of the camera.
  110328. */
  110329. keysDown: number[];
  110330. /**
  110331. * The list of keyboard keys used to control the right strafe move of the camera.
  110332. */
  110333. keysRight: number[];
  110334. /**
  110335. * The list of keyboard keys used to control the left strafe move of the camera.
  110336. */
  110337. keysLeft: number[];
  110338. private _keys;
  110339. private _onCanvasBlurObserver;
  110340. private _onKeyboardObserver;
  110341. private _engine;
  110342. private _scene;
  110343. /**
  110344. * Attach the input controls to a specific dom element to get the input from.
  110345. * @param element Defines the element the controls should be listened from
  110346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110347. */
  110348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110349. /**
  110350. * Detach the current controls from the specified dom element.
  110351. * @param element Defines the element to stop listening the inputs from
  110352. */
  110353. detachControl(element: Nullable<HTMLElement>): void;
  110354. /**
  110355. * Gets the class name of the current intput.
  110356. * @returns the class name
  110357. */
  110358. getClassName(): string;
  110359. /** @hidden */
  110360. _onLostFocus(e: FocusEvent): void;
  110361. /**
  110362. * Get the friendly name associated with the input class.
  110363. * @returns the input friendly name
  110364. */
  110365. getSimpleName(): string;
  110366. /**
  110367. * Update the current camera state depending on the inputs that have been used this frame.
  110368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110369. */
  110370. checkInputs(): void;
  110371. }
  110372. }
  110373. declare module BABYLON {
  110374. /**
  110375. * Manage the mouse wheel inputs to control a follow camera.
  110376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110377. */
  110378. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110379. /**
  110380. * Defines the camera the input is attached to.
  110381. */
  110382. camera: FollowCamera;
  110383. /**
  110384. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110385. */
  110386. axisControlRadius: boolean;
  110387. /**
  110388. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110389. */
  110390. axisControlHeight: boolean;
  110391. /**
  110392. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110393. */
  110394. axisControlRotation: boolean;
  110395. /**
  110396. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110397. * relation to mouseWheel events.
  110398. */
  110399. wheelPrecision: number;
  110400. /**
  110401. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110402. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110403. */
  110404. wheelDeltaPercentage: number;
  110405. private _wheel;
  110406. private _observer;
  110407. /**
  110408. * Attach the input controls to a specific dom element to get the input from.
  110409. * @param element Defines the element the controls should be listened from
  110410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110411. */
  110412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110413. /**
  110414. * Detach the current controls from the specified dom element.
  110415. * @param element Defines the element to stop listening the inputs from
  110416. */
  110417. detachControl(element: Nullable<HTMLElement>): void;
  110418. /**
  110419. * Gets the class name of the current intput.
  110420. * @returns the class name
  110421. */
  110422. getClassName(): string;
  110423. /**
  110424. * Get the friendly name associated with the input class.
  110425. * @returns the input friendly name
  110426. */
  110427. getSimpleName(): string;
  110428. }
  110429. }
  110430. declare module BABYLON {
  110431. /**
  110432. * Manage the pointers inputs to control an follow camera.
  110433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110434. */
  110435. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110436. /**
  110437. * Defines the camera the input is attached to.
  110438. */
  110439. camera: FollowCamera;
  110440. /**
  110441. * Gets the class name of the current input.
  110442. * @returns the class name
  110443. */
  110444. getClassName(): string;
  110445. /**
  110446. * Defines the pointer angular sensibility along the X axis or how fast is
  110447. * the camera rotating.
  110448. * A negative number will reverse the axis direction.
  110449. */
  110450. angularSensibilityX: number;
  110451. /**
  110452. * Defines the pointer angular sensibility along the Y axis or how fast is
  110453. * the camera rotating.
  110454. * A negative number will reverse the axis direction.
  110455. */
  110456. angularSensibilityY: number;
  110457. /**
  110458. * Defines the pointer pinch precision or how fast is the camera zooming.
  110459. * A negative number will reverse the axis direction.
  110460. */
  110461. pinchPrecision: number;
  110462. /**
  110463. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110464. * from 0.
  110465. * It defines the percentage of current camera.radius to use as delta when
  110466. * pinch zoom is used.
  110467. */
  110468. pinchDeltaPercentage: number;
  110469. /**
  110470. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110471. */
  110472. axisXControlRadius: boolean;
  110473. /**
  110474. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110475. */
  110476. axisXControlHeight: boolean;
  110477. /**
  110478. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110479. */
  110480. axisXControlRotation: boolean;
  110481. /**
  110482. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110483. */
  110484. axisYControlRadius: boolean;
  110485. /**
  110486. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110487. */
  110488. axisYControlHeight: boolean;
  110489. /**
  110490. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110491. */
  110492. axisYControlRotation: boolean;
  110493. /**
  110494. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110495. */
  110496. axisPinchControlRadius: boolean;
  110497. /**
  110498. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110499. */
  110500. axisPinchControlHeight: boolean;
  110501. /**
  110502. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110503. */
  110504. axisPinchControlRotation: boolean;
  110505. /**
  110506. * Log error messages if basic misconfiguration has occurred.
  110507. */
  110508. warningEnable: boolean;
  110509. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110510. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110511. private _warningCounter;
  110512. private _warning;
  110513. }
  110514. }
  110515. declare module BABYLON {
  110516. /**
  110517. * Default Inputs manager for the FollowCamera.
  110518. * It groups all the default supported inputs for ease of use.
  110519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110520. */
  110521. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110522. /**
  110523. * Instantiates a new FollowCameraInputsManager.
  110524. * @param camera Defines the camera the inputs belong to
  110525. */
  110526. constructor(camera: FollowCamera);
  110527. /**
  110528. * Add keyboard input support to the input manager.
  110529. * @returns the current input manager
  110530. */
  110531. addKeyboard(): FollowCameraInputsManager;
  110532. /**
  110533. * Add mouse wheel input support to the input manager.
  110534. * @returns the current input manager
  110535. */
  110536. addMouseWheel(): FollowCameraInputsManager;
  110537. /**
  110538. * Add pointers input support to the input manager.
  110539. * @returns the current input manager
  110540. */
  110541. addPointers(): FollowCameraInputsManager;
  110542. /**
  110543. * Add orientation input support to the input manager.
  110544. * @returns the current input manager
  110545. */
  110546. addVRDeviceOrientation(): FollowCameraInputsManager;
  110547. }
  110548. }
  110549. declare module BABYLON {
  110550. /**
  110551. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110552. * an arc rotate version arcFollowCamera are available.
  110553. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110554. */
  110555. export class FollowCamera extends TargetCamera {
  110556. /**
  110557. * Distance the follow camera should follow an object at
  110558. */
  110559. radius: number;
  110560. /**
  110561. * Minimum allowed distance of the camera to the axis of rotation
  110562. * (The camera can not get closer).
  110563. * This can help limiting how the Camera is able to move in the scene.
  110564. */
  110565. lowerRadiusLimit: Nullable<number>;
  110566. /**
  110567. * Maximum allowed distance of the camera to the axis of rotation
  110568. * (The camera can not get further).
  110569. * This can help limiting how the Camera is able to move in the scene.
  110570. */
  110571. upperRadiusLimit: Nullable<number>;
  110572. /**
  110573. * Define a rotation offset between the camera and the object it follows
  110574. */
  110575. rotationOffset: number;
  110576. /**
  110577. * Minimum allowed angle to camera position relative to target object.
  110578. * This can help limiting how the Camera is able to move in the scene.
  110579. */
  110580. lowerRotationOffsetLimit: Nullable<number>;
  110581. /**
  110582. * Maximum allowed angle to camera position relative to target object.
  110583. * This can help limiting how the Camera is able to move in the scene.
  110584. */
  110585. upperRotationOffsetLimit: Nullable<number>;
  110586. /**
  110587. * Define a height offset between the camera and the object it follows.
  110588. * It can help following an object from the top (like a car chaing a plane)
  110589. */
  110590. heightOffset: number;
  110591. /**
  110592. * Minimum allowed height of camera position relative to target object.
  110593. * This can help limiting how the Camera is able to move in the scene.
  110594. */
  110595. lowerHeightOffsetLimit: Nullable<number>;
  110596. /**
  110597. * Maximum allowed height of camera position relative to target object.
  110598. * This can help limiting how the Camera is able to move in the scene.
  110599. */
  110600. upperHeightOffsetLimit: Nullable<number>;
  110601. /**
  110602. * Define how fast the camera can accelerate to follow it s target.
  110603. */
  110604. cameraAcceleration: number;
  110605. /**
  110606. * Define the speed limit of the camera following an object.
  110607. */
  110608. maxCameraSpeed: number;
  110609. /**
  110610. * Define the target of the camera.
  110611. */
  110612. lockedTarget: Nullable<AbstractMesh>;
  110613. /**
  110614. * Defines the input associated with the camera.
  110615. */
  110616. inputs: FollowCameraInputsManager;
  110617. /**
  110618. * Instantiates the follow camera.
  110619. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110620. * @param name Define the name of the camera in the scene
  110621. * @param position Define the position of the camera
  110622. * @param scene Define the scene the camera belong to
  110623. * @param lockedTarget Define the target of the camera
  110624. */
  110625. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110626. private _follow;
  110627. /**
  110628. * Attached controls to the current camera.
  110629. * @param element Defines the element the controls should be listened from
  110630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110631. */
  110632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110633. /**
  110634. * Detach the current controls from the camera.
  110635. * The camera will stop reacting to inputs.
  110636. * @param element Defines the element to stop listening the inputs from
  110637. */
  110638. detachControl(element: HTMLElement): void;
  110639. /** @hidden */
  110640. _checkInputs(): void;
  110641. private _checkLimits;
  110642. /**
  110643. * Gets the camera class name.
  110644. * @returns the class name
  110645. */
  110646. getClassName(): string;
  110647. }
  110648. /**
  110649. * Arc Rotate version of the follow camera.
  110650. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110651. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110652. */
  110653. export class ArcFollowCamera extends TargetCamera {
  110654. /** The longitudinal angle of the camera */
  110655. alpha: number;
  110656. /** The latitudinal angle of the camera */
  110657. beta: number;
  110658. /** The radius of the camera from its target */
  110659. radius: number;
  110660. /** Define the camera target (the messh it should follow) */
  110661. target: Nullable<AbstractMesh>;
  110662. private _cartesianCoordinates;
  110663. /**
  110664. * Instantiates a new ArcFollowCamera
  110665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110666. * @param name Define the name of the camera
  110667. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110668. * @param beta Define the rotation angle of the camera around the elevation axis
  110669. * @param radius Define the radius of the camera from its target point
  110670. * @param target Define the target of the camera
  110671. * @param scene Define the scene the camera belongs to
  110672. */
  110673. constructor(name: string,
  110674. /** The longitudinal angle of the camera */
  110675. alpha: number,
  110676. /** The latitudinal angle of the camera */
  110677. beta: number,
  110678. /** The radius of the camera from its target */
  110679. radius: number,
  110680. /** Define the camera target (the messh it should follow) */
  110681. target: Nullable<AbstractMesh>, scene: Scene);
  110682. private _follow;
  110683. /** @hidden */
  110684. _checkInputs(): void;
  110685. /**
  110686. * Returns the class name of the object.
  110687. * It is mostly used internally for serialization purposes.
  110688. */
  110689. getClassName(): string;
  110690. }
  110691. }
  110692. declare module BABYLON {
  110693. /**
  110694. * Manage the keyboard inputs to control the movement of a follow camera.
  110695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110696. */
  110697. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110698. /**
  110699. * Defines the camera the input is attached to.
  110700. */
  110701. camera: FollowCamera;
  110702. /**
  110703. * Defines the list of key codes associated with the up action (increase heightOffset)
  110704. */
  110705. keysHeightOffsetIncr: number[];
  110706. /**
  110707. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110708. */
  110709. keysHeightOffsetDecr: number[];
  110710. /**
  110711. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110712. */
  110713. keysHeightOffsetModifierAlt: boolean;
  110714. /**
  110715. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110716. */
  110717. keysHeightOffsetModifierCtrl: boolean;
  110718. /**
  110719. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110720. */
  110721. keysHeightOffsetModifierShift: boolean;
  110722. /**
  110723. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110724. */
  110725. keysRotationOffsetIncr: number[];
  110726. /**
  110727. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110728. */
  110729. keysRotationOffsetDecr: number[];
  110730. /**
  110731. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110732. */
  110733. keysRotationOffsetModifierAlt: boolean;
  110734. /**
  110735. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110736. */
  110737. keysRotationOffsetModifierCtrl: boolean;
  110738. /**
  110739. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110740. */
  110741. keysRotationOffsetModifierShift: boolean;
  110742. /**
  110743. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110744. */
  110745. keysRadiusIncr: number[];
  110746. /**
  110747. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110748. */
  110749. keysRadiusDecr: number[];
  110750. /**
  110751. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110752. */
  110753. keysRadiusModifierAlt: boolean;
  110754. /**
  110755. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110756. */
  110757. keysRadiusModifierCtrl: boolean;
  110758. /**
  110759. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110760. */
  110761. keysRadiusModifierShift: boolean;
  110762. /**
  110763. * Defines the rate of change of heightOffset.
  110764. */
  110765. heightSensibility: number;
  110766. /**
  110767. * Defines the rate of change of rotationOffset.
  110768. */
  110769. rotationSensibility: number;
  110770. /**
  110771. * Defines the rate of change of radius.
  110772. */
  110773. radiusSensibility: number;
  110774. private _keys;
  110775. private _ctrlPressed;
  110776. private _altPressed;
  110777. private _shiftPressed;
  110778. private _onCanvasBlurObserver;
  110779. private _onKeyboardObserver;
  110780. private _engine;
  110781. private _scene;
  110782. /**
  110783. * Attach the input controls to a specific dom element to get the input from.
  110784. * @param element Defines the element the controls should be listened from
  110785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110786. */
  110787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110788. /**
  110789. * Detach the current controls from the specified dom element.
  110790. * @param element Defines the element to stop listening the inputs from
  110791. */
  110792. detachControl(element: Nullable<HTMLElement>): void;
  110793. /**
  110794. * Update the current camera state depending on the inputs that have been used this frame.
  110795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110796. */
  110797. checkInputs(): void;
  110798. /**
  110799. * Gets the class name of the current input.
  110800. * @returns the class name
  110801. */
  110802. getClassName(): string;
  110803. /**
  110804. * Get the friendly name associated with the input class.
  110805. * @returns the input friendly name
  110806. */
  110807. getSimpleName(): string;
  110808. /**
  110809. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110810. * allow modification of the heightOffset value.
  110811. */
  110812. private _modifierHeightOffset;
  110813. /**
  110814. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110815. * allow modification of the rotationOffset value.
  110816. */
  110817. private _modifierRotationOffset;
  110818. /**
  110819. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110820. * allow modification of the radius value.
  110821. */
  110822. private _modifierRadius;
  110823. }
  110824. }
  110825. declare module BABYLON {
  110826. interface FreeCameraInputsManager {
  110827. /**
  110828. * @hidden
  110829. */
  110830. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110831. /**
  110832. * Add orientation input support to the input manager.
  110833. * @returns the current input manager
  110834. */
  110835. addDeviceOrientation(): FreeCameraInputsManager;
  110836. }
  110837. /**
  110838. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110839. * Screen rotation is taken into account.
  110840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110841. */
  110842. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110843. private _camera;
  110844. private _screenOrientationAngle;
  110845. private _constantTranform;
  110846. private _screenQuaternion;
  110847. private _alpha;
  110848. private _beta;
  110849. private _gamma;
  110850. /**
  110851. * Can be used to detect if a device orientation sensor is available on a device
  110852. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110853. * @returns a promise that will resolve on orientation change
  110854. */
  110855. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110856. /**
  110857. * @hidden
  110858. */
  110859. _onDeviceOrientationChangedObservable: Observable<void>;
  110860. /**
  110861. * Instantiates a new input
  110862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110863. */
  110864. constructor();
  110865. /**
  110866. * Define the camera controlled by the input.
  110867. */
  110868. get camera(): FreeCamera;
  110869. set camera(camera: FreeCamera);
  110870. /**
  110871. * Attach the input controls to a specific dom element to get the input from.
  110872. * @param element Defines the element the controls should be listened from
  110873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110874. */
  110875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110876. private _orientationChanged;
  110877. private _deviceOrientation;
  110878. /**
  110879. * Detach the current controls from the specified dom element.
  110880. * @param element Defines the element to stop listening the inputs from
  110881. */
  110882. detachControl(element: Nullable<HTMLElement>): void;
  110883. /**
  110884. * Update the current camera state depending on the inputs that have been used this frame.
  110885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110886. */
  110887. checkInputs(): void;
  110888. /**
  110889. * Gets the class name of the current intput.
  110890. * @returns the class name
  110891. */
  110892. getClassName(): string;
  110893. /**
  110894. * Get the friendly name associated with the input class.
  110895. * @returns the input friendly name
  110896. */
  110897. getSimpleName(): string;
  110898. }
  110899. }
  110900. declare module BABYLON {
  110901. /**
  110902. * Manage the gamepad inputs to control a free camera.
  110903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110904. */
  110905. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  110906. /**
  110907. * Define the camera the input is attached to.
  110908. */
  110909. camera: FreeCamera;
  110910. /**
  110911. * Define the Gamepad controlling the input
  110912. */
  110913. gamepad: Nullable<Gamepad>;
  110914. /**
  110915. * Defines the gamepad rotation sensiblity.
  110916. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110917. */
  110918. gamepadAngularSensibility: number;
  110919. /**
  110920. * Defines the gamepad move sensiblity.
  110921. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110922. */
  110923. gamepadMoveSensibility: number;
  110924. private _yAxisScale;
  110925. /**
  110926. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110927. */
  110928. get invertYAxis(): boolean;
  110929. set invertYAxis(value: boolean);
  110930. private _onGamepadConnectedObserver;
  110931. private _onGamepadDisconnectedObserver;
  110932. private _cameraTransform;
  110933. private _deltaTransform;
  110934. private _vector3;
  110935. private _vector2;
  110936. /**
  110937. * Attach the input controls to a specific dom element to get the input from.
  110938. * @param element Defines the element the controls should be listened from
  110939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110940. */
  110941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110942. /**
  110943. * Detach the current controls from the specified dom element.
  110944. * @param element Defines the element to stop listening the inputs from
  110945. */
  110946. detachControl(element: Nullable<HTMLElement>): void;
  110947. /**
  110948. * Update the current camera state depending on the inputs that have been used this frame.
  110949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110950. */
  110951. checkInputs(): void;
  110952. /**
  110953. * Gets the class name of the current intput.
  110954. * @returns the class name
  110955. */
  110956. getClassName(): string;
  110957. /**
  110958. * Get the friendly name associated with the input class.
  110959. * @returns the input friendly name
  110960. */
  110961. getSimpleName(): string;
  110962. }
  110963. }
  110964. declare module BABYLON {
  110965. /**
  110966. * Defines the potential axis of a Joystick
  110967. */
  110968. export enum JoystickAxis {
  110969. /** X axis */
  110970. X = 0,
  110971. /** Y axis */
  110972. Y = 1,
  110973. /** Z axis */
  110974. Z = 2
  110975. }
  110976. /**
  110977. * Class used to define virtual joystick (used in touch mode)
  110978. */
  110979. export class VirtualJoystick {
  110980. /**
  110981. * Gets or sets a boolean indicating that left and right values must be inverted
  110982. */
  110983. reverseLeftRight: boolean;
  110984. /**
  110985. * Gets or sets a boolean indicating that up and down values must be inverted
  110986. */
  110987. reverseUpDown: boolean;
  110988. /**
  110989. * Gets the offset value for the position (ie. the change of the position value)
  110990. */
  110991. deltaPosition: Vector3;
  110992. /**
  110993. * Gets a boolean indicating if the virtual joystick was pressed
  110994. */
  110995. pressed: boolean;
  110996. /**
  110997. * Canvas the virtual joystick will render onto, default z-index of this is 5
  110998. */
  110999. static Canvas: Nullable<HTMLCanvasElement>;
  111000. private static _globalJoystickIndex;
  111001. private static vjCanvasContext;
  111002. private static vjCanvasWidth;
  111003. private static vjCanvasHeight;
  111004. private static halfWidth;
  111005. private _action;
  111006. private _axisTargetedByLeftAndRight;
  111007. private _axisTargetedByUpAndDown;
  111008. private _joystickSensibility;
  111009. private _inversedSensibility;
  111010. private _joystickPointerID;
  111011. private _joystickColor;
  111012. private _joystickPointerPos;
  111013. private _joystickPreviousPointerPos;
  111014. private _joystickPointerStartPos;
  111015. private _deltaJoystickVector;
  111016. private _leftJoystick;
  111017. private _touches;
  111018. private _onPointerDownHandlerRef;
  111019. private _onPointerMoveHandlerRef;
  111020. private _onPointerUpHandlerRef;
  111021. private _onResize;
  111022. /**
  111023. * Creates a new virtual joystick
  111024. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111025. */
  111026. constructor(leftJoystick?: boolean);
  111027. /**
  111028. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111029. * @param newJoystickSensibility defines the new sensibility
  111030. */
  111031. setJoystickSensibility(newJoystickSensibility: number): void;
  111032. private _onPointerDown;
  111033. private _onPointerMove;
  111034. private _onPointerUp;
  111035. /**
  111036. * Change the color of the virtual joystick
  111037. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111038. */
  111039. setJoystickColor(newColor: string): void;
  111040. /**
  111041. * Defines a callback to call when the joystick is touched
  111042. * @param action defines the callback
  111043. */
  111044. setActionOnTouch(action: () => any): void;
  111045. /**
  111046. * Defines which axis you'd like to control for left & right
  111047. * @param axis defines the axis to use
  111048. */
  111049. setAxisForLeftRight(axis: JoystickAxis): void;
  111050. /**
  111051. * Defines which axis you'd like to control for up & down
  111052. * @param axis defines the axis to use
  111053. */
  111054. setAxisForUpDown(axis: JoystickAxis): void;
  111055. private _drawVirtualJoystick;
  111056. /**
  111057. * Release internal HTML canvas
  111058. */
  111059. releaseCanvas(): void;
  111060. }
  111061. }
  111062. declare module BABYLON {
  111063. interface FreeCameraInputsManager {
  111064. /**
  111065. * Add virtual joystick input support to the input manager.
  111066. * @returns the current input manager
  111067. */
  111068. addVirtualJoystick(): FreeCameraInputsManager;
  111069. }
  111070. /**
  111071. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111073. */
  111074. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111075. /**
  111076. * Defines the camera the input is attached to.
  111077. */
  111078. camera: FreeCamera;
  111079. private _leftjoystick;
  111080. private _rightjoystick;
  111081. /**
  111082. * Gets the left stick of the virtual joystick.
  111083. * @returns The virtual Joystick
  111084. */
  111085. getLeftJoystick(): VirtualJoystick;
  111086. /**
  111087. * Gets the right stick of the virtual joystick.
  111088. * @returns The virtual Joystick
  111089. */
  111090. getRightJoystick(): VirtualJoystick;
  111091. /**
  111092. * Update the current camera state depending on the inputs that have been used this frame.
  111093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111094. */
  111095. checkInputs(): void;
  111096. /**
  111097. * Attach the input controls to a specific dom element to get the input from.
  111098. * @param element Defines the element the controls should be listened from
  111099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111100. */
  111101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111102. /**
  111103. * Detach the current controls from the specified dom element.
  111104. * @param element Defines the element to stop listening the inputs from
  111105. */
  111106. detachControl(element: Nullable<HTMLElement>): void;
  111107. /**
  111108. * Gets the class name of the current intput.
  111109. * @returns the class name
  111110. */
  111111. getClassName(): string;
  111112. /**
  111113. * Get the friendly name associated with the input class.
  111114. * @returns the input friendly name
  111115. */
  111116. getSimpleName(): string;
  111117. }
  111118. }
  111119. declare module BABYLON {
  111120. /**
  111121. * This represents a FPS type of camera controlled by touch.
  111122. * This is like a universal camera minus the Gamepad controls.
  111123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111124. */
  111125. export class TouchCamera extends FreeCamera {
  111126. /**
  111127. * Defines the touch sensibility for rotation.
  111128. * The higher the faster.
  111129. */
  111130. get touchAngularSensibility(): number;
  111131. set touchAngularSensibility(value: number);
  111132. /**
  111133. * Defines the touch sensibility for move.
  111134. * The higher the faster.
  111135. */
  111136. get touchMoveSensibility(): number;
  111137. set touchMoveSensibility(value: number);
  111138. /**
  111139. * Instantiates a new touch camera.
  111140. * This represents a FPS type of camera controlled by touch.
  111141. * This is like a universal camera minus the Gamepad controls.
  111142. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111143. * @param name Define the name of the camera in the scene
  111144. * @param position Define the start position of the camera in the scene
  111145. * @param scene Define the scene the camera belongs to
  111146. */
  111147. constructor(name: string, position: Vector3, scene: Scene);
  111148. /**
  111149. * Gets the current object class name.
  111150. * @return the class name
  111151. */
  111152. getClassName(): string;
  111153. /** @hidden */
  111154. _setupInputs(): void;
  111155. }
  111156. }
  111157. declare module BABYLON {
  111158. /**
  111159. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111160. * being tilted forward or back and left or right.
  111161. */
  111162. export class DeviceOrientationCamera extends FreeCamera {
  111163. private _initialQuaternion;
  111164. private _quaternionCache;
  111165. private _tmpDragQuaternion;
  111166. private _disablePointerInputWhenUsingDeviceOrientation;
  111167. /**
  111168. * Creates a new device orientation camera
  111169. * @param name The name of the camera
  111170. * @param position The start position camera
  111171. * @param scene The scene the camera belongs to
  111172. */
  111173. constructor(name: string, position: Vector3, scene: Scene);
  111174. /**
  111175. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111176. */
  111177. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111178. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111179. private _dragFactor;
  111180. /**
  111181. * Enabled turning on the y axis when the orientation sensor is active
  111182. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111183. */
  111184. enableHorizontalDragging(dragFactor?: number): void;
  111185. /**
  111186. * Gets the current instance class name ("DeviceOrientationCamera").
  111187. * This helps avoiding instanceof at run time.
  111188. * @returns the class name
  111189. */
  111190. getClassName(): string;
  111191. /**
  111192. * @hidden
  111193. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111194. */
  111195. _checkInputs(): void;
  111196. /**
  111197. * Reset the camera to its default orientation on the specified axis only.
  111198. * @param axis The axis to reset
  111199. */
  111200. resetToCurrentRotation(axis?: Axis): void;
  111201. }
  111202. }
  111203. declare module BABYLON {
  111204. /**
  111205. * Defines supported buttons for XBox360 compatible gamepads
  111206. */
  111207. export enum Xbox360Button {
  111208. /** A */
  111209. A = 0,
  111210. /** B */
  111211. B = 1,
  111212. /** X */
  111213. X = 2,
  111214. /** Y */
  111215. Y = 3,
  111216. /** Start */
  111217. Start = 4,
  111218. /** Back */
  111219. Back = 5,
  111220. /** Left button */
  111221. LB = 6,
  111222. /** Right button */
  111223. RB = 7,
  111224. /** Left stick */
  111225. LeftStick = 8,
  111226. /** Right stick */
  111227. RightStick = 9
  111228. }
  111229. /** Defines values for XBox360 DPad */
  111230. export enum Xbox360Dpad {
  111231. /** Up */
  111232. Up = 0,
  111233. /** Down */
  111234. Down = 1,
  111235. /** Left */
  111236. Left = 2,
  111237. /** Right */
  111238. Right = 3
  111239. }
  111240. /**
  111241. * Defines a XBox360 gamepad
  111242. */
  111243. export class Xbox360Pad extends Gamepad {
  111244. private _leftTrigger;
  111245. private _rightTrigger;
  111246. private _onlefttriggerchanged;
  111247. private _onrighttriggerchanged;
  111248. private _onbuttondown;
  111249. private _onbuttonup;
  111250. private _ondpaddown;
  111251. private _ondpadup;
  111252. /** Observable raised when a button is pressed */
  111253. onButtonDownObservable: Observable<Xbox360Button>;
  111254. /** Observable raised when a button is released */
  111255. onButtonUpObservable: Observable<Xbox360Button>;
  111256. /** Observable raised when a pad is pressed */
  111257. onPadDownObservable: Observable<Xbox360Dpad>;
  111258. /** Observable raised when a pad is released */
  111259. onPadUpObservable: Observable<Xbox360Dpad>;
  111260. private _buttonA;
  111261. private _buttonB;
  111262. private _buttonX;
  111263. private _buttonY;
  111264. private _buttonBack;
  111265. private _buttonStart;
  111266. private _buttonLB;
  111267. private _buttonRB;
  111268. private _buttonLeftStick;
  111269. private _buttonRightStick;
  111270. private _dPadUp;
  111271. private _dPadDown;
  111272. private _dPadLeft;
  111273. private _dPadRight;
  111274. private _isXboxOnePad;
  111275. /**
  111276. * Creates a new XBox360 gamepad object
  111277. * @param id defines the id of this gamepad
  111278. * @param index defines its index
  111279. * @param gamepad defines the internal HTML gamepad object
  111280. * @param xboxOne defines if it is a XBox One gamepad
  111281. */
  111282. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111283. /**
  111284. * Defines the callback to call when left trigger is pressed
  111285. * @param callback defines the callback to use
  111286. */
  111287. onlefttriggerchanged(callback: (value: number) => void): void;
  111288. /**
  111289. * Defines the callback to call when right trigger is pressed
  111290. * @param callback defines the callback to use
  111291. */
  111292. onrighttriggerchanged(callback: (value: number) => void): void;
  111293. /**
  111294. * Gets the left trigger value
  111295. */
  111296. get leftTrigger(): number;
  111297. /**
  111298. * Sets the left trigger value
  111299. */
  111300. set leftTrigger(newValue: number);
  111301. /**
  111302. * Gets the right trigger value
  111303. */
  111304. get rightTrigger(): number;
  111305. /**
  111306. * Sets the right trigger value
  111307. */
  111308. set rightTrigger(newValue: number);
  111309. /**
  111310. * Defines the callback to call when a button is pressed
  111311. * @param callback defines the callback to use
  111312. */
  111313. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111314. /**
  111315. * Defines the callback to call when a button is released
  111316. * @param callback defines the callback to use
  111317. */
  111318. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111319. /**
  111320. * Defines the callback to call when a pad is pressed
  111321. * @param callback defines the callback to use
  111322. */
  111323. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111324. /**
  111325. * Defines the callback to call when a pad is released
  111326. * @param callback defines the callback to use
  111327. */
  111328. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111329. private _setButtonValue;
  111330. private _setDPadValue;
  111331. /**
  111332. * Gets the value of the `A` button
  111333. */
  111334. get buttonA(): number;
  111335. /**
  111336. * Sets the value of the `A` button
  111337. */
  111338. set buttonA(value: number);
  111339. /**
  111340. * Gets the value of the `B` button
  111341. */
  111342. get buttonB(): number;
  111343. /**
  111344. * Sets the value of the `B` button
  111345. */
  111346. set buttonB(value: number);
  111347. /**
  111348. * Gets the value of the `X` button
  111349. */
  111350. get buttonX(): number;
  111351. /**
  111352. * Sets the value of the `X` button
  111353. */
  111354. set buttonX(value: number);
  111355. /**
  111356. * Gets the value of the `Y` button
  111357. */
  111358. get buttonY(): number;
  111359. /**
  111360. * Sets the value of the `Y` button
  111361. */
  111362. set buttonY(value: number);
  111363. /**
  111364. * Gets the value of the `Start` button
  111365. */
  111366. get buttonStart(): number;
  111367. /**
  111368. * Sets the value of the `Start` button
  111369. */
  111370. set buttonStart(value: number);
  111371. /**
  111372. * Gets the value of the `Back` button
  111373. */
  111374. get buttonBack(): number;
  111375. /**
  111376. * Sets the value of the `Back` button
  111377. */
  111378. set buttonBack(value: number);
  111379. /**
  111380. * Gets the value of the `Left` button
  111381. */
  111382. get buttonLB(): number;
  111383. /**
  111384. * Sets the value of the `Left` button
  111385. */
  111386. set buttonLB(value: number);
  111387. /**
  111388. * Gets the value of the `Right` button
  111389. */
  111390. get buttonRB(): number;
  111391. /**
  111392. * Sets the value of the `Right` button
  111393. */
  111394. set buttonRB(value: number);
  111395. /**
  111396. * Gets the value of the Left joystick
  111397. */
  111398. get buttonLeftStick(): number;
  111399. /**
  111400. * Sets the value of the Left joystick
  111401. */
  111402. set buttonLeftStick(value: number);
  111403. /**
  111404. * Gets the value of the Right joystick
  111405. */
  111406. get buttonRightStick(): number;
  111407. /**
  111408. * Sets the value of the Right joystick
  111409. */
  111410. set buttonRightStick(value: number);
  111411. /**
  111412. * Gets the value of D-pad up
  111413. */
  111414. get dPadUp(): number;
  111415. /**
  111416. * Sets the value of D-pad up
  111417. */
  111418. set dPadUp(value: number);
  111419. /**
  111420. * Gets the value of D-pad down
  111421. */
  111422. get dPadDown(): number;
  111423. /**
  111424. * Sets the value of D-pad down
  111425. */
  111426. set dPadDown(value: number);
  111427. /**
  111428. * Gets the value of D-pad left
  111429. */
  111430. get dPadLeft(): number;
  111431. /**
  111432. * Sets the value of D-pad left
  111433. */
  111434. set dPadLeft(value: number);
  111435. /**
  111436. * Gets the value of D-pad right
  111437. */
  111438. get dPadRight(): number;
  111439. /**
  111440. * Sets the value of D-pad right
  111441. */
  111442. set dPadRight(value: number);
  111443. /**
  111444. * Force the gamepad to synchronize with device values
  111445. */
  111446. update(): void;
  111447. /**
  111448. * Disposes the gamepad
  111449. */
  111450. dispose(): void;
  111451. }
  111452. }
  111453. declare module BABYLON {
  111454. /**
  111455. * Defines supported buttons for DualShock compatible gamepads
  111456. */
  111457. export enum DualShockButton {
  111458. /** Cross */
  111459. Cross = 0,
  111460. /** Circle */
  111461. Circle = 1,
  111462. /** Square */
  111463. Square = 2,
  111464. /** Triangle */
  111465. Triangle = 3,
  111466. /** Options */
  111467. Options = 4,
  111468. /** Share */
  111469. Share = 5,
  111470. /** L1 */
  111471. L1 = 6,
  111472. /** R1 */
  111473. R1 = 7,
  111474. /** Left stick */
  111475. LeftStick = 8,
  111476. /** Right stick */
  111477. RightStick = 9
  111478. }
  111479. /** Defines values for DualShock DPad */
  111480. export enum DualShockDpad {
  111481. /** Up */
  111482. Up = 0,
  111483. /** Down */
  111484. Down = 1,
  111485. /** Left */
  111486. Left = 2,
  111487. /** Right */
  111488. Right = 3
  111489. }
  111490. /**
  111491. * Defines a DualShock gamepad
  111492. */
  111493. export class DualShockPad extends Gamepad {
  111494. private _leftTrigger;
  111495. private _rightTrigger;
  111496. private _onlefttriggerchanged;
  111497. private _onrighttriggerchanged;
  111498. private _onbuttondown;
  111499. private _onbuttonup;
  111500. private _ondpaddown;
  111501. private _ondpadup;
  111502. /** Observable raised when a button is pressed */
  111503. onButtonDownObservable: Observable<DualShockButton>;
  111504. /** Observable raised when a button is released */
  111505. onButtonUpObservable: Observable<DualShockButton>;
  111506. /** Observable raised when a pad is pressed */
  111507. onPadDownObservable: Observable<DualShockDpad>;
  111508. /** Observable raised when a pad is released */
  111509. onPadUpObservable: Observable<DualShockDpad>;
  111510. private _buttonCross;
  111511. private _buttonCircle;
  111512. private _buttonSquare;
  111513. private _buttonTriangle;
  111514. private _buttonShare;
  111515. private _buttonOptions;
  111516. private _buttonL1;
  111517. private _buttonR1;
  111518. private _buttonLeftStick;
  111519. private _buttonRightStick;
  111520. private _dPadUp;
  111521. private _dPadDown;
  111522. private _dPadLeft;
  111523. private _dPadRight;
  111524. /**
  111525. * Creates a new DualShock gamepad object
  111526. * @param id defines the id of this gamepad
  111527. * @param index defines its index
  111528. * @param gamepad defines the internal HTML gamepad object
  111529. */
  111530. constructor(id: string, index: number, gamepad: any);
  111531. /**
  111532. * Defines the callback to call when left trigger is pressed
  111533. * @param callback defines the callback to use
  111534. */
  111535. onlefttriggerchanged(callback: (value: number) => void): void;
  111536. /**
  111537. * Defines the callback to call when right trigger is pressed
  111538. * @param callback defines the callback to use
  111539. */
  111540. onrighttriggerchanged(callback: (value: number) => void): void;
  111541. /**
  111542. * Gets the left trigger value
  111543. */
  111544. get leftTrigger(): number;
  111545. /**
  111546. * Sets the left trigger value
  111547. */
  111548. set leftTrigger(newValue: number);
  111549. /**
  111550. * Gets the right trigger value
  111551. */
  111552. get rightTrigger(): number;
  111553. /**
  111554. * Sets the right trigger value
  111555. */
  111556. set rightTrigger(newValue: number);
  111557. /**
  111558. * Defines the callback to call when a button is pressed
  111559. * @param callback defines the callback to use
  111560. */
  111561. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111562. /**
  111563. * Defines the callback to call when a button is released
  111564. * @param callback defines the callback to use
  111565. */
  111566. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111567. /**
  111568. * Defines the callback to call when a pad is pressed
  111569. * @param callback defines the callback to use
  111570. */
  111571. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111572. /**
  111573. * Defines the callback to call when a pad is released
  111574. * @param callback defines the callback to use
  111575. */
  111576. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111577. private _setButtonValue;
  111578. private _setDPadValue;
  111579. /**
  111580. * Gets the value of the `Cross` button
  111581. */
  111582. get buttonCross(): number;
  111583. /**
  111584. * Sets the value of the `Cross` button
  111585. */
  111586. set buttonCross(value: number);
  111587. /**
  111588. * Gets the value of the `Circle` button
  111589. */
  111590. get buttonCircle(): number;
  111591. /**
  111592. * Sets the value of the `Circle` button
  111593. */
  111594. set buttonCircle(value: number);
  111595. /**
  111596. * Gets the value of the `Square` button
  111597. */
  111598. get buttonSquare(): number;
  111599. /**
  111600. * Sets the value of the `Square` button
  111601. */
  111602. set buttonSquare(value: number);
  111603. /**
  111604. * Gets the value of the `Triangle` button
  111605. */
  111606. get buttonTriangle(): number;
  111607. /**
  111608. * Sets the value of the `Triangle` button
  111609. */
  111610. set buttonTriangle(value: number);
  111611. /**
  111612. * Gets the value of the `Options` button
  111613. */
  111614. get buttonOptions(): number;
  111615. /**
  111616. * Sets the value of the `Options` button
  111617. */
  111618. set buttonOptions(value: number);
  111619. /**
  111620. * Gets the value of the `Share` button
  111621. */
  111622. get buttonShare(): number;
  111623. /**
  111624. * Sets the value of the `Share` button
  111625. */
  111626. set buttonShare(value: number);
  111627. /**
  111628. * Gets the value of the `L1` button
  111629. */
  111630. get buttonL1(): number;
  111631. /**
  111632. * Sets the value of the `L1` button
  111633. */
  111634. set buttonL1(value: number);
  111635. /**
  111636. * Gets the value of the `R1` button
  111637. */
  111638. get buttonR1(): number;
  111639. /**
  111640. * Sets the value of the `R1` button
  111641. */
  111642. set buttonR1(value: number);
  111643. /**
  111644. * Gets the value of the Left joystick
  111645. */
  111646. get buttonLeftStick(): number;
  111647. /**
  111648. * Sets the value of the Left joystick
  111649. */
  111650. set buttonLeftStick(value: number);
  111651. /**
  111652. * Gets the value of the Right joystick
  111653. */
  111654. get buttonRightStick(): number;
  111655. /**
  111656. * Sets the value of the Right joystick
  111657. */
  111658. set buttonRightStick(value: number);
  111659. /**
  111660. * Gets the value of D-pad up
  111661. */
  111662. get dPadUp(): number;
  111663. /**
  111664. * Sets the value of D-pad up
  111665. */
  111666. set dPadUp(value: number);
  111667. /**
  111668. * Gets the value of D-pad down
  111669. */
  111670. get dPadDown(): number;
  111671. /**
  111672. * Sets the value of D-pad down
  111673. */
  111674. set dPadDown(value: number);
  111675. /**
  111676. * Gets the value of D-pad left
  111677. */
  111678. get dPadLeft(): number;
  111679. /**
  111680. * Sets the value of D-pad left
  111681. */
  111682. set dPadLeft(value: number);
  111683. /**
  111684. * Gets the value of D-pad right
  111685. */
  111686. get dPadRight(): number;
  111687. /**
  111688. * Sets the value of D-pad right
  111689. */
  111690. set dPadRight(value: number);
  111691. /**
  111692. * Force the gamepad to synchronize with device values
  111693. */
  111694. update(): void;
  111695. /**
  111696. * Disposes the gamepad
  111697. */
  111698. dispose(): void;
  111699. }
  111700. }
  111701. declare module BABYLON {
  111702. /**
  111703. * Manager for handling gamepads
  111704. */
  111705. export class GamepadManager {
  111706. private _scene?;
  111707. private _babylonGamepads;
  111708. private _oneGamepadConnected;
  111709. /** @hidden */
  111710. _isMonitoring: boolean;
  111711. private _gamepadEventSupported;
  111712. private _gamepadSupport?;
  111713. /**
  111714. * observable to be triggered when the gamepad controller has been connected
  111715. */
  111716. onGamepadConnectedObservable: Observable<Gamepad>;
  111717. /**
  111718. * observable to be triggered when the gamepad controller has been disconnected
  111719. */
  111720. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111721. private _onGamepadConnectedEvent;
  111722. private _onGamepadDisconnectedEvent;
  111723. /**
  111724. * Initializes the gamepad manager
  111725. * @param _scene BabylonJS scene
  111726. */
  111727. constructor(_scene?: Scene | undefined);
  111728. /**
  111729. * The gamepads in the game pad manager
  111730. */
  111731. get gamepads(): Gamepad[];
  111732. /**
  111733. * Get the gamepad controllers based on type
  111734. * @param type The type of gamepad controller
  111735. * @returns Nullable gamepad
  111736. */
  111737. getGamepadByType(type?: number): Nullable<Gamepad>;
  111738. /**
  111739. * Disposes the gamepad manager
  111740. */
  111741. dispose(): void;
  111742. private _addNewGamepad;
  111743. private _startMonitoringGamepads;
  111744. private _stopMonitoringGamepads;
  111745. /** @hidden */
  111746. _checkGamepadsStatus(): void;
  111747. private _updateGamepadObjects;
  111748. }
  111749. }
  111750. declare module BABYLON {
  111751. interface Scene {
  111752. /** @hidden */
  111753. _gamepadManager: Nullable<GamepadManager>;
  111754. /**
  111755. * Gets the gamepad manager associated with the scene
  111756. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111757. */
  111758. gamepadManager: GamepadManager;
  111759. }
  111760. /**
  111761. * Interface representing a free camera inputs manager
  111762. */
  111763. interface FreeCameraInputsManager {
  111764. /**
  111765. * Adds gamepad input support to the FreeCameraInputsManager.
  111766. * @returns the FreeCameraInputsManager
  111767. */
  111768. addGamepad(): FreeCameraInputsManager;
  111769. }
  111770. /**
  111771. * Interface representing an arc rotate camera inputs manager
  111772. */
  111773. interface ArcRotateCameraInputsManager {
  111774. /**
  111775. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111776. * @returns the camera inputs manager
  111777. */
  111778. addGamepad(): ArcRotateCameraInputsManager;
  111779. }
  111780. /**
  111781. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111782. */
  111783. export class GamepadSystemSceneComponent implements ISceneComponent {
  111784. /**
  111785. * The component name helpfull to identify the component in the list of scene components.
  111786. */
  111787. readonly name: string;
  111788. /**
  111789. * The scene the component belongs to.
  111790. */
  111791. scene: Scene;
  111792. /**
  111793. * Creates a new instance of the component for the given scene
  111794. * @param scene Defines the scene to register the component in
  111795. */
  111796. constructor(scene: Scene);
  111797. /**
  111798. * Registers the component in a given scene
  111799. */
  111800. register(): void;
  111801. /**
  111802. * Rebuilds the elements related to this component in case of
  111803. * context lost for instance.
  111804. */
  111805. rebuild(): void;
  111806. /**
  111807. * Disposes the component and the associated ressources
  111808. */
  111809. dispose(): void;
  111810. private _beforeCameraUpdate;
  111811. }
  111812. }
  111813. declare module BABYLON {
  111814. /**
  111815. * 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,
  111816. * which still works and will still be found in many Playgrounds.
  111817. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111818. */
  111819. export class UniversalCamera extends TouchCamera {
  111820. /**
  111821. * Defines the gamepad rotation sensiblity.
  111822. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111823. */
  111824. get gamepadAngularSensibility(): number;
  111825. set gamepadAngularSensibility(value: number);
  111826. /**
  111827. * Defines the gamepad move sensiblity.
  111828. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111829. */
  111830. get gamepadMoveSensibility(): number;
  111831. set gamepadMoveSensibility(value: number);
  111832. /**
  111833. * 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,
  111834. * which still works and will still be found in many Playgrounds.
  111835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111836. * @param name Define the name of the camera in the scene
  111837. * @param position Define the start position of the camera in the scene
  111838. * @param scene Define the scene the camera belongs to
  111839. */
  111840. constructor(name: string, position: Vector3, scene: Scene);
  111841. /**
  111842. * Gets the current object class name.
  111843. * @return the class name
  111844. */
  111845. getClassName(): string;
  111846. }
  111847. }
  111848. declare module BABYLON {
  111849. /**
  111850. * This represents a FPS type of camera. This is only here for back compat purpose.
  111851. * Please use the UniversalCamera instead as both are identical.
  111852. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111853. */
  111854. export class GamepadCamera extends UniversalCamera {
  111855. /**
  111856. * Instantiates a new Gamepad Camera
  111857. * This represents a FPS type of camera. This is only here for back compat purpose.
  111858. * Please use the UniversalCamera instead as both are identical.
  111859. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111860. * @param name Define the name of the camera in the scene
  111861. * @param position Define the start position of the camera in the scene
  111862. * @param scene Define the scene the camera belongs to
  111863. */
  111864. constructor(name: string, position: Vector3, scene: Scene);
  111865. /**
  111866. * Gets the current object class name.
  111867. * @return the class name
  111868. */
  111869. getClassName(): string;
  111870. }
  111871. }
  111872. declare module BABYLON {
  111873. /** @hidden */
  111874. export var passPixelShader: {
  111875. name: string;
  111876. shader: string;
  111877. };
  111878. }
  111879. declare module BABYLON {
  111880. /** @hidden */
  111881. export var passCubePixelShader: {
  111882. name: string;
  111883. shader: string;
  111884. };
  111885. }
  111886. declare module BABYLON {
  111887. /**
  111888. * PassPostProcess which produces an output the same as it's input
  111889. */
  111890. export class PassPostProcess extends PostProcess {
  111891. /**
  111892. * Creates the PassPostProcess
  111893. * @param name The name of the effect.
  111894. * @param options The required width/height ratio to downsize to before computing the render pass.
  111895. * @param camera The camera to apply the render pass to.
  111896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111897. * @param engine The engine which the post process will be applied. (default: current engine)
  111898. * @param reusable If the post process can be reused on the same frame. (default: false)
  111899. * @param textureType The type of texture to be used when performing the post processing.
  111900. * @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)
  111901. */
  111902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111903. }
  111904. /**
  111905. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  111906. */
  111907. export class PassCubePostProcess extends PostProcess {
  111908. private _face;
  111909. /**
  111910. * Gets or sets the cube face to display.
  111911. * * 0 is +X
  111912. * * 1 is -X
  111913. * * 2 is +Y
  111914. * * 3 is -Y
  111915. * * 4 is +Z
  111916. * * 5 is -Z
  111917. */
  111918. get face(): number;
  111919. set face(value: number);
  111920. /**
  111921. * Creates the PassCubePostProcess
  111922. * @param name The name of the effect.
  111923. * @param options The required width/height ratio to downsize to before computing the render pass.
  111924. * @param camera The camera to apply the render pass to.
  111925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111926. * @param engine The engine which the post process will be applied. (default: current engine)
  111927. * @param reusable If the post process can be reused on the same frame. (default: false)
  111928. * @param textureType The type of texture to be used when performing the post processing.
  111929. * @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)
  111930. */
  111931. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111932. }
  111933. }
  111934. declare module BABYLON {
  111935. /** @hidden */
  111936. export var anaglyphPixelShader: {
  111937. name: string;
  111938. shader: string;
  111939. };
  111940. }
  111941. declare module BABYLON {
  111942. /**
  111943. * Postprocess used to generate anaglyphic rendering
  111944. */
  111945. export class AnaglyphPostProcess extends PostProcess {
  111946. private _passedProcess;
  111947. /**
  111948. * Creates a new AnaglyphPostProcess
  111949. * @param name defines postprocess name
  111950. * @param options defines creation options or target ratio scale
  111951. * @param rigCameras defines cameras using this postprocess
  111952. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  111953. * @param engine defines hosting engine
  111954. * @param reusable defines if the postprocess will be reused multiple times per frame
  111955. */
  111956. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  111957. }
  111958. }
  111959. declare module BABYLON {
  111960. /**
  111961. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  111962. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111963. */
  111964. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  111965. /**
  111966. * Creates a new AnaglyphArcRotateCamera
  111967. * @param name defines camera name
  111968. * @param alpha defines alpha angle (in radians)
  111969. * @param beta defines beta angle (in radians)
  111970. * @param radius defines radius
  111971. * @param target defines camera target
  111972. * @param interaxialDistance defines distance between each color axis
  111973. * @param scene defines the hosting scene
  111974. */
  111975. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  111976. /**
  111977. * Gets camera class name
  111978. * @returns AnaglyphArcRotateCamera
  111979. */
  111980. getClassName(): string;
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  111986. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111987. */
  111988. export class AnaglyphFreeCamera extends FreeCamera {
  111989. /**
  111990. * Creates a new AnaglyphFreeCamera
  111991. * @param name defines camera name
  111992. * @param position defines initial position
  111993. * @param interaxialDistance defines distance between each color axis
  111994. * @param scene defines the hosting scene
  111995. */
  111996. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  111997. /**
  111998. * Gets camera class name
  111999. * @returns AnaglyphFreeCamera
  112000. */
  112001. getClassName(): string;
  112002. }
  112003. }
  112004. declare module BABYLON {
  112005. /**
  112006. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112007. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112008. */
  112009. export class AnaglyphGamepadCamera extends GamepadCamera {
  112010. /**
  112011. * Creates a new AnaglyphGamepadCamera
  112012. * @param name defines camera name
  112013. * @param position defines initial position
  112014. * @param interaxialDistance defines distance between each color axis
  112015. * @param scene defines the hosting scene
  112016. */
  112017. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112018. /**
  112019. * Gets camera class name
  112020. * @returns AnaglyphGamepadCamera
  112021. */
  112022. getClassName(): string;
  112023. }
  112024. }
  112025. declare module BABYLON {
  112026. /**
  112027. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112028. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112029. */
  112030. export class AnaglyphUniversalCamera extends UniversalCamera {
  112031. /**
  112032. * Creates a new AnaglyphUniversalCamera
  112033. * @param name defines camera name
  112034. * @param position defines initial position
  112035. * @param interaxialDistance defines distance between each color axis
  112036. * @param scene defines the hosting scene
  112037. */
  112038. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112039. /**
  112040. * Gets camera class name
  112041. * @returns AnaglyphUniversalCamera
  112042. */
  112043. getClassName(): string;
  112044. }
  112045. }
  112046. declare module BABYLON {
  112047. /** @hidden */
  112048. export var stereoscopicInterlacePixelShader: {
  112049. name: string;
  112050. shader: string;
  112051. };
  112052. }
  112053. declare module BABYLON {
  112054. /**
  112055. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112056. */
  112057. export class StereoscopicInterlacePostProcess extends PostProcess {
  112058. private _stepSize;
  112059. private _passedProcess;
  112060. /**
  112061. * Initializes a StereoscopicInterlacePostProcess
  112062. * @param name The name of the effect.
  112063. * @param rigCameras The rig cameras to be appled to the post process
  112064. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112066. * @param engine The engine which the post process will be applied. (default: current engine)
  112067. * @param reusable If the post process can be reused on the same frame. (default: false)
  112068. */
  112069. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112070. }
  112071. }
  112072. declare module BABYLON {
  112073. /**
  112074. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112075. * @see http://doc.babylonjs.com/features/cameras
  112076. */
  112077. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112078. /**
  112079. * Creates a new StereoscopicArcRotateCamera
  112080. * @param name defines camera name
  112081. * @param alpha defines alpha angle (in radians)
  112082. * @param beta defines beta angle (in radians)
  112083. * @param radius defines radius
  112084. * @param target defines camera target
  112085. * @param interaxialDistance defines distance between each color axis
  112086. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112087. * @param scene defines the hosting scene
  112088. */
  112089. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112090. /**
  112091. * Gets camera class name
  112092. * @returns StereoscopicArcRotateCamera
  112093. */
  112094. getClassName(): string;
  112095. }
  112096. }
  112097. declare module BABYLON {
  112098. /**
  112099. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112100. * @see http://doc.babylonjs.com/features/cameras
  112101. */
  112102. export class StereoscopicFreeCamera extends FreeCamera {
  112103. /**
  112104. * Creates a new StereoscopicFreeCamera
  112105. * @param name defines camera name
  112106. * @param position defines initial position
  112107. * @param interaxialDistance defines distance between each color axis
  112108. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112109. * @param scene defines the hosting scene
  112110. */
  112111. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112112. /**
  112113. * Gets camera class name
  112114. * @returns StereoscopicFreeCamera
  112115. */
  112116. getClassName(): string;
  112117. }
  112118. }
  112119. declare module BABYLON {
  112120. /**
  112121. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112122. * @see http://doc.babylonjs.com/features/cameras
  112123. */
  112124. export class StereoscopicGamepadCamera extends GamepadCamera {
  112125. /**
  112126. * Creates a new StereoscopicGamepadCamera
  112127. * @param name defines camera name
  112128. * @param position defines initial position
  112129. * @param interaxialDistance defines distance between each color axis
  112130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112131. * @param scene defines the hosting scene
  112132. */
  112133. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112134. /**
  112135. * Gets camera class name
  112136. * @returns StereoscopicGamepadCamera
  112137. */
  112138. getClassName(): string;
  112139. }
  112140. }
  112141. declare module BABYLON {
  112142. /**
  112143. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112144. * @see http://doc.babylonjs.com/features/cameras
  112145. */
  112146. export class StereoscopicUniversalCamera extends UniversalCamera {
  112147. /**
  112148. * Creates a new StereoscopicUniversalCamera
  112149. * @param name defines camera name
  112150. * @param position defines initial position
  112151. * @param interaxialDistance defines distance between each color axis
  112152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112153. * @param scene defines the hosting scene
  112154. */
  112155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112156. /**
  112157. * Gets camera class name
  112158. * @returns StereoscopicUniversalCamera
  112159. */
  112160. getClassName(): string;
  112161. }
  112162. }
  112163. declare module BABYLON {
  112164. /**
  112165. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112166. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112167. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112168. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112169. */
  112170. export class VirtualJoysticksCamera extends FreeCamera {
  112171. /**
  112172. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112173. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112174. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112175. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112176. * @param name Define the name of the camera in the scene
  112177. * @param position Define the start position of the camera in the scene
  112178. * @param scene Define the scene the camera belongs to
  112179. */
  112180. constructor(name: string, position: Vector3, scene: Scene);
  112181. /**
  112182. * Gets the current object class name.
  112183. * @return the class name
  112184. */
  112185. getClassName(): string;
  112186. }
  112187. }
  112188. declare module BABYLON {
  112189. /**
  112190. * This represents all the required metrics to create a VR camera.
  112191. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112192. */
  112193. export class VRCameraMetrics {
  112194. /**
  112195. * Define the horizontal resolution off the screen.
  112196. */
  112197. hResolution: number;
  112198. /**
  112199. * Define the vertical resolution off the screen.
  112200. */
  112201. vResolution: number;
  112202. /**
  112203. * Define the horizontal screen size.
  112204. */
  112205. hScreenSize: number;
  112206. /**
  112207. * Define the vertical screen size.
  112208. */
  112209. vScreenSize: number;
  112210. /**
  112211. * Define the vertical screen center position.
  112212. */
  112213. vScreenCenter: number;
  112214. /**
  112215. * Define the distance of the eyes to the screen.
  112216. */
  112217. eyeToScreenDistance: number;
  112218. /**
  112219. * Define the distance between both lenses
  112220. */
  112221. lensSeparationDistance: number;
  112222. /**
  112223. * Define the distance between both viewer's eyes.
  112224. */
  112225. interpupillaryDistance: number;
  112226. /**
  112227. * Define the distortion factor of the VR postprocess.
  112228. * Please, touch with care.
  112229. */
  112230. distortionK: number[];
  112231. /**
  112232. * Define the chromatic aberration correction factors for the VR post process.
  112233. */
  112234. chromaAbCorrection: number[];
  112235. /**
  112236. * Define the scale factor of the post process.
  112237. * The smaller the better but the slower.
  112238. */
  112239. postProcessScaleFactor: number;
  112240. /**
  112241. * Define an offset for the lens center.
  112242. */
  112243. lensCenterOffset: number;
  112244. /**
  112245. * Define if the current vr camera should compensate the distortion of the lense or not.
  112246. */
  112247. compensateDistortion: boolean;
  112248. /**
  112249. * Defines if multiview should be enabled when rendering (Default: false)
  112250. */
  112251. multiviewEnabled: boolean;
  112252. /**
  112253. * Gets the rendering aspect ratio based on the provided resolutions.
  112254. */
  112255. get aspectRatio(): number;
  112256. /**
  112257. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112258. */
  112259. get aspectRatioFov(): number;
  112260. /**
  112261. * @hidden
  112262. */
  112263. get leftHMatrix(): Matrix;
  112264. /**
  112265. * @hidden
  112266. */
  112267. get rightHMatrix(): Matrix;
  112268. /**
  112269. * @hidden
  112270. */
  112271. get leftPreViewMatrix(): Matrix;
  112272. /**
  112273. * @hidden
  112274. */
  112275. get rightPreViewMatrix(): Matrix;
  112276. /**
  112277. * Get the default VRMetrics based on the most generic setup.
  112278. * @returns the default vr metrics
  112279. */
  112280. static GetDefault(): VRCameraMetrics;
  112281. }
  112282. }
  112283. declare module BABYLON {
  112284. /** @hidden */
  112285. export var vrDistortionCorrectionPixelShader: {
  112286. name: string;
  112287. shader: string;
  112288. };
  112289. }
  112290. declare module BABYLON {
  112291. /**
  112292. * VRDistortionCorrectionPostProcess used for mobile VR
  112293. */
  112294. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112295. private _isRightEye;
  112296. private _distortionFactors;
  112297. private _postProcessScaleFactor;
  112298. private _lensCenterOffset;
  112299. private _scaleIn;
  112300. private _scaleFactor;
  112301. private _lensCenter;
  112302. /**
  112303. * Initializes the VRDistortionCorrectionPostProcess
  112304. * @param name The name of the effect.
  112305. * @param camera The camera to apply the render pass to.
  112306. * @param isRightEye If this is for the right eye distortion
  112307. * @param vrMetrics All the required metrics for the VR camera
  112308. */
  112309. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112310. }
  112311. }
  112312. declare module BABYLON {
  112313. /**
  112314. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112315. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112316. */
  112317. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112318. /**
  112319. * Creates a new VRDeviceOrientationArcRotateCamera
  112320. * @param name defines camera name
  112321. * @param alpha defines the camera rotation along the logitudinal axis
  112322. * @param beta defines the camera rotation along the latitudinal axis
  112323. * @param radius defines the camera distance from its target
  112324. * @param target defines the camera target
  112325. * @param scene defines the scene the camera belongs to
  112326. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112327. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112328. */
  112329. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112330. /**
  112331. * Gets camera class name
  112332. * @returns VRDeviceOrientationArcRotateCamera
  112333. */
  112334. getClassName(): string;
  112335. }
  112336. }
  112337. declare module BABYLON {
  112338. /**
  112339. * Camera used to simulate VR rendering (based on FreeCamera)
  112340. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112341. */
  112342. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112343. /**
  112344. * Creates a new VRDeviceOrientationFreeCamera
  112345. * @param name defines camera name
  112346. * @param position defines the start position of the camera
  112347. * @param scene defines the scene the camera belongs to
  112348. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112349. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112350. */
  112351. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112352. /**
  112353. * Gets camera class name
  112354. * @returns VRDeviceOrientationFreeCamera
  112355. */
  112356. getClassName(): string;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /**
  112361. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112362. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112363. */
  112364. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112365. /**
  112366. * Creates a new VRDeviceOrientationGamepadCamera
  112367. * @param name defines camera name
  112368. * @param position defines the start position of the camera
  112369. * @param scene defines the scene the camera belongs to
  112370. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112371. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112372. */
  112373. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112374. /**
  112375. * Gets camera class name
  112376. * @returns VRDeviceOrientationGamepadCamera
  112377. */
  112378. getClassName(): string;
  112379. }
  112380. }
  112381. declare module BABYLON {
  112382. /** @hidden */
  112383. export var imageProcessingPixelShader: {
  112384. name: string;
  112385. shader: string;
  112386. };
  112387. }
  112388. declare module BABYLON {
  112389. /**
  112390. * ImageProcessingPostProcess
  112391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112392. */
  112393. export class ImageProcessingPostProcess extends PostProcess {
  112394. /**
  112395. * Default configuration related to image processing available in the PBR Material.
  112396. */
  112397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112398. /**
  112399. * Gets the image processing configuration used either in this material.
  112400. */
  112401. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112402. /**
  112403. * Sets the Default image processing configuration used either in the this material.
  112404. *
  112405. * If sets to null, the scene one is in use.
  112406. */
  112407. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112408. /**
  112409. * Keep track of the image processing observer to allow dispose and replace.
  112410. */
  112411. private _imageProcessingObserver;
  112412. /**
  112413. * Attaches a new image processing configuration to the PBR Material.
  112414. * @param configuration
  112415. */
  112416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112417. /**
  112418. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112419. */
  112420. get colorCurves(): Nullable<ColorCurves>;
  112421. /**
  112422. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112423. */
  112424. set colorCurves(value: Nullable<ColorCurves>);
  112425. /**
  112426. * Gets wether the color curves effect is enabled.
  112427. */
  112428. get colorCurvesEnabled(): boolean;
  112429. /**
  112430. * Sets wether the color curves effect is enabled.
  112431. */
  112432. set colorCurvesEnabled(value: boolean);
  112433. /**
  112434. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112435. */
  112436. get colorGradingTexture(): Nullable<BaseTexture>;
  112437. /**
  112438. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112439. */
  112440. set colorGradingTexture(value: Nullable<BaseTexture>);
  112441. /**
  112442. * Gets wether the color grading effect is enabled.
  112443. */
  112444. get colorGradingEnabled(): boolean;
  112445. /**
  112446. * Gets wether the color grading effect is enabled.
  112447. */
  112448. set colorGradingEnabled(value: boolean);
  112449. /**
  112450. * Gets exposure used in the effect.
  112451. */
  112452. get exposure(): number;
  112453. /**
  112454. * Sets exposure used in the effect.
  112455. */
  112456. set exposure(value: number);
  112457. /**
  112458. * Gets wether tonemapping is enabled or not.
  112459. */
  112460. get toneMappingEnabled(): boolean;
  112461. /**
  112462. * Sets wether tonemapping is enabled or not
  112463. */
  112464. set toneMappingEnabled(value: boolean);
  112465. /**
  112466. * Gets the type of tone mapping effect.
  112467. */
  112468. get toneMappingType(): number;
  112469. /**
  112470. * Sets the type of tone mapping effect.
  112471. */
  112472. set toneMappingType(value: number);
  112473. /**
  112474. * Gets contrast used in the effect.
  112475. */
  112476. get contrast(): number;
  112477. /**
  112478. * Sets contrast used in the effect.
  112479. */
  112480. set contrast(value: number);
  112481. /**
  112482. * Gets Vignette stretch size.
  112483. */
  112484. get vignetteStretch(): number;
  112485. /**
  112486. * Sets Vignette stretch size.
  112487. */
  112488. set vignetteStretch(value: number);
  112489. /**
  112490. * Gets Vignette centre X Offset.
  112491. */
  112492. get vignetteCentreX(): number;
  112493. /**
  112494. * Sets Vignette centre X Offset.
  112495. */
  112496. set vignetteCentreX(value: number);
  112497. /**
  112498. * Gets Vignette centre Y Offset.
  112499. */
  112500. get vignetteCentreY(): number;
  112501. /**
  112502. * Sets Vignette centre Y Offset.
  112503. */
  112504. set vignetteCentreY(value: number);
  112505. /**
  112506. * Gets Vignette weight or intensity of the vignette effect.
  112507. */
  112508. get vignetteWeight(): number;
  112509. /**
  112510. * Sets Vignette weight or intensity of the vignette effect.
  112511. */
  112512. set vignetteWeight(value: number);
  112513. /**
  112514. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112515. * if vignetteEnabled is set to true.
  112516. */
  112517. get vignetteColor(): Color4;
  112518. /**
  112519. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112520. * if vignetteEnabled is set to true.
  112521. */
  112522. set vignetteColor(value: Color4);
  112523. /**
  112524. * Gets Camera field of view used by the Vignette effect.
  112525. */
  112526. get vignetteCameraFov(): number;
  112527. /**
  112528. * Sets Camera field of view used by the Vignette effect.
  112529. */
  112530. set vignetteCameraFov(value: number);
  112531. /**
  112532. * Gets the vignette blend mode allowing different kind of effect.
  112533. */
  112534. get vignetteBlendMode(): number;
  112535. /**
  112536. * Sets the vignette blend mode allowing different kind of effect.
  112537. */
  112538. set vignetteBlendMode(value: number);
  112539. /**
  112540. * Gets wether the vignette effect is enabled.
  112541. */
  112542. get vignetteEnabled(): boolean;
  112543. /**
  112544. * Sets wether the vignette effect is enabled.
  112545. */
  112546. set vignetteEnabled(value: boolean);
  112547. private _fromLinearSpace;
  112548. /**
  112549. * Gets wether the input of the processing is in Gamma or Linear Space.
  112550. */
  112551. get fromLinearSpace(): boolean;
  112552. /**
  112553. * Sets wether the input of the processing is in Gamma or Linear Space.
  112554. */
  112555. set fromLinearSpace(value: boolean);
  112556. /**
  112557. * Defines cache preventing GC.
  112558. */
  112559. private _defines;
  112560. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112561. /**
  112562. * "ImageProcessingPostProcess"
  112563. * @returns "ImageProcessingPostProcess"
  112564. */
  112565. getClassName(): string;
  112566. protected _updateParameters(): void;
  112567. dispose(camera?: Camera): void;
  112568. }
  112569. }
  112570. declare module BABYLON {
  112571. /**
  112572. * Class containing static functions to help procedurally build meshes
  112573. */
  112574. export class GroundBuilder {
  112575. /**
  112576. * Creates a ground mesh
  112577. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112578. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112580. * @param name defines the name of the mesh
  112581. * @param options defines the options used to create the mesh
  112582. * @param scene defines the hosting scene
  112583. * @returns the ground mesh
  112584. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112585. */
  112586. static CreateGround(name: string, options: {
  112587. width?: number;
  112588. height?: number;
  112589. subdivisions?: number;
  112590. subdivisionsX?: number;
  112591. subdivisionsY?: number;
  112592. updatable?: boolean;
  112593. }, scene: any): Mesh;
  112594. /**
  112595. * Creates a tiled ground mesh
  112596. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112597. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112598. * * 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
  112599. * * 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
  112600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112601. * @param name defines the name of the mesh
  112602. * @param options defines the options used to create the mesh
  112603. * @param scene defines the hosting scene
  112604. * @returns the tiled ground mesh
  112605. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112606. */
  112607. static CreateTiledGround(name: string, options: {
  112608. xmin: number;
  112609. zmin: number;
  112610. xmax: number;
  112611. zmax: number;
  112612. subdivisions?: {
  112613. w: number;
  112614. h: number;
  112615. };
  112616. precision?: {
  112617. w: number;
  112618. h: number;
  112619. };
  112620. updatable?: boolean;
  112621. }, scene?: Nullable<Scene>): Mesh;
  112622. /**
  112623. * Creates a ground mesh from a height map
  112624. * * The parameter `url` sets the URL of the height map image resource.
  112625. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112626. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112627. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112628. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112629. * * 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.
  112630. * * 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).
  112631. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112633. * @param name defines the name of the mesh
  112634. * @param url defines the url to the height map
  112635. * @param options defines the options used to create the mesh
  112636. * @param scene defines the hosting scene
  112637. * @returns the ground mesh
  112638. * @see https://doc.babylonjs.com/babylon101/height_map
  112639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112640. */
  112641. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112642. width?: number;
  112643. height?: number;
  112644. subdivisions?: number;
  112645. minHeight?: number;
  112646. maxHeight?: number;
  112647. colorFilter?: Color3;
  112648. alphaFilter?: number;
  112649. updatable?: boolean;
  112650. onReady?: (mesh: GroundMesh) => void;
  112651. }, scene?: Nullable<Scene>): GroundMesh;
  112652. }
  112653. }
  112654. declare module BABYLON {
  112655. /**
  112656. * Class containing static functions to help procedurally build meshes
  112657. */
  112658. export class TorusBuilder {
  112659. /**
  112660. * Creates a torus mesh
  112661. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112662. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112663. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112667. * @param name defines the name of the mesh
  112668. * @param options defines the options used to create the mesh
  112669. * @param scene defines the hosting scene
  112670. * @returns the torus mesh
  112671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112672. */
  112673. static CreateTorus(name: string, options: {
  112674. diameter?: number;
  112675. thickness?: number;
  112676. tessellation?: number;
  112677. updatable?: boolean;
  112678. sideOrientation?: number;
  112679. frontUVs?: Vector4;
  112680. backUVs?: Vector4;
  112681. }, scene: any): Mesh;
  112682. }
  112683. }
  112684. declare module BABYLON {
  112685. /**
  112686. * Class containing static functions to help procedurally build meshes
  112687. */
  112688. export class CylinderBuilder {
  112689. /**
  112690. * Creates a cylinder or a cone mesh
  112691. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112692. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112693. * * 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.
  112694. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112695. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112696. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112697. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112698. * * 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).
  112699. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112700. * * 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).
  112701. * * 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
  112702. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112703. * * 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
  112704. * * 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.
  112705. * * If `enclose` is false, a ring surface is one element.
  112706. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112707. * * 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
  112708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112711. * @param name defines the name of the mesh
  112712. * @param options defines the options used to create the mesh
  112713. * @param scene defines the hosting scene
  112714. * @returns the cylinder mesh
  112715. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112716. */
  112717. static CreateCylinder(name: string, options: {
  112718. height?: number;
  112719. diameterTop?: number;
  112720. diameterBottom?: number;
  112721. diameter?: number;
  112722. tessellation?: number;
  112723. subdivisions?: number;
  112724. arc?: number;
  112725. faceColors?: Color4[];
  112726. faceUV?: Vector4[];
  112727. updatable?: boolean;
  112728. hasRings?: boolean;
  112729. enclose?: boolean;
  112730. cap?: number;
  112731. sideOrientation?: number;
  112732. frontUVs?: Vector4;
  112733. backUVs?: Vector4;
  112734. }, scene: any): Mesh;
  112735. }
  112736. }
  112737. declare module BABYLON {
  112738. /**
  112739. * States of the webXR experience
  112740. */
  112741. export enum WebXRState {
  112742. /**
  112743. * Transitioning to being in XR mode
  112744. */
  112745. ENTERING_XR = 0,
  112746. /**
  112747. * Transitioning to non XR mode
  112748. */
  112749. EXITING_XR = 1,
  112750. /**
  112751. * In XR mode and presenting
  112752. */
  112753. IN_XR = 2,
  112754. /**
  112755. * Not entered XR mode
  112756. */
  112757. NOT_IN_XR = 3
  112758. }
  112759. /**
  112760. * Abstraction of the XR render target
  112761. */
  112762. export interface WebXRRenderTarget extends IDisposable {
  112763. /**
  112764. * xrpresent context of the canvas which can be used to display/mirror xr content
  112765. */
  112766. canvasContext: WebGLRenderingContext;
  112767. /**
  112768. * xr layer for the canvas
  112769. */
  112770. xrLayer: Nullable<XRWebGLLayer>;
  112771. /**
  112772. * Initializes the xr layer for the session
  112773. * @param xrSession xr session
  112774. * @returns a promise that will resolve once the XR Layer has been created
  112775. */
  112776. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112777. }
  112778. }
  112779. declare module BABYLON {
  112780. /**
  112781. * COnfiguration object for WebXR output canvas
  112782. */
  112783. export class WebXRManagedOutputCanvasOptions {
  112784. /**
  112785. * Options for this XR Layer output
  112786. */
  112787. canvasOptions: XRWebGLLayerOptions;
  112788. /**
  112789. * CSS styling for a newly created canvas (if not provided)
  112790. */
  112791. newCanvasCssStyle?: string;
  112792. /**
  112793. * Get the default values of the configuration object
  112794. * @returns default values of this configuration object
  112795. */
  112796. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112797. }
  112798. /**
  112799. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112800. */
  112801. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112802. private configuration;
  112803. private _engine;
  112804. private _canvas;
  112805. /**
  112806. * xrpresent context of the canvas which can be used to display/mirror xr content
  112807. */
  112808. canvasContext: WebGLRenderingContext;
  112809. /**
  112810. * xr layer for the canvas
  112811. */
  112812. xrLayer: Nullable<XRWebGLLayer>;
  112813. /**
  112814. * Initializes the xr layer for the session
  112815. * @param xrSession xr session
  112816. * @returns a promise that will resolve once the XR Layer has been created
  112817. */
  112818. initializeXRLayerAsync(xrSession: any): any;
  112819. /**
  112820. * Initializes the canvas to be added/removed upon entering/exiting xr
  112821. * @param engine the Babylon engine
  112822. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112823. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112824. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112825. */
  112826. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112827. /**
  112828. * Disposes of the object
  112829. */
  112830. dispose(): void;
  112831. private _setManagedOutputCanvas;
  112832. private _addCanvas;
  112833. private _removeCanvas;
  112834. }
  112835. }
  112836. declare module BABYLON {
  112837. /**
  112838. * Manages an XRSession to work with Babylon's engine
  112839. * @see https://doc.babylonjs.com/how_to/webxr
  112840. */
  112841. export class WebXRSessionManager implements IDisposable {
  112842. /** The scene which the session should be created for */
  112843. scene: Scene;
  112844. /**
  112845. * Fires every time a new xrFrame arrives which can be used to update the camera
  112846. */
  112847. onXRFrameObservable: Observable<XRFrame>;
  112848. /**
  112849. * Fires when the xr session is ended either by the device or manually done
  112850. */
  112851. onXRSessionEnded: Observable<any>;
  112852. /**
  112853. * Fires when the xr session is ended either by the device or manually done
  112854. */
  112855. onXRSessionInit: Observable<XRSession>;
  112856. /**
  112857. * Underlying xr session
  112858. */
  112859. session: XRSession;
  112860. /**
  112861. * Type of reference space used when creating the session
  112862. */
  112863. referenceSpace: XRReferenceSpace;
  112864. /**
  112865. * Current XR frame
  112866. */
  112867. currentFrame: Nullable<XRFrame>;
  112868. /** WebXR timestamp updated every frame */
  112869. currentTimestamp: number;
  112870. private _xrNavigator;
  112871. private baseLayer;
  112872. private _rttProvider;
  112873. private _sessionEnded;
  112874. /**
  112875. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  112876. * @param scene The scene which the session should be created for
  112877. */
  112878. constructor(
  112879. /** The scene which the session should be created for */
  112880. scene: Scene);
  112881. /**
  112882. * Initializes the manager
  112883. * After initialization enterXR can be called to start an XR session
  112884. * @returns Promise which resolves after it is initialized
  112885. */
  112886. initializeAsync(): Promise<void>;
  112887. /**
  112888. * Initializes an xr session
  112889. * @param xrSessionMode mode to initialize
  112890. * @param optionalFeatures defines optional values to pass to the session builder
  112891. * @returns a promise which will resolve once the session has been initialized
  112892. */
  112893. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  112894. /**
  112895. * Sets the reference space on the xr session
  112896. * @param referenceSpace space to set
  112897. * @returns a promise that will resolve once the reference space has been set
  112898. */
  112899. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  112900. /**
  112901. * Updates the render state of the session
  112902. * @param state state to set
  112903. * @returns a promise that resolves once the render state has been updated
  112904. */
  112905. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  112906. /**
  112907. * Starts rendering to the xr layer
  112908. * @returns a promise that will resolve once rendering has started
  112909. */
  112910. startRenderingToXRAsync(): Promise<void>;
  112911. /**
  112912. * Gets the correct render target texture to be rendered this frame for this eye
  112913. * @param eye the eye for which to get the render target
  112914. * @returns the render target for the specified eye
  112915. */
  112916. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  112917. /**
  112918. * Stops the xrSession and restores the renderloop
  112919. * @returns Promise which resolves after it exits XR
  112920. */
  112921. exitXRAsync(): Promise<void>;
  112922. /**
  112923. * Checks if a session would be supported for the creation options specified
  112924. * @param sessionMode session mode to check if supported eg. immersive-vr
  112925. * @returns true if supported
  112926. */
  112927. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112928. /**
  112929. * Creates a WebXRRenderTarget object for the XR session
  112930. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  112931. * @param options optional options to provide when creating a new render target
  112932. * @returns a WebXR render target to which the session can render
  112933. */
  112934. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  112935. /**
  112936. * @hidden
  112937. * Converts the render layer of xrSession to a render target
  112938. * @param session session to create render target for
  112939. * @param scene scene the new render target should be created for
  112940. * @param baseLayer the webgl layer to create the render target for
  112941. */
  112942. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  112943. /**
  112944. * Disposes of the session manager
  112945. */
  112946. dispose(): void;
  112947. /**
  112948. * Gets a promise returning true when fullfiled if the given session mode is supported
  112949. * @param sessionMode defines the session to test
  112950. * @returns a promise
  112951. */
  112952. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112953. }
  112954. }
  112955. declare module BABYLON {
  112956. /**
  112957. * WebXR Camera which holds the views for the xrSession
  112958. * @see https://doc.babylonjs.com/how_to/webxr
  112959. */
  112960. export class WebXRCamera extends FreeCamera {
  112961. /**
  112962. * Is the camera in debug mode. Used when using an emulator
  112963. */
  112964. debugMode: boolean;
  112965. /**
  112966. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  112967. * @param name the name of the camera
  112968. * @param scene the scene to add the camera to
  112969. */
  112970. constructor(name: string, scene: Scene);
  112971. private _updateNumberOfRigCameras;
  112972. /** @hidden */
  112973. _updateForDualEyeDebugging(): void;
  112974. /**
  112975. * Updates the cameras position from the current pose information of the XR session
  112976. * @param xrSessionManager the session containing pose information
  112977. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  112978. */
  112979. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  112980. }
  112981. }
  112982. declare module BABYLON {
  112983. /**
  112984. * Defining the interface required for a (webxr) feature
  112985. */
  112986. export interface IWebXRFeature extends IDisposable {
  112987. /**
  112988. * Attach the feature to the session
  112989. * Will usually be called by the features manager
  112990. *
  112991. * @returns true if successful.
  112992. */
  112993. attach(): boolean;
  112994. /**
  112995. * Detach the feature from the session
  112996. * Will usually be called by the features manager
  112997. *
  112998. * @returns true if successful.
  112999. */
  113000. detach(): boolean;
  113001. }
  113002. /**
  113003. * Defining the constructor of a feature. Used to register the modules.
  113004. */
  113005. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113006. /**
  113007. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113008. * It is mainly used in AR sessions.
  113009. *
  113010. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113011. */
  113012. export class WebXRFeaturesManager implements IDisposable {
  113013. private _xrSessionManager;
  113014. private static readonly _AvailableFeatures;
  113015. /**
  113016. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113017. * Mainly used internally.
  113018. *
  113019. * @param featureName the name of the feature to register
  113020. * @param constructorFunction the function used to construct the module
  113021. * @param version the (babylon) version of the module
  113022. * @param stable is that a stable version of this module
  113023. */
  113024. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113025. /**
  113026. * Returns a constructor of a specific feature.
  113027. *
  113028. * @param featureName the name of the feature to construct
  113029. * @param version the version of the feature to load
  113030. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113031. * @param options optional options provided to the module.
  113032. * @returns a function that, when called, will return a new instance of this feature
  113033. */
  113034. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113035. /**
  113036. * Return the latest unstable version of this feature
  113037. * @param featureName the name of the feature to search
  113038. * @returns the version number. if not found will return -1
  113039. */
  113040. static GetLatestVersionOfFeature(featureName: string): number;
  113041. /**
  113042. * Return the latest stable version of this feature
  113043. * @param featureName the name of the feature to search
  113044. * @returns the version number. if not found will return -1
  113045. */
  113046. static GetStableVersionOfFeature(featureName: string): number;
  113047. /**
  113048. * Can be used to return the list of features currently registered
  113049. *
  113050. * @returns an Array of available features
  113051. */
  113052. static GetAvailableFeatures(): string[];
  113053. /**
  113054. * Gets the versions available for a specific feature
  113055. * @param featureName the name of the feature
  113056. * @returns an array with the available versions
  113057. */
  113058. static GetAvailableVersions(featureName: string): string[];
  113059. private _features;
  113060. /**
  113061. * constructs a new features manages.
  113062. *
  113063. * @param _xrSessionManager an instance of WebXRSessionManager
  113064. */
  113065. constructor(_xrSessionManager: WebXRSessionManager);
  113066. /**
  113067. * 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.
  113068. *
  113069. * @param featureName the name of the feature to load or the class of the feature
  113070. * @param version optional version to load. if not provided the latest version will be enabled
  113071. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113072. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113073. * @returns a new constructed feature or throws an error if feature not found.
  113074. */
  113075. enableFeature(featureName: string | {
  113076. Name: string;
  113077. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113078. /**
  113079. * Used to disable an already-enabled feature
  113080. * @param featureName the feature to disable
  113081. * @returns true if disable was successful
  113082. */
  113083. disableFeature(featureName: string | {
  113084. Name: string;
  113085. }): boolean;
  113086. /**
  113087. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113088. * Can be used during a session to start a feature
  113089. * @param featureName the name of feature to attach
  113090. */
  113091. attachFeature(featureName: string): void;
  113092. /**
  113093. * Can be used inside a session or when the session ends to detach a specific feature
  113094. * @param featureName the name of the feature to detach
  113095. */
  113096. detachFeature(featureName: string): void;
  113097. /**
  113098. * Get the list of enabled features
  113099. * @returns an array of enabled features
  113100. */
  113101. getEnabledFeatures(): string[];
  113102. /**
  113103. * get the implementation of an enabled feature.
  113104. * @param featureName the name of the feature to load
  113105. * @returns the feature class, if found
  113106. */
  113107. getEnabledFeature(featureName: string): IWebXRFeature;
  113108. /**
  113109. * dispose this features manager
  113110. */
  113111. dispose(): void;
  113112. }
  113113. }
  113114. declare module BABYLON {
  113115. /**
  113116. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113117. * @see https://doc.babylonjs.com/how_to/webxr
  113118. */
  113119. export class WebXRExperienceHelper implements IDisposable {
  113120. private scene;
  113121. /**
  113122. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  113123. */
  113124. container: AbstractMesh;
  113125. /**
  113126. * Camera used to render xr content
  113127. */
  113128. camera: WebXRCamera;
  113129. /**
  113130. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113131. */
  113132. state: WebXRState;
  113133. private _setState;
  113134. private static _TmpVector;
  113135. /**
  113136. * Fires when the state of the experience helper has changed
  113137. */
  113138. onStateChangedObservable: Observable<WebXRState>;
  113139. /** Session manager used to keep track of xr session */
  113140. sessionManager: WebXRSessionManager;
  113141. /** A features manager for this xr session */
  113142. featuresManager: WebXRFeaturesManager;
  113143. private _nonVRCamera;
  113144. private _originalSceneAutoClear;
  113145. private _supported;
  113146. /**
  113147. * Creates the experience helper
  113148. * @param scene the scene to attach the experience helper to
  113149. * @returns a promise for the experience helper
  113150. */
  113151. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113152. /**
  113153. * Creates a WebXRExperienceHelper
  113154. * @param scene The scene the helper should be created in
  113155. */
  113156. private constructor();
  113157. /**
  113158. * Exits XR mode and returns the scene to its original state
  113159. * @returns promise that resolves after xr mode has exited
  113160. */
  113161. exitXRAsync(): Promise<void>;
  113162. /**
  113163. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113164. * @param sessionMode options for the XR session
  113165. * @param referenceSpaceType frame of reference of the XR session
  113166. * @param renderTarget the output canvas that will be used to enter XR mode
  113167. * @returns promise that resolves after xr mode has entered
  113168. */
  113169. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113170. /**
  113171. * Updates the global position of the camera by moving the camera's container
  113172. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113173. * @param position The desired global position of the camera
  113174. */
  113175. setPositionOfCameraUsingContainer(position: Vector3): void;
  113176. /**
  113177. * Rotates the xr camera by rotating the camera's container around the camera's position
  113178. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113179. * @param rotation the desired quaternion rotation to apply to the camera
  113180. */
  113181. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113182. /**
  113183. * Disposes of the experience helper
  113184. */
  113185. dispose(): void;
  113186. }
  113187. }
  113188. declare module BABYLON {
  113189. /**
  113190. * Represents an XR input
  113191. */
  113192. export class WebXRController {
  113193. private scene;
  113194. /** The underlying input source for the controller */
  113195. inputSource: XRInputSource;
  113196. private parentContainer;
  113197. /**
  113198. * 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
  113199. */
  113200. grip?: AbstractMesh;
  113201. /**
  113202. * Pointer which can be used to select objects or attach a visible laser to
  113203. */
  113204. pointer: AbstractMesh;
  113205. private _gamepadMode;
  113206. /**
  113207. * If available, this is the gamepad object related to this controller.
  113208. * Using this object it is possible to get click events and trackpad changes of the
  113209. * webxr controller that is currently being used.
  113210. */
  113211. gamepadController?: WebVRController;
  113212. /**
  113213. * Event that fires when the controller is removed/disposed
  113214. */
  113215. onDisposeObservable: Observable<{}>;
  113216. private _tmpQuaternion;
  113217. private _tmpVector;
  113218. /**
  113219. * Creates the controller
  113220. * @see https://doc.babylonjs.com/how_to/webxr
  113221. * @param scene the scene which the controller should be associated to
  113222. * @param inputSource the underlying input source for the controller
  113223. * @param parentContainer parent that the controller meshes should be children of
  113224. */
  113225. constructor(scene: Scene,
  113226. /** The underlying input source for the controller */
  113227. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113228. /**
  113229. * Updates the controller pose based on the given XRFrame
  113230. * @param xrFrame xr frame to update the pose with
  113231. * @param referenceSpace reference space to use
  113232. */
  113233. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113234. /**
  113235. * Gets a world space ray coming from the controller
  113236. * @param result the resulting ray
  113237. */
  113238. getWorldPointerRayToRef(result: Ray): void;
  113239. /**
  113240. * Get the scene associated with this controller
  113241. * @returns the scene object
  113242. */
  113243. getScene(): Scene;
  113244. /**
  113245. * Disposes of the object
  113246. */
  113247. dispose(): void;
  113248. }
  113249. }
  113250. declare module BABYLON {
  113251. /**
  113252. * XR input used to track XR inputs such as controllers/rays
  113253. */
  113254. export class WebXRInput implements IDisposable {
  113255. /**
  113256. * Base experience the input listens to
  113257. */
  113258. baseExperience: WebXRExperienceHelper;
  113259. /**
  113260. * XR controllers being tracked
  113261. */
  113262. controllers: Array<WebXRController>;
  113263. private _frameObserver;
  113264. private _stateObserver;
  113265. /**
  113266. * Event when a controller has been connected/added
  113267. */
  113268. onControllerAddedObservable: Observable<WebXRController>;
  113269. /**
  113270. * Event when a controller has been removed/disconnected
  113271. */
  113272. onControllerRemovedObservable: Observable<WebXRController>;
  113273. /**
  113274. * Initializes the WebXRInput
  113275. * @param baseExperience experience helper which the input should be created for
  113276. */
  113277. constructor(
  113278. /**
  113279. * Base experience the input listens to
  113280. */
  113281. baseExperience: WebXRExperienceHelper);
  113282. private _onInputSourcesChange;
  113283. private _addAndRemoveControllers;
  113284. /**
  113285. * Disposes of the object
  113286. */
  113287. dispose(): void;
  113288. }
  113289. }
  113290. declare module BABYLON {
  113291. /**
  113292. * Class used to represent data loading progression
  113293. */
  113294. export class SceneLoaderProgressEvent {
  113295. /** defines if data length to load can be evaluated */
  113296. readonly lengthComputable: boolean;
  113297. /** defines the loaded data length */
  113298. readonly loaded: number;
  113299. /** defines the data length to load */
  113300. readonly total: number;
  113301. /**
  113302. * Create a new progress event
  113303. * @param lengthComputable defines if data length to load can be evaluated
  113304. * @param loaded defines the loaded data length
  113305. * @param total defines the data length to load
  113306. */
  113307. constructor(
  113308. /** defines if data length to load can be evaluated */
  113309. lengthComputable: boolean,
  113310. /** defines the loaded data length */
  113311. loaded: number,
  113312. /** defines the data length to load */
  113313. total: number);
  113314. /**
  113315. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113316. * @param event defines the source event
  113317. * @returns a new SceneLoaderProgressEvent
  113318. */
  113319. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113320. }
  113321. /**
  113322. * Interface used by SceneLoader plugins to define supported file extensions
  113323. */
  113324. export interface ISceneLoaderPluginExtensions {
  113325. /**
  113326. * Defines the list of supported extensions
  113327. */
  113328. [extension: string]: {
  113329. isBinary: boolean;
  113330. };
  113331. }
  113332. /**
  113333. * Interface used by SceneLoader plugin factory
  113334. */
  113335. export interface ISceneLoaderPluginFactory {
  113336. /**
  113337. * Defines the name of the factory
  113338. */
  113339. name: string;
  113340. /**
  113341. * Function called to create a new plugin
  113342. * @return the new plugin
  113343. */
  113344. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113345. /**
  113346. * The callback that returns true if the data can be directly loaded.
  113347. * @param data string containing the file data
  113348. * @returns if the data can be loaded directly
  113349. */
  113350. canDirectLoad?(data: string): boolean;
  113351. }
  113352. /**
  113353. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113354. */
  113355. export interface ISceneLoaderPluginBase {
  113356. /**
  113357. * The friendly name of this plugin.
  113358. */
  113359. name: string;
  113360. /**
  113361. * The file extensions supported by this plugin.
  113362. */
  113363. extensions: string | ISceneLoaderPluginExtensions;
  113364. /**
  113365. * The callback called when loading from a url.
  113366. * @param scene scene loading this url
  113367. * @param url url to load
  113368. * @param onSuccess callback called when the file successfully loads
  113369. * @param onProgress callback called while file is loading (if the server supports this mode)
  113370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113371. * @param onError callback called when the file fails to load
  113372. * @returns a file request object
  113373. */
  113374. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113375. /**
  113376. * The callback called when loading from a file object.
  113377. * @param scene scene loading this file
  113378. * @param file defines the file to load
  113379. * @param onSuccess defines the callback to call when data is loaded
  113380. * @param onProgress defines the callback to call during loading process
  113381. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113382. * @param onError defines the callback to call when an error occurs
  113383. * @returns a file request object
  113384. */
  113385. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113386. /**
  113387. * The callback that returns true if the data can be directly loaded.
  113388. * @param data string containing the file data
  113389. * @returns if the data can be loaded directly
  113390. */
  113391. canDirectLoad?(data: string): boolean;
  113392. /**
  113393. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113394. * @param scene scene loading this data
  113395. * @param data string containing the data
  113396. * @returns data to pass to the plugin
  113397. */
  113398. directLoad?(scene: Scene, data: string): any;
  113399. /**
  113400. * The callback that allows custom handling of the root url based on the response url.
  113401. * @param rootUrl the original root url
  113402. * @param responseURL the response url if available
  113403. * @returns the new root url
  113404. */
  113405. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113406. }
  113407. /**
  113408. * Interface used to define a SceneLoader plugin
  113409. */
  113410. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113411. /**
  113412. * Import meshes into a scene.
  113413. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113414. * @param scene The scene to import into
  113415. * @param data The data to import
  113416. * @param rootUrl The root url for scene and resources
  113417. * @param meshes The meshes array to import into
  113418. * @param particleSystems The particle systems array to import into
  113419. * @param skeletons The skeletons array to import into
  113420. * @param onError The callback when import fails
  113421. * @returns True if successful or false otherwise
  113422. */
  113423. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113424. /**
  113425. * Load into a scene.
  113426. * @param scene The scene to load into
  113427. * @param data The data to import
  113428. * @param rootUrl The root url for scene and resources
  113429. * @param onError The callback when import fails
  113430. * @returns True if successful or false otherwise
  113431. */
  113432. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113433. /**
  113434. * Load into an asset container.
  113435. * @param scene The scene to load into
  113436. * @param data The data to import
  113437. * @param rootUrl The root url for scene and resources
  113438. * @param onError The callback when import fails
  113439. * @returns The loaded asset container
  113440. */
  113441. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113442. }
  113443. /**
  113444. * Interface used to define an async SceneLoader plugin
  113445. */
  113446. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113447. /**
  113448. * Import meshes into a scene.
  113449. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113450. * @param scene The scene to import into
  113451. * @param data The data to import
  113452. * @param rootUrl The root url for scene and resources
  113453. * @param onProgress The callback when the load progresses
  113454. * @param fileName Defines the name of the file to load
  113455. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113456. */
  113457. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113458. meshes: AbstractMesh[];
  113459. particleSystems: IParticleSystem[];
  113460. skeletons: Skeleton[];
  113461. animationGroups: AnimationGroup[];
  113462. }>;
  113463. /**
  113464. * Load into a scene.
  113465. * @param scene The scene to load into
  113466. * @param data The data to import
  113467. * @param rootUrl The root url for scene and resources
  113468. * @param onProgress The callback when the load progresses
  113469. * @param fileName Defines the name of the file to load
  113470. * @returns Nothing
  113471. */
  113472. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113473. /**
  113474. * Load into an asset container.
  113475. * @param scene The scene to load into
  113476. * @param data The data to import
  113477. * @param rootUrl The root url for scene and resources
  113478. * @param onProgress The callback when the load progresses
  113479. * @param fileName Defines the name of the file to load
  113480. * @returns The loaded asset container
  113481. */
  113482. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113483. }
  113484. /**
  113485. * Mode that determines how to handle old animation groups before loading new ones.
  113486. */
  113487. export enum SceneLoaderAnimationGroupLoadingMode {
  113488. /**
  113489. * Reset all old animations to initial state then dispose them.
  113490. */
  113491. Clean = 0,
  113492. /**
  113493. * Stop all old animations.
  113494. */
  113495. Stop = 1,
  113496. /**
  113497. * Restart old animations from first frame.
  113498. */
  113499. Sync = 2,
  113500. /**
  113501. * Old animations remains untouched.
  113502. */
  113503. NoSync = 3
  113504. }
  113505. /**
  113506. * Class used to load scene from various file formats using registered plugins
  113507. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113508. */
  113509. export class SceneLoader {
  113510. /**
  113511. * No logging while loading
  113512. */
  113513. static readonly NO_LOGGING: number;
  113514. /**
  113515. * Minimal logging while loading
  113516. */
  113517. static readonly MINIMAL_LOGGING: number;
  113518. /**
  113519. * Summary logging while loading
  113520. */
  113521. static readonly SUMMARY_LOGGING: number;
  113522. /**
  113523. * Detailled logging while loading
  113524. */
  113525. static readonly DETAILED_LOGGING: number;
  113526. /**
  113527. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113528. */
  113529. static get ForceFullSceneLoadingForIncremental(): boolean;
  113530. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113531. /**
  113532. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113533. */
  113534. static get ShowLoadingScreen(): boolean;
  113535. static set ShowLoadingScreen(value: boolean);
  113536. /**
  113537. * Defines the current logging level (while loading the scene)
  113538. * @ignorenaming
  113539. */
  113540. static get loggingLevel(): number;
  113541. static set loggingLevel(value: number);
  113542. /**
  113543. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113544. */
  113545. static get CleanBoneMatrixWeights(): boolean;
  113546. static set CleanBoneMatrixWeights(value: boolean);
  113547. /**
  113548. * Event raised when a plugin is used to load a scene
  113549. */
  113550. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113551. private static _registeredPlugins;
  113552. private static _getDefaultPlugin;
  113553. private static _getPluginForExtension;
  113554. private static _getPluginForDirectLoad;
  113555. private static _getPluginForFilename;
  113556. private static _getDirectLoad;
  113557. private static _loadData;
  113558. private static _getFileInfo;
  113559. /**
  113560. * Gets a plugin that can load the given extension
  113561. * @param extension defines the extension to load
  113562. * @returns a plugin or null if none works
  113563. */
  113564. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113565. /**
  113566. * Gets a boolean indicating that the given extension can be loaded
  113567. * @param extension defines the extension to load
  113568. * @returns true if the extension is supported
  113569. */
  113570. static IsPluginForExtensionAvailable(extension: string): boolean;
  113571. /**
  113572. * Adds a new plugin to the list of registered plugins
  113573. * @param plugin defines the plugin to add
  113574. */
  113575. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113576. /**
  113577. * Import meshes into a scene
  113578. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113579. * @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)
  113580. * @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)
  113581. * @param scene the instance of BABYLON.Scene to append to
  113582. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113583. * @param onProgress a callback with a progress event for each file being loaded
  113584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113585. * @param pluginExtension the extension used to determine the plugin
  113586. * @returns The loaded plugin
  113587. */
  113588. 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>;
  113589. /**
  113590. * Import meshes into a scene
  113591. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113592. * @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)
  113593. * @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)
  113594. * @param scene the instance of BABYLON.Scene to append to
  113595. * @param onProgress a callback with a progress event for each file being loaded
  113596. * @param pluginExtension the extension used to determine the plugin
  113597. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113598. */
  113599. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113600. meshes: AbstractMesh[];
  113601. particleSystems: IParticleSystem[];
  113602. skeletons: Skeleton[];
  113603. animationGroups: AnimationGroup[];
  113604. }>;
  113605. /**
  113606. * Load a scene
  113607. * @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)
  113608. * @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)
  113609. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113610. * @param onSuccess a callback with the scene when import succeeds
  113611. * @param onProgress a callback with a progress event for each file being loaded
  113612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113613. * @param pluginExtension the extension used to determine the plugin
  113614. * @returns The loaded plugin
  113615. */
  113616. 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>;
  113617. /**
  113618. * Load a scene
  113619. * @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)
  113620. * @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)
  113621. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113622. * @param onProgress a callback with a progress event for each file being loaded
  113623. * @param pluginExtension the extension used to determine the plugin
  113624. * @returns The loaded scene
  113625. */
  113626. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113627. /**
  113628. * Append a scene
  113629. * @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)
  113630. * @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)
  113631. * @param scene is the instance of BABYLON.Scene to append to
  113632. * @param onSuccess a callback with the scene when import succeeds
  113633. * @param onProgress a callback with a progress event for each file being loaded
  113634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113635. * @param pluginExtension the extension used to determine the plugin
  113636. * @returns The loaded plugin
  113637. */
  113638. 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>;
  113639. /**
  113640. * Append a scene
  113641. * @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)
  113642. * @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)
  113643. * @param scene is the instance of BABYLON.Scene to append to
  113644. * @param onProgress a callback with a progress event for each file being loaded
  113645. * @param pluginExtension the extension used to determine the plugin
  113646. * @returns The given scene
  113647. */
  113648. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113649. /**
  113650. * Load a scene into an asset container
  113651. * @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)
  113652. * @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)
  113653. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113654. * @param onSuccess a callback with the scene when import succeeds
  113655. * @param onProgress a callback with a progress event for each file being loaded
  113656. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113657. * @param pluginExtension the extension used to determine the plugin
  113658. * @returns The loaded plugin
  113659. */
  113660. 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>;
  113661. /**
  113662. * Load a scene into an asset container
  113663. * @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)
  113664. * @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)
  113665. * @param scene is the instance of Scene to append to
  113666. * @param onProgress a callback with a progress event for each file being loaded
  113667. * @param pluginExtension the extension used to determine the plugin
  113668. * @returns The loaded asset container
  113669. */
  113670. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113671. /**
  113672. * Import animations from a file into a scene
  113673. * @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)
  113674. * @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)
  113675. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113676. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113677. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113678. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113679. * @param onSuccess a callback with the scene when import succeeds
  113680. * @param onProgress a callback with a progress event for each file being loaded
  113681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113682. */
  113683. 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;
  113684. /**
  113685. * Import animations from a file into a scene
  113686. * @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)
  113687. * @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)
  113688. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113689. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113690. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113691. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113692. * @param onSuccess a callback with the scene when import succeeds
  113693. * @param onProgress a callback with a progress event for each file being loaded
  113694. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113695. * @returns the updated scene with imported animations
  113696. */
  113697. 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>;
  113698. }
  113699. }
  113700. declare module BABYLON {
  113701. /**
  113702. * Generic Controller
  113703. */
  113704. export class GenericController extends WebVRController {
  113705. /**
  113706. * Base Url for the controller model.
  113707. */
  113708. static readonly MODEL_BASE_URL: string;
  113709. /**
  113710. * File name for the controller model.
  113711. */
  113712. static readonly MODEL_FILENAME: string;
  113713. /**
  113714. * Creates a new GenericController from a gamepad
  113715. * @param vrGamepad the gamepad that the controller should be created from
  113716. */
  113717. constructor(vrGamepad: any);
  113718. /**
  113719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113720. * @param scene scene in which to add meshes
  113721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113722. */
  113723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113724. /**
  113725. * Called once for each button that changed state since the last frame
  113726. * @param buttonIdx Which button index changed
  113727. * @param state New state of the button
  113728. * @param changes Which properties on the state changed since last frame
  113729. */
  113730. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113731. }
  113732. }
  113733. declare module BABYLON {
  113734. /**
  113735. * Defines the WindowsMotionController object that the state of the windows motion controller
  113736. */
  113737. export class WindowsMotionController extends WebVRController {
  113738. /**
  113739. * The base url used to load the left and right controller models
  113740. */
  113741. static MODEL_BASE_URL: string;
  113742. /**
  113743. * The name of the left controller model file
  113744. */
  113745. static MODEL_LEFT_FILENAME: string;
  113746. /**
  113747. * The name of the right controller model file
  113748. */
  113749. static MODEL_RIGHT_FILENAME: string;
  113750. /**
  113751. * The controller name prefix for this controller type
  113752. */
  113753. static readonly GAMEPAD_ID_PREFIX: string;
  113754. /**
  113755. * The controller id pattern for this controller type
  113756. */
  113757. private static readonly GAMEPAD_ID_PATTERN;
  113758. private _loadedMeshInfo;
  113759. protected readonly _mapping: {
  113760. buttons: string[];
  113761. buttonMeshNames: {
  113762. 'trigger': string;
  113763. 'menu': string;
  113764. 'grip': string;
  113765. 'thumbstick': string;
  113766. 'trackpad': string;
  113767. };
  113768. buttonObservableNames: {
  113769. 'trigger': string;
  113770. 'menu': string;
  113771. 'grip': string;
  113772. 'thumbstick': string;
  113773. 'trackpad': string;
  113774. };
  113775. axisMeshNames: string[];
  113776. pointingPoseMeshName: string;
  113777. };
  113778. /**
  113779. * Fired when the trackpad on this controller is clicked
  113780. */
  113781. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113782. /**
  113783. * Fired when the trackpad on this controller is modified
  113784. */
  113785. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113786. /**
  113787. * The current x and y values of this controller's trackpad
  113788. */
  113789. trackpad: StickValues;
  113790. /**
  113791. * Creates a new WindowsMotionController from a gamepad
  113792. * @param vrGamepad the gamepad that the controller should be created from
  113793. */
  113794. constructor(vrGamepad: any);
  113795. /**
  113796. * Fired when the trigger on this controller is modified
  113797. */
  113798. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113799. /**
  113800. * Fired when the menu button on this controller is modified
  113801. */
  113802. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113803. /**
  113804. * Fired when the grip button on this controller is modified
  113805. */
  113806. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113807. /**
  113808. * Fired when the thumbstick button on this controller is modified
  113809. */
  113810. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113811. /**
  113812. * Fired when the touchpad button on this controller is modified
  113813. */
  113814. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113815. /**
  113816. * Fired when the touchpad values on this controller are modified
  113817. */
  113818. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113819. protected _updateTrackpad(): void;
  113820. /**
  113821. * Called once per frame by the engine.
  113822. */
  113823. update(): void;
  113824. /**
  113825. * Called once for each button that changed state since the last frame
  113826. * @param buttonIdx Which button index changed
  113827. * @param state New state of the button
  113828. * @param changes Which properties on the state changed since last frame
  113829. */
  113830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113831. /**
  113832. * Moves the buttons on the controller mesh based on their current state
  113833. * @param buttonName the name of the button to move
  113834. * @param buttonValue the value of the button which determines the buttons new position
  113835. */
  113836. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113837. /**
  113838. * Moves the axis on the controller mesh based on its current state
  113839. * @param axis the index of the axis
  113840. * @param axisValue the value of the axis which determines the meshes new position
  113841. * @hidden
  113842. */
  113843. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113844. /**
  113845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113846. * @param scene scene in which to add meshes
  113847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113848. */
  113849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113850. /**
  113851. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113852. * can be transformed by button presses and axes values, based on this._mapping.
  113853. *
  113854. * @param scene scene in which the meshes exist
  113855. * @param meshes list of meshes that make up the controller model to process
  113856. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113857. */
  113858. private processModel;
  113859. private createMeshInfo;
  113860. /**
  113861. * Gets the ray of the controller in the direction the controller is pointing
  113862. * @param length the length the resulting ray should be
  113863. * @returns a ray in the direction the controller is pointing
  113864. */
  113865. getForwardRay(length?: number): Ray;
  113866. /**
  113867. * Disposes of the controller
  113868. */
  113869. dispose(): void;
  113870. }
  113871. /**
  113872. * This class represents a new windows motion controller in XR.
  113873. */
  113874. export class XRWindowsMotionController extends WindowsMotionController {
  113875. /**
  113876. * Changing the original WIndowsMotionController mapping to fir the new mapping
  113877. */
  113878. protected readonly _mapping: {
  113879. buttons: string[];
  113880. buttonMeshNames: {
  113881. 'trigger': string;
  113882. 'menu': string;
  113883. 'grip': string;
  113884. 'thumbstick': string;
  113885. 'trackpad': string;
  113886. };
  113887. buttonObservableNames: {
  113888. 'trigger': string;
  113889. 'menu': string;
  113890. 'grip': string;
  113891. 'thumbstick': string;
  113892. 'trackpad': string;
  113893. };
  113894. axisMeshNames: string[];
  113895. pointingPoseMeshName: string;
  113896. };
  113897. /**
  113898. * Construct a new XR-Based windows motion controller
  113899. *
  113900. * @param gamepadInfo the gamepad object from the browser
  113901. */
  113902. constructor(gamepadInfo: any);
  113903. /**
  113904. * holds the thumbstick values (X,Y)
  113905. */
  113906. thumbstickValues: StickValues;
  113907. /**
  113908. * Fired when the thumbstick on this controller is clicked
  113909. */
  113910. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  113911. /**
  113912. * Fired when the thumbstick on this controller is modified
  113913. */
  113914. onThumbstickValuesChangedObservable: Observable<StickValues>;
  113915. /**
  113916. * Fired when the touchpad button on this controller is modified
  113917. */
  113918. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113919. /**
  113920. * Fired when the touchpad values on this controller are modified
  113921. */
  113922. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113923. /**
  113924. * Fired when the thumbstick button on this controller is modified
  113925. * here to prevent breaking changes
  113926. */
  113927. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113928. /**
  113929. * updating the thumbstick(!) and not the trackpad.
  113930. * This is named this way due to the difference between WebVR and XR and to avoid
  113931. * changing the parent class.
  113932. */
  113933. protected _updateTrackpad(): void;
  113934. /**
  113935. * Disposes the class with joy
  113936. */
  113937. dispose(): void;
  113938. }
  113939. }
  113940. declare module BABYLON {
  113941. /**
  113942. * Oculus Touch Controller
  113943. */
  113944. export class OculusTouchController extends WebVRController {
  113945. /**
  113946. * Base Url for the controller model.
  113947. */
  113948. static MODEL_BASE_URL: string;
  113949. /**
  113950. * File name for the left controller model.
  113951. */
  113952. static MODEL_LEFT_FILENAME: string;
  113953. /**
  113954. * File name for the right controller model.
  113955. */
  113956. static MODEL_RIGHT_FILENAME: string;
  113957. /**
  113958. * Base Url for the Quest controller model.
  113959. */
  113960. static QUEST_MODEL_BASE_URL: string;
  113961. /**
  113962. * @hidden
  113963. * If the controllers are running on a device that needs the updated Quest controller models
  113964. */
  113965. static _IsQuest: boolean;
  113966. /**
  113967. * Fired when the secondary trigger on this controller is modified
  113968. */
  113969. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  113970. /**
  113971. * Fired when the thumb rest on this controller is modified
  113972. */
  113973. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  113974. /**
  113975. * Creates a new OculusTouchController from a gamepad
  113976. * @param vrGamepad the gamepad that the controller should be created from
  113977. */
  113978. constructor(vrGamepad: any);
  113979. /**
  113980. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113981. * @param scene scene in which to add meshes
  113982. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113983. */
  113984. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113985. /**
  113986. * Fired when the A button on this controller is modified
  113987. */
  113988. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113989. /**
  113990. * Fired when the B button on this controller is modified
  113991. */
  113992. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113993. /**
  113994. * Fired when the X button on this controller is modified
  113995. */
  113996. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113997. /**
  113998. * Fired when the Y button on this controller is modified
  113999. */
  114000. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114001. /**
  114002. * Called once for each button that changed state since the last frame
  114003. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114004. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114005. * 2) secondary trigger (same)
  114006. * 3) A (right) X (left), touch, pressed = value
  114007. * 4) B / Y
  114008. * 5) thumb rest
  114009. * @param buttonIdx Which button index changed
  114010. * @param state New state of the button
  114011. * @param changes Which properties on the state changed since last frame
  114012. */
  114013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114014. }
  114015. }
  114016. declare module BABYLON {
  114017. /**
  114018. * Vive Controller
  114019. */
  114020. export class ViveController extends WebVRController {
  114021. /**
  114022. * Base Url for the controller model.
  114023. */
  114024. static MODEL_BASE_URL: string;
  114025. /**
  114026. * File name for the controller model.
  114027. */
  114028. static MODEL_FILENAME: string;
  114029. /**
  114030. * Creates a new ViveController from a gamepad
  114031. * @param vrGamepad the gamepad that the controller should be created from
  114032. */
  114033. constructor(vrGamepad: any);
  114034. /**
  114035. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114036. * @param scene scene in which to add meshes
  114037. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114038. */
  114039. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114040. /**
  114041. * Fired when the left button on this controller is modified
  114042. */
  114043. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114044. /**
  114045. * Fired when the right button on this controller is modified
  114046. */
  114047. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114048. /**
  114049. * Fired when the menu button on this controller is modified
  114050. */
  114051. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114052. /**
  114053. * Called once for each button that changed state since the last frame
  114054. * Vive mapping:
  114055. * 0: touchpad
  114056. * 1: trigger
  114057. * 2: left AND right buttons
  114058. * 3: menu button
  114059. * @param buttonIdx Which button index changed
  114060. * @param state New state of the button
  114061. * @param changes Which properties on the state changed since last frame
  114062. */
  114063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114064. }
  114065. }
  114066. declare module BABYLON {
  114067. /**
  114068. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114069. */
  114070. export class WebXRControllerModelLoader {
  114071. /**
  114072. * an observable that triggers when a new model (the mesh itself) was initialized.
  114073. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114074. */
  114075. onControllerModelLoaded: Observable<WebXRController>;
  114076. /**
  114077. * Creates the WebXRControllerModelLoader
  114078. * @param input xr input that creates the controllers
  114079. */
  114080. constructor(input: WebXRInput);
  114081. }
  114082. }
  114083. declare module BABYLON {
  114084. /**
  114085. * Handles pointer input automatically for the pointer of XR controllers
  114086. */
  114087. export class WebXRControllerPointerSelection {
  114088. private static _idCounter;
  114089. private _tmpRay;
  114090. /**
  114091. * Creates a WebXRControllerPointerSelection
  114092. * @param input input manager to setup pointer selection
  114093. */
  114094. constructor(input: WebXRInput);
  114095. private _convertNormalToDirectionOfRay;
  114096. private _updatePointerDistance;
  114097. }
  114098. }
  114099. declare module BABYLON {
  114100. /**
  114101. * Enables teleportation
  114102. */
  114103. export class WebXRControllerTeleportation {
  114104. private _teleportationFillColor;
  114105. private _teleportationBorderColor;
  114106. private _tmpRay;
  114107. private _tmpVector;
  114108. /**
  114109. * when set to true (default) teleportation will wait for thumbstick changes.
  114110. * When set to false teleportation will be disabled.
  114111. *
  114112. * If set to false while teleporting results can be unexpected.
  114113. */
  114114. enabled: boolean;
  114115. /**
  114116. * Creates a WebXRControllerTeleportation
  114117. * @param input input manager to add teleportation to
  114118. * @param floorMeshes floormeshes which can be teleported to
  114119. */
  114120. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114121. }
  114122. }
  114123. declare module BABYLON {
  114124. /**
  114125. * Button which can be used to enter a different mode of XR
  114126. */
  114127. export class WebXREnterExitUIButton {
  114128. /** button element */
  114129. element: HTMLElement;
  114130. /** XR initialization options for the button */
  114131. sessionMode: XRSessionMode;
  114132. /** Reference space type */
  114133. referenceSpaceType: XRReferenceSpaceType;
  114134. /**
  114135. * Creates a WebXREnterExitUIButton
  114136. * @param element button element
  114137. * @param sessionMode XR initialization session mode
  114138. * @param referenceSpaceType the type of reference space to be used
  114139. */
  114140. constructor(
  114141. /** button element */
  114142. element: HTMLElement,
  114143. /** XR initialization options for the button */
  114144. sessionMode: XRSessionMode,
  114145. /** Reference space type */
  114146. referenceSpaceType: XRReferenceSpaceType);
  114147. /**
  114148. * Overwritable function which can be used to update the button's visuals when the state changes
  114149. * @param activeButton the current active button in the UI
  114150. */
  114151. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114152. }
  114153. /**
  114154. * Options to create the webXR UI
  114155. */
  114156. export class WebXREnterExitUIOptions {
  114157. /**
  114158. * Context to enter xr with
  114159. */
  114160. renderTarget?: Nullable<WebXRRenderTarget>;
  114161. /**
  114162. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114163. */
  114164. customButtons?: Array<WebXREnterExitUIButton>;
  114165. /**
  114166. * A session mode to use when creating the default button.
  114167. * Default is immersive-vr
  114168. */
  114169. sessionMode?: XRSessionMode;
  114170. /**
  114171. * A reference space type to use when creating the default button.
  114172. * Default is local-floor
  114173. */
  114174. referenceSpaceType?: XRReferenceSpaceType;
  114175. }
  114176. /**
  114177. * UI to allow the user to enter/exit XR mode
  114178. */
  114179. export class WebXREnterExitUI implements IDisposable {
  114180. private scene;
  114181. /** version of the options passed to this UI */
  114182. options: WebXREnterExitUIOptions;
  114183. private _overlay;
  114184. private _buttons;
  114185. private _activeButton;
  114186. /**
  114187. * Fired every time the active button is changed.
  114188. *
  114189. * When xr is entered via a button that launches xr that button will be the callback parameter
  114190. *
  114191. * When exiting xr the callback parameter will be null)
  114192. */
  114193. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114194. /**
  114195. * Creates UI to allow the user to enter/exit XR mode
  114196. * @param scene the scene to add the ui to
  114197. * @param helper the xr experience helper to enter/exit xr with
  114198. * @param options options to configure the UI
  114199. * @returns the created ui
  114200. */
  114201. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114202. /**
  114203. *
  114204. * @param scene babylon scene object to use
  114205. * @param options (read-only) version of the options passed to this UI
  114206. */
  114207. private constructor();
  114208. private _updateButtons;
  114209. /**
  114210. * Disposes of the object
  114211. */
  114212. dispose(): void;
  114213. }
  114214. }
  114215. declare module BABYLON {
  114216. /**
  114217. * Options for the default xr helper
  114218. */
  114219. export class WebXRDefaultExperienceOptions {
  114220. /**
  114221. * Floor meshes that should be used for teleporting
  114222. */
  114223. floorMeshes: Array<AbstractMesh>;
  114224. /**
  114225. * Enable or disable default UI to enter XR
  114226. */
  114227. disableDefaultUI?: boolean;
  114228. /**
  114229. * optional configuration for the output canvas
  114230. */
  114231. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114232. /**
  114233. * optional UI options. This can be used among other to change session mode and reference space type
  114234. */
  114235. uiOptions?: WebXREnterExitUIOptions;
  114236. }
  114237. /**
  114238. * Default experience which provides a similar setup to the previous webVRExperience
  114239. */
  114240. export class WebXRDefaultExperience {
  114241. /**
  114242. * Base experience
  114243. */
  114244. baseExperience: WebXRExperienceHelper;
  114245. /**
  114246. * Input experience extension
  114247. */
  114248. input: WebXRInput;
  114249. /**
  114250. * Loads the controller models
  114251. */
  114252. controllerModelLoader: WebXRControllerModelLoader;
  114253. /**
  114254. * Enables laser pointer and selection
  114255. */
  114256. pointerSelection: WebXRControllerPointerSelection;
  114257. /**
  114258. * Enables teleportation
  114259. */
  114260. teleportation: WebXRControllerTeleportation;
  114261. /**
  114262. * Enables ui for entering/exiting xr
  114263. */
  114264. enterExitUI: WebXREnterExitUI;
  114265. /**
  114266. * Default target xr should render to
  114267. */
  114268. renderTarget: WebXRRenderTarget;
  114269. /**
  114270. * Creates the default xr experience
  114271. * @param scene scene
  114272. * @param options options for basic configuration
  114273. * @returns resulting WebXRDefaultExperience
  114274. */
  114275. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114276. private constructor();
  114277. /**
  114278. * DIsposes of the experience helper
  114279. */
  114280. dispose(): void;
  114281. }
  114282. }
  114283. declare module BABYLON {
  114284. /**
  114285. * Options to modify the vr teleportation behavior.
  114286. */
  114287. export interface VRTeleportationOptions {
  114288. /**
  114289. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114290. */
  114291. floorMeshName?: string;
  114292. /**
  114293. * A list of meshes to be used as the teleportation floor. (default: empty)
  114294. */
  114295. floorMeshes?: Mesh[];
  114296. /**
  114297. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114298. */
  114299. teleportationMode?: number;
  114300. /**
  114301. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114302. */
  114303. teleportationTime?: number;
  114304. /**
  114305. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114306. */
  114307. teleportationSpeed?: number;
  114308. /**
  114309. * The easing function used in the animation or null for Linear. (default CircleEase)
  114310. */
  114311. easingFunction?: EasingFunction;
  114312. }
  114313. /**
  114314. * Options to modify the vr experience helper's behavior.
  114315. */
  114316. export interface VRExperienceHelperOptions extends WebVROptions {
  114317. /**
  114318. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114319. */
  114320. createDeviceOrientationCamera?: boolean;
  114321. /**
  114322. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114323. */
  114324. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114325. /**
  114326. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114327. */
  114328. laserToggle?: boolean;
  114329. /**
  114330. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114331. */
  114332. floorMeshes?: Mesh[];
  114333. /**
  114334. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114335. */
  114336. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114337. /**
  114338. * Defines if WebXR should be used instead of WebVR (if available)
  114339. */
  114340. useXR?: boolean;
  114341. }
  114342. /**
  114343. * Event containing information after VR has been entered
  114344. */
  114345. export class OnAfterEnteringVRObservableEvent {
  114346. /**
  114347. * If entering vr was successful
  114348. */
  114349. success: boolean;
  114350. }
  114351. /**
  114352. * Helps to quickly add VR support to an existing scene.
  114353. * See http://doc.babylonjs.com/how_to/webvr_helper
  114354. */
  114355. export class VRExperienceHelper {
  114356. /** Options to modify the vr experience helper's behavior. */
  114357. webVROptions: VRExperienceHelperOptions;
  114358. private _scene;
  114359. private _position;
  114360. private _btnVR;
  114361. private _btnVRDisplayed;
  114362. private _webVRsupported;
  114363. private _webVRready;
  114364. private _webVRrequesting;
  114365. private _webVRpresenting;
  114366. private _hasEnteredVR;
  114367. private _fullscreenVRpresenting;
  114368. private _inputElement;
  114369. private _webVRCamera;
  114370. private _vrDeviceOrientationCamera;
  114371. private _deviceOrientationCamera;
  114372. private _existingCamera;
  114373. private _onKeyDown;
  114374. private _onVrDisplayPresentChange;
  114375. private _onVRDisplayChanged;
  114376. private _onVRRequestPresentStart;
  114377. private _onVRRequestPresentComplete;
  114378. /**
  114379. * 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)
  114380. */
  114381. enableGazeEvenWhenNoPointerLock: boolean;
  114382. /**
  114383. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114384. */
  114385. exitVROnDoubleTap: boolean;
  114386. /**
  114387. * Observable raised right before entering VR.
  114388. */
  114389. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114390. /**
  114391. * Observable raised when entering VR has completed.
  114392. */
  114393. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114394. /**
  114395. * Observable raised when exiting VR.
  114396. */
  114397. onExitingVRObservable: Observable<VRExperienceHelper>;
  114398. /**
  114399. * Observable raised when controller mesh is loaded.
  114400. */
  114401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114402. /** Return this.onEnteringVRObservable
  114403. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114404. */
  114405. get onEnteringVR(): Observable<VRExperienceHelper>;
  114406. /** Return this.onExitingVRObservable
  114407. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114408. */
  114409. get onExitingVR(): Observable<VRExperienceHelper>;
  114410. /** Return this.onControllerMeshLoadedObservable
  114411. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114412. */
  114413. get onControllerMeshLoaded(): Observable<WebVRController>;
  114414. private _rayLength;
  114415. private _useCustomVRButton;
  114416. private _teleportationRequested;
  114417. private _teleportActive;
  114418. private _floorMeshName;
  114419. private _floorMeshesCollection;
  114420. private _teleportationMode;
  114421. private _teleportationTime;
  114422. private _teleportationSpeed;
  114423. private _teleportationEasing;
  114424. private _rotationAllowed;
  114425. private _teleportBackwardsVector;
  114426. private _teleportationTarget;
  114427. private _isDefaultTeleportationTarget;
  114428. private _postProcessMove;
  114429. private _teleportationFillColor;
  114430. private _teleportationBorderColor;
  114431. private _rotationAngle;
  114432. private _haloCenter;
  114433. private _cameraGazer;
  114434. private _padSensibilityUp;
  114435. private _padSensibilityDown;
  114436. private _leftController;
  114437. private _rightController;
  114438. /**
  114439. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114440. */
  114441. onNewMeshSelected: Observable<AbstractMesh>;
  114442. /**
  114443. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114444. * This observable will provide the mesh and the controller used to select the mesh
  114445. */
  114446. onMeshSelectedWithController: Observable<{
  114447. mesh: AbstractMesh;
  114448. controller: WebVRController;
  114449. }>;
  114450. /**
  114451. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114452. */
  114453. onNewMeshPicked: Observable<PickingInfo>;
  114454. private _circleEase;
  114455. /**
  114456. * Observable raised before camera teleportation
  114457. */
  114458. onBeforeCameraTeleport: Observable<Vector3>;
  114459. /**
  114460. * Observable raised after camera teleportation
  114461. */
  114462. onAfterCameraTeleport: Observable<Vector3>;
  114463. /**
  114464. * Observable raised when current selected mesh gets unselected
  114465. */
  114466. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114467. private _raySelectionPredicate;
  114468. /**
  114469. * To be optionaly changed by user to define custom ray selection
  114470. */
  114471. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114472. /**
  114473. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114474. */
  114475. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114476. /**
  114477. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114478. */
  114479. teleportationEnabled: boolean;
  114480. private _defaultHeight;
  114481. private _teleportationInitialized;
  114482. private _interactionsEnabled;
  114483. private _interactionsRequested;
  114484. private _displayGaze;
  114485. private _displayLaserPointer;
  114486. /**
  114487. * The mesh used to display where the user is going to teleport.
  114488. */
  114489. get teleportationTarget(): Mesh;
  114490. /**
  114491. * Sets the mesh to be used to display where the user is going to teleport.
  114492. */
  114493. set teleportationTarget(value: Mesh);
  114494. /**
  114495. * 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
  114496. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114497. * See http://doc.babylonjs.com/resources/baking_transformations
  114498. */
  114499. get gazeTrackerMesh(): Mesh;
  114500. set gazeTrackerMesh(value: Mesh);
  114501. /**
  114502. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114503. */
  114504. updateGazeTrackerScale: boolean;
  114505. /**
  114506. * If the gaze trackers color should be updated when selecting meshes
  114507. */
  114508. updateGazeTrackerColor: boolean;
  114509. /**
  114510. * If the controller laser color should be updated when selecting meshes
  114511. */
  114512. updateControllerLaserColor: boolean;
  114513. /**
  114514. * The gaze tracking mesh corresponding to the left controller
  114515. */
  114516. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114517. /**
  114518. * The gaze tracking mesh corresponding to the right controller
  114519. */
  114520. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114521. /**
  114522. * If the ray of the gaze should be displayed.
  114523. */
  114524. get displayGaze(): boolean;
  114525. /**
  114526. * Sets if the ray of the gaze should be displayed.
  114527. */
  114528. set displayGaze(value: boolean);
  114529. /**
  114530. * If the ray of the LaserPointer should be displayed.
  114531. */
  114532. get displayLaserPointer(): boolean;
  114533. /**
  114534. * Sets if the ray of the LaserPointer should be displayed.
  114535. */
  114536. set displayLaserPointer(value: boolean);
  114537. /**
  114538. * The deviceOrientationCamera used as the camera when not in VR.
  114539. */
  114540. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114541. /**
  114542. * Based on the current WebVR support, returns the current VR camera used.
  114543. */
  114544. get currentVRCamera(): Nullable<Camera>;
  114545. /**
  114546. * The webVRCamera which is used when in VR.
  114547. */
  114548. get webVRCamera(): WebVRFreeCamera;
  114549. /**
  114550. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114551. */
  114552. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114553. /**
  114554. * The html button that is used to trigger entering into VR.
  114555. */
  114556. get vrButton(): Nullable<HTMLButtonElement>;
  114557. private get _teleportationRequestInitiated();
  114558. /**
  114559. * Defines wether or not Pointer lock should be requested when switching to
  114560. * full screen.
  114561. */
  114562. requestPointerLockOnFullScreen: boolean;
  114563. /**
  114564. * If asking to force XR, this will be populated with the default xr experience
  114565. */
  114566. xr: WebXRDefaultExperience;
  114567. /**
  114568. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114569. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114570. */
  114571. xrTestDone: boolean;
  114572. /**
  114573. * Instantiates a VRExperienceHelper.
  114574. * Helps to quickly add VR support to an existing scene.
  114575. * @param scene The scene the VRExperienceHelper belongs to.
  114576. * @param webVROptions Options to modify the vr experience helper's behavior.
  114577. */
  114578. constructor(scene: Scene,
  114579. /** Options to modify the vr experience helper's behavior. */
  114580. webVROptions?: VRExperienceHelperOptions);
  114581. private completeVRInit;
  114582. private _onDefaultMeshLoaded;
  114583. private _onResize;
  114584. private _onFullscreenChange;
  114585. /**
  114586. * Gets a value indicating if we are currently in VR mode.
  114587. */
  114588. get isInVRMode(): boolean;
  114589. private onVrDisplayPresentChange;
  114590. private onVRDisplayChanged;
  114591. private moveButtonToBottomRight;
  114592. private displayVRButton;
  114593. private updateButtonVisibility;
  114594. private _cachedAngularSensibility;
  114595. /**
  114596. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114597. * Otherwise, will use the fullscreen API.
  114598. */
  114599. enterVR(): void;
  114600. /**
  114601. * Attempt to exit VR, or fullscreen.
  114602. */
  114603. exitVR(): void;
  114604. /**
  114605. * The position of the vr experience helper.
  114606. */
  114607. get position(): Vector3;
  114608. /**
  114609. * Sets the position of the vr experience helper.
  114610. */
  114611. set position(value: Vector3);
  114612. /**
  114613. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114614. */
  114615. enableInteractions(): void;
  114616. private get _noControllerIsActive();
  114617. private beforeRender;
  114618. private _isTeleportationFloor;
  114619. /**
  114620. * Adds a floor mesh to be used for teleportation.
  114621. * @param floorMesh the mesh to be used for teleportation.
  114622. */
  114623. addFloorMesh(floorMesh: Mesh): void;
  114624. /**
  114625. * Removes a floor mesh from being used for teleportation.
  114626. * @param floorMesh the mesh to be removed.
  114627. */
  114628. removeFloorMesh(floorMesh: Mesh): void;
  114629. /**
  114630. * Enables interactions and teleportation using the VR controllers and gaze.
  114631. * @param vrTeleportationOptions options to modify teleportation behavior.
  114632. */
  114633. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114634. private _onNewGamepadConnected;
  114635. private _tryEnableInteractionOnController;
  114636. private _onNewGamepadDisconnected;
  114637. private _enableInteractionOnController;
  114638. private _checkTeleportWithRay;
  114639. private _checkRotate;
  114640. private _checkTeleportBackwards;
  114641. private _enableTeleportationOnController;
  114642. private _createTeleportationCircles;
  114643. private _displayTeleportationTarget;
  114644. private _hideTeleportationTarget;
  114645. private _rotateCamera;
  114646. private _moveTeleportationSelectorTo;
  114647. private _workingVector;
  114648. private _workingQuaternion;
  114649. private _workingMatrix;
  114650. /**
  114651. * Time Constant Teleportation Mode
  114652. */
  114653. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114654. /**
  114655. * Speed Constant Teleportation Mode
  114656. */
  114657. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114658. /**
  114659. * Teleports the users feet to the desired location
  114660. * @param location The location where the user's feet should be placed
  114661. */
  114662. teleportCamera(location: Vector3): void;
  114663. private _convertNormalToDirectionOfRay;
  114664. private _castRayAndSelectObject;
  114665. private _notifySelectedMeshUnselected;
  114666. /**
  114667. * Sets the color of the laser ray from the vr controllers.
  114668. * @param color new color for the ray.
  114669. */
  114670. changeLaserColor(color: Color3): void;
  114671. /**
  114672. * Sets the color of the ray from the vr headsets gaze.
  114673. * @param color new color for the ray.
  114674. */
  114675. changeGazeColor(color: Color3): void;
  114676. /**
  114677. * Exits VR and disposes of the vr experience helper
  114678. */
  114679. dispose(): void;
  114680. /**
  114681. * Gets the name of the VRExperienceHelper class
  114682. * @returns "VRExperienceHelper"
  114683. */
  114684. getClassName(): string;
  114685. }
  114686. }
  114687. declare module BABYLON {
  114688. /**
  114689. * Options used for hit testing
  114690. */
  114691. export interface IWebXRHitTestOptions {
  114692. /**
  114693. * Only test when user interacted with the scene. Default - hit test every frame
  114694. */
  114695. testOnPointerDownOnly?: boolean;
  114696. /**
  114697. * The node to use to transform the local results to world coordinates
  114698. */
  114699. worldParentNode?: TransformNode;
  114700. }
  114701. /**
  114702. * Interface defining the babylon result of raycasting/hit-test
  114703. */
  114704. export interface IWebXRHitResult {
  114705. /**
  114706. * The native hit test result
  114707. */
  114708. xrHitResult: XRHitResult;
  114709. /**
  114710. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114711. */
  114712. transformationMatrix: Matrix;
  114713. }
  114714. /**
  114715. * The currently-working hit-test module.
  114716. * Hit test (or raycasting) is used to interact with the real world.
  114717. * For further information read here - https://github.com/immersive-web/hit-test
  114718. */
  114719. export class WebXRHitTestLegacy implements IWebXRFeature {
  114720. private _xrSessionManager;
  114721. /**
  114722. * options to use when constructing this feature
  114723. */
  114724. readonly options: IWebXRHitTestOptions;
  114725. /**
  114726. * The module's name
  114727. */
  114728. static readonly Name: string;
  114729. /**
  114730. * The (Babylon) version of this module.
  114731. * This is an integer representing the implementation version.
  114732. * This number does not correspond to the webxr specs version
  114733. */
  114734. static readonly Version: number;
  114735. /**
  114736. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114737. * @param event the (select) event to use to select with
  114738. * @param referenceSpace the reference space to use for this hit test
  114739. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114740. */
  114741. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114742. /**
  114743. * execute a hit test with an XR Ray
  114744. *
  114745. * @param xrSession a native xrSession that will execute this hit test
  114746. * @param xrRay the ray (position and direction) to use for raycasting
  114747. * @param referenceSpace native XR reference space to use for the hit-test
  114748. * @param filter filter function that will filter the results
  114749. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114750. */
  114751. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114752. /**
  114753. * Triggered when new babylon (transformed) hit test results are available
  114754. */
  114755. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114756. /**
  114757. * Creates a new instance of the (legacy version) hit test feature
  114758. * @param _xrSessionManager an instance of WebXRSessionManager
  114759. * @param options options to use when constructing this feature
  114760. */
  114761. constructor(_xrSessionManager: WebXRSessionManager,
  114762. /**
  114763. * options to use when constructing this feature
  114764. */
  114765. options?: IWebXRHitTestOptions);
  114766. private _onSelectEnabled;
  114767. private _xrFrameObserver;
  114768. private _attached;
  114769. /**
  114770. * Populated with the last native XR Hit Results
  114771. */
  114772. lastNativeXRHitResults: XRHitResult[];
  114773. /**
  114774. * attach this feature
  114775. * Will usually be called by the features manager
  114776. *
  114777. * @returns true if successful.
  114778. */
  114779. attach(): boolean;
  114780. /**
  114781. * detach this feature.
  114782. * Will usually be called by the features manager
  114783. *
  114784. * @returns true if successful.
  114785. */
  114786. detach(): boolean;
  114787. private _onHitTestResults;
  114788. private _onSelect;
  114789. /**
  114790. * Dispose this feature and all of the resources attached
  114791. */
  114792. dispose(): void;
  114793. }
  114794. }
  114795. declare module BABYLON {
  114796. /**
  114797. * Options used in the plane detector module
  114798. */
  114799. export interface IWebXRPlaneDetectorOptions {
  114800. /**
  114801. * The node to use to transform the local results to world coordinates
  114802. */
  114803. worldParentNode?: TransformNode;
  114804. }
  114805. /**
  114806. * A babylon interface for a webxr plane.
  114807. * A Plane is actually a polygon, built from N points in space
  114808. */
  114809. export interface IWebXRPlane {
  114810. /**
  114811. * a babylon-assigned ID for this polygon
  114812. */
  114813. id: number;
  114814. /**
  114815. * the native xr-plane object
  114816. */
  114817. xrPlane: XRPlane;
  114818. /**
  114819. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114820. */
  114821. polygonDefinition: Array<Vector3>;
  114822. /**
  114823. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114824. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114825. */
  114826. transformationMatrix: Matrix;
  114827. }
  114828. /**
  114829. * The plane detector is used to detect planes in the real world when in AR
  114830. * For more information see https://github.com/immersive-web/real-world-geometry/
  114831. */
  114832. export class WebXRPlaneDetector implements IWebXRFeature {
  114833. private _xrSessionManager;
  114834. private _options;
  114835. /**
  114836. * The module's name
  114837. */
  114838. static readonly Name: string;
  114839. /**
  114840. * The (Babylon) version of this module.
  114841. * This is an integer representing the implementation version.
  114842. * This number does not correspond to the webxr specs version
  114843. */
  114844. static readonly Version: number;
  114845. /**
  114846. * Observers registered here will be executed when a new plane was added to the session
  114847. */
  114848. onPlaneAddedObservable: Observable<IWebXRPlane>;
  114849. /**
  114850. * Observers registered here will be executed when a plane is no longer detected in the session
  114851. */
  114852. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  114853. /**
  114854. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  114855. * This can execute N times every frame
  114856. */
  114857. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  114858. private _enabled;
  114859. private _attached;
  114860. private _detectedPlanes;
  114861. private _lastFrameDetected;
  114862. private _observerTracked;
  114863. /**
  114864. * construct a new Plane Detector
  114865. * @param _xrSessionManager an instance of xr Session manager
  114866. * @param _options configuration to use when constructing this feature
  114867. */
  114868. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  114869. /**
  114870. * attach this feature
  114871. * Will usually be called by the features manager
  114872. *
  114873. * @returns true if successful.
  114874. */
  114875. attach(): boolean;
  114876. /**
  114877. * detach this feature.
  114878. * Will usually be called by the features manager
  114879. *
  114880. * @returns true if successful.
  114881. */
  114882. detach(): boolean;
  114883. /**
  114884. * Dispose this feature and all of the resources attached
  114885. */
  114886. dispose(): void;
  114887. private _updatePlaneWithXRPlane;
  114888. /**
  114889. * avoiding using Array.find for global support.
  114890. * @param xrPlane the plane to find in the array
  114891. */
  114892. private findIndexInPlaneArray;
  114893. }
  114894. }
  114895. declare module BABYLON {
  114896. /**
  114897. * Configuration options of the anchor system
  114898. */
  114899. export interface IWebXRAnchorSystemOptions {
  114900. /**
  114901. * a node that will be used to convert local to world coordinates
  114902. */
  114903. worldParentNode?: TransformNode;
  114904. /**
  114905. * should the anchor system use plane detection.
  114906. * If set to true, the plane-detection feature should be set using setPlaneDetector
  114907. */
  114908. usePlaneDetection?: boolean;
  114909. /**
  114910. * Should a new anchor be added every time a select event is triggered
  114911. */
  114912. addAnchorOnSelect?: boolean;
  114913. }
  114914. /**
  114915. * A babylon container for an XR Anchor
  114916. */
  114917. export interface IWebXRAnchor {
  114918. /**
  114919. * A babylon-assigned ID for this anchor
  114920. */
  114921. id: number;
  114922. /**
  114923. * The native anchor object
  114924. */
  114925. xrAnchor: XRAnchor;
  114926. /**
  114927. * Transformation matrix to apply to an object attached to this anchor
  114928. */
  114929. transformationMatrix: Matrix;
  114930. }
  114931. /**
  114932. * An implementation of the anchor system of WebXR.
  114933. * Note that the current documented implementation is not available in any browser. Future implementations
  114934. * will use the frame to create an anchor and not the session or a detected plane
  114935. * For further information see https://github.com/immersive-web/anchors/
  114936. */
  114937. export class WebXRAnchorSystem implements IWebXRFeature {
  114938. private _xrSessionManager;
  114939. private _options;
  114940. /**
  114941. * The module's name
  114942. */
  114943. static readonly Name: string;
  114944. /**
  114945. * The (Babylon) version of this module.
  114946. * This is an integer representing the implementation version.
  114947. * This number does not correspond to the webxr specs version
  114948. */
  114949. static readonly Version: number;
  114950. /**
  114951. * Observers registered here will be executed when a new anchor was added to the session
  114952. */
  114953. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  114954. /**
  114955. * Observers registered here will be executed when an existing anchor updates
  114956. * This can execute N times every frame
  114957. */
  114958. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  114959. /**
  114960. * Observers registered here will be executed when an anchor was removed from the session
  114961. */
  114962. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  114963. private _planeDetector;
  114964. private _hitTestModule;
  114965. private _enabled;
  114966. private _attached;
  114967. private _trackedAnchors;
  114968. private _lastFrameDetected;
  114969. private _observerTracked;
  114970. /**
  114971. * constructs a new anchor system
  114972. * @param _xrSessionManager an instance of WebXRSessionManager
  114973. * @param _options configuration object for this feature
  114974. */
  114975. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  114976. /**
  114977. * set the plane detector to use in order to create anchors from frames
  114978. * @param planeDetector the plane-detector module to use
  114979. * @param enable enable plane-anchors. default is true
  114980. */
  114981. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  114982. /**
  114983. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  114984. * @param hitTestModule the hit-test module to use.
  114985. */
  114986. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  114987. /**
  114988. * attach this feature
  114989. * Will usually be called by the features manager
  114990. *
  114991. * @returns true if successful.
  114992. */
  114993. attach(): boolean;
  114994. /**
  114995. * detach this feature.
  114996. * Will usually be called by the features manager
  114997. *
  114998. * @returns true if successful.
  114999. */
  115000. detach(): boolean;
  115001. /**
  115002. * Dispose this feature and all of the resources attached
  115003. */
  115004. dispose(): void;
  115005. private _onSelect;
  115006. /**
  115007. * Add anchor at a specific XR point.
  115008. *
  115009. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115010. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115011. * @returns a promise the fulfills when the anchor was created
  115012. */
  115013. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115014. private _updateAnchorWithXRFrame;
  115015. /**
  115016. * avoiding using Array.find for global support.
  115017. * @param xrAnchor the plane to find in the array
  115018. */
  115019. private _findIndexInAnchorArray;
  115020. }
  115021. }
  115022. declare module BABYLON {
  115023. /**
  115024. * Options interface for the background remover plugin
  115025. */
  115026. export interface IWebXRBackgroundRemoverOptions {
  115027. /**
  115028. * don't disable the environment helper
  115029. */
  115030. ignoreEnvironmentHelper?: boolean;
  115031. /**
  115032. * flags to configure the removal of the environment helper.
  115033. * If not set, the entire background will be removed. If set, flags should be set as well.
  115034. */
  115035. environmentHelperRemovalFlags?: {
  115036. /**
  115037. * Should the skybox be removed (default false)
  115038. */
  115039. skyBox?: boolean;
  115040. /**
  115041. * Should the ground be removed (default false)
  115042. */
  115043. ground?: boolean;
  115044. };
  115045. /**
  115046. * Further background meshes to disable when entering AR
  115047. */
  115048. backgroundMeshes?: AbstractMesh[];
  115049. }
  115050. /**
  115051. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115052. */
  115053. export class WebXRBackgroundRemover implements IWebXRFeature {
  115054. private _xrSessionManager;
  115055. /**
  115056. * read-only options to be used in this module
  115057. */
  115058. readonly options: IWebXRBackgroundRemoverOptions;
  115059. /**
  115060. * The module's name
  115061. */
  115062. static readonly Name: string;
  115063. /**
  115064. * The (Babylon) version of this module.
  115065. * This is an integer representing the implementation version.
  115066. * This number does not correspond to the webxr specs version
  115067. */
  115068. static readonly Version: number;
  115069. /**
  115070. * registered observers will be triggered when the background state changes
  115071. */
  115072. onBackgroundStateChangedObservable: Observable<boolean>;
  115073. /**
  115074. * constructs a new background remover module
  115075. * @param _xrSessionManager the session manager for this module
  115076. * @param options read-only options to be used in this module
  115077. */
  115078. constructor(_xrSessionManager: WebXRSessionManager,
  115079. /**
  115080. * read-only options to be used in this module
  115081. */
  115082. options?: IWebXRBackgroundRemoverOptions);
  115083. /**
  115084. * attach this feature
  115085. * Will usually be called by the features manager
  115086. *
  115087. * @returns true if successful.
  115088. */
  115089. attach(): boolean;
  115090. /**
  115091. * detach this feature.
  115092. * Will usually be called by the features manager
  115093. *
  115094. * @returns true if successful.
  115095. */
  115096. detach(): boolean;
  115097. private _setBackgroundState;
  115098. /**
  115099. * Dispose this feature and all of the resources attached
  115100. */
  115101. dispose(): void;
  115102. }
  115103. }
  115104. declare module BABYLON {
  115105. /**
  115106. * Contains an array of blocks representing the octree
  115107. */
  115108. export interface IOctreeContainer<T> {
  115109. /**
  115110. * Blocks within the octree
  115111. */
  115112. blocks: Array<OctreeBlock<T>>;
  115113. }
  115114. /**
  115115. * Class used to store a cell in an octree
  115116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115117. */
  115118. export class OctreeBlock<T> {
  115119. /**
  115120. * Gets the content of the current block
  115121. */
  115122. entries: T[];
  115123. /**
  115124. * Gets the list of block children
  115125. */
  115126. blocks: Array<OctreeBlock<T>>;
  115127. private _depth;
  115128. private _maxDepth;
  115129. private _capacity;
  115130. private _minPoint;
  115131. private _maxPoint;
  115132. private _boundingVectors;
  115133. private _creationFunc;
  115134. /**
  115135. * Creates a new block
  115136. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115137. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115138. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115139. * @param depth defines the current depth of this block in the octree
  115140. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115141. * @param creationFunc defines a callback to call when an element is added to the block
  115142. */
  115143. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115144. /**
  115145. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115146. */
  115147. get capacity(): number;
  115148. /**
  115149. * Gets the minimum vector (in world space) of the block's bounding box
  115150. */
  115151. get minPoint(): Vector3;
  115152. /**
  115153. * Gets the maximum vector (in world space) of the block's bounding box
  115154. */
  115155. get maxPoint(): Vector3;
  115156. /**
  115157. * Add a new element to this block
  115158. * @param entry defines the element to add
  115159. */
  115160. addEntry(entry: T): void;
  115161. /**
  115162. * Remove an element from this block
  115163. * @param entry defines the element to remove
  115164. */
  115165. removeEntry(entry: T): void;
  115166. /**
  115167. * Add an array of elements to this block
  115168. * @param entries defines the array of elements to add
  115169. */
  115170. addEntries(entries: T[]): void;
  115171. /**
  115172. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115173. * @param frustumPlanes defines the frustum planes to test
  115174. * @param selection defines the array to store current content if selection is positive
  115175. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115176. */
  115177. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115178. /**
  115179. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115180. * @param sphereCenter defines the bounding sphere center
  115181. * @param sphereRadius defines the bounding sphere radius
  115182. * @param selection defines the array to store current content if selection is positive
  115183. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115184. */
  115185. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115186. /**
  115187. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115188. * @param ray defines the ray to test with
  115189. * @param selection defines the array to store current content if selection is positive
  115190. */
  115191. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115192. /**
  115193. * Subdivide the content into child blocks (this block will then be empty)
  115194. */
  115195. createInnerBlocks(): void;
  115196. /**
  115197. * @hidden
  115198. */
  115199. 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;
  115200. }
  115201. }
  115202. declare module BABYLON {
  115203. /**
  115204. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115206. */
  115207. export class Octree<T> {
  115208. /** 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.) */
  115209. maxDepth: number;
  115210. /**
  115211. * Blocks within the octree containing objects
  115212. */
  115213. blocks: Array<OctreeBlock<T>>;
  115214. /**
  115215. * Content stored in the octree
  115216. */
  115217. dynamicContent: T[];
  115218. private _maxBlockCapacity;
  115219. private _selectionContent;
  115220. private _creationFunc;
  115221. /**
  115222. * Creates a octree
  115223. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115224. * @param creationFunc function to be used to instatiate the octree
  115225. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115226. * @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.)
  115227. */
  115228. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115229. /** 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.) */
  115230. maxDepth?: number);
  115231. /**
  115232. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115233. * @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);
  115234. * @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);
  115235. * @param entries meshes to be added to the octree blocks
  115236. */
  115237. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115238. /**
  115239. * Adds a mesh to the octree
  115240. * @param entry Mesh to add to the octree
  115241. */
  115242. addMesh(entry: T): void;
  115243. /**
  115244. * Remove an element from the octree
  115245. * @param entry defines the element to remove
  115246. */
  115247. removeMesh(entry: T): void;
  115248. /**
  115249. * Selects an array of meshes within the frustum
  115250. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115251. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115252. * @returns array of meshes within the frustum
  115253. */
  115254. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115255. /**
  115256. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115257. * @param sphereCenter defines the bounding sphere center
  115258. * @param sphereRadius defines the bounding sphere radius
  115259. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115260. * @returns an array of objects that intersect the sphere
  115261. */
  115262. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115263. /**
  115264. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115265. * @param ray defines the ray to test with
  115266. * @returns array of intersected objects
  115267. */
  115268. intersectsRay(ray: Ray): SmartArray<T>;
  115269. /**
  115270. * Adds a mesh into the octree block if it intersects the block
  115271. */
  115272. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115273. /**
  115274. * Adds a submesh into the octree block if it intersects the block
  115275. */
  115276. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115277. }
  115278. }
  115279. declare module BABYLON {
  115280. interface Scene {
  115281. /**
  115282. * @hidden
  115283. * Backing Filed
  115284. */
  115285. _selectionOctree: Octree<AbstractMesh>;
  115286. /**
  115287. * Gets the octree used to boost mesh selection (picking)
  115288. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115289. */
  115290. selectionOctree: Octree<AbstractMesh>;
  115291. /**
  115292. * Creates or updates the octree used to boost selection (picking)
  115293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115294. * @param maxCapacity defines the maximum capacity per leaf
  115295. * @param maxDepth defines the maximum depth of the octree
  115296. * @returns an octree of AbstractMesh
  115297. */
  115298. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115299. }
  115300. interface AbstractMesh {
  115301. /**
  115302. * @hidden
  115303. * Backing Field
  115304. */
  115305. _submeshesOctree: Octree<SubMesh>;
  115306. /**
  115307. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115308. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115309. * @param maxCapacity defines the maximum size of each block (64 by default)
  115310. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115311. * @returns the new octree
  115312. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115314. */
  115315. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115316. }
  115317. /**
  115318. * Defines the octree scene component responsible to manage any octrees
  115319. * in a given scene.
  115320. */
  115321. export class OctreeSceneComponent {
  115322. /**
  115323. * The component name help to identify the component in the list of scene components.
  115324. */
  115325. readonly name: string;
  115326. /**
  115327. * The scene the component belongs to.
  115328. */
  115329. scene: Scene;
  115330. /**
  115331. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115332. */
  115333. readonly checksIsEnabled: boolean;
  115334. /**
  115335. * Creates a new instance of the component for the given scene
  115336. * @param scene Defines the scene to register the component in
  115337. */
  115338. constructor(scene: Scene);
  115339. /**
  115340. * Registers the component in a given scene
  115341. */
  115342. register(): void;
  115343. /**
  115344. * Return the list of active meshes
  115345. * @returns the list of active meshes
  115346. */
  115347. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115348. /**
  115349. * Return the list of active sub meshes
  115350. * @param mesh The mesh to get the candidates sub meshes from
  115351. * @returns the list of active sub meshes
  115352. */
  115353. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115354. private _tempRay;
  115355. /**
  115356. * Return the list of sub meshes intersecting with a given local ray
  115357. * @param mesh defines the mesh to find the submesh for
  115358. * @param localRay defines the ray in local space
  115359. * @returns the list of intersecting sub meshes
  115360. */
  115361. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115362. /**
  115363. * Return the list of sub meshes colliding with a collider
  115364. * @param mesh defines the mesh to find the submesh for
  115365. * @param collider defines the collider to evaluate the collision against
  115366. * @returns the list of colliding sub meshes
  115367. */
  115368. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115369. /**
  115370. * Rebuilds the elements related to this component in case of
  115371. * context lost for instance.
  115372. */
  115373. rebuild(): void;
  115374. /**
  115375. * Disposes the component and the associated ressources.
  115376. */
  115377. dispose(): void;
  115378. }
  115379. }
  115380. declare module BABYLON {
  115381. /**
  115382. * Renders a layer on top of an existing scene
  115383. */
  115384. export class UtilityLayerRenderer implements IDisposable {
  115385. /** the original scene that will be rendered on top of */
  115386. originalScene: Scene;
  115387. private _pointerCaptures;
  115388. private _lastPointerEvents;
  115389. private static _DefaultUtilityLayer;
  115390. private static _DefaultKeepDepthUtilityLayer;
  115391. private _sharedGizmoLight;
  115392. private _renderCamera;
  115393. /**
  115394. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115395. * @returns the camera that is used when rendering the utility layer
  115396. */
  115397. getRenderCamera(): Nullable<Camera>;
  115398. /**
  115399. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115400. * @param cam the camera that should be used when rendering the utility layer
  115401. */
  115402. setRenderCamera(cam: Nullable<Camera>): void;
  115403. /**
  115404. * @hidden
  115405. * Light which used by gizmos to get light shading
  115406. */
  115407. _getSharedGizmoLight(): HemisphericLight;
  115408. /**
  115409. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115410. */
  115411. pickUtilitySceneFirst: boolean;
  115412. /**
  115413. * 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)
  115414. */
  115415. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115416. /**
  115417. * 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)
  115418. */
  115419. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115420. /**
  115421. * The scene that is rendered on top of the original scene
  115422. */
  115423. utilityLayerScene: Scene;
  115424. /**
  115425. * If the utility layer should automatically be rendered on top of existing scene
  115426. */
  115427. shouldRender: boolean;
  115428. /**
  115429. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115430. */
  115431. onlyCheckPointerDownEvents: boolean;
  115432. /**
  115433. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115434. */
  115435. processAllEvents: boolean;
  115436. /**
  115437. * Observable raised when the pointer move from the utility layer scene to the main scene
  115438. */
  115439. onPointerOutObservable: Observable<number>;
  115440. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115441. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115442. private _afterRenderObserver;
  115443. private _sceneDisposeObserver;
  115444. private _originalPointerObserver;
  115445. /**
  115446. * Instantiates a UtilityLayerRenderer
  115447. * @param originalScene the original scene that will be rendered on top of
  115448. * @param handleEvents boolean indicating if the utility layer should handle events
  115449. */
  115450. constructor(
  115451. /** the original scene that will be rendered on top of */
  115452. originalScene: Scene, handleEvents?: boolean);
  115453. private _notifyObservers;
  115454. /**
  115455. * Renders the utility layers scene on top of the original scene
  115456. */
  115457. render(): void;
  115458. /**
  115459. * Disposes of the renderer
  115460. */
  115461. dispose(): void;
  115462. private _updateCamera;
  115463. }
  115464. }
  115465. declare module BABYLON {
  115466. /**
  115467. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115468. */
  115469. export class Gizmo implements IDisposable {
  115470. /** The utility layer the gizmo will be added to */
  115471. gizmoLayer: UtilityLayerRenderer;
  115472. /**
  115473. * The root mesh of the gizmo
  115474. */
  115475. _rootMesh: Mesh;
  115476. private _attachedMesh;
  115477. /**
  115478. * Ratio for the scale of the gizmo (Default: 1)
  115479. */
  115480. scaleRatio: number;
  115481. /**
  115482. * If a custom mesh has been set (Default: false)
  115483. */
  115484. protected _customMeshSet: boolean;
  115485. /**
  115486. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115487. * * When set, interactions will be enabled
  115488. */
  115489. get attachedMesh(): Nullable<AbstractMesh>;
  115490. set attachedMesh(value: Nullable<AbstractMesh>);
  115491. /**
  115492. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115493. * @param mesh The mesh to replace the default mesh of the gizmo
  115494. */
  115495. setCustomMesh(mesh: Mesh): void;
  115496. /**
  115497. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115498. */
  115499. updateGizmoRotationToMatchAttachedMesh: boolean;
  115500. /**
  115501. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115502. */
  115503. updateGizmoPositionToMatchAttachedMesh: boolean;
  115504. /**
  115505. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115506. */
  115507. updateScale: boolean;
  115508. protected _interactionsEnabled: boolean;
  115509. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115510. private _beforeRenderObserver;
  115511. private _tempVector;
  115512. /**
  115513. * Creates a gizmo
  115514. * @param gizmoLayer The utility layer the gizmo will be added to
  115515. */
  115516. constructor(
  115517. /** The utility layer the gizmo will be added to */
  115518. gizmoLayer?: UtilityLayerRenderer);
  115519. /**
  115520. * Updates the gizmo to match the attached mesh's position/rotation
  115521. */
  115522. protected _update(): void;
  115523. /**
  115524. * Disposes of the gizmo
  115525. */
  115526. dispose(): void;
  115527. }
  115528. }
  115529. declare module BABYLON {
  115530. /**
  115531. * Single plane drag gizmo
  115532. */
  115533. export class PlaneDragGizmo extends Gizmo {
  115534. /**
  115535. * Drag behavior responsible for the gizmos dragging interactions
  115536. */
  115537. dragBehavior: PointerDragBehavior;
  115538. private _pointerObserver;
  115539. /**
  115540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115541. */
  115542. snapDistance: number;
  115543. /**
  115544. * Event that fires each time the gizmo snaps to a new location.
  115545. * * snapDistance is the the change in distance
  115546. */
  115547. onSnapObservable: Observable<{
  115548. snapDistance: number;
  115549. }>;
  115550. private _plane;
  115551. private _coloredMaterial;
  115552. private _hoverMaterial;
  115553. private _isEnabled;
  115554. private _parent;
  115555. /** @hidden */
  115556. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115557. /** @hidden */
  115558. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115559. /**
  115560. * Creates a PlaneDragGizmo
  115561. * @param gizmoLayer The utility layer the gizmo will be added to
  115562. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115563. * @param color The color of the gizmo
  115564. */
  115565. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115567. /**
  115568. * If the gizmo is enabled
  115569. */
  115570. set isEnabled(value: boolean);
  115571. get isEnabled(): boolean;
  115572. /**
  115573. * Disposes of the gizmo
  115574. */
  115575. dispose(): void;
  115576. }
  115577. }
  115578. declare module BABYLON {
  115579. /**
  115580. * Gizmo that enables dragging a mesh along 3 axis
  115581. */
  115582. export class PositionGizmo extends Gizmo {
  115583. /**
  115584. * Internal gizmo used for interactions on the x axis
  115585. */
  115586. xGizmo: AxisDragGizmo;
  115587. /**
  115588. * Internal gizmo used for interactions on the y axis
  115589. */
  115590. yGizmo: AxisDragGizmo;
  115591. /**
  115592. * Internal gizmo used for interactions on the z axis
  115593. */
  115594. zGizmo: AxisDragGizmo;
  115595. /**
  115596. * Internal gizmo used for interactions on the yz plane
  115597. */
  115598. xPlaneGizmo: PlaneDragGizmo;
  115599. /**
  115600. * Internal gizmo used for interactions on the xz plane
  115601. */
  115602. yPlaneGizmo: PlaneDragGizmo;
  115603. /**
  115604. * Internal gizmo used for interactions on the xy plane
  115605. */
  115606. zPlaneGizmo: PlaneDragGizmo;
  115607. /**
  115608. * private variables
  115609. */
  115610. private _meshAttached;
  115611. private _updateGizmoRotationToMatchAttachedMesh;
  115612. private _snapDistance;
  115613. private _scaleRatio;
  115614. /** Fires an event when any of it's sub gizmos are dragged */
  115615. onDragStartObservable: Observable<unknown>;
  115616. /** Fires an event when any of it's sub gizmos are released from dragging */
  115617. onDragEndObservable: Observable<unknown>;
  115618. /**
  115619. * If set to true, planar drag is enabled
  115620. */
  115621. private _planarGizmoEnabled;
  115622. get attachedMesh(): Nullable<AbstractMesh>;
  115623. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115624. /**
  115625. * Creates a PositionGizmo
  115626. * @param gizmoLayer The utility layer the gizmo will be added to
  115627. */
  115628. constructor(gizmoLayer?: UtilityLayerRenderer);
  115629. /**
  115630. * If the planar drag gizmo is enabled
  115631. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115632. */
  115633. set planarGizmoEnabled(value: boolean);
  115634. get planarGizmoEnabled(): boolean;
  115635. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115636. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115637. /**
  115638. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115639. */
  115640. set snapDistance(value: number);
  115641. get snapDistance(): number;
  115642. /**
  115643. * Ratio for the scale of the gizmo (Default: 1)
  115644. */
  115645. set scaleRatio(value: number);
  115646. get scaleRatio(): number;
  115647. /**
  115648. * Disposes of the gizmo
  115649. */
  115650. dispose(): void;
  115651. /**
  115652. * CustomMeshes are not supported by this gizmo
  115653. * @param mesh The mesh to replace the default mesh of the gizmo
  115654. */
  115655. setCustomMesh(mesh: Mesh): void;
  115656. }
  115657. }
  115658. declare module BABYLON {
  115659. /**
  115660. * Single axis drag gizmo
  115661. */
  115662. export class AxisDragGizmo extends Gizmo {
  115663. /**
  115664. * Drag behavior responsible for the gizmos dragging interactions
  115665. */
  115666. dragBehavior: PointerDragBehavior;
  115667. private _pointerObserver;
  115668. /**
  115669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115670. */
  115671. snapDistance: number;
  115672. /**
  115673. * Event that fires each time the gizmo snaps to a new location.
  115674. * * snapDistance is the the change in distance
  115675. */
  115676. onSnapObservable: Observable<{
  115677. snapDistance: number;
  115678. }>;
  115679. private _isEnabled;
  115680. private _parent;
  115681. private _arrow;
  115682. private _coloredMaterial;
  115683. private _hoverMaterial;
  115684. /** @hidden */
  115685. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115686. /** @hidden */
  115687. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115688. /**
  115689. * Creates an AxisDragGizmo
  115690. * @param gizmoLayer The utility layer the gizmo will be added to
  115691. * @param dragAxis The axis which the gizmo will be able to drag on
  115692. * @param color The color of the gizmo
  115693. */
  115694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115696. /**
  115697. * If the gizmo is enabled
  115698. */
  115699. set isEnabled(value: boolean);
  115700. get isEnabled(): boolean;
  115701. /**
  115702. * Disposes of the gizmo
  115703. */
  115704. dispose(): void;
  115705. }
  115706. }
  115707. declare module BABYLON.Debug {
  115708. /**
  115709. * The Axes viewer will show 3 axes in a specific point in space
  115710. */
  115711. export class AxesViewer {
  115712. private _xAxis;
  115713. private _yAxis;
  115714. private _zAxis;
  115715. private _scaleLinesFactor;
  115716. private _instanced;
  115717. /**
  115718. * Gets the hosting scene
  115719. */
  115720. scene: Scene;
  115721. /**
  115722. * Gets or sets a number used to scale line length
  115723. */
  115724. scaleLines: number;
  115725. /** Gets the node hierarchy used to render x-axis */
  115726. get xAxis(): TransformNode;
  115727. /** Gets the node hierarchy used to render y-axis */
  115728. get yAxis(): TransformNode;
  115729. /** Gets the node hierarchy used to render z-axis */
  115730. get zAxis(): TransformNode;
  115731. /**
  115732. * Creates a new AxesViewer
  115733. * @param scene defines the hosting scene
  115734. * @param scaleLines defines a number used to scale line length (1 by default)
  115735. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115736. * @param xAxis defines the node hierarchy used to render the x-axis
  115737. * @param yAxis defines the node hierarchy used to render the y-axis
  115738. * @param zAxis defines the node hierarchy used to render the z-axis
  115739. */
  115740. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115741. /**
  115742. * Force the viewer to update
  115743. * @param position defines the position of the viewer
  115744. * @param xaxis defines the x axis of the viewer
  115745. * @param yaxis defines the y axis of the viewer
  115746. * @param zaxis defines the z axis of the viewer
  115747. */
  115748. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115749. /**
  115750. * Creates an instance of this axes viewer.
  115751. * @returns a new axes viewer with instanced meshes
  115752. */
  115753. createInstance(): AxesViewer;
  115754. /** Releases resources */
  115755. dispose(): void;
  115756. private static _SetRenderingGroupId;
  115757. }
  115758. }
  115759. declare module BABYLON.Debug {
  115760. /**
  115761. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115762. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115763. */
  115764. export class BoneAxesViewer extends AxesViewer {
  115765. /**
  115766. * Gets or sets the target mesh where to display the axes viewer
  115767. */
  115768. mesh: Nullable<Mesh>;
  115769. /**
  115770. * Gets or sets the target bone where to display the axes viewer
  115771. */
  115772. bone: Nullable<Bone>;
  115773. /** Gets current position */
  115774. pos: Vector3;
  115775. /** Gets direction of X axis */
  115776. xaxis: Vector3;
  115777. /** Gets direction of Y axis */
  115778. yaxis: Vector3;
  115779. /** Gets direction of Z axis */
  115780. zaxis: Vector3;
  115781. /**
  115782. * Creates a new BoneAxesViewer
  115783. * @param scene defines the hosting scene
  115784. * @param bone defines the target bone
  115785. * @param mesh defines the target mesh
  115786. * @param scaleLines defines a scaling factor for line length (1 by default)
  115787. */
  115788. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115789. /**
  115790. * Force the viewer to update
  115791. */
  115792. update(): void;
  115793. /** Releases resources */
  115794. dispose(): void;
  115795. }
  115796. }
  115797. declare module BABYLON {
  115798. /**
  115799. * Interface used to define scene explorer extensibility option
  115800. */
  115801. export interface IExplorerExtensibilityOption {
  115802. /**
  115803. * Define the option label
  115804. */
  115805. label: string;
  115806. /**
  115807. * Defines the action to execute on click
  115808. */
  115809. action: (entity: any) => void;
  115810. }
  115811. /**
  115812. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115813. */
  115814. export interface IExplorerExtensibilityGroup {
  115815. /**
  115816. * Defines a predicate to test if a given type mut be extended
  115817. */
  115818. predicate: (entity: any) => boolean;
  115819. /**
  115820. * Gets the list of options added to a type
  115821. */
  115822. entries: IExplorerExtensibilityOption[];
  115823. }
  115824. /**
  115825. * Interface used to define the options to use to create the Inspector
  115826. */
  115827. export interface IInspectorOptions {
  115828. /**
  115829. * Display in overlay mode (default: false)
  115830. */
  115831. overlay?: boolean;
  115832. /**
  115833. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115834. */
  115835. globalRoot?: HTMLElement;
  115836. /**
  115837. * Display the Scene explorer
  115838. */
  115839. showExplorer?: boolean;
  115840. /**
  115841. * Display the property inspector
  115842. */
  115843. showInspector?: boolean;
  115844. /**
  115845. * Display in embed mode (both panes on the right)
  115846. */
  115847. embedMode?: boolean;
  115848. /**
  115849. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  115850. */
  115851. handleResize?: boolean;
  115852. /**
  115853. * Allow the panes to popup (default: true)
  115854. */
  115855. enablePopup?: boolean;
  115856. /**
  115857. * Allow the panes to be closed by users (default: true)
  115858. */
  115859. enableClose?: boolean;
  115860. /**
  115861. * Optional list of extensibility entries
  115862. */
  115863. explorerExtensibility?: IExplorerExtensibilityGroup[];
  115864. /**
  115865. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  115866. */
  115867. inspectorURL?: string;
  115868. /**
  115869. * Optional initial tab (default to DebugLayerTab.Properties)
  115870. */
  115871. initialTab?: DebugLayerTab;
  115872. }
  115873. interface Scene {
  115874. /**
  115875. * @hidden
  115876. * Backing field
  115877. */
  115878. _debugLayer: DebugLayer;
  115879. /**
  115880. * Gets the debug layer (aka Inspector) associated with the scene
  115881. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115882. */
  115883. debugLayer: DebugLayer;
  115884. }
  115885. /**
  115886. * Enum of inspector action tab
  115887. */
  115888. export enum DebugLayerTab {
  115889. /**
  115890. * Properties tag (default)
  115891. */
  115892. Properties = 0,
  115893. /**
  115894. * Debug tab
  115895. */
  115896. Debug = 1,
  115897. /**
  115898. * Statistics tab
  115899. */
  115900. Statistics = 2,
  115901. /**
  115902. * Tools tab
  115903. */
  115904. Tools = 3,
  115905. /**
  115906. * Settings tab
  115907. */
  115908. Settings = 4
  115909. }
  115910. /**
  115911. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115912. * what is happening in your scene
  115913. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115914. */
  115915. export class DebugLayer {
  115916. /**
  115917. * Define the url to get the inspector script from.
  115918. * By default it uses the babylonjs CDN.
  115919. * @ignoreNaming
  115920. */
  115921. static InspectorURL: string;
  115922. private _scene;
  115923. private BJSINSPECTOR;
  115924. private _onPropertyChangedObservable?;
  115925. /**
  115926. * Observable triggered when a property is changed through the inspector.
  115927. */
  115928. get onPropertyChangedObservable(): any;
  115929. /**
  115930. * Instantiates a new debug layer.
  115931. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115932. * what is happening in your scene
  115933. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115934. * @param scene Defines the scene to inspect
  115935. */
  115936. constructor(scene: Scene);
  115937. /** Creates the inspector window. */
  115938. private _createInspector;
  115939. /**
  115940. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  115941. * @param entity defines the entity to select
  115942. * @param lineContainerTitle defines the specific block to highlight
  115943. */
  115944. select(entity: any, lineContainerTitle?: string): void;
  115945. /** Get the inspector from bundle or global */
  115946. private _getGlobalInspector;
  115947. /**
  115948. * Get if the inspector is visible or not.
  115949. * @returns true if visible otherwise, false
  115950. */
  115951. isVisible(): boolean;
  115952. /**
  115953. * Hide the inspector and close its window.
  115954. */
  115955. hide(): void;
  115956. /**
  115957. * Launch the debugLayer.
  115958. * @param config Define the configuration of the inspector
  115959. * @return a promise fulfilled when the debug layer is visible
  115960. */
  115961. show(config?: IInspectorOptions): Promise<DebugLayer>;
  115962. }
  115963. }
  115964. declare module BABYLON {
  115965. /**
  115966. * Class containing static functions to help procedurally build meshes
  115967. */
  115968. export class BoxBuilder {
  115969. /**
  115970. * Creates a box mesh
  115971. * * The parameter `size` sets the size (float) of each box side (default 1)
  115972. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115973. * * 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)
  115974. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115978. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115979. * @param name defines the name of the mesh
  115980. * @param options defines the options used to create the mesh
  115981. * @param scene defines the hosting scene
  115982. * @returns the box mesh
  115983. */
  115984. static CreateBox(name: string, options: {
  115985. size?: number;
  115986. width?: number;
  115987. height?: number;
  115988. depth?: number;
  115989. faceUV?: Vector4[];
  115990. faceColors?: Color4[];
  115991. sideOrientation?: number;
  115992. frontUVs?: Vector4;
  115993. backUVs?: Vector4;
  115994. wrap?: boolean;
  115995. topBaseAt?: number;
  115996. bottomBaseAt?: number;
  115997. updatable?: boolean;
  115998. }, scene?: Nullable<Scene>): Mesh;
  115999. }
  116000. }
  116001. declare module BABYLON {
  116002. /**
  116003. * Class containing static functions to help procedurally build meshes
  116004. */
  116005. export class SphereBuilder {
  116006. /**
  116007. * Creates a sphere mesh
  116008. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116009. * * 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`)
  116010. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116011. * * 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
  116012. * * 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)
  116013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116016. * @param name defines the name of the mesh
  116017. * @param options defines the options used to create the mesh
  116018. * @param scene defines the hosting scene
  116019. * @returns the sphere mesh
  116020. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116021. */
  116022. static CreateSphere(name: string, options: {
  116023. segments?: number;
  116024. diameter?: number;
  116025. diameterX?: number;
  116026. diameterY?: number;
  116027. diameterZ?: number;
  116028. arc?: number;
  116029. slice?: number;
  116030. sideOrientation?: number;
  116031. frontUVs?: Vector4;
  116032. backUVs?: Vector4;
  116033. updatable?: boolean;
  116034. }, scene?: Nullable<Scene>): Mesh;
  116035. }
  116036. }
  116037. declare module BABYLON.Debug {
  116038. /**
  116039. * Used to show the physics impostor around the specific mesh
  116040. */
  116041. export class PhysicsViewer {
  116042. /** @hidden */
  116043. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116044. /** @hidden */
  116045. protected _meshes: Array<Nullable<AbstractMesh>>;
  116046. /** @hidden */
  116047. protected _scene: Nullable<Scene>;
  116048. /** @hidden */
  116049. protected _numMeshes: number;
  116050. /** @hidden */
  116051. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116052. private _renderFunction;
  116053. private _utilityLayer;
  116054. private _debugBoxMesh;
  116055. private _debugSphereMesh;
  116056. private _debugCylinderMesh;
  116057. private _debugMaterial;
  116058. private _debugMeshMeshes;
  116059. /**
  116060. * Creates a new PhysicsViewer
  116061. * @param scene defines the hosting scene
  116062. */
  116063. constructor(scene: Scene);
  116064. /** @hidden */
  116065. protected _updateDebugMeshes(): void;
  116066. /**
  116067. * Renders a specified physic impostor
  116068. * @param impostor defines the impostor to render
  116069. * @param targetMesh defines the mesh represented by the impostor
  116070. * @returns the new debug mesh used to render the impostor
  116071. */
  116072. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116073. /**
  116074. * Hides a specified physic impostor
  116075. * @param impostor defines the impostor to hide
  116076. */
  116077. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116078. private _getDebugMaterial;
  116079. private _getDebugBoxMesh;
  116080. private _getDebugSphereMesh;
  116081. private _getDebugCylinderMesh;
  116082. private _getDebugMeshMesh;
  116083. private _getDebugMesh;
  116084. /** Releases all resources */
  116085. dispose(): void;
  116086. }
  116087. }
  116088. declare module BABYLON {
  116089. /**
  116090. * Class containing static functions to help procedurally build meshes
  116091. */
  116092. export class LinesBuilder {
  116093. /**
  116094. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116095. * * 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
  116096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116097. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116098. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116099. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116100. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116101. * * 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
  116102. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116105. * @param name defines the name of the new line system
  116106. * @param options defines the options used to create the line system
  116107. * @param scene defines the hosting scene
  116108. * @returns a new line system mesh
  116109. */
  116110. static CreateLineSystem(name: string, options: {
  116111. lines: Vector3[][];
  116112. updatable?: boolean;
  116113. instance?: Nullable<LinesMesh>;
  116114. colors?: Nullable<Color4[][]>;
  116115. useVertexAlpha?: boolean;
  116116. }, scene: Nullable<Scene>): LinesMesh;
  116117. /**
  116118. * Creates a line mesh
  116119. * 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
  116120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116121. * * The parameter `points` is an array successive Vector3
  116122. * * 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
  116123. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116125. * * When updating an instance, remember that only point positions can change, not the number of points
  116126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116128. * @param name defines the name of the new line system
  116129. * @param options defines the options used to create the line system
  116130. * @param scene defines the hosting scene
  116131. * @returns a new line mesh
  116132. */
  116133. static CreateLines(name: string, options: {
  116134. points: Vector3[];
  116135. updatable?: boolean;
  116136. instance?: Nullable<LinesMesh>;
  116137. colors?: Color4[];
  116138. useVertexAlpha?: boolean;
  116139. }, scene?: Nullable<Scene>): LinesMesh;
  116140. /**
  116141. * Creates a dashed line mesh
  116142. * * 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
  116143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116144. * * The parameter `points` is an array successive Vector3
  116145. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116146. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116147. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116148. * * 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
  116149. * * When updating an instance, remember that only point positions can change, not the number of points
  116150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116151. * @param name defines the name of the mesh
  116152. * @param options defines the options used to create the mesh
  116153. * @param scene defines the hosting scene
  116154. * @returns the dashed line mesh
  116155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116156. */
  116157. static CreateDashedLines(name: string, options: {
  116158. points: Vector3[];
  116159. dashSize?: number;
  116160. gapSize?: number;
  116161. dashNb?: number;
  116162. updatable?: boolean;
  116163. instance?: LinesMesh;
  116164. }, scene?: Nullable<Scene>): LinesMesh;
  116165. }
  116166. }
  116167. declare module BABYLON {
  116168. /**
  116169. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116170. * in order to better appreciate the issue one might have.
  116171. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116172. */
  116173. export class RayHelper {
  116174. /**
  116175. * Defines the ray we are currently tryin to visualize.
  116176. */
  116177. ray: Nullable<Ray>;
  116178. private _renderPoints;
  116179. private _renderLine;
  116180. private _renderFunction;
  116181. private _scene;
  116182. private _updateToMeshFunction;
  116183. private _attachedToMesh;
  116184. private _meshSpaceDirection;
  116185. private _meshSpaceOrigin;
  116186. /**
  116187. * Helper function to create a colored helper in a scene in one line.
  116188. * @param ray Defines the ray we are currently tryin to visualize
  116189. * @param scene Defines the scene the ray is used in
  116190. * @param color Defines the color we want to see the ray in
  116191. * @returns The newly created ray helper.
  116192. */
  116193. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116194. /**
  116195. * Instantiate a new ray helper.
  116196. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116197. * in order to better appreciate the issue one might have.
  116198. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116199. * @param ray Defines the ray we are currently tryin to visualize
  116200. */
  116201. constructor(ray: Ray);
  116202. /**
  116203. * Shows the ray we are willing to debug.
  116204. * @param scene Defines the scene the ray needs to be rendered in
  116205. * @param color Defines the color the ray needs to be rendered in
  116206. */
  116207. show(scene: Scene, color?: Color3): void;
  116208. /**
  116209. * Hides the ray we are debugging.
  116210. */
  116211. hide(): void;
  116212. private _render;
  116213. /**
  116214. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116215. * @param mesh Defines the mesh we want the helper attached to
  116216. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116217. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116218. * @param length Defines the length of the ray
  116219. */
  116220. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116221. /**
  116222. * Detach the ray helper from the mesh it has previously been attached to.
  116223. */
  116224. detachFromMesh(): void;
  116225. private _updateToMesh;
  116226. /**
  116227. * Dispose the helper and release its associated resources.
  116228. */
  116229. dispose(): void;
  116230. }
  116231. }
  116232. declare module BABYLON.Debug {
  116233. /**
  116234. * Class used to render a debug view of a given skeleton
  116235. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116236. */
  116237. export class SkeletonViewer {
  116238. /** defines the skeleton to render */
  116239. skeleton: Skeleton;
  116240. /** defines the mesh attached to the skeleton */
  116241. mesh: AbstractMesh;
  116242. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116243. autoUpdateBonesMatrices: boolean;
  116244. /** defines the rendering group id to use with the viewer */
  116245. renderingGroupId: number;
  116246. /** Gets or sets the color used to render the skeleton */
  116247. color: Color3;
  116248. private _scene;
  116249. private _debugLines;
  116250. private _debugMesh;
  116251. private _isEnabled;
  116252. private _renderFunction;
  116253. private _utilityLayer;
  116254. /**
  116255. * Returns the mesh used to render the bones
  116256. */
  116257. get debugMesh(): Nullable<LinesMesh>;
  116258. /**
  116259. * Creates a new SkeletonViewer
  116260. * @param skeleton defines the skeleton to render
  116261. * @param mesh defines the mesh attached to the skeleton
  116262. * @param scene defines the hosting scene
  116263. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116264. * @param renderingGroupId defines the rendering group id to use with the viewer
  116265. */
  116266. constructor(
  116267. /** defines the skeleton to render */
  116268. skeleton: Skeleton,
  116269. /** defines the mesh attached to the skeleton */
  116270. mesh: AbstractMesh, scene: Scene,
  116271. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116272. autoUpdateBonesMatrices?: boolean,
  116273. /** defines the rendering group id to use with the viewer */
  116274. renderingGroupId?: number);
  116275. /** Gets or sets a boolean indicating if the viewer is enabled */
  116276. set isEnabled(value: boolean);
  116277. get isEnabled(): boolean;
  116278. private _getBonePosition;
  116279. private _getLinesForBonesWithLength;
  116280. private _getLinesForBonesNoLength;
  116281. /** Update the viewer to sync with current skeleton state */
  116282. update(): void;
  116283. /** Release associated resources */
  116284. dispose(): void;
  116285. }
  116286. }
  116287. declare module BABYLON {
  116288. /**
  116289. * Options to create the null engine
  116290. */
  116291. export class NullEngineOptions {
  116292. /**
  116293. * Render width (Default: 512)
  116294. */
  116295. renderWidth: number;
  116296. /**
  116297. * Render height (Default: 256)
  116298. */
  116299. renderHeight: number;
  116300. /**
  116301. * Texture size (Default: 512)
  116302. */
  116303. textureSize: number;
  116304. /**
  116305. * If delta time between frames should be constant
  116306. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116307. */
  116308. deterministicLockstep: boolean;
  116309. /**
  116310. * Maximum about of steps between frames (Default: 4)
  116311. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116312. */
  116313. lockstepMaxSteps: number;
  116314. }
  116315. /**
  116316. * The null engine class provides support for headless version of babylon.js.
  116317. * This can be used in server side scenario or for testing purposes
  116318. */
  116319. export class NullEngine extends Engine {
  116320. private _options;
  116321. /**
  116322. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116323. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116324. * @returns true if engine is in deterministic lock step mode
  116325. */
  116326. isDeterministicLockStep(): boolean;
  116327. /**
  116328. * Gets the max steps when engine is running in deterministic lock step
  116329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116330. * @returns the max steps
  116331. */
  116332. getLockstepMaxSteps(): number;
  116333. /**
  116334. * Gets the current hardware scaling level.
  116335. * By default the hardware scaling level is computed from the window device ratio.
  116336. * 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.
  116337. * @returns a number indicating the current hardware scaling level
  116338. */
  116339. getHardwareScalingLevel(): number;
  116340. constructor(options?: NullEngineOptions);
  116341. /**
  116342. * Creates a vertex buffer
  116343. * @param vertices the data for the vertex buffer
  116344. * @returns the new WebGL static buffer
  116345. */
  116346. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116347. /**
  116348. * Creates a new index buffer
  116349. * @param indices defines the content of the index buffer
  116350. * @param updatable defines if the index buffer must be updatable
  116351. * @returns a new webGL buffer
  116352. */
  116353. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116354. /**
  116355. * Clear the current render buffer or the current render target (if any is set up)
  116356. * @param color defines the color to use
  116357. * @param backBuffer defines if the back buffer must be cleared
  116358. * @param depth defines if the depth buffer must be cleared
  116359. * @param stencil defines if the stencil buffer must be cleared
  116360. */
  116361. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116362. /**
  116363. * Gets the current render width
  116364. * @param useScreen defines if screen size must be used (or the current render target if any)
  116365. * @returns a number defining the current render width
  116366. */
  116367. getRenderWidth(useScreen?: boolean): number;
  116368. /**
  116369. * Gets the current render height
  116370. * @param useScreen defines if screen size must be used (or the current render target if any)
  116371. * @returns a number defining the current render height
  116372. */
  116373. getRenderHeight(useScreen?: boolean): number;
  116374. /**
  116375. * Set the WebGL's viewport
  116376. * @param viewport defines the viewport element to be used
  116377. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116378. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116379. */
  116380. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116381. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116382. /**
  116383. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116384. * @param pipelineContext defines the pipeline context to use
  116385. * @param uniformsNames defines the list of uniform names
  116386. * @returns an array of webGL uniform locations
  116387. */
  116388. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116389. /**
  116390. * Gets the lsit of active attributes for a given webGL program
  116391. * @param pipelineContext defines the pipeline context to use
  116392. * @param attributesNames defines the list of attribute names to get
  116393. * @returns an array of indices indicating the offset of each attribute
  116394. */
  116395. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116396. /**
  116397. * Binds an effect to the webGL context
  116398. * @param effect defines the effect to bind
  116399. */
  116400. bindSamplers(effect: Effect): void;
  116401. /**
  116402. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116403. * @param effect defines the effect to activate
  116404. */
  116405. enableEffect(effect: Effect): void;
  116406. /**
  116407. * Set various states to the webGL context
  116408. * @param culling defines backface culling state
  116409. * @param zOffset defines the value to apply to zOffset (0 by default)
  116410. * @param force defines if states must be applied even if cache is up to date
  116411. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116412. */
  116413. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116414. /**
  116415. * Set the value of an uniform to an array of int32
  116416. * @param uniform defines the webGL uniform location where to store the value
  116417. * @param array defines the array of int32 to store
  116418. */
  116419. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116420. /**
  116421. * Set the value of an uniform to an array of int32 (stored as vec2)
  116422. * @param uniform defines the webGL uniform location where to store the value
  116423. * @param array defines the array of int32 to store
  116424. */
  116425. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116426. /**
  116427. * Set the value of an uniform to an array of int32 (stored as vec3)
  116428. * @param uniform defines the webGL uniform location where to store the value
  116429. * @param array defines the array of int32 to store
  116430. */
  116431. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116432. /**
  116433. * Set the value of an uniform to an array of int32 (stored as vec4)
  116434. * @param uniform defines the webGL uniform location where to store the value
  116435. * @param array defines the array of int32 to store
  116436. */
  116437. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116438. /**
  116439. * Set the value of an uniform to an array of float32
  116440. * @param uniform defines the webGL uniform location where to store the value
  116441. * @param array defines the array of float32 to store
  116442. */
  116443. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116444. /**
  116445. * Set the value of an uniform to an array of float32 (stored as vec2)
  116446. * @param uniform defines the webGL uniform location where to store the value
  116447. * @param array defines the array of float32 to store
  116448. */
  116449. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116450. /**
  116451. * Set the value of an uniform to an array of float32 (stored as vec3)
  116452. * @param uniform defines the webGL uniform location where to store the value
  116453. * @param array defines the array of float32 to store
  116454. */
  116455. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116456. /**
  116457. * Set the value of an uniform to an array of float32 (stored as vec4)
  116458. * @param uniform defines the webGL uniform location where to store the value
  116459. * @param array defines the array of float32 to store
  116460. */
  116461. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116462. /**
  116463. * Set the value of an uniform to an array of number
  116464. * @param uniform defines the webGL uniform location where to store the value
  116465. * @param array defines the array of number to store
  116466. */
  116467. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116468. /**
  116469. * Set the value of an uniform to an array of number (stored as vec2)
  116470. * @param uniform defines the webGL uniform location where to store the value
  116471. * @param array defines the array of number to store
  116472. */
  116473. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116474. /**
  116475. * Set the value of an uniform to an array of number (stored as vec3)
  116476. * @param uniform defines the webGL uniform location where to store the value
  116477. * @param array defines the array of number to store
  116478. */
  116479. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116480. /**
  116481. * Set the value of an uniform to an array of number (stored as vec4)
  116482. * @param uniform defines the webGL uniform location where to store the value
  116483. * @param array defines the array of number to store
  116484. */
  116485. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116486. /**
  116487. * Set the value of an uniform to an array of float32 (stored as matrices)
  116488. * @param uniform defines the webGL uniform location where to store the value
  116489. * @param matrices defines the array of float32 to store
  116490. */
  116491. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116492. /**
  116493. * Set the value of an uniform to a matrix (3x3)
  116494. * @param uniform defines the webGL uniform location where to store the value
  116495. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116496. */
  116497. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116498. /**
  116499. * Set the value of an uniform to a matrix (2x2)
  116500. * @param uniform defines the webGL uniform location where to store the value
  116501. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116502. */
  116503. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116504. /**
  116505. * Set the value of an uniform to a number (float)
  116506. * @param uniform defines the webGL uniform location where to store the value
  116507. * @param value defines the float number to store
  116508. */
  116509. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116510. /**
  116511. * Set the value of an uniform to a vec2
  116512. * @param uniform defines the webGL uniform location where to store the value
  116513. * @param x defines the 1st component of the value
  116514. * @param y defines the 2nd component of the value
  116515. */
  116516. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116517. /**
  116518. * Set the value of an uniform to a vec3
  116519. * @param uniform defines the webGL uniform location where to store the value
  116520. * @param x defines the 1st component of the value
  116521. * @param y defines the 2nd component of the value
  116522. * @param z defines the 3rd component of the value
  116523. */
  116524. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116525. /**
  116526. * Set the value of an uniform to a boolean
  116527. * @param uniform defines the webGL uniform location where to store the value
  116528. * @param bool defines the boolean to store
  116529. */
  116530. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116531. /**
  116532. * Set the value of an uniform to a vec4
  116533. * @param uniform defines the webGL uniform location where to store the value
  116534. * @param x defines the 1st component of the value
  116535. * @param y defines the 2nd component of the value
  116536. * @param z defines the 3rd component of the value
  116537. * @param w defines the 4th component of the value
  116538. */
  116539. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116540. /**
  116541. * Sets the current alpha mode
  116542. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116543. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116545. */
  116546. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116547. /**
  116548. * Bind webGl buffers directly to the webGL context
  116549. * @param vertexBuffers defines the vertex buffer to bind
  116550. * @param indexBuffer defines the index buffer to bind
  116551. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116552. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116553. * @param effect defines the effect associated with the vertex buffer
  116554. */
  116555. bindBuffers(vertexBuffers: {
  116556. [key: string]: VertexBuffer;
  116557. }, indexBuffer: DataBuffer, effect: Effect): void;
  116558. /**
  116559. * Force the entire cache to be cleared
  116560. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116561. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116562. */
  116563. wipeCaches(bruteForce?: boolean): void;
  116564. /**
  116565. * Send a draw order
  116566. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116567. * @param indexStart defines the starting index
  116568. * @param indexCount defines the number of index to draw
  116569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116570. */
  116571. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116572. /**
  116573. * Draw a list of indexed primitives
  116574. * @param fillMode defines the primitive to use
  116575. * @param indexStart defines the starting index
  116576. * @param indexCount defines the number of index to draw
  116577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116578. */
  116579. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116580. /**
  116581. * Draw a list of unindexed primitives
  116582. * @param fillMode defines the primitive to use
  116583. * @param verticesStart defines the index of first vertex to draw
  116584. * @param verticesCount defines the count of vertices to draw
  116585. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116586. */
  116587. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116588. /** @hidden */
  116589. _createTexture(): WebGLTexture;
  116590. /** @hidden */
  116591. _releaseTexture(texture: InternalTexture): void;
  116592. /**
  116593. * Usually called from Texture.ts.
  116594. * Passed information to create a WebGLTexture
  116595. * @param urlArg defines a value which contains one of the following:
  116596. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116597. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116598. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116599. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116600. * @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)
  116601. * @param scene needed for loading to the correct scene
  116602. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116603. * @param onLoad optional callback to be called upon successful completion
  116604. * @param onError optional callback to be called upon failure
  116605. * @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
  116606. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116607. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116608. * @param forcedExtension defines the extension to use to pick the right loader
  116609. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116610. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116611. */
  116612. 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;
  116613. /**
  116614. * Creates a new render target texture
  116615. * @param size defines the size of the texture
  116616. * @param options defines the options used to create the texture
  116617. * @returns a new render target texture stored in an InternalTexture
  116618. */
  116619. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116620. /**
  116621. * Update the sampling mode of a given texture
  116622. * @param samplingMode defines the required sampling mode
  116623. * @param texture defines the texture to update
  116624. */
  116625. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116626. /**
  116627. * Binds the frame buffer to the specified texture.
  116628. * @param texture The texture to render to or null for the default canvas
  116629. * @param faceIndex The face of the texture to render to in case of cube texture
  116630. * @param requiredWidth The width of the target to render to
  116631. * @param requiredHeight The height of the target to render to
  116632. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116633. * @param depthStencilTexture The depth stencil texture to use to render
  116634. * @param lodLevel defines le lod level to bind to the frame buffer
  116635. */
  116636. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116637. /**
  116638. * Unbind the current render target texture from the webGL context
  116639. * @param texture defines the render target texture to unbind
  116640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116642. */
  116643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116644. /**
  116645. * Creates a dynamic vertex buffer
  116646. * @param vertices the data for the dynamic vertex buffer
  116647. * @returns the new WebGL dynamic buffer
  116648. */
  116649. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116650. /**
  116651. * Update the content of a dynamic texture
  116652. * @param texture defines the texture to update
  116653. * @param canvas defines the canvas containing the source
  116654. * @param invertY defines if data must be stored with Y axis inverted
  116655. * @param premulAlpha defines if alpha is stored as premultiplied
  116656. * @param format defines the format of the data
  116657. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116658. */
  116659. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116660. /**
  116661. * Gets a boolean indicating if all created effects are ready
  116662. * @returns true if all effects are ready
  116663. */
  116664. areAllEffectsReady(): boolean;
  116665. /**
  116666. * @hidden
  116667. * Get the current error code of the webGL context
  116668. * @returns the error code
  116669. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116670. */
  116671. getError(): number;
  116672. /** @hidden */
  116673. _getUnpackAlignement(): number;
  116674. /** @hidden */
  116675. _unpackFlipY(value: boolean): void;
  116676. /**
  116677. * Update a dynamic index buffer
  116678. * @param indexBuffer defines the target index buffer
  116679. * @param indices defines the data to update
  116680. * @param offset defines the offset in the target index buffer where update should start
  116681. */
  116682. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116683. /**
  116684. * Updates a dynamic vertex buffer.
  116685. * @param vertexBuffer the vertex buffer to update
  116686. * @param vertices the data used to update the vertex buffer
  116687. * @param byteOffset the byte offset of the data (optional)
  116688. * @param byteLength the byte length of the data (optional)
  116689. */
  116690. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116691. /** @hidden */
  116692. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116693. /** @hidden */
  116694. _bindTexture(channel: number, texture: InternalTexture): void;
  116695. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116696. /**
  116697. * 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
  116698. */
  116699. releaseEffects(): void;
  116700. displayLoadingUI(): void;
  116701. hideLoadingUI(): void;
  116702. /** @hidden */
  116703. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116704. /** @hidden */
  116705. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116706. /** @hidden */
  116707. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116708. /** @hidden */
  116709. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116710. }
  116711. }
  116712. declare module BABYLON {
  116713. /** @hidden */
  116714. export class _OcclusionDataStorage {
  116715. /** @hidden */
  116716. occlusionInternalRetryCounter: number;
  116717. /** @hidden */
  116718. isOcclusionQueryInProgress: boolean;
  116719. /** @hidden */
  116720. isOccluded: boolean;
  116721. /** @hidden */
  116722. occlusionRetryCount: number;
  116723. /** @hidden */
  116724. occlusionType: number;
  116725. /** @hidden */
  116726. occlusionQueryAlgorithmType: number;
  116727. }
  116728. interface Engine {
  116729. /**
  116730. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116731. * @return the new query
  116732. */
  116733. createQuery(): WebGLQuery;
  116734. /**
  116735. * Delete and release a webGL query
  116736. * @param query defines the query to delete
  116737. * @return the current engine
  116738. */
  116739. deleteQuery(query: WebGLQuery): Engine;
  116740. /**
  116741. * Check if a given query has resolved and got its value
  116742. * @param query defines the query to check
  116743. * @returns true if the query got its value
  116744. */
  116745. isQueryResultAvailable(query: WebGLQuery): boolean;
  116746. /**
  116747. * Gets the value of a given query
  116748. * @param query defines the query to check
  116749. * @returns the value of the query
  116750. */
  116751. getQueryResult(query: WebGLQuery): number;
  116752. /**
  116753. * Initiates an occlusion query
  116754. * @param algorithmType defines the algorithm to use
  116755. * @param query defines the query to use
  116756. * @returns the current engine
  116757. * @see http://doc.babylonjs.com/features/occlusionquery
  116758. */
  116759. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116760. /**
  116761. * Ends an occlusion query
  116762. * @see http://doc.babylonjs.com/features/occlusionquery
  116763. * @param algorithmType defines the algorithm to use
  116764. * @returns the current engine
  116765. */
  116766. endOcclusionQuery(algorithmType: number): Engine;
  116767. /**
  116768. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116769. * Please note that only one query can be issued at a time
  116770. * @returns a time token used to track the time span
  116771. */
  116772. startTimeQuery(): Nullable<_TimeToken>;
  116773. /**
  116774. * Ends a time query
  116775. * @param token defines the token used to measure the time span
  116776. * @returns the time spent (in ns)
  116777. */
  116778. endTimeQuery(token: _TimeToken): int;
  116779. /** @hidden */
  116780. _currentNonTimestampToken: Nullable<_TimeToken>;
  116781. /** @hidden */
  116782. _createTimeQuery(): WebGLQuery;
  116783. /** @hidden */
  116784. _deleteTimeQuery(query: WebGLQuery): void;
  116785. /** @hidden */
  116786. _getGlAlgorithmType(algorithmType: number): number;
  116787. /** @hidden */
  116788. _getTimeQueryResult(query: WebGLQuery): any;
  116789. /** @hidden */
  116790. _getTimeQueryAvailability(query: WebGLQuery): any;
  116791. }
  116792. interface AbstractMesh {
  116793. /**
  116794. * Backing filed
  116795. * @hidden
  116796. */
  116797. __occlusionDataStorage: _OcclusionDataStorage;
  116798. /**
  116799. * Access property
  116800. * @hidden
  116801. */
  116802. _occlusionDataStorage: _OcclusionDataStorage;
  116803. /**
  116804. * 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.
  116805. * The default value is -1 which means don't break the query and wait till the result
  116806. * @see http://doc.babylonjs.com/features/occlusionquery
  116807. */
  116808. occlusionRetryCount: number;
  116809. /**
  116810. * 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:
  116811. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116812. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116813. * * 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.
  116814. * @see http://doc.babylonjs.com/features/occlusionquery
  116815. */
  116816. occlusionType: number;
  116817. /**
  116818. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116819. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116820. * * 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.
  116821. * @see http://doc.babylonjs.com/features/occlusionquery
  116822. */
  116823. occlusionQueryAlgorithmType: number;
  116824. /**
  116825. * 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
  116826. * @see http://doc.babylonjs.com/features/occlusionquery
  116827. */
  116828. isOccluded: boolean;
  116829. /**
  116830. * Flag to check the progress status of the query
  116831. * @see http://doc.babylonjs.com/features/occlusionquery
  116832. */
  116833. isOcclusionQueryInProgress: boolean;
  116834. }
  116835. }
  116836. declare module BABYLON {
  116837. /** @hidden */
  116838. export var _forceTransformFeedbackToBundle: boolean;
  116839. interface Engine {
  116840. /**
  116841. * Creates a webGL transform feedback object
  116842. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116843. * @returns the webGL transform feedback object
  116844. */
  116845. createTransformFeedback(): WebGLTransformFeedback;
  116846. /**
  116847. * Delete a webGL transform feedback object
  116848. * @param value defines the webGL transform feedback object to delete
  116849. */
  116850. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  116851. /**
  116852. * Bind a webGL transform feedback object to the webgl context
  116853. * @param value defines the webGL transform feedback object to bind
  116854. */
  116855. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  116856. /**
  116857. * Begins a transform feedback operation
  116858. * @param usePoints defines if points or triangles must be used
  116859. */
  116860. beginTransformFeedback(usePoints: boolean): void;
  116861. /**
  116862. * Ends a transform feedback operation
  116863. */
  116864. endTransformFeedback(): void;
  116865. /**
  116866. * Specify the varyings to use with transform feedback
  116867. * @param program defines the associated webGL program
  116868. * @param value defines the list of strings representing the varying names
  116869. */
  116870. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  116871. /**
  116872. * Bind a webGL buffer for a transform feedback operation
  116873. * @param value defines the webGL buffer to bind
  116874. */
  116875. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  116876. }
  116877. }
  116878. declare module BABYLON {
  116879. /**
  116880. * Creation options of the multi render target texture.
  116881. */
  116882. export interface IMultiRenderTargetOptions {
  116883. /**
  116884. * Define if the texture needs to create mip maps after render.
  116885. */
  116886. generateMipMaps?: boolean;
  116887. /**
  116888. * Define the types of all the draw buffers we want to create
  116889. */
  116890. types?: number[];
  116891. /**
  116892. * Define the sampling modes of all the draw buffers we want to create
  116893. */
  116894. samplingModes?: number[];
  116895. /**
  116896. * Define if a depth buffer is required
  116897. */
  116898. generateDepthBuffer?: boolean;
  116899. /**
  116900. * Define if a stencil buffer is required
  116901. */
  116902. generateStencilBuffer?: boolean;
  116903. /**
  116904. * Define if a depth texture is required instead of a depth buffer
  116905. */
  116906. generateDepthTexture?: boolean;
  116907. /**
  116908. * Define the number of desired draw buffers
  116909. */
  116910. textureCount?: number;
  116911. /**
  116912. * Define if aspect ratio should be adapted to the texture or stay the scene one
  116913. */
  116914. doNotChangeAspectRatio?: boolean;
  116915. /**
  116916. * Define the default type of the buffers we are creating
  116917. */
  116918. defaultType?: number;
  116919. }
  116920. /**
  116921. * A multi render target, like a render target provides the ability to render to a texture.
  116922. * Unlike the render target, it can render to several draw buffers in one draw.
  116923. * This is specially interesting in deferred rendering or for any effects requiring more than
  116924. * just one color from a single pass.
  116925. */
  116926. export class MultiRenderTarget extends RenderTargetTexture {
  116927. private _internalTextures;
  116928. private _textures;
  116929. private _multiRenderTargetOptions;
  116930. /**
  116931. * Get if draw buffers are currently supported by the used hardware and browser.
  116932. */
  116933. get isSupported(): boolean;
  116934. /**
  116935. * Get the list of textures generated by the multi render target.
  116936. */
  116937. get textures(): Texture[];
  116938. /**
  116939. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  116940. */
  116941. get depthTexture(): Texture;
  116942. /**
  116943. * Set the wrapping mode on U of all the textures we are rendering to.
  116944. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116945. */
  116946. set wrapU(wrap: number);
  116947. /**
  116948. * Set the wrapping mode on V of all the textures we are rendering to.
  116949. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116950. */
  116951. set wrapV(wrap: number);
  116952. /**
  116953. * Instantiate a new multi render target texture.
  116954. * A multi render target, like a render target provides the ability to render to a texture.
  116955. * Unlike the render target, it can render to several draw buffers in one draw.
  116956. * This is specially interesting in deferred rendering or for any effects requiring more than
  116957. * just one color from a single pass.
  116958. * @param name Define the name of the texture
  116959. * @param size Define the size of the buffers to render to
  116960. * @param count Define the number of target we are rendering into
  116961. * @param scene Define the scene the texture belongs to
  116962. * @param options Define the options used to create the multi render target
  116963. */
  116964. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  116965. /** @hidden */
  116966. _rebuild(): void;
  116967. private _createInternalTextures;
  116968. private _createTextures;
  116969. /**
  116970. * Define the number of samples used if MSAA is enabled.
  116971. */
  116972. get samples(): number;
  116973. set samples(value: number);
  116974. /**
  116975. * Resize all the textures in the multi render target.
  116976. * Be carrefull as it will recreate all the data in the new texture.
  116977. * @param size Define the new size
  116978. */
  116979. resize(size: any): void;
  116980. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  116981. /**
  116982. * Dispose the render targets and their associated resources
  116983. */
  116984. dispose(): void;
  116985. /**
  116986. * Release all the underlying texture used as draw buffers.
  116987. */
  116988. releaseInternalTextures(): void;
  116989. }
  116990. }
  116991. declare module BABYLON {
  116992. interface ThinEngine {
  116993. /**
  116994. * Unbind a list of render target textures from the webGL context
  116995. * This is used only when drawBuffer extension or webGL2 are active
  116996. * @param textures defines the render target textures to unbind
  116997. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116998. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116999. */
  117000. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117001. /**
  117002. * Create a multi render target texture
  117003. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117004. * @param size defines the size of the texture
  117005. * @param options defines the creation options
  117006. * @returns the cube texture as an InternalTexture
  117007. */
  117008. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117009. /**
  117010. * Update the sample count for a given multiple render target texture
  117011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117012. * @param textures defines the textures to update
  117013. * @param samples defines the sample count to set
  117014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117015. */
  117016. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117017. }
  117018. }
  117019. declare module BABYLON {
  117020. /**
  117021. * Class used to define an additional view for the engine
  117022. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117023. */
  117024. export class EngineView {
  117025. /** Defines the canvas where to render the view */
  117026. target: HTMLCanvasElement;
  117027. /** Defines an optional camera used to render the view (will use active camera else) */
  117028. camera?: Camera;
  117029. }
  117030. interface Engine {
  117031. /**
  117032. * Gets or sets the HTML element to use for attaching events
  117033. */
  117034. inputElement: Nullable<HTMLElement>;
  117035. /**
  117036. * Gets the current engine view
  117037. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117038. */
  117039. activeView: Nullable<EngineView>;
  117040. /** Gets or sets the list of views */
  117041. views: EngineView[];
  117042. /**
  117043. * Register a new child canvas
  117044. * @param canvas defines the canvas to register
  117045. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117046. * @returns the associated view
  117047. */
  117048. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117049. /**
  117050. * Remove a registered child canvas
  117051. * @param canvas defines the canvas to remove
  117052. * @returns the current engine
  117053. */
  117054. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117055. }
  117056. }
  117057. declare module BABYLON {
  117058. /**
  117059. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117060. */
  117061. export interface CubeMapInfo {
  117062. /**
  117063. * The pixel array for the front face.
  117064. * This is stored in format, left to right, up to down format.
  117065. */
  117066. front: Nullable<ArrayBufferView>;
  117067. /**
  117068. * The pixel array for the back face.
  117069. * This is stored in format, left to right, up to down format.
  117070. */
  117071. back: Nullable<ArrayBufferView>;
  117072. /**
  117073. * The pixel array for the left face.
  117074. * This is stored in format, left to right, up to down format.
  117075. */
  117076. left: Nullable<ArrayBufferView>;
  117077. /**
  117078. * The pixel array for the right face.
  117079. * This is stored in format, left to right, up to down format.
  117080. */
  117081. right: Nullable<ArrayBufferView>;
  117082. /**
  117083. * The pixel array for the up face.
  117084. * This is stored in format, left to right, up to down format.
  117085. */
  117086. up: Nullable<ArrayBufferView>;
  117087. /**
  117088. * The pixel array for the down face.
  117089. * This is stored in format, left to right, up to down format.
  117090. */
  117091. down: Nullable<ArrayBufferView>;
  117092. /**
  117093. * The size of the cubemap stored.
  117094. *
  117095. * Each faces will be size * size pixels.
  117096. */
  117097. size: number;
  117098. /**
  117099. * The format of the texture.
  117100. *
  117101. * RGBA, RGB.
  117102. */
  117103. format: number;
  117104. /**
  117105. * The type of the texture data.
  117106. *
  117107. * UNSIGNED_INT, FLOAT.
  117108. */
  117109. type: number;
  117110. /**
  117111. * Specifies whether the texture is in gamma space.
  117112. */
  117113. gammaSpace: boolean;
  117114. }
  117115. /**
  117116. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117117. */
  117118. export class PanoramaToCubeMapTools {
  117119. private static FACE_FRONT;
  117120. private static FACE_BACK;
  117121. private static FACE_RIGHT;
  117122. private static FACE_LEFT;
  117123. private static FACE_DOWN;
  117124. private static FACE_UP;
  117125. /**
  117126. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117127. *
  117128. * @param float32Array The source data.
  117129. * @param inputWidth The width of the input panorama.
  117130. * @param inputHeight The height of the input panorama.
  117131. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117132. * @return The cubemap data
  117133. */
  117134. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117135. private static CreateCubemapTexture;
  117136. private static CalcProjectionSpherical;
  117137. }
  117138. }
  117139. declare module BABYLON {
  117140. /**
  117141. * Helper class dealing with the extraction of spherical polynomial dataArray
  117142. * from a cube map.
  117143. */
  117144. export class CubeMapToSphericalPolynomialTools {
  117145. private static FileFaces;
  117146. /**
  117147. * Converts a texture to the according Spherical Polynomial data.
  117148. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117149. *
  117150. * @param texture The texture to extract the information from.
  117151. * @return The Spherical Polynomial data.
  117152. */
  117153. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117154. /**
  117155. * Converts a cubemap to the according Spherical Polynomial data.
  117156. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117157. *
  117158. * @param cubeInfo The Cube map to extract the information from.
  117159. * @return The Spherical Polynomial data.
  117160. */
  117161. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117162. }
  117163. }
  117164. declare module BABYLON {
  117165. interface BaseTexture {
  117166. /**
  117167. * Get the polynomial representation of the texture data.
  117168. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117169. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117170. */
  117171. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117172. }
  117173. }
  117174. declare module BABYLON {
  117175. /** @hidden */
  117176. export var rgbdEncodePixelShader: {
  117177. name: string;
  117178. shader: string;
  117179. };
  117180. }
  117181. declare module BABYLON {
  117182. /** @hidden */
  117183. export var rgbdDecodePixelShader: {
  117184. name: string;
  117185. shader: string;
  117186. };
  117187. }
  117188. declare module BABYLON {
  117189. /**
  117190. * Raw texture data and descriptor sufficient for WebGL texture upload
  117191. */
  117192. export interface EnvironmentTextureInfo {
  117193. /**
  117194. * Version of the environment map
  117195. */
  117196. version: number;
  117197. /**
  117198. * Width of image
  117199. */
  117200. width: number;
  117201. /**
  117202. * Irradiance information stored in the file.
  117203. */
  117204. irradiance: any;
  117205. /**
  117206. * Specular information stored in the file.
  117207. */
  117208. specular: any;
  117209. }
  117210. /**
  117211. * Defines One Image in the file. It requires only the position in the file
  117212. * as well as the length.
  117213. */
  117214. interface BufferImageData {
  117215. /**
  117216. * Length of the image data.
  117217. */
  117218. length: number;
  117219. /**
  117220. * Position of the data from the null terminator delimiting the end of the JSON.
  117221. */
  117222. position: number;
  117223. }
  117224. /**
  117225. * Defines the specular data enclosed in the file.
  117226. * This corresponds to the version 1 of the data.
  117227. */
  117228. export interface EnvironmentTextureSpecularInfoV1 {
  117229. /**
  117230. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117231. */
  117232. specularDataPosition?: number;
  117233. /**
  117234. * This contains all the images data needed to reconstruct the cubemap.
  117235. */
  117236. mipmaps: Array<BufferImageData>;
  117237. /**
  117238. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117239. */
  117240. lodGenerationScale: number;
  117241. }
  117242. /**
  117243. * Sets of helpers addressing the serialization and deserialization of environment texture
  117244. * stored in a BabylonJS env file.
  117245. * Those files are usually stored as .env files.
  117246. */
  117247. export class EnvironmentTextureTools {
  117248. /**
  117249. * Magic number identifying the env file.
  117250. */
  117251. private static _MagicBytes;
  117252. /**
  117253. * Gets the environment info from an env file.
  117254. * @param data The array buffer containing the .env bytes.
  117255. * @returns the environment file info (the json header) if successfully parsed.
  117256. */
  117257. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117258. /**
  117259. * Creates an environment texture from a loaded cube texture.
  117260. * @param texture defines the cube texture to convert in env file
  117261. * @return a promise containing the environment data if succesfull.
  117262. */
  117263. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117264. /**
  117265. * Creates a JSON representation of the spherical data.
  117266. * @param texture defines the texture containing the polynomials
  117267. * @return the JSON representation of the spherical info
  117268. */
  117269. private static _CreateEnvTextureIrradiance;
  117270. /**
  117271. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117272. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117273. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117274. * @return the views described by info providing access to the underlying buffer
  117275. */
  117276. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117277. /**
  117278. * Uploads the texture info contained in the env file to the GPU.
  117279. * @param texture defines the internal texture to upload to
  117280. * @param arrayBuffer defines the buffer cotaining the data to load
  117281. * @param info defines the texture info retrieved through the GetEnvInfo method
  117282. * @returns a promise
  117283. */
  117284. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117285. private static _OnImageReadyAsync;
  117286. /**
  117287. * Uploads the levels of image data to the GPU.
  117288. * @param texture defines the internal texture to upload to
  117289. * @param imageData defines the array buffer views of image data [mipmap][face]
  117290. * @returns a promise
  117291. */
  117292. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117293. /**
  117294. * Uploads spherical polynomials information to the texture.
  117295. * @param texture defines the texture we are trying to upload the information to
  117296. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117297. */
  117298. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117299. /** @hidden */
  117300. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117301. }
  117302. }
  117303. declare module BABYLON {
  117304. /**
  117305. * Contains position and normal vectors for a vertex
  117306. */
  117307. export class PositionNormalVertex {
  117308. /** the position of the vertex (defaut: 0,0,0) */
  117309. position: Vector3;
  117310. /** the normal of the vertex (defaut: 0,1,0) */
  117311. normal: Vector3;
  117312. /**
  117313. * Creates a PositionNormalVertex
  117314. * @param position the position of the vertex (defaut: 0,0,0)
  117315. * @param normal the normal of the vertex (defaut: 0,1,0)
  117316. */
  117317. constructor(
  117318. /** the position of the vertex (defaut: 0,0,0) */
  117319. position?: Vector3,
  117320. /** the normal of the vertex (defaut: 0,1,0) */
  117321. normal?: Vector3);
  117322. /**
  117323. * Clones the PositionNormalVertex
  117324. * @returns the cloned PositionNormalVertex
  117325. */
  117326. clone(): PositionNormalVertex;
  117327. }
  117328. /**
  117329. * Contains position, normal and uv vectors for a vertex
  117330. */
  117331. export class PositionNormalTextureVertex {
  117332. /** the position of the vertex (defaut: 0,0,0) */
  117333. position: Vector3;
  117334. /** the normal of the vertex (defaut: 0,1,0) */
  117335. normal: Vector3;
  117336. /** the uv of the vertex (default: 0,0) */
  117337. uv: Vector2;
  117338. /**
  117339. * Creates a PositionNormalTextureVertex
  117340. * @param position the position of the vertex (defaut: 0,0,0)
  117341. * @param normal the normal of the vertex (defaut: 0,1,0)
  117342. * @param uv the uv of the vertex (default: 0,0)
  117343. */
  117344. constructor(
  117345. /** the position of the vertex (defaut: 0,0,0) */
  117346. position?: Vector3,
  117347. /** the normal of the vertex (defaut: 0,1,0) */
  117348. normal?: Vector3,
  117349. /** the uv of the vertex (default: 0,0) */
  117350. uv?: Vector2);
  117351. /**
  117352. * Clones the PositionNormalTextureVertex
  117353. * @returns the cloned PositionNormalTextureVertex
  117354. */
  117355. clone(): PositionNormalTextureVertex;
  117356. }
  117357. }
  117358. declare module BABYLON {
  117359. /** @hidden */
  117360. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117361. private _genericAttributeLocation;
  117362. private _varyingLocationCount;
  117363. private _varyingLocationMap;
  117364. private _replacements;
  117365. private _textureCount;
  117366. private _uniforms;
  117367. lineProcessor(line: string): string;
  117368. attributeProcessor(attribute: string): string;
  117369. varyingProcessor(varying: string, isFragment: boolean): string;
  117370. uniformProcessor(uniform: string): string;
  117371. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117372. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117373. }
  117374. }
  117375. declare module BABYLON {
  117376. /**
  117377. * Container for accessors for natively-stored mesh data buffers.
  117378. */
  117379. class NativeDataBuffer extends DataBuffer {
  117380. /**
  117381. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117382. */
  117383. nativeIndexBuffer?: any;
  117384. /**
  117385. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117386. */
  117387. nativeVertexBuffer?: any;
  117388. }
  117389. /** @hidden */
  117390. class NativeTexture extends InternalTexture {
  117391. getInternalTexture(): InternalTexture;
  117392. getViewCount(): number;
  117393. }
  117394. /** @hidden */
  117395. export class NativeEngine extends Engine {
  117396. private readonly _native;
  117397. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117398. private readonly INVALID_HANDLE;
  117399. getHardwareScalingLevel(): number;
  117400. constructor();
  117401. /**
  117402. * Can be used to override the current requestAnimationFrame requester.
  117403. * @hidden
  117404. */
  117405. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117406. /**
  117407. * Override default engine behavior.
  117408. * @param color
  117409. * @param backBuffer
  117410. * @param depth
  117411. * @param stencil
  117412. */
  117413. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117414. /**
  117415. * Gets host document
  117416. * @returns the host document object
  117417. */
  117418. getHostDocument(): Nullable<Document>;
  117419. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117420. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117421. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117422. recordVertexArrayObject(vertexBuffers: {
  117423. [key: string]: VertexBuffer;
  117424. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117425. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117426. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117428. /**
  117429. * Draw a list of indexed primitives
  117430. * @param fillMode defines the primitive to use
  117431. * @param indexStart defines the starting index
  117432. * @param indexCount defines the number of index to draw
  117433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117434. */
  117435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117436. /**
  117437. * Draw a list of unindexed primitives
  117438. * @param fillMode defines the primitive to use
  117439. * @param verticesStart defines the index of first vertex to draw
  117440. * @param verticesCount defines the count of vertices to draw
  117441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117442. */
  117443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117444. createPipelineContext(): IPipelineContext;
  117445. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117446. /** @hidden */
  117447. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117448. /** @hidden */
  117449. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117450. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117451. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117452. protected _setProgram(program: WebGLProgram): void;
  117453. _releaseEffect(effect: Effect): void;
  117454. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117456. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117457. bindSamplers(effect: Effect): void;
  117458. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117459. getRenderWidth(useScreen?: boolean): number;
  117460. getRenderHeight(useScreen?: boolean): number;
  117461. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117462. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117463. /**
  117464. * Set the z offset to apply to current rendering
  117465. * @param value defines the offset to apply
  117466. */
  117467. setZOffset(value: number): void;
  117468. /**
  117469. * Gets the current value of the zOffset
  117470. * @returns the current zOffset state
  117471. */
  117472. getZOffset(): number;
  117473. /**
  117474. * Enable or disable depth buffering
  117475. * @param enable defines the state to set
  117476. */
  117477. setDepthBuffer(enable: boolean): void;
  117478. /**
  117479. * Gets a boolean indicating if depth writing is enabled
  117480. * @returns the current depth writing state
  117481. */
  117482. getDepthWrite(): boolean;
  117483. /**
  117484. * Enable or disable depth writing
  117485. * @param enable defines the state to set
  117486. */
  117487. setDepthWrite(enable: boolean): void;
  117488. /**
  117489. * Enable or disable color writing
  117490. * @param enable defines the state to set
  117491. */
  117492. setColorWrite(enable: boolean): void;
  117493. /**
  117494. * Gets a boolean indicating if color writing is enabled
  117495. * @returns the current color writing state
  117496. */
  117497. getColorWrite(): boolean;
  117498. /**
  117499. * Sets alpha constants used by some alpha blending modes
  117500. * @param r defines the red component
  117501. * @param g defines the green component
  117502. * @param b defines the blue component
  117503. * @param a defines the alpha component
  117504. */
  117505. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117506. /**
  117507. * Sets the current alpha mode
  117508. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117511. */
  117512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117513. /**
  117514. * Gets the current alpha mode
  117515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117516. * @returns the current alpha mode
  117517. */
  117518. getAlphaMode(): number;
  117519. setInt(uniform: WebGLUniformLocation, int: number): void;
  117520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117523. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117525. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117526. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117527. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117529. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117530. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117531. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117532. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117533. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117534. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117535. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117536. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117537. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117538. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117539. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117540. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117541. wipeCaches(bruteForce?: boolean): void;
  117542. _createTexture(): WebGLTexture;
  117543. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117544. /**
  117545. * Usually called from BABYLON.Texture.ts.
  117546. * Passed information to create a WebGLTexture
  117547. * @param urlArg defines a value which contains one of the following:
  117548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117552. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117553. * @param scene needed for loading to the correct scene
  117554. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117555. * @param onLoad optional callback to be called upon successful completion
  117556. * @param onError optional callback to be called upon failure
  117557. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117560. * @param forcedExtension defines the extension to use to pick the right loader
  117561. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117562. */
  117563. 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;
  117564. /**
  117565. * Creates a cube texture
  117566. * @param rootUrl defines the url where the files to load is located
  117567. * @param scene defines the current scene
  117568. * @param files defines the list of files to load (1 per face)
  117569. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117570. * @param onLoad defines an optional callback raised when the texture is loaded
  117571. * @param onError defines an optional callback raised if there is an issue to load the texture
  117572. * @param format defines the format of the data
  117573. * @param forcedExtension defines the extension to use to pick the right loader
  117574. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117577. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117578. * @returns the cube texture as an InternalTexture
  117579. */
  117580. 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;
  117581. private _getSamplingFilter;
  117582. private static _GetNativeTextureFormat;
  117583. createRenderTargetTexture(size: number | {
  117584. width: number;
  117585. height: number;
  117586. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117587. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117589. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117590. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117591. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117592. /**
  117593. * Updates a dynamic vertex buffer.
  117594. * @param vertexBuffer the vertex buffer to update
  117595. * @param data the data used to update the vertex buffer
  117596. * @param byteOffset the byte offset of the data (optional)
  117597. * @param byteLength the byte length of the data (optional)
  117598. */
  117599. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117600. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117601. private _updateAnisotropicLevel;
  117602. private _getAddressMode;
  117603. /** @hidden */
  117604. _bindTexture(channel: number, texture: InternalTexture): void;
  117605. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117606. releaseEffects(): void;
  117607. /** @hidden */
  117608. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117609. /** @hidden */
  117610. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117611. /** @hidden */
  117612. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117613. /** @hidden */
  117614. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117615. }
  117616. }
  117617. declare module BABYLON {
  117618. /**
  117619. * Gather the list of clipboard event types as constants.
  117620. */
  117621. export class ClipboardEventTypes {
  117622. /**
  117623. * The clipboard event is fired when a copy command is active (pressed).
  117624. */
  117625. static readonly COPY: number;
  117626. /**
  117627. * The clipboard event is fired when a cut command is active (pressed).
  117628. */
  117629. static readonly CUT: number;
  117630. /**
  117631. * The clipboard event is fired when a paste command is active (pressed).
  117632. */
  117633. static readonly PASTE: number;
  117634. }
  117635. /**
  117636. * This class is used to store clipboard related info for the onClipboardObservable event.
  117637. */
  117638. export class ClipboardInfo {
  117639. /**
  117640. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117641. */
  117642. type: number;
  117643. /**
  117644. * Defines the related dom event
  117645. */
  117646. event: ClipboardEvent;
  117647. /**
  117648. *Creates an instance of ClipboardInfo.
  117649. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117650. * @param event Defines the related dom event
  117651. */
  117652. constructor(
  117653. /**
  117654. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117655. */
  117656. type: number,
  117657. /**
  117658. * Defines the related dom event
  117659. */
  117660. event: ClipboardEvent);
  117661. /**
  117662. * Get the clipboard event's type from the keycode.
  117663. * @param keyCode Defines the keyCode for the current keyboard event.
  117664. * @return {number}
  117665. */
  117666. static GetTypeFromCharacter(keyCode: number): number;
  117667. }
  117668. }
  117669. declare module BABYLON {
  117670. /**
  117671. * Google Daydream controller
  117672. */
  117673. export class DaydreamController extends WebVRController {
  117674. /**
  117675. * Base Url for the controller model.
  117676. */
  117677. static MODEL_BASE_URL: string;
  117678. /**
  117679. * File name for the controller model.
  117680. */
  117681. static MODEL_FILENAME: string;
  117682. /**
  117683. * Gamepad Id prefix used to identify Daydream Controller.
  117684. */
  117685. static readonly GAMEPAD_ID_PREFIX: string;
  117686. /**
  117687. * Creates a new DaydreamController from a gamepad
  117688. * @param vrGamepad the gamepad that the controller should be created from
  117689. */
  117690. constructor(vrGamepad: any);
  117691. /**
  117692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117693. * @param scene scene in which to add meshes
  117694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117695. */
  117696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117697. /**
  117698. * Called once for each button that changed state since the last frame
  117699. * @param buttonIdx Which button index changed
  117700. * @param state New state of the button
  117701. * @param changes Which properties on the state changed since last frame
  117702. */
  117703. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117704. }
  117705. }
  117706. declare module BABYLON {
  117707. /**
  117708. * Gear VR Controller
  117709. */
  117710. export class GearVRController extends WebVRController {
  117711. /**
  117712. * Base Url for the controller model.
  117713. */
  117714. static MODEL_BASE_URL: string;
  117715. /**
  117716. * File name for the controller model.
  117717. */
  117718. static MODEL_FILENAME: string;
  117719. /**
  117720. * Gamepad Id prefix used to identify this controller.
  117721. */
  117722. static readonly GAMEPAD_ID_PREFIX: string;
  117723. private readonly _buttonIndexToObservableNameMap;
  117724. /**
  117725. * Creates a new GearVRController from a gamepad
  117726. * @param vrGamepad the gamepad that the controller should be created from
  117727. */
  117728. constructor(vrGamepad: any);
  117729. /**
  117730. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117731. * @param scene scene in which to add meshes
  117732. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117733. */
  117734. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117735. /**
  117736. * Called once for each button that changed state since the last frame
  117737. * @param buttonIdx Which button index changed
  117738. * @param state New state of the button
  117739. * @param changes Which properties on the state changed since last frame
  117740. */
  117741. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117742. }
  117743. }
  117744. declare module BABYLON {
  117745. /**
  117746. * Class containing static functions to help procedurally build meshes
  117747. */
  117748. export class PolyhedronBuilder {
  117749. /**
  117750. * Creates a polyhedron mesh
  117751. * * 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
  117752. * * The parameter `size` (positive float, default 1) sets the polygon size
  117753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117754. * * 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`
  117755. * * 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
  117756. * * 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)`)
  117757. * * 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
  117758. * * 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
  117759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117762. * @param name defines the name of the mesh
  117763. * @param options defines the options used to create the mesh
  117764. * @param scene defines the hosting scene
  117765. * @returns the polyhedron mesh
  117766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117767. */
  117768. static CreatePolyhedron(name: string, options: {
  117769. type?: number;
  117770. size?: number;
  117771. sizeX?: number;
  117772. sizeY?: number;
  117773. sizeZ?: number;
  117774. custom?: any;
  117775. faceUV?: Vector4[];
  117776. faceColors?: Color4[];
  117777. flat?: boolean;
  117778. updatable?: boolean;
  117779. sideOrientation?: number;
  117780. frontUVs?: Vector4;
  117781. backUVs?: Vector4;
  117782. }, scene?: Nullable<Scene>): Mesh;
  117783. }
  117784. }
  117785. declare module BABYLON {
  117786. /**
  117787. * Gizmo that enables scaling a mesh along 3 axis
  117788. */
  117789. export class ScaleGizmo extends Gizmo {
  117790. /**
  117791. * Internal gizmo used for interactions on the x axis
  117792. */
  117793. xGizmo: AxisScaleGizmo;
  117794. /**
  117795. * Internal gizmo used for interactions on the y axis
  117796. */
  117797. yGizmo: AxisScaleGizmo;
  117798. /**
  117799. * Internal gizmo used for interactions on the z axis
  117800. */
  117801. zGizmo: AxisScaleGizmo;
  117802. /**
  117803. * Internal gizmo used to scale all axis equally
  117804. */
  117805. uniformScaleGizmo: AxisScaleGizmo;
  117806. private _meshAttached;
  117807. private _updateGizmoRotationToMatchAttachedMesh;
  117808. private _snapDistance;
  117809. private _scaleRatio;
  117810. private _uniformScalingMesh;
  117811. private _octahedron;
  117812. private _sensitivity;
  117813. /** Fires an event when any of it's sub gizmos are dragged */
  117814. onDragStartObservable: Observable<unknown>;
  117815. /** Fires an event when any of it's sub gizmos are released from dragging */
  117816. onDragEndObservable: Observable<unknown>;
  117817. get attachedMesh(): Nullable<AbstractMesh>;
  117818. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117819. /**
  117820. * Creates a ScaleGizmo
  117821. * @param gizmoLayer The utility layer the gizmo will be added to
  117822. */
  117823. constructor(gizmoLayer?: UtilityLayerRenderer);
  117824. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117825. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117826. /**
  117827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117828. */
  117829. set snapDistance(value: number);
  117830. get snapDistance(): number;
  117831. /**
  117832. * Ratio for the scale of the gizmo (Default: 1)
  117833. */
  117834. set scaleRatio(value: number);
  117835. get scaleRatio(): number;
  117836. /**
  117837. * Sensitivity factor for dragging (Default: 1)
  117838. */
  117839. set sensitivity(value: number);
  117840. get sensitivity(): number;
  117841. /**
  117842. * Disposes of the gizmo
  117843. */
  117844. dispose(): void;
  117845. }
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * Single axis scale gizmo
  117850. */
  117851. export class AxisScaleGizmo extends Gizmo {
  117852. /**
  117853. * Drag behavior responsible for the gizmos dragging interactions
  117854. */
  117855. dragBehavior: PointerDragBehavior;
  117856. private _pointerObserver;
  117857. /**
  117858. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117859. */
  117860. snapDistance: number;
  117861. /**
  117862. * Event that fires each time the gizmo snaps to a new location.
  117863. * * snapDistance is the the change in distance
  117864. */
  117865. onSnapObservable: Observable<{
  117866. snapDistance: number;
  117867. }>;
  117868. /**
  117869. * If the scaling operation should be done on all axis (default: false)
  117870. */
  117871. uniformScaling: boolean;
  117872. /**
  117873. * Custom sensitivity value for the drag strength
  117874. */
  117875. sensitivity: number;
  117876. private _isEnabled;
  117877. private _parent;
  117878. private _arrow;
  117879. private _coloredMaterial;
  117880. private _hoverMaterial;
  117881. /**
  117882. * Creates an AxisScaleGizmo
  117883. * @param gizmoLayer The utility layer the gizmo will be added to
  117884. * @param dragAxis The axis which the gizmo will be able to scale on
  117885. * @param color The color of the gizmo
  117886. */
  117887. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  117888. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117889. /**
  117890. * If the gizmo is enabled
  117891. */
  117892. set isEnabled(value: boolean);
  117893. get isEnabled(): boolean;
  117894. /**
  117895. * Disposes of the gizmo
  117896. */
  117897. dispose(): void;
  117898. /**
  117899. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  117900. * @param mesh The mesh to replace the default mesh of the gizmo
  117901. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  117902. */
  117903. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  117904. }
  117905. }
  117906. declare module BABYLON {
  117907. /**
  117908. * Bounding box gizmo
  117909. */
  117910. export class BoundingBoxGizmo extends Gizmo {
  117911. private _lineBoundingBox;
  117912. private _rotateSpheresParent;
  117913. private _scaleBoxesParent;
  117914. private _boundingDimensions;
  117915. private _renderObserver;
  117916. private _pointerObserver;
  117917. private _scaleDragSpeed;
  117918. private _tmpQuaternion;
  117919. private _tmpVector;
  117920. private _tmpRotationMatrix;
  117921. /**
  117922. * 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)
  117923. */
  117924. ignoreChildren: boolean;
  117925. /**
  117926. * 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)
  117927. */
  117928. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  117929. /**
  117930. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  117931. */
  117932. rotationSphereSize: number;
  117933. /**
  117934. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  117935. */
  117936. scaleBoxSize: number;
  117937. /**
  117938. * 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)
  117939. */
  117940. fixedDragMeshScreenSize: boolean;
  117941. /**
  117942. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  117943. */
  117944. fixedDragMeshScreenSizeDistanceFactor: number;
  117945. /**
  117946. * Fired when a rotation sphere or scale box is dragged
  117947. */
  117948. onDragStartObservable: Observable<{}>;
  117949. /**
  117950. * Fired when a scale box is dragged
  117951. */
  117952. onScaleBoxDragObservable: Observable<{}>;
  117953. /**
  117954. * Fired when a scale box drag is ended
  117955. */
  117956. onScaleBoxDragEndObservable: Observable<{}>;
  117957. /**
  117958. * Fired when a rotation sphere is dragged
  117959. */
  117960. onRotationSphereDragObservable: Observable<{}>;
  117961. /**
  117962. * Fired when a rotation sphere drag is ended
  117963. */
  117964. onRotationSphereDragEndObservable: Observable<{}>;
  117965. /**
  117966. * 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)
  117967. */
  117968. scalePivot: Nullable<Vector3>;
  117969. /**
  117970. * Mesh used as a pivot to rotate the attached mesh
  117971. */
  117972. private _anchorMesh;
  117973. private _existingMeshScale;
  117974. private _dragMesh;
  117975. private pointerDragBehavior;
  117976. private coloredMaterial;
  117977. private hoverColoredMaterial;
  117978. /**
  117979. * Sets the color of the bounding box gizmo
  117980. * @param color the color to set
  117981. */
  117982. setColor(color: Color3): void;
  117983. /**
  117984. * Creates an BoundingBoxGizmo
  117985. * @param gizmoLayer The utility layer the gizmo will be added to
  117986. * @param color The color of the gizmo
  117987. */
  117988. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  117989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117990. private _selectNode;
  117991. /**
  117992. * Updates the bounding box information for the Gizmo
  117993. */
  117994. updateBoundingBox(): void;
  117995. private _updateRotationSpheres;
  117996. private _updateScaleBoxes;
  117997. /**
  117998. * Enables rotation on the specified axis and disables rotation on the others
  117999. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118000. */
  118001. setEnabledRotationAxis(axis: string): void;
  118002. /**
  118003. * Enables/disables scaling
  118004. * @param enable if scaling should be enabled
  118005. */
  118006. setEnabledScaling(enable: boolean): void;
  118007. private _updateDummy;
  118008. /**
  118009. * Enables a pointer drag behavior on the bounding box of the gizmo
  118010. */
  118011. enableDragBehavior(): void;
  118012. /**
  118013. * Disposes of the gizmo
  118014. */
  118015. dispose(): void;
  118016. /**
  118017. * 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)
  118018. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118019. * @returns the bounding box mesh with the passed in mesh as a child
  118020. */
  118021. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118022. /**
  118023. * CustomMeshes are not supported by this gizmo
  118024. * @param mesh The mesh to replace the default mesh of the gizmo
  118025. */
  118026. setCustomMesh(mesh: Mesh): void;
  118027. }
  118028. }
  118029. declare module BABYLON {
  118030. /**
  118031. * Single plane rotation gizmo
  118032. */
  118033. export class PlaneRotationGizmo extends Gizmo {
  118034. /**
  118035. * Drag behavior responsible for the gizmos dragging interactions
  118036. */
  118037. dragBehavior: PointerDragBehavior;
  118038. private _pointerObserver;
  118039. /**
  118040. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118041. */
  118042. snapDistance: number;
  118043. /**
  118044. * Event that fires each time the gizmo snaps to a new location.
  118045. * * snapDistance is the the change in distance
  118046. */
  118047. onSnapObservable: Observable<{
  118048. snapDistance: number;
  118049. }>;
  118050. private _isEnabled;
  118051. private _parent;
  118052. /**
  118053. * Creates a PlaneRotationGizmo
  118054. * @param gizmoLayer The utility layer the gizmo will be added to
  118055. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118056. * @param color The color of the gizmo
  118057. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118058. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118059. */
  118060. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118061. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118062. /**
  118063. * If the gizmo is enabled
  118064. */
  118065. set isEnabled(value: boolean);
  118066. get isEnabled(): boolean;
  118067. /**
  118068. * Disposes of the gizmo
  118069. */
  118070. dispose(): void;
  118071. }
  118072. }
  118073. declare module BABYLON {
  118074. /**
  118075. * Gizmo that enables rotating a mesh along 3 axis
  118076. */
  118077. export class RotationGizmo extends Gizmo {
  118078. /**
  118079. * Internal gizmo used for interactions on the x axis
  118080. */
  118081. xGizmo: PlaneRotationGizmo;
  118082. /**
  118083. * Internal gizmo used for interactions on the y axis
  118084. */
  118085. yGizmo: PlaneRotationGizmo;
  118086. /**
  118087. * Internal gizmo used for interactions on the z axis
  118088. */
  118089. zGizmo: PlaneRotationGizmo;
  118090. /** Fires an event when any of it's sub gizmos are dragged */
  118091. onDragStartObservable: Observable<unknown>;
  118092. /** Fires an event when any of it's sub gizmos are released from dragging */
  118093. onDragEndObservable: Observable<unknown>;
  118094. private _meshAttached;
  118095. get attachedMesh(): Nullable<AbstractMesh>;
  118096. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118097. /**
  118098. * Creates a RotationGizmo
  118099. * @param gizmoLayer The utility layer the gizmo will be added to
  118100. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118101. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118102. */
  118103. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118104. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118105. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118106. /**
  118107. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118108. */
  118109. set snapDistance(value: number);
  118110. get snapDistance(): number;
  118111. /**
  118112. * Ratio for the scale of the gizmo (Default: 1)
  118113. */
  118114. set scaleRatio(value: number);
  118115. get scaleRatio(): number;
  118116. /**
  118117. * Disposes of the gizmo
  118118. */
  118119. dispose(): void;
  118120. /**
  118121. * CustomMeshes are not supported by this gizmo
  118122. * @param mesh The mesh to replace the default mesh of the gizmo
  118123. */
  118124. setCustomMesh(mesh: Mesh): void;
  118125. }
  118126. }
  118127. declare module BABYLON {
  118128. /**
  118129. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118130. */
  118131. export class GizmoManager implements IDisposable {
  118132. private scene;
  118133. /**
  118134. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118135. */
  118136. gizmos: {
  118137. positionGizmo: Nullable<PositionGizmo>;
  118138. rotationGizmo: Nullable<RotationGizmo>;
  118139. scaleGizmo: Nullable<ScaleGizmo>;
  118140. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118141. };
  118142. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118143. clearGizmoOnEmptyPointerEvent: boolean;
  118144. /** Fires an event when the manager is attached to a mesh */
  118145. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118146. private _gizmosEnabled;
  118147. private _pointerObserver;
  118148. private _attachedMesh;
  118149. private _boundingBoxColor;
  118150. private _defaultUtilityLayer;
  118151. private _defaultKeepDepthUtilityLayer;
  118152. /**
  118153. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118154. */
  118155. boundingBoxDragBehavior: SixDofDragBehavior;
  118156. /**
  118157. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118158. */
  118159. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118160. /**
  118161. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118162. */
  118163. usePointerToAttachGizmos: boolean;
  118164. /**
  118165. * Utility layer that the bounding box gizmo belongs to
  118166. */
  118167. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118168. /**
  118169. * Utility layer that all gizmos besides bounding box belong to
  118170. */
  118171. get utilityLayer(): UtilityLayerRenderer;
  118172. /**
  118173. * Instatiates a gizmo manager
  118174. * @param scene the scene to overlay the gizmos on top of
  118175. */
  118176. constructor(scene: Scene);
  118177. /**
  118178. * Attaches a set of gizmos to the specified mesh
  118179. * @param mesh The mesh the gizmo's should be attached to
  118180. */
  118181. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118182. /**
  118183. * If the position gizmo is enabled
  118184. */
  118185. set positionGizmoEnabled(value: boolean);
  118186. get positionGizmoEnabled(): boolean;
  118187. /**
  118188. * If the rotation gizmo is enabled
  118189. */
  118190. set rotationGizmoEnabled(value: boolean);
  118191. get rotationGizmoEnabled(): boolean;
  118192. /**
  118193. * If the scale gizmo is enabled
  118194. */
  118195. set scaleGizmoEnabled(value: boolean);
  118196. get scaleGizmoEnabled(): boolean;
  118197. /**
  118198. * If the boundingBox gizmo is enabled
  118199. */
  118200. set boundingBoxGizmoEnabled(value: boolean);
  118201. get boundingBoxGizmoEnabled(): boolean;
  118202. /**
  118203. * Disposes of the gizmo manager
  118204. */
  118205. dispose(): void;
  118206. }
  118207. }
  118208. declare module BABYLON {
  118209. /**
  118210. * A directional light is defined by a direction (what a surprise!).
  118211. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118212. * 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.
  118213. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118214. */
  118215. export class DirectionalLight extends ShadowLight {
  118216. private _shadowFrustumSize;
  118217. /**
  118218. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118219. */
  118220. get shadowFrustumSize(): number;
  118221. /**
  118222. * Specifies a fix frustum size for the shadow generation.
  118223. */
  118224. set shadowFrustumSize(value: number);
  118225. private _shadowOrthoScale;
  118226. /**
  118227. * Gets the shadow projection scale against the optimal computed one.
  118228. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118229. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118230. */
  118231. get shadowOrthoScale(): number;
  118232. /**
  118233. * Sets the shadow projection scale against the optimal computed one.
  118234. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118235. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118236. */
  118237. set shadowOrthoScale(value: number);
  118238. /**
  118239. * Automatically compute the projection matrix to best fit (including all the casters)
  118240. * on each frame.
  118241. */
  118242. autoUpdateExtends: boolean;
  118243. private _orthoLeft;
  118244. private _orthoRight;
  118245. private _orthoTop;
  118246. private _orthoBottom;
  118247. /**
  118248. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118249. * The directional light is emitted from everywhere in the given direction.
  118250. * It can cast shadows.
  118251. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118252. * @param name The friendly name of the light
  118253. * @param direction The direction of the light
  118254. * @param scene The scene the light belongs to
  118255. */
  118256. constructor(name: string, direction: Vector3, scene: Scene);
  118257. /**
  118258. * Returns the string "DirectionalLight".
  118259. * @return The class name
  118260. */
  118261. getClassName(): string;
  118262. /**
  118263. * Returns the integer 1.
  118264. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118265. */
  118266. getTypeID(): number;
  118267. /**
  118268. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118269. * Returns the DirectionalLight Shadow projection matrix.
  118270. */
  118271. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118272. /**
  118273. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118274. * Returns the DirectionalLight Shadow projection matrix.
  118275. */
  118276. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118277. /**
  118278. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118279. * Returns the DirectionalLight Shadow projection matrix.
  118280. */
  118281. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118282. protected _buildUniformLayout(): void;
  118283. /**
  118284. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118285. * @param effect The effect to update
  118286. * @param lightIndex The index of the light in the effect to update
  118287. * @returns The directional light
  118288. */
  118289. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118290. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118291. /**
  118292. * Gets the minZ used for shadow according to both the scene and the light.
  118293. *
  118294. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118295. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118296. * @param activeCamera The camera we are returning the min for
  118297. * @returns the depth min z
  118298. */
  118299. getDepthMinZ(activeCamera: Camera): number;
  118300. /**
  118301. * Gets the maxZ used for shadow according to both the scene and the light.
  118302. *
  118303. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118304. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118305. * @param activeCamera The camera we are returning the max for
  118306. * @returns the depth max z
  118307. */
  118308. getDepthMaxZ(activeCamera: Camera): number;
  118309. /**
  118310. * Prepares the list of defines specific to the light type.
  118311. * @param defines the list of defines
  118312. * @param lightIndex defines the index of the light for the effect
  118313. */
  118314. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118315. }
  118316. }
  118317. declare module BABYLON {
  118318. /**
  118319. * Class containing static functions to help procedurally build meshes
  118320. */
  118321. export class HemisphereBuilder {
  118322. /**
  118323. * Creates a hemisphere mesh
  118324. * @param name defines the name of the mesh
  118325. * @param options defines the options used to create the mesh
  118326. * @param scene defines the hosting scene
  118327. * @returns the hemisphere mesh
  118328. */
  118329. static CreateHemisphere(name: string, options: {
  118330. segments?: number;
  118331. diameter?: number;
  118332. sideOrientation?: number;
  118333. }, scene: any): Mesh;
  118334. }
  118335. }
  118336. declare module BABYLON {
  118337. /**
  118338. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118339. * These values define a cone of light starting from the position, emitting toward the direction.
  118340. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118341. * and the exponent defines the speed of the decay of the light with distance (reach).
  118342. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118343. */
  118344. export class SpotLight extends ShadowLight {
  118345. private _angle;
  118346. private _innerAngle;
  118347. private _cosHalfAngle;
  118348. private _lightAngleScale;
  118349. private _lightAngleOffset;
  118350. /**
  118351. * Gets the cone angle of the spot light in Radians.
  118352. */
  118353. get angle(): number;
  118354. /**
  118355. * Sets the cone angle of the spot light in Radians.
  118356. */
  118357. set angle(value: number);
  118358. /**
  118359. * Only used in gltf falloff mode, this defines the angle where
  118360. * the directional falloff will start before cutting at angle which could be seen
  118361. * as outer angle.
  118362. */
  118363. get innerAngle(): number;
  118364. /**
  118365. * Only used in gltf falloff mode, this defines the angle where
  118366. * the directional falloff will start before cutting at angle which could be seen
  118367. * as outer angle.
  118368. */
  118369. set innerAngle(value: number);
  118370. private _shadowAngleScale;
  118371. /**
  118372. * Allows scaling the angle of the light for shadow generation only.
  118373. */
  118374. get shadowAngleScale(): number;
  118375. /**
  118376. * Allows scaling the angle of the light for shadow generation only.
  118377. */
  118378. set shadowAngleScale(value: number);
  118379. /**
  118380. * The light decay speed with the distance from the emission spot.
  118381. */
  118382. exponent: number;
  118383. private _projectionTextureMatrix;
  118384. /**
  118385. * Allows reading the projecton texture
  118386. */
  118387. get projectionTextureMatrix(): Matrix;
  118388. protected _projectionTextureLightNear: number;
  118389. /**
  118390. * Gets the near clip of the Spotlight for texture projection.
  118391. */
  118392. get projectionTextureLightNear(): number;
  118393. /**
  118394. * Sets the near clip of the Spotlight for texture projection.
  118395. */
  118396. set projectionTextureLightNear(value: number);
  118397. protected _projectionTextureLightFar: number;
  118398. /**
  118399. * Gets the far clip of the Spotlight for texture projection.
  118400. */
  118401. get projectionTextureLightFar(): number;
  118402. /**
  118403. * Sets the far clip of the Spotlight for texture projection.
  118404. */
  118405. set projectionTextureLightFar(value: number);
  118406. protected _projectionTextureUpDirection: Vector3;
  118407. /**
  118408. * Gets the Up vector of the Spotlight for texture projection.
  118409. */
  118410. get projectionTextureUpDirection(): Vector3;
  118411. /**
  118412. * Sets the Up vector of the Spotlight for texture projection.
  118413. */
  118414. set projectionTextureUpDirection(value: Vector3);
  118415. private _projectionTexture;
  118416. /**
  118417. * Gets the projection texture of the light.
  118418. */
  118419. get projectionTexture(): Nullable<BaseTexture>;
  118420. /**
  118421. * Sets the projection texture of the light.
  118422. */
  118423. set projectionTexture(value: Nullable<BaseTexture>);
  118424. private _projectionTextureViewLightDirty;
  118425. private _projectionTextureProjectionLightDirty;
  118426. private _projectionTextureDirty;
  118427. private _projectionTextureViewTargetVector;
  118428. private _projectionTextureViewLightMatrix;
  118429. private _projectionTextureProjectionLightMatrix;
  118430. private _projectionTextureScalingMatrix;
  118431. /**
  118432. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118433. * It can cast shadows.
  118434. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118435. * @param name The light friendly name
  118436. * @param position The position of the spot light in the scene
  118437. * @param direction The direction of the light in the scene
  118438. * @param angle The cone angle of the light in Radians
  118439. * @param exponent The light decay speed with the distance from the emission spot
  118440. * @param scene The scene the lights belongs to
  118441. */
  118442. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118443. /**
  118444. * Returns the string "SpotLight".
  118445. * @returns the class name
  118446. */
  118447. getClassName(): string;
  118448. /**
  118449. * Returns the integer 2.
  118450. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118451. */
  118452. getTypeID(): number;
  118453. /**
  118454. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118455. */
  118456. protected _setDirection(value: Vector3): void;
  118457. /**
  118458. * Overrides the position setter to recompute the projection texture view light Matrix.
  118459. */
  118460. protected _setPosition(value: Vector3): void;
  118461. /**
  118462. * 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.
  118463. * Returns the SpotLight.
  118464. */
  118465. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118466. protected _computeProjectionTextureViewLightMatrix(): void;
  118467. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118468. /**
  118469. * Main function for light texture projection matrix computing.
  118470. */
  118471. protected _computeProjectionTextureMatrix(): void;
  118472. protected _buildUniformLayout(): void;
  118473. private _computeAngleValues;
  118474. /**
  118475. * Sets the passed Effect "effect" with the Light textures.
  118476. * @param effect The effect to update
  118477. * @param lightIndex The index of the light in the effect to update
  118478. * @returns The light
  118479. */
  118480. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118481. /**
  118482. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118483. * @param effect The effect to update
  118484. * @param lightIndex The index of the light in the effect to update
  118485. * @returns The spot light
  118486. */
  118487. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118488. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118489. /**
  118490. * Disposes the light and the associated resources.
  118491. */
  118492. dispose(): void;
  118493. /**
  118494. * Prepares the list of defines specific to the light type.
  118495. * @param defines the list of defines
  118496. * @param lightIndex defines the index of the light for the effect
  118497. */
  118498. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118499. }
  118500. }
  118501. declare module BABYLON {
  118502. /**
  118503. * Gizmo that enables viewing a light
  118504. */
  118505. export class LightGizmo extends Gizmo {
  118506. private _lightMesh;
  118507. private _material;
  118508. private _cachedPosition;
  118509. private _cachedForward;
  118510. private _attachedMeshParent;
  118511. /**
  118512. * Creates a LightGizmo
  118513. * @param gizmoLayer The utility layer the gizmo will be added to
  118514. */
  118515. constructor(gizmoLayer?: UtilityLayerRenderer);
  118516. private _light;
  118517. /**
  118518. * The light that the gizmo is attached to
  118519. */
  118520. set light(light: Nullable<Light>);
  118521. get light(): Nullable<Light>;
  118522. /**
  118523. * Gets the material used to render the light gizmo
  118524. */
  118525. get material(): StandardMaterial;
  118526. /**
  118527. * @hidden
  118528. * Updates the gizmo to match the attached mesh's position/rotation
  118529. */
  118530. protected _update(): void;
  118531. private static _Scale;
  118532. /**
  118533. * Creates the lines for a light mesh
  118534. */
  118535. private static _CreateLightLines;
  118536. /**
  118537. * Disposes of the light gizmo
  118538. */
  118539. dispose(): void;
  118540. private static _CreateHemisphericLightMesh;
  118541. private static _CreatePointLightMesh;
  118542. private static _CreateSpotLightMesh;
  118543. private static _CreateDirectionalLightMesh;
  118544. }
  118545. }
  118546. declare module BABYLON {
  118547. /** @hidden */
  118548. export var backgroundFragmentDeclaration: {
  118549. name: string;
  118550. shader: string;
  118551. };
  118552. }
  118553. declare module BABYLON {
  118554. /** @hidden */
  118555. export var backgroundUboDeclaration: {
  118556. name: string;
  118557. shader: string;
  118558. };
  118559. }
  118560. declare module BABYLON {
  118561. /** @hidden */
  118562. export var backgroundPixelShader: {
  118563. name: string;
  118564. shader: string;
  118565. };
  118566. }
  118567. declare module BABYLON {
  118568. /** @hidden */
  118569. export var backgroundVertexDeclaration: {
  118570. name: string;
  118571. shader: string;
  118572. };
  118573. }
  118574. declare module BABYLON {
  118575. /** @hidden */
  118576. export var backgroundVertexShader: {
  118577. name: string;
  118578. shader: string;
  118579. };
  118580. }
  118581. declare module BABYLON {
  118582. /**
  118583. * Background material used to create an efficient environement around your scene.
  118584. */
  118585. export class BackgroundMaterial extends PushMaterial {
  118586. /**
  118587. * Standard reflectance value at parallel view angle.
  118588. */
  118589. static StandardReflectance0: number;
  118590. /**
  118591. * Standard reflectance value at grazing angle.
  118592. */
  118593. static StandardReflectance90: number;
  118594. protected _primaryColor: Color3;
  118595. /**
  118596. * Key light Color (multiply against the environement texture)
  118597. */
  118598. primaryColor: Color3;
  118599. protected __perceptualColor: Nullable<Color3>;
  118600. /**
  118601. * Experimental Internal Use Only.
  118602. *
  118603. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118604. * This acts as a helper to set the primary color to a more "human friendly" value.
  118605. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118606. * output color as close as possible from the chosen value.
  118607. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118608. * part of lighting setup.)
  118609. */
  118610. get _perceptualColor(): Nullable<Color3>;
  118611. set _perceptualColor(value: Nullable<Color3>);
  118612. protected _primaryColorShadowLevel: float;
  118613. /**
  118614. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118615. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118616. */
  118617. get primaryColorShadowLevel(): float;
  118618. set primaryColorShadowLevel(value: float);
  118619. protected _primaryColorHighlightLevel: float;
  118620. /**
  118621. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118622. * The primary color is used at the level chosen to define what the white area would look.
  118623. */
  118624. get primaryColorHighlightLevel(): float;
  118625. set primaryColorHighlightLevel(value: float);
  118626. protected _reflectionTexture: Nullable<BaseTexture>;
  118627. /**
  118628. * Reflection Texture used in the material.
  118629. * Should be author in a specific way for the best result (refer to the documentation).
  118630. */
  118631. reflectionTexture: Nullable<BaseTexture>;
  118632. protected _reflectionBlur: float;
  118633. /**
  118634. * Reflection Texture level of blur.
  118635. *
  118636. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118637. * texture twice.
  118638. */
  118639. reflectionBlur: float;
  118640. protected _diffuseTexture: Nullable<BaseTexture>;
  118641. /**
  118642. * Diffuse Texture used in the material.
  118643. * Should be author in a specific way for the best result (refer to the documentation).
  118644. */
  118645. diffuseTexture: Nullable<BaseTexture>;
  118646. protected _shadowLights: Nullable<IShadowLight[]>;
  118647. /**
  118648. * Specify the list of lights casting shadow on the material.
  118649. * All scene shadow lights will be included if null.
  118650. */
  118651. shadowLights: Nullable<IShadowLight[]>;
  118652. protected _shadowLevel: float;
  118653. /**
  118654. * Helps adjusting the shadow to a softer level if required.
  118655. * 0 means black shadows and 1 means no shadows.
  118656. */
  118657. shadowLevel: float;
  118658. protected _sceneCenter: Vector3;
  118659. /**
  118660. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118661. * It is usually zero but might be interesting to modify according to your setup.
  118662. */
  118663. sceneCenter: Vector3;
  118664. protected _opacityFresnel: boolean;
  118665. /**
  118666. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118667. * This helps ensuring a nice transition when the camera goes under the ground.
  118668. */
  118669. opacityFresnel: boolean;
  118670. protected _reflectionFresnel: boolean;
  118671. /**
  118672. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118673. * This helps adding a mirror texture on the ground.
  118674. */
  118675. reflectionFresnel: boolean;
  118676. protected _reflectionFalloffDistance: number;
  118677. /**
  118678. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118679. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118680. */
  118681. reflectionFalloffDistance: number;
  118682. protected _reflectionAmount: number;
  118683. /**
  118684. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118685. */
  118686. reflectionAmount: number;
  118687. protected _reflectionReflectance0: number;
  118688. /**
  118689. * This specifies the weight of the reflection at grazing angle.
  118690. */
  118691. reflectionReflectance0: number;
  118692. protected _reflectionReflectance90: number;
  118693. /**
  118694. * This specifies the weight of the reflection at a perpendicular point of view.
  118695. */
  118696. reflectionReflectance90: number;
  118697. /**
  118698. * Sets the reflection reflectance fresnel values according to the default standard
  118699. * empirically know to work well :-)
  118700. */
  118701. set reflectionStandardFresnelWeight(value: number);
  118702. protected _useRGBColor: boolean;
  118703. /**
  118704. * Helps to directly use the maps channels instead of their level.
  118705. */
  118706. useRGBColor: boolean;
  118707. protected _enableNoise: boolean;
  118708. /**
  118709. * This helps reducing the banding effect that could occur on the background.
  118710. */
  118711. enableNoise: boolean;
  118712. /**
  118713. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118714. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118715. * Recommended to be keep at 1.0 except for special cases.
  118716. */
  118717. get fovMultiplier(): number;
  118718. set fovMultiplier(value: number);
  118719. private _fovMultiplier;
  118720. /**
  118721. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118722. */
  118723. useEquirectangularFOV: boolean;
  118724. private _maxSimultaneousLights;
  118725. /**
  118726. * Number of Simultaneous lights allowed on the material.
  118727. */
  118728. maxSimultaneousLights: int;
  118729. /**
  118730. * Default configuration related to image processing available in the Background Material.
  118731. */
  118732. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118733. /**
  118734. * Keep track of the image processing observer to allow dispose and replace.
  118735. */
  118736. private _imageProcessingObserver;
  118737. /**
  118738. * Attaches a new image processing configuration to the PBR Material.
  118739. * @param configuration (if null the scene configuration will be use)
  118740. */
  118741. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118742. /**
  118743. * Gets the image processing configuration used either in this material.
  118744. */
  118745. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118746. /**
  118747. * Sets the Default image processing configuration used either in the this material.
  118748. *
  118749. * If sets to null, the scene one is in use.
  118750. */
  118751. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118752. /**
  118753. * Gets wether the color curves effect is enabled.
  118754. */
  118755. get cameraColorCurvesEnabled(): boolean;
  118756. /**
  118757. * Sets wether the color curves effect is enabled.
  118758. */
  118759. set cameraColorCurvesEnabled(value: boolean);
  118760. /**
  118761. * Gets wether the color grading effect is enabled.
  118762. */
  118763. get cameraColorGradingEnabled(): boolean;
  118764. /**
  118765. * Gets wether the color grading effect is enabled.
  118766. */
  118767. set cameraColorGradingEnabled(value: boolean);
  118768. /**
  118769. * Gets wether tonemapping is enabled or not.
  118770. */
  118771. get cameraToneMappingEnabled(): boolean;
  118772. /**
  118773. * Sets wether tonemapping is enabled or not
  118774. */
  118775. set cameraToneMappingEnabled(value: boolean);
  118776. /**
  118777. * The camera exposure used on this material.
  118778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118779. * This corresponds to a photographic exposure.
  118780. */
  118781. get cameraExposure(): float;
  118782. /**
  118783. * The camera exposure used on this material.
  118784. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118785. * This corresponds to a photographic exposure.
  118786. */
  118787. set cameraExposure(value: float);
  118788. /**
  118789. * Gets The camera contrast used on this material.
  118790. */
  118791. get cameraContrast(): float;
  118792. /**
  118793. * Sets The camera contrast used on this material.
  118794. */
  118795. set cameraContrast(value: float);
  118796. /**
  118797. * Gets the Color Grading 2D Lookup Texture.
  118798. */
  118799. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118800. /**
  118801. * Sets the Color Grading 2D Lookup Texture.
  118802. */
  118803. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118804. /**
  118805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118807. * 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;
  118808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118809. */
  118810. get cameraColorCurves(): Nullable<ColorCurves>;
  118811. /**
  118812. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118813. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118814. * 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;
  118815. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118816. */
  118817. set cameraColorCurves(value: Nullable<ColorCurves>);
  118818. /**
  118819. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118820. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118821. */
  118822. switchToBGR: boolean;
  118823. private _renderTargets;
  118824. private _reflectionControls;
  118825. private _white;
  118826. private _primaryShadowColor;
  118827. private _primaryHighlightColor;
  118828. /**
  118829. * Instantiates a Background Material in the given scene
  118830. * @param name The friendly name of the material
  118831. * @param scene The scene to add the material to
  118832. */
  118833. constructor(name: string, scene: Scene);
  118834. /**
  118835. * Gets a boolean indicating that current material needs to register RTT
  118836. */
  118837. get hasRenderTargetTextures(): boolean;
  118838. /**
  118839. * The entire material has been created in order to prevent overdraw.
  118840. * @returns false
  118841. */
  118842. needAlphaTesting(): boolean;
  118843. /**
  118844. * The entire material has been created in order to prevent overdraw.
  118845. * @returns true if blending is enable
  118846. */
  118847. needAlphaBlending(): boolean;
  118848. /**
  118849. * Checks wether the material is ready to be rendered for a given mesh.
  118850. * @param mesh The mesh to render
  118851. * @param subMesh The submesh to check against
  118852. * @param useInstances Specify wether or not the material is used with instances
  118853. * @returns true if all the dependencies are ready (Textures, Effects...)
  118854. */
  118855. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118856. /**
  118857. * Compute the primary color according to the chosen perceptual color.
  118858. */
  118859. private _computePrimaryColorFromPerceptualColor;
  118860. /**
  118861. * Compute the highlights and shadow colors according to their chosen levels.
  118862. */
  118863. private _computePrimaryColors;
  118864. /**
  118865. * Build the uniform buffer used in the material.
  118866. */
  118867. buildUniformLayout(): void;
  118868. /**
  118869. * Unbind the material.
  118870. */
  118871. unbind(): void;
  118872. /**
  118873. * Bind only the world matrix to the material.
  118874. * @param world The world matrix to bind.
  118875. */
  118876. bindOnlyWorldMatrix(world: Matrix): void;
  118877. /**
  118878. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  118879. * @param world The world matrix to bind.
  118880. * @param subMesh The submesh to bind for.
  118881. */
  118882. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118883. /**
  118884. * Checks to see if a texture is used in the material.
  118885. * @param texture - Base texture to use.
  118886. * @returns - Boolean specifying if a texture is used in the material.
  118887. */
  118888. hasTexture(texture: BaseTexture): boolean;
  118889. /**
  118890. * Dispose the material.
  118891. * @param forceDisposeEffect Force disposal of the associated effect.
  118892. * @param forceDisposeTextures Force disposal of the associated textures.
  118893. */
  118894. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118895. /**
  118896. * Clones the material.
  118897. * @param name The cloned name.
  118898. * @returns The cloned material.
  118899. */
  118900. clone(name: string): BackgroundMaterial;
  118901. /**
  118902. * Serializes the current material to its JSON representation.
  118903. * @returns The JSON representation.
  118904. */
  118905. serialize(): any;
  118906. /**
  118907. * Gets the class name of the material
  118908. * @returns "BackgroundMaterial"
  118909. */
  118910. getClassName(): string;
  118911. /**
  118912. * Parse a JSON input to create back a background material.
  118913. * @param source The JSON data to parse
  118914. * @param scene The scene to create the parsed material in
  118915. * @param rootUrl The root url of the assets the material depends upon
  118916. * @returns the instantiated BackgroundMaterial.
  118917. */
  118918. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  118919. }
  118920. }
  118921. declare module BABYLON {
  118922. /**
  118923. * Represents the different options available during the creation of
  118924. * a Environment helper.
  118925. *
  118926. * This can control the default ground, skybox and image processing setup of your scene.
  118927. */
  118928. export interface IEnvironmentHelperOptions {
  118929. /**
  118930. * Specifies wether or not to create a ground.
  118931. * True by default.
  118932. */
  118933. createGround: boolean;
  118934. /**
  118935. * Specifies the ground size.
  118936. * 15 by default.
  118937. */
  118938. groundSize: number;
  118939. /**
  118940. * The texture used on the ground for the main color.
  118941. * Comes from the BabylonJS CDN by default.
  118942. *
  118943. * Remarks: Can be either a texture or a url.
  118944. */
  118945. groundTexture: string | BaseTexture;
  118946. /**
  118947. * The color mixed in the ground texture by default.
  118948. * BabylonJS clearColor by default.
  118949. */
  118950. groundColor: Color3;
  118951. /**
  118952. * Specifies the ground opacity.
  118953. * 1 by default.
  118954. */
  118955. groundOpacity: number;
  118956. /**
  118957. * Enables the ground to receive shadows.
  118958. * True by default.
  118959. */
  118960. enableGroundShadow: boolean;
  118961. /**
  118962. * Helps preventing the shadow to be fully black on the ground.
  118963. * 0.5 by default.
  118964. */
  118965. groundShadowLevel: number;
  118966. /**
  118967. * Creates a mirror texture attach to the ground.
  118968. * false by default.
  118969. */
  118970. enableGroundMirror: boolean;
  118971. /**
  118972. * Specifies the ground mirror size ratio.
  118973. * 0.3 by default as the default kernel is 64.
  118974. */
  118975. groundMirrorSizeRatio: number;
  118976. /**
  118977. * Specifies the ground mirror blur kernel size.
  118978. * 64 by default.
  118979. */
  118980. groundMirrorBlurKernel: number;
  118981. /**
  118982. * Specifies the ground mirror visibility amount.
  118983. * 1 by default
  118984. */
  118985. groundMirrorAmount: number;
  118986. /**
  118987. * Specifies the ground mirror reflectance weight.
  118988. * This uses the standard weight of the background material to setup the fresnel effect
  118989. * of the mirror.
  118990. * 1 by default.
  118991. */
  118992. groundMirrorFresnelWeight: number;
  118993. /**
  118994. * Specifies the ground mirror Falloff distance.
  118995. * This can helps reducing the size of the reflection.
  118996. * 0 by Default.
  118997. */
  118998. groundMirrorFallOffDistance: number;
  118999. /**
  119000. * Specifies the ground mirror texture type.
  119001. * Unsigned Int by Default.
  119002. */
  119003. groundMirrorTextureType: number;
  119004. /**
  119005. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119006. * the shown objects.
  119007. */
  119008. groundYBias: number;
  119009. /**
  119010. * Specifies wether or not to create a skybox.
  119011. * True by default.
  119012. */
  119013. createSkybox: boolean;
  119014. /**
  119015. * Specifies the skybox size.
  119016. * 20 by default.
  119017. */
  119018. skyboxSize: number;
  119019. /**
  119020. * The texture used on the skybox for the main color.
  119021. * Comes from the BabylonJS CDN by default.
  119022. *
  119023. * Remarks: Can be either a texture or a url.
  119024. */
  119025. skyboxTexture: string | BaseTexture;
  119026. /**
  119027. * The color mixed in the skybox texture by default.
  119028. * BabylonJS clearColor by default.
  119029. */
  119030. skyboxColor: Color3;
  119031. /**
  119032. * The background rotation around the Y axis of the scene.
  119033. * This helps aligning the key lights of your scene with the background.
  119034. * 0 by default.
  119035. */
  119036. backgroundYRotation: number;
  119037. /**
  119038. * Compute automatically the size of the elements to best fit with the scene.
  119039. */
  119040. sizeAuto: boolean;
  119041. /**
  119042. * Default position of the rootMesh if autoSize is not true.
  119043. */
  119044. rootPosition: Vector3;
  119045. /**
  119046. * Sets up the image processing in the scene.
  119047. * true by default.
  119048. */
  119049. setupImageProcessing: boolean;
  119050. /**
  119051. * The texture used as your environment texture in the scene.
  119052. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119053. *
  119054. * Remarks: Can be either a texture or a url.
  119055. */
  119056. environmentTexture: string | BaseTexture;
  119057. /**
  119058. * The value of the exposure to apply to the scene.
  119059. * 0.6 by default if setupImageProcessing is true.
  119060. */
  119061. cameraExposure: number;
  119062. /**
  119063. * The value of the contrast to apply to the scene.
  119064. * 1.6 by default if setupImageProcessing is true.
  119065. */
  119066. cameraContrast: number;
  119067. /**
  119068. * Specifies wether or not tonemapping should be enabled in the scene.
  119069. * true by default if setupImageProcessing is true.
  119070. */
  119071. toneMappingEnabled: boolean;
  119072. }
  119073. /**
  119074. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119075. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119076. * It also helps with the default setup of your imageProcessing configuration.
  119077. */
  119078. export class EnvironmentHelper {
  119079. /**
  119080. * Default ground texture URL.
  119081. */
  119082. private static _groundTextureCDNUrl;
  119083. /**
  119084. * Default skybox texture URL.
  119085. */
  119086. private static _skyboxTextureCDNUrl;
  119087. /**
  119088. * Default environment texture URL.
  119089. */
  119090. private static _environmentTextureCDNUrl;
  119091. /**
  119092. * Creates the default options for the helper.
  119093. */
  119094. private static _getDefaultOptions;
  119095. private _rootMesh;
  119096. /**
  119097. * Gets the root mesh created by the helper.
  119098. */
  119099. get rootMesh(): Mesh;
  119100. private _skybox;
  119101. /**
  119102. * Gets the skybox created by the helper.
  119103. */
  119104. get skybox(): Nullable<Mesh>;
  119105. private _skyboxTexture;
  119106. /**
  119107. * Gets the skybox texture created by the helper.
  119108. */
  119109. get skyboxTexture(): Nullable<BaseTexture>;
  119110. private _skyboxMaterial;
  119111. /**
  119112. * Gets the skybox material created by the helper.
  119113. */
  119114. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119115. private _ground;
  119116. /**
  119117. * Gets the ground mesh created by the helper.
  119118. */
  119119. get ground(): Nullable<Mesh>;
  119120. private _groundTexture;
  119121. /**
  119122. * Gets the ground texture created by the helper.
  119123. */
  119124. get groundTexture(): Nullable<BaseTexture>;
  119125. private _groundMirror;
  119126. /**
  119127. * Gets the ground mirror created by the helper.
  119128. */
  119129. get groundMirror(): Nullable<MirrorTexture>;
  119130. /**
  119131. * Gets the ground mirror render list to helps pushing the meshes
  119132. * you wish in the ground reflection.
  119133. */
  119134. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119135. private _groundMaterial;
  119136. /**
  119137. * Gets the ground material created by the helper.
  119138. */
  119139. get groundMaterial(): Nullable<BackgroundMaterial>;
  119140. /**
  119141. * Stores the creation options.
  119142. */
  119143. private readonly _scene;
  119144. private _options;
  119145. /**
  119146. * This observable will be notified with any error during the creation of the environment,
  119147. * mainly texture creation errors.
  119148. */
  119149. onErrorObservable: Observable<{
  119150. message?: string;
  119151. exception?: any;
  119152. }>;
  119153. /**
  119154. * constructor
  119155. * @param options Defines the options we want to customize the helper
  119156. * @param scene The scene to add the material to
  119157. */
  119158. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119159. /**
  119160. * Updates the background according to the new options
  119161. * @param options
  119162. */
  119163. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119164. /**
  119165. * Sets the primary color of all the available elements.
  119166. * @param color the main color to affect to the ground and the background
  119167. */
  119168. setMainColor(color: Color3): void;
  119169. /**
  119170. * Setup the image processing according to the specified options.
  119171. */
  119172. private _setupImageProcessing;
  119173. /**
  119174. * Setup the environment texture according to the specified options.
  119175. */
  119176. private _setupEnvironmentTexture;
  119177. /**
  119178. * Setup the background according to the specified options.
  119179. */
  119180. private _setupBackground;
  119181. /**
  119182. * Get the scene sizes according to the setup.
  119183. */
  119184. private _getSceneSize;
  119185. /**
  119186. * Setup the ground according to the specified options.
  119187. */
  119188. private _setupGround;
  119189. /**
  119190. * Setup the ground material according to the specified options.
  119191. */
  119192. private _setupGroundMaterial;
  119193. /**
  119194. * Setup the ground diffuse texture according to the specified options.
  119195. */
  119196. private _setupGroundDiffuseTexture;
  119197. /**
  119198. * Setup the ground mirror texture according to the specified options.
  119199. */
  119200. private _setupGroundMirrorTexture;
  119201. /**
  119202. * Setup the ground to receive the mirror texture.
  119203. */
  119204. private _setupMirrorInGroundMaterial;
  119205. /**
  119206. * Setup the skybox according to the specified options.
  119207. */
  119208. private _setupSkybox;
  119209. /**
  119210. * Setup the skybox material according to the specified options.
  119211. */
  119212. private _setupSkyboxMaterial;
  119213. /**
  119214. * Setup the skybox reflection texture according to the specified options.
  119215. */
  119216. private _setupSkyboxReflectionTexture;
  119217. private _errorHandler;
  119218. /**
  119219. * Dispose all the elements created by the Helper.
  119220. */
  119221. dispose(): void;
  119222. }
  119223. }
  119224. declare module BABYLON {
  119225. /**
  119226. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119227. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119228. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119229. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119230. */
  119231. export class PhotoDome extends TransformNode {
  119232. /**
  119233. * Define the image as a Monoscopic panoramic 360 image.
  119234. */
  119235. static readonly MODE_MONOSCOPIC: number;
  119236. /**
  119237. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119238. */
  119239. static readonly MODE_TOPBOTTOM: number;
  119240. /**
  119241. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119242. */
  119243. static readonly MODE_SIDEBYSIDE: number;
  119244. private _useDirectMapping;
  119245. /**
  119246. * The texture being displayed on the sphere
  119247. */
  119248. protected _photoTexture: Texture;
  119249. /**
  119250. * Gets or sets the texture being displayed on the sphere
  119251. */
  119252. get photoTexture(): Texture;
  119253. set photoTexture(value: Texture);
  119254. /**
  119255. * Observable raised when an error occured while loading the 360 image
  119256. */
  119257. onLoadErrorObservable: Observable<string>;
  119258. /**
  119259. * The skybox material
  119260. */
  119261. protected _material: BackgroundMaterial;
  119262. /**
  119263. * The surface used for the skybox
  119264. */
  119265. protected _mesh: Mesh;
  119266. /**
  119267. * Gets the mesh used for the skybox.
  119268. */
  119269. get mesh(): Mesh;
  119270. /**
  119271. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119272. * Also see the options.resolution property.
  119273. */
  119274. get fovMultiplier(): number;
  119275. set fovMultiplier(value: number);
  119276. private _imageMode;
  119277. /**
  119278. * Gets or set the current video mode for the video. It can be:
  119279. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119280. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119281. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119282. */
  119283. get imageMode(): number;
  119284. set imageMode(value: number);
  119285. /**
  119286. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119287. * @param name Element's name, child elements will append suffixes for their own names.
  119288. * @param urlsOfPhoto defines the url of the photo to display
  119289. * @param options defines an object containing optional or exposed sub element properties
  119290. * @param onError defines a callback called when an error occured while loading the texture
  119291. */
  119292. constructor(name: string, urlOfPhoto: string, options: {
  119293. resolution?: number;
  119294. size?: number;
  119295. useDirectMapping?: boolean;
  119296. faceForward?: boolean;
  119297. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119298. private _onBeforeCameraRenderObserver;
  119299. private _changeImageMode;
  119300. /**
  119301. * Releases resources associated with this node.
  119302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119304. */
  119305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /**
  119310. * Class used to host RGBD texture specific utilities
  119311. */
  119312. export class RGBDTextureTools {
  119313. /**
  119314. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119315. * @param texture the texture to expand.
  119316. */
  119317. static ExpandRGBDTexture(texture: Texture): void;
  119318. }
  119319. }
  119320. declare module BABYLON {
  119321. /**
  119322. * Class used to host texture specific utilities
  119323. */
  119324. export class BRDFTextureTools {
  119325. /**
  119326. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119327. * @param scene defines the hosting scene
  119328. * @returns the environment BRDF texture
  119329. */
  119330. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119331. private static _environmentBRDFBase64Texture;
  119332. }
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * @hidden
  119337. */
  119338. export interface IMaterialClearCoatDefines {
  119339. CLEARCOAT: boolean;
  119340. CLEARCOAT_DEFAULTIOR: boolean;
  119341. CLEARCOAT_TEXTURE: boolean;
  119342. CLEARCOAT_TEXTUREDIRECTUV: number;
  119343. CLEARCOAT_BUMP: boolean;
  119344. CLEARCOAT_BUMPDIRECTUV: number;
  119345. CLEARCOAT_TINT: boolean;
  119346. CLEARCOAT_TINT_TEXTURE: boolean;
  119347. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119348. /** @hidden */
  119349. _areTexturesDirty: boolean;
  119350. }
  119351. /**
  119352. * Define the code related to the clear coat parameters of the pbr material.
  119353. */
  119354. export class PBRClearCoatConfiguration {
  119355. /**
  119356. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119357. * The default fits with a polyurethane material.
  119358. */
  119359. private static readonly _DefaultIndexOfRefraction;
  119360. private _isEnabled;
  119361. /**
  119362. * Defines if the clear coat is enabled in the material.
  119363. */
  119364. isEnabled: boolean;
  119365. /**
  119366. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119367. */
  119368. intensity: number;
  119369. /**
  119370. * Defines the clear coat layer roughness.
  119371. */
  119372. roughness: number;
  119373. private _indexOfRefraction;
  119374. /**
  119375. * Defines the index of refraction of the clear coat.
  119376. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119377. * The default fits with a polyurethane material.
  119378. * Changing the default value is more performance intensive.
  119379. */
  119380. indexOfRefraction: number;
  119381. private _texture;
  119382. /**
  119383. * Stores the clear coat values in a texture.
  119384. */
  119385. texture: Nullable<BaseTexture>;
  119386. private _bumpTexture;
  119387. /**
  119388. * Define the clear coat specific bump texture.
  119389. */
  119390. bumpTexture: Nullable<BaseTexture>;
  119391. private _isTintEnabled;
  119392. /**
  119393. * Defines if the clear coat tint is enabled in the material.
  119394. */
  119395. isTintEnabled: boolean;
  119396. /**
  119397. * Defines the clear coat tint of the material.
  119398. * This is only use if tint is enabled
  119399. */
  119400. tintColor: Color3;
  119401. /**
  119402. * Defines the distance at which the tint color should be found in the
  119403. * clear coat media.
  119404. * This is only use if tint is enabled
  119405. */
  119406. tintColorAtDistance: number;
  119407. /**
  119408. * Defines the clear coat layer thickness.
  119409. * This is only use if tint is enabled
  119410. */
  119411. tintThickness: number;
  119412. private _tintTexture;
  119413. /**
  119414. * Stores the clear tint values in a texture.
  119415. * rgb is tint
  119416. * a is a thickness factor
  119417. */
  119418. tintTexture: Nullable<BaseTexture>;
  119419. /** @hidden */
  119420. private _internalMarkAllSubMeshesAsTexturesDirty;
  119421. /** @hidden */
  119422. _markAllSubMeshesAsTexturesDirty(): void;
  119423. /**
  119424. * Instantiate a new istance of clear coat configuration.
  119425. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119426. */
  119427. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119428. /**
  119429. * Gets wehter the submesh is ready to be used or not.
  119430. * @param defines the list of "defines" to update.
  119431. * @param scene defines the scene the material belongs to.
  119432. * @param engine defines the engine the material belongs to.
  119433. * @param disableBumpMap defines wether the material disables bump or not.
  119434. * @returns - boolean indicating that the submesh is ready or not.
  119435. */
  119436. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119437. /**
  119438. * Checks to see if a texture is used in the material.
  119439. * @param defines the list of "defines" to update.
  119440. * @param scene defines the scene to the material belongs to.
  119441. */
  119442. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119443. /**
  119444. * Binds the material data.
  119445. * @param uniformBuffer defines the Uniform buffer to fill in.
  119446. * @param scene defines the scene the material belongs to.
  119447. * @param engine defines the engine the material belongs to.
  119448. * @param disableBumpMap defines wether the material disables bump or not.
  119449. * @param isFrozen defines wether the material is frozen or not.
  119450. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119451. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119452. */
  119453. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119454. /**
  119455. * Checks to see if a texture is used in the material.
  119456. * @param texture - Base texture to use.
  119457. * @returns - Boolean specifying if a texture is used in the material.
  119458. */
  119459. hasTexture(texture: BaseTexture): boolean;
  119460. /**
  119461. * Returns an array of the actively used textures.
  119462. * @param activeTextures Array of BaseTextures
  119463. */
  119464. getActiveTextures(activeTextures: BaseTexture[]): void;
  119465. /**
  119466. * Returns the animatable textures.
  119467. * @param animatables Array of animatable textures.
  119468. */
  119469. getAnimatables(animatables: IAnimatable[]): void;
  119470. /**
  119471. * Disposes the resources of the material.
  119472. * @param forceDisposeTextures - Forces the disposal of all textures.
  119473. */
  119474. dispose(forceDisposeTextures?: boolean): void;
  119475. /**
  119476. * Get the current class name of the texture useful for serialization or dynamic coding.
  119477. * @returns "PBRClearCoatConfiguration"
  119478. */
  119479. getClassName(): string;
  119480. /**
  119481. * Add fallbacks to the effect fallbacks list.
  119482. * @param defines defines the Base texture to use.
  119483. * @param fallbacks defines the current fallback list.
  119484. * @param currentRank defines the current fallback rank.
  119485. * @returns the new fallback rank.
  119486. */
  119487. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119488. /**
  119489. * Add the required uniforms to the current list.
  119490. * @param uniforms defines the current uniform list.
  119491. */
  119492. static AddUniforms(uniforms: string[]): void;
  119493. /**
  119494. * Add the required samplers to the current list.
  119495. * @param samplers defines the current sampler list.
  119496. */
  119497. static AddSamplers(samplers: string[]): void;
  119498. /**
  119499. * Add the required uniforms to the current buffer.
  119500. * @param uniformBuffer defines the current uniform buffer.
  119501. */
  119502. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119503. /**
  119504. * Makes a duplicate of the current configuration into another one.
  119505. * @param clearCoatConfiguration define the config where to copy the info
  119506. */
  119507. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119508. /**
  119509. * Serializes this clear coat configuration.
  119510. * @returns - An object with the serialized config.
  119511. */
  119512. serialize(): any;
  119513. /**
  119514. * Parses a anisotropy Configuration from a serialized object.
  119515. * @param source - Serialized object.
  119516. * @param scene Defines the scene we are parsing for
  119517. * @param rootUrl Defines the rootUrl to load from
  119518. */
  119519. parse(source: any, scene: Scene, rootUrl: string): void;
  119520. }
  119521. }
  119522. declare module BABYLON {
  119523. /**
  119524. * @hidden
  119525. */
  119526. export interface IMaterialAnisotropicDefines {
  119527. ANISOTROPIC: boolean;
  119528. ANISOTROPIC_TEXTURE: boolean;
  119529. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119530. MAINUV1: boolean;
  119531. _areTexturesDirty: boolean;
  119532. _needUVs: boolean;
  119533. }
  119534. /**
  119535. * Define the code related to the anisotropic parameters of the pbr material.
  119536. */
  119537. export class PBRAnisotropicConfiguration {
  119538. private _isEnabled;
  119539. /**
  119540. * Defines if the anisotropy is enabled in the material.
  119541. */
  119542. isEnabled: boolean;
  119543. /**
  119544. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119545. */
  119546. intensity: number;
  119547. /**
  119548. * Defines if the effect is along the tangents, bitangents or in between.
  119549. * By default, the effect is "strectching" the highlights along the tangents.
  119550. */
  119551. direction: Vector2;
  119552. private _texture;
  119553. /**
  119554. * Stores the anisotropy values in a texture.
  119555. * rg is direction (like normal from -1 to 1)
  119556. * b is a intensity
  119557. */
  119558. texture: Nullable<BaseTexture>;
  119559. /** @hidden */
  119560. private _internalMarkAllSubMeshesAsTexturesDirty;
  119561. /** @hidden */
  119562. _markAllSubMeshesAsTexturesDirty(): void;
  119563. /**
  119564. * Instantiate a new istance of anisotropy configuration.
  119565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119566. */
  119567. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119568. /**
  119569. * Specifies that the submesh is ready to be used.
  119570. * @param defines the list of "defines" to update.
  119571. * @param scene defines the scene the material belongs to.
  119572. * @returns - boolean indicating that the submesh is ready or not.
  119573. */
  119574. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119575. /**
  119576. * Checks to see if a texture is used in the material.
  119577. * @param defines the list of "defines" to update.
  119578. * @param mesh the mesh we are preparing the defines for.
  119579. * @param scene defines the scene the material belongs to.
  119580. */
  119581. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119582. /**
  119583. * Binds the material data.
  119584. * @param uniformBuffer defines the Uniform buffer to fill in.
  119585. * @param scene defines the scene the material belongs to.
  119586. * @param isFrozen defines wether the material is frozen or not.
  119587. */
  119588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119589. /**
  119590. * Checks to see if a texture is used in the material.
  119591. * @param texture - Base texture to use.
  119592. * @returns - Boolean specifying if a texture is used in the material.
  119593. */
  119594. hasTexture(texture: BaseTexture): boolean;
  119595. /**
  119596. * Returns an array of the actively used textures.
  119597. * @param activeTextures Array of BaseTextures
  119598. */
  119599. getActiveTextures(activeTextures: BaseTexture[]): void;
  119600. /**
  119601. * Returns the animatable textures.
  119602. * @param animatables Array of animatable textures.
  119603. */
  119604. getAnimatables(animatables: IAnimatable[]): void;
  119605. /**
  119606. * Disposes the resources of the material.
  119607. * @param forceDisposeTextures - Forces the disposal of all textures.
  119608. */
  119609. dispose(forceDisposeTextures?: boolean): void;
  119610. /**
  119611. * Get the current class name of the texture useful for serialization or dynamic coding.
  119612. * @returns "PBRAnisotropicConfiguration"
  119613. */
  119614. getClassName(): string;
  119615. /**
  119616. * Add fallbacks to the effect fallbacks list.
  119617. * @param defines defines the Base texture to use.
  119618. * @param fallbacks defines the current fallback list.
  119619. * @param currentRank defines the current fallback rank.
  119620. * @returns the new fallback rank.
  119621. */
  119622. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119623. /**
  119624. * Add the required uniforms to the current list.
  119625. * @param uniforms defines the current uniform list.
  119626. */
  119627. static AddUniforms(uniforms: string[]): void;
  119628. /**
  119629. * Add the required uniforms to the current buffer.
  119630. * @param uniformBuffer defines the current uniform buffer.
  119631. */
  119632. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119633. /**
  119634. * Add the required samplers to the current list.
  119635. * @param samplers defines the current sampler list.
  119636. */
  119637. static AddSamplers(samplers: string[]): void;
  119638. /**
  119639. * Makes a duplicate of the current configuration into another one.
  119640. * @param anisotropicConfiguration define the config where to copy the info
  119641. */
  119642. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119643. /**
  119644. * Serializes this anisotropy configuration.
  119645. * @returns - An object with the serialized config.
  119646. */
  119647. serialize(): any;
  119648. /**
  119649. * Parses a anisotropy Configuration from a serialized object.
  119650. * @param source - Serialized object.
  119651. * @param scene Defines the scene we are parsing for
  119652. * @param rootUrl Defines the rootUrl to load from
  119653. */
  119654. parse(source: any, scene: Scene, rootUrl: string): void;
  119655. }
  119656. }
  119657. declare module BABYLON {
  119658. /**
  119659. * @hidden
  119660. */
  119661. export interface IMaterialBRDFDefines {
  119662. BRDF_V_HEIGHT_CORRELATED: boolean;
  119663. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119664. SPHERICAL_HARMONICS: boolean;
  119665. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119666. /** @hidden */
  119667. _areMiscDirty: boolean;
  119668. }
  119669. /**
  119670. * Define the code related to the BRDF parameters of the pbr material.
  119671. */
  119672. export class PBRBRDFConfiguration {
  119673. /**
  119674. * Default value used for the energy conservation.
  119675. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119676. */
  119677. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119678. /**
  119679. * Default value used for the Smith Visibility Height Correlated mode.
  119680. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119681. */
  119682. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119683. /**
  119684. * Default value used for the IBL diffuse part.
  119685. * This can help switching back to the polynomials mode globally which is a tiny bit
  119686. * less GPU intensive at the drawback of a lower quality.
  119687. */
  119688. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119689. /**
  119690. * Default value used for activating energy conservation for the specular workflow.
  119691. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119692. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119693. */
  119694. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119695. private _useEnergyConservation;
  119696. /**
  119697. * Defines if the material uses energy conservation.
  119698. */
  119699. useEnergyConservation: boolean;
  119700. private _useSmithVisibilityHeightCorrelated;
  119701. /**
  119702. * LEGACY Mode set to false
  119703. * Defines if the material uses height smith correlated visibility term.
  119704. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119705. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119706. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119707. * Not relying on height correlated will also disable energy conservation.
  119708. */
  119709. useSmithVisibilityHeightCorrelated: boolean;
  119710. private _useSphericalHarmonics;
  119711. /**
  119712. * LEGACY Mode set to false
  119713. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119714. * diffuse part of the IBL.
  119715. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119716. * to the ground truth.
  119717. */
  119718. useSphericalHarmonics: boolean;
  119719. private _useSpecularGlossinessInputEnergyConservation;
  119720. /**
  119721. * Defines if the material uses energy conservation, when the specular workflow is active.
  119722. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119723. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119724. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119725. */
  119726. useSpecularGlossinessInputEnergyConservation: boolean;
  119727. /** @hidden */
  119728. private _internalMarkAllSubMeshesAsMiscDirty;
  119729. /** @hidden */
  119730. _markAllSubMeshesAsMiscDirty(): void;
  119731. /**
  119732. * Instantiate a new istance of clear coat configuration.
  119733. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119734. */
  119735. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119736. /**
  119737. * Checks to see if a texture is used in the material.
  119738. * @param defines the list of "defines" to update.
  119739. */
  119740. prepareDefines(defines: IMaterialBRDFDefines): void;
  119741. /**
  119742. * Get the current class name of the texture useful for serialization or dynamic coding.
  119743. * @returns "PBRClearCoatConfiguration"
  119744. */
  119745. getClassName(): string;
  119746. /**
  119747. * Makes a duplicate of the current configuration into another one.
  119748. * @param brdfConfiguration define the config where to copy the info
  119749. */
  119750. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119751. /**
  119752. * Serializes this BRDF configuration.
  119753. * @returns - An object with the serialized config.
  119754. */
  119755. serialize(): any;
  119756. /**
  119757. * Parses a anisotropy Configuration from a serialized object.
  119758. * @param source - Serialized object.
  119759. * @param scene Defines the scene we are parsing for
  119760. * @param rootUrl Defines the rootUrl to load from
  119761. */
  119762. parse(source: any, scene: Scene, rootUrl: string): void;
  119763. }
  119764. }
  119765. declare module BABYLON {
  119766. /**
  119767. * @hidden
  119768. */
  119769. export interface IMaterialSheenDefines {
  119770. SHEEN: boolean;
  119771. SHEEN_TEXTURE: boolean;
  119772. SHEEN_TEXTUREDIRECTUV: number;
  119773. SHEEN_LINKWITHALBEDO: boolean;
  119774. /** @hidden */
  119775. _areTexturesDirty: boolean;
  119776. }
  119777. /**
  119778. * Define the code related to the Sheen parameters of the pbr material.
  119779. */
  119780. export class PBRSheenConfiguration {
  119781. private _isEnabled;
  119782. /**
  119783. * Defines if the material uses sheen.
  119784. */
  119785. isEnabled: boolean;
  119786. private _linkSheenWithAlbedo;
  119787. /**
  119788. * Defines if the sheen is linked to the sheen color.
  119789. */
  119790. linkSheenWithAlbedo: boolean;
  119791. /**
  119792. * Defines the sheen intensity.
  119793. */
  119794. intensity: number;
  119795. /**
  119796. * Defines the sheen color.
  119797. */
  119798. color: Color3;
  119799. private _texture;
  119800. /**
  119801. * Stores the sheen tint values in a texture.
  119802. * rgb is tint
  119803. * a is a intensity
  119804. */
  119805. texture: Nullable<BaseTexture>;
  119806. /** @hidden */
  119807. private _internalMarkAllSubMeshesAsTexturesDirty;
  119808. /** @hidden */
  119809. _markAllSubMeshesAsTexturesDirty(): void;
  119810. /**
  119811. * Instantiate a new istance of clear coat configuration.
  119812. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119813. */
  119814. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119815. /**
  119816. * Specifies that the submesh is ready to be used.
  119817. * @param defines the list of "defines" to update.
  119818. * @param scene defines the scene the material belongs to.
  119819. * @returns - boolean indicating that the submesh is ready or not.
  119820. */
  119821. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119822. /**
  119823. * Checks to see if a texture is used in the material.
  119824. * @param defines the list of "defines" to update.
  119825. * @param scene defines the scene the material belongs to.
  119826. */
  119827. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119828. /**
  119829. * Binds the material data.
  119830. * @param uniformBuffer defines the Uniform buffer to fill in.
  119831. * @param scene defines the scene the material belongs to.
  119832. * @param isFrozen defines wether the material is frozen or not.
  119833. */
  119834. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119835. /**
  119836. * Checks to see if a texture is used in the material.
  119837. * @param texture - Base texture to use.
  119838. * @returns - Boolean specifying if a texture is used in the material.
  119839. */
  119840. hasTexture(texture: BaseTexture): boolean;
  119841. /**
  119842. * Returns an array of the actively used textures.
  119843. * @param activeTextures Array of BaseTextures
  119844. */
  119845. getActiveTextures(activeTextures: BaseTexture[]): void;
  119846. /**
  119847. * Returns the animatable textures.
  119848. * @param animatables Array of animatable textures.
  119849. */
  119850. getAnimatables(animatables: IAnimatable[]): void;
  119851. /**
  119852. * Disposes the resources of the material.
  119853. * @param forceDisposeTextures - Forces the disposal of all textures.
  119854. */
  119855. dispose(forceDisposeTextures?: boolean): void;
  119856. /**
  119857. * Get the current class name of the texture useful for serialization or dynamic coding.
  119858. * @returns "PBRSheenConfiguration"
  119859. */
  119860. getClassName(): string;
  119861. /**
  119862. * Add fallbacks to the effect fallbacks list.
  119863. * @param defines defines the Base texture to use.
  119864. * @param fallbacks defines the current fallback list.
  119865. * @param currentRank defines the current fallback rank.
  119866. * @returns the new fallback rank.
  119867. */
  119868. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119869. /**
  119870. * Add the required uniforms to the current list.
  119871. * @param uniforms defines the current uniform list.
  119872. */
  119873. static AddUniforms(uniforms: string[]): void;
  119874. /**
  119875. * Add the required uniforms to the current buffer.
  119876. * @param uniformBuffer defines the current uniform buffer.
  119877. */
  119878. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119879. /**
  119880. * Add the required samplers to the current list.
  119881. * @param samplers defines the current sampler list.
  119882. */
  119883. static AddSamplers(samplers: string[]): void;
  119884. /**
  119885. * Makes a duplicate of the current configuration into another one.
  119886. * @param sheenConfiguration define the config where to copy the info
  119887. */
  119888. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  119889. /**
  119890. * Serializes this BRDF configuration.
  119891. * @returns - An object with the serialized config.
  119892. */
  119893. serialize(): any;
  119894. /**
  119895. * Parses a anisotropy Configuration from a serialized object.
  119896. * @param source - Serialized object.
  119897. * @param scene Defines the scene we are parsing for
  119898. * @param rootUrl Defines the rootUrl to load from
  119899. */
  119900. parse(source: any, scene: Scene, rootUrl: string): void;
  119901. }
  119902. }
  119903. declare module BABYLON {
  119904. /**
  119905. * @hidden
  119906. */
  119907. export interface IMaterialSubSurfaceDefines {
  119908. SUBSURFACE: boolean;
  119909. SS_REFRACTION: boolean;
  119910. SS_TRANSLUCENCY: boolean;
  119911. SS_SCATERRING: boolean;
  119912. SS_THICKNESSANDMASK_TEXTURE: boolean;
  119913. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  119914. SS_REFRACTIONMAP_3D: boolean;
  119915. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  119916. SS_LODINREFRACTIONALPHA: boolean;
  119917. SS_GAMMAREFRACTION: boolean;
  119918. SS_RGBDREFRACTION: boolean;
  119919. SS_LINEARSPECULARREFRACTION: boolean;
  119920. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  119921. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  119922. /** @hidden */
  119923. _areTexturesDirty: boolean;
  119924. }
  119925. /**
  119926. * Define the code related to the sub surface parameters of the pbr material.
  119927. */
  119928. export class PBRSubSurfaceConfiguration {
  119929. private _isRefractionEnabled;
  119930. /**
  119931. * Defines if the refraction is enabled in the material.
  119932. */
  119933. isRefractionEnabled: boolean;
  119934. private _isTranslucencyEnabled;
  119935. /**
  119936. * Defines if the translucency is enabled in the material.
  119937. */
  119938. isTranslucencyEnabled: boolean;
  119939. private _isScatteringEnabled;
  119940. /**
  119941. * Defines the refraction intensity of the material.
  119942. * The refraction when enabled replaces the Diffuse part of the material.
  119943. * The intensity helps transitionning between diffuse and refraction.
  119944. */
  119945. refractionIntensity: number;
  119946. /**
  119947. * Defines the translucency intensity of the material.
  119948. * When translucency has been enabled, this defines how much of the "translucency"
  119949. * is addded to the diffuse part of the material.
  119950. */
  119951. translucencyIntensity: number;
  119952. /**
  119953. * Defines the scattering intensity of the material.
  119954. * When scattering has been enabled, this defines how much of the "scattered light"
  119955. * is addded to the diffuse part of the material.
  119956. */
  119957. scatteringIntensity: number;
  119958. private _thicknessTexture;
  119959. /**
  119960. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  119961. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  119962. * 0 would mean minimumThickness
  119963. * 1 would mean maximumThickness
  119964. * The other channels might be use as a mask to vary the different effects intensity.
  119965. */
  119966. thicknessTexture: Nullable<BaseTexture>;
  119967. private _refractionTexture;
  119968. /**
  119969. * Defines the texture to use for refraction.
  119970. */
  119971. refractionTexture: Nullable<BaseTexture>;
  119972. private _indexOfRefraction;
  119973. /**
  119974. * Defines the index of refraction used in the material.
  119975. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  119976. */
  119977. indexOfRefraction: number;
  119978. private _invertRefractionY;
  119979. /**
  119980. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  119981. */
  119982. invertRefractionY: boolean;
  119983. private _linkRefractionWithTransparency;
  119984. /**
  119985. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  119986. * Materials half opaque for instance using refraction could benefit from this control.
  119987. */
  119988. linkRefractionWithTransparency: boolean;
  119989. /**
  119990. * Defines the minimum thickness stored in the thickness map.
  119991. * If no thickness map is defined, this value will be used to simulate thickness.
  119992. */
  119993. minimumThickness: number;
  119994. /**
  119995. * Defines the maximum thickness stored in the thickness map.
  119996. */
  119997. maximumThickness: number;
  119998. /**
  119999. * Defines the volume tint of the material.
  120000. * This is used for both translucency and scattering.
  120001. */
  120002. tintColor: Color3;
  120003. /**
  120004. * Defines the distance at which the tint color should be found in the media.
  120005. * This is used for refraction only.
  120006. */
  120007. tintColorAtDistance: number;
  120008. /**
  120009. * Defines how far each channel transmit through the media.
  120010. * It is defined as a color to simplify it selection.
  120011. */
  120012. diffusionDistance: Color3;
  120013. private _useMaskFromThicknessTexture;
  120014. /**
  120015. * Stores the intensity of the different subsurface effects in the thickness texture.
  120016. * * the green channel is the translucency intensity.
  120017. * * the blue channel is the scattering intensity.
  120018. * * the alpha channel is the refraction intensity.
  120019. */
  120020. useMaskFromThicknessTexture: boolean;
  120021. /** @hidden */
  120022. private _internalMarkAllSubMeshesAsTexturesDirty;
  120023. /** @hidden */
  120024. _markAllSubMeshesAsTexturesDirty(): void;
  120025. /**
  120026. * Instantiate a new istance of sub surface configuration.
  120027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120028. */
  120029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120030. /**
  120031. * Gets wehter the submesh is ready to be used or not.
  120032. * @param defines the list of "defines" to update.
  120033. * @param scene defines the scene the material belongs to.
  120034. * @returns - boolean indicating that the submesh is ready or not.
  120035. */
  120036. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120037. /**
  120038. * Checks to see if a texture is used in the material.
  120039. * @param defines the list of "defines" to update.
  120040. * @param scene defines the scene to the material belongs to.
  120041. */
  120042. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120043. /**
  120044. * Binds the material data.
  120045. * @param uniformBuffer defines the Uniform buffer to fill in.
  120046. * @param scene defines the scene the material belongs to.
  120047. * @param engine defines the engine the material belongs to.
  120048. * @param isFrozen defines wether the material is frozen or not.
  120049. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120050. */
  120051. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120052. /**
  120053. * Unbinds the material from the mesh.
  120054. * @param activeEffect defines the effect that should be unbound from.
  120055. * @returns true if unbound, otherwise false
  120056. */
  120057. unbind(activeEffect: Effect): boolean;
  120058. /**
  120059. * Returns the texture used for refraction or null if none is used.
  120060. * @param scene defines the scene the material belongs to.
  120061. * @returns - Refraction texture if present. If no refraction texture and refraction
  120062. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120063. */
  120064. private _getRefractionTexture;
  120065. /**
  120066. * Returns true if alpha blending should be disabled.
  120067. */
  120068. get disableAlphaBlending(): boolean;
  120069. /**
  120070. * Fills the list of render target textures.
  120071. * @param renderTargets the list of render targets to update
  120072. */
  120073. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120074. /**
  120075. * Checks to see if a texture is used in the material.
  120076. * @param texture - Base texture to use.
  120077. * @returns - Boolean specifying if a texture is used in the material.
  120078. */
  120079. hasTexture(texture: BaseTexture): boolean;
  120080. /**
  120081. * Gets a boolean indicating that current material needs to register RTT
  120082. * @returns true if this uses a render target otherwise false.
  120083. */
  120084. hasRenderTargetTextures(): boolean;
  120085. /**
  120086. * Returns an array of the actively used textures.
  120087. * @param activeTextures Array of BaseTextures
  120088. */
  120089. getActiveTextures(activeTextures: BaseTexture[]): void;
  120090. /**
  120091. * Returns the animatable textures.
  120092. * @param animatables Array of animatable textures.
  120093. */
  120094. getAnimatables(animatables: IAnimatable[]): void;
  120095. /**
  120096. * Disposes the resources of the material.
  120097. * @param forceDisposeTextures - Forces the disposal of all textures.
  120098. */
  120099. dispose(forceDisposeTextures?: boolean): void;
  120100. /**
  120101. * Get the current class name of the texture useful for serialization or dynamic coding.
  120102. * @returns "PBRSubSurfaceConfiguration"
  120103. */
  120104. getClassName(): string;
  120105. /**
  120106. * Add fallbacks to the effect fallbacks list.
  120107. * @param defines defines the Base texture to use.
  120108. * @param fallbacks defines the current fallback list.
  120109. * @param currentRank defines the current fallback rank.
  120110. * @returns the new fallback rank.
  120111. */
  120112. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120113. /**
  120114. * Add the required uniforms to the current list.
  120115. * @param uniforms defines the current uniform list.
  120116. */
  120117. static AddUniforms(uniforms: string[]): void;
  120118. /**
  120119. * Add the required samplers to the current list.
  120120. * @param samplers defines the current sampler list.
  120121. */
  120122. static AddSamplers(samplers: string[]): void;
  120123. /**
  120124. * Add the required uniforms to the current buffer.
  120125. * @param uniformBuffer defines the current uniform buffer.
  120126. */
  120127. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120128. /**
  120129. * Makes a duplicate of the current configuration into another one.
  120130. * @param configuration define the config where to copy the info
  120131. */
  120132. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120133. /**
  120134. * Serializes this Sub Surface configuration.
  120135. * @returns - An object with the serialized config.
  120136. */
  120137. serialize(): any;
  120138. /**
  120139. * Parses a anisotropy Configuration from a serialized object.
  120140. * @param source - Serialized object.
  120141. * @param scene Defines the scene we are parsing for
  120142. * @param rootUrl Defines the rootUrl to load from
  120143. */
  120144. parse(source: any, scene: Scene, rootUrl: string): void;
  120145. }
  120146. }
  120147. declare module BABYLON {
  120148. /** @hidden */
  120149. export var pbrFragmentDeclaration: {
  120150. name: string;
  120151. shader: string;
  120152. };
  120153. }
  120154. declare module BABYLON {
  120155. /** @hidden */
  120156. export var pbrUboDeclaration: {
  120157. name: string;
  120158. shader: string;
  120159. };
  120160. }
  120161. declare module BABYLON {
  120162. /** @hidden */
  120163. export var pbrFragmentExtraDeclaration: {
  120164. name: string;
  120165. shader: string;
  120166. };
  120167. }
  120168. declare module BABYLON {
  120169. /** @hidden */
  120170. export var pbrFragmentSamplersDeclaration: {
  120171. name: string;
  120172. shader: string;
  120173. };
  120174. }
  120175. declare module BABYLON {
  120176. /** @hidden */
  120177. export var pbrHelperFunctions: {
  120178. name: string;
  120179. shader: string;
  120180. };
  120181. }
  120182. declare module BABYLON {
  120183. /** @hidden */
  120184. export var harmonicsFunctions: {
  120185. name: string;
  120186. shader: string;
  120187. };
  120188. }
  120189. declare module BABYLON {
  120190. /** @hidden */
  120191. export var pbrDirectLightingSetupFunctions: {
  120192. name: string;
  120193. shader: string;
  120194. };
  120195. }
  120196. declare module BABYLON {
  120197. /** @hidden */
  120198. export var pbrDirectLightingFalloffFunctions: {
  120199. name: string;
  120200. shader: string;
  120201. };
  120202. }
  120203. declare module BABYLON {
  120204. /** @hidden */
  120205. export var pbrBRDFFunctions: {
  120206. name: string;
  120207. shader: string;
  120208. };
  120209. }
  120210. declare module BABYLON {
  120211. /** @hidden */
  120212. export var pbrDirectLightingFunctions: {
  120213. name: string;
  120214. shader: string;
  120215. };
  120216. }
  120217. declare module BABYLON {
  120218. /** @hidden */
  120219. export var pbrIBLFunctions: {
  120220. name: string;
  120221. shader: string;
  120222. };
  120223. }
  120224. declare module BABYLON {
  120225. /** @hidden */
  120226. export var pbrDebug: {
  120227. name: string;
  120228. shader: string;
  120229. };
  120230. }
  120231. declare module BABYLON {
  120232. /** @hidden */
  120233. export var pbrPixelShader: {
  120234. name: string;
  120235. shader: string;
  120236. };
  120237. }
  120238. declare module BABYLON {
  120239. /** @hidden */
  120240. export var pbrVertexDeclaration: {
  120241. name: string;
  120242. shader: string;
  120243. };
  120244. }
  120245. declare module BABYLON {
  120246. /** @hidden */
  120247. export var pbrVertexShader: {
  120248. name: string;
  120249. shader: string;
  120250. };
  120251. }
  120252. declare module BABYLON {
  120253. /**
  120254. * Manages the defines for the PBR Material.
  120255. * @hidden
  120256. */
  120257. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120258. PBR: boolean;
  120259. MAINUV1: boolean;
  120260. MAINUV2: boolean;
  120261. UV1: boolean;
  120262. UV2: boolean;
  120263. ALBEDO: boolean;
  120264. ALBEDODIRECTUV: number;
  120265. VERTEXCOLOR: boolean;
  120266. AMBIENT: boolean;
  120267. AMBIENTDIRECTUV: number;
  120268. AMBIENTINGRAYSCALE: boolean;
  120269. OPACITY: boolean;
  120270. VERTEXALPHA: boolean;
  120271. OPACITYDIRECTUV: number;
  120272. OPACITYRGB: boolean;
  120273. ALPHATEST: boolean;
  120274. DEPTHPREPASS: boolean;
  120275. ALPHABLEND: boolean;
  120276. ALPHAFROMALBEDO: boolean;
  120277. ALPHATESTVALUE: string;
  120278. SPECULAROVERALPHA: boolean;
  120279. RADIANCEOVERALPHA: boolean;
  120280. ALPHAFRESNEL: boolean;
  120281. LINEARALPHAFRESNEL: boolean;
  120282. PREMULTIPLYALPHA: boolean;
  120283. EMISSIVE: boolean;
  120284. EMISSIVEDIRECTUV: number;
  120285. REFLECTIVITY: boolean;
  120286. REFLECTIVITYDIRECTUV: number;
  120287. SPECULARTERM: boolean;
  120288. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120289. MICROSURFACEAUTOMATIC: boolean;
  120290. LODBASEDMICROSFURACE: boolean;
  120291. MICROSURFACEMAP: boolean;
  120292. MICROSURFACEMAPDIRECTUV: number;
  120293. METALLICWORKFLOW: boolean;
  120294. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120295. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120296. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120297. AOSTOREINMETALMAPRED: boolean;
  120298. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120299. ENVIRONMENTBRDF: boolean;
  120300. ENVIRONMENTBRDF_RGBD: boolean;
  120301. NORMAL: boolean;
  120302. TANGENT: boolean;
  120303. BUMP: boolean;
  120304. BUMPDIRECTUV: number;
  120305. OBJECTSPACE_NORMALMAP: boolean;
  120306. PARALLAX: boolean;
  120307. PARALLAXOCCLUSION: boolean;
  120308. NORMALXYSCALE: boolean;
  120309. LIGHTMAP: boolean;
  120310. LIGHTMAPDIRECTUV: number;
  120311. USELIGHTMAPASSHADOWMAP: boolean;
  120312. GAMMALIGHTMAP: boolean;
  120313. RGBDLIGHTMAP: boolean;
  120314. REFLECTION: boolean;
  120315. REFLECTIONMAP_3D: boolean;
  120316. REFLECTIONMAP_SPHERICAL: boolean;
  120317. REFLECTIONMAP_PLANAR: boolean;
  120318. REFLECTIONMAP_CUBIC: boolean;
  120319. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120320. REFLECTIONMAP_PROJECTION: boolean;
  120321. REFLECTIONMAP_SKYBOX: boolean;
  120322. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120323. REFLECTIONMAP_EXPLICIT: boolean;
  120324. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120325. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120326. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120327. INVERTCUBICMAP: boolean;
  120328. USESPHERICALFROMREFLECTIONMAP: boolean;
  120329. USEIRRADIANCEMAP: boolean;
  120330. SPHERICAL_HARMONICS: boolean;
  120331. USESPHERICALINVERTEX: boolean;
  120332. REFLECTIONMAP_OPPOSITEZ: boolean;
  120333. LODINREFLECTIONALPHA: boolean;
  120334. GAMMAREFLECTION: boolean;
  120335. RGBDREFLECTION: boolean;
  120336. LINEARSPECULARREFLECTION: boolean;
  120337. RADIANCEOCCLUSION: boolean;
  120338. HORIZONOCCLUSION: boolean;
  120339. INSTANCES: boolean;
  120340. NUM_BONE_INFLUENCERS: number;
  120341. BonesPerMesh: number;
  120342. BONETEXTURE: boolean;
  120343. NONUNIFORMSCALING: boolean;
  120344. MORPHTARGETS: boolean;
  120345. MORPHTARGETS_NORMAL: boolean;
  120346. MORPHTARGETS_TANGENT: boolean;
  120347. MORPHTARGETS_UV: boolean;
  120348. NUM_MORPH_INFLUENCERS: number;
  120349. IMAGEPROCESSING: boolean;
  120350. VIGNETTE: boolean;
  120351. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120352. VIGNETTEBLENDMODEOPAQUE: boolean;
  120353. TONEMAPPING: boolean;
  120354. TONEMAPPING_ACES: boolean;
  120355. CONTRAST: boolean;
  120356. COLORCURVES: boolean;
  120357. COLORGRADING: boolean;
  120358. COLORGRADING3D: boolean;
  120359. SAMPLER3DGREENDEPTH: boolean;
  120360. SAMPLER3DBGRMAP: boolean;
  120361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120362. EXPOSURE: boolean;
  120363. MULTIVIEW: boolean;
  120364. USEPHYSICALLIGHTFALLOFF: boolean;
  120365. USEGLTFLIGHTFALLOFF: boolean;
  120366. TWOSIDEDLIGHTING: boolean;
  120367. SHADOWFLOAT: boolean;
  120368. CLIPPLANE: boolean;
  120369. CLIPPLANE2: boolean;
  120370. CLIPPLANE3: boolean;
  120371. CLIPPLANE4: boolean;
  120372. POINTSIZE: boolean;
  120373. FOG: boolean;
  120374. LOGARITHMICDEPTH: boolean;
  120375. FORCENORMALFORWARD: boolean;
  120376. SPECULARAA: boolean;
  120377. CLEARCOAT: boolean;
  120378. CLEARCOAT_DEFAULTIOR: boolean;
  120379. CLEARCOAT_TEXTURE: boolean;
  120380. CLEARCOAT_TEXTUREDIRECTUV: number;
  120381. CLEARCOAT_BUMP: boolean;
  120382. CLEARCOAT_BUMPDIRECTUV: number;
  120383. CLEARCOAT_TINT: boolean;
  120384. CLEARCOAT_TINT_TEXTURE: boolean;
  120385. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120386. ANISOTROPIC: boolean;
  120387. ANISOTROPIC_TEXTURE: boolean;
  120388. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120389. BRDF_V_HEIGHT_CORRELATED: boolean;
  120390. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120391. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120392. SHEEN: boolean;
  120393. SHEEN_TEXTURE: boolean;
  120394. SHEEN_TEXTUREDIRECTUV: number;
  120395. SHEEN_LINKWITHALBEDO: boolean;
  120396. SUBSURFACE: boolean;
  120397. SS_REFRACTION: boolean;
  120398. SS_TRANSLUCENCY: boolean;
  120399. SS_SCATERRING: boolean;
  120400. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120401. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120402. SS_REFRACTIONMAP_3D: boolean;
  120403. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120404. SS_LODINREFRACTIONALPHA: boolean;
  120405. SS_GAMMAREFRACTION: boolean;
  120406. SS_RGBDREFRACTION: boolean;
  120407. SS_LINEARSPECULARREFRACTION: boolean;
  120408. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120409. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120410. UNLIT: boolean;
  120411. DEBUGMODE: number;
  120412. /**
  120413. * Initializes the PBR Material defines.
  120414. */
  120415. constructor();
  120416. /**
  120417. * Resets the PBR Material defines.
  120418. */
  120419. reset(): void;
  120420. }
  120421. /**
  120422. * The Physically based material base class of BJS.
  120423. *
  120424. * This offers the main features of a standard PBR material.
  120425. * For more information, please refer to the documentation :
  120426. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120427. */
  120428. export abstract class PBRBaseMaterial extends PushMaterial {
  120429. /**
  120430. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120431. */
  120432. static readonly PBRMATERIAL_OPAQUE: number;
  120433. /**
  120434. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120435. */
  120436. static readonly PBRMATERIAL_ALPHATEST: number;
  120437. /**
  120438. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120439. */
  120440. static readonly PBRMATERIAL_ALPHABLEND: number;
  120441. /**
  120442. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120443. * They are also discarded below the alpha cutoff threshold to improve performances.
  120444. */
  120445. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120446. /**
  120447. * Defines the default value of how much AO map is occluding the analytical lights
  120448. * (point spot...).
  120449. */
  120450. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120451. /**
  120452. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120453. */
  120454. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120455. /**
  120456. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120457. * to enhance interoperability with other engines.
  120458. */
  120459. static readonly LIGHTFALLOFF_GLTF: number;
  120460. /**
  120461. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120462. * to enhance interoperability with other materials.
  120463. */
  120464. static readonly LIGHTFALLOFF_STANDARD: number;
  120465. /**
  120466. * Intensity of the direct lights e.g. the four lights available in your scene.
  120467. * This impacts both the direct diffuse and specular highlights.
  120468. */
  120469. protected _directIntensity: number;
  120470. /**
  120471. * Intensity of the emissive part of the material.
  120472. * This helps controlling the emissive effect without modifying the emissive color.
  120473. */
  120474. protected _emissiveIntensity: number;
  120475. /**
  120476. * Intensity of the environment e.g. how much the environment will light the object
  120477. * either through harmonics for rough material or through the refelction for shiny ones.
  120478. */
  120479. protected _environmentIntensity: number;
  120480. /**
  120481. * This is a special control allowing the reduction of the specular highlights coming from the
  120482. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120483. */
  120484. protected _specularIntensity: number;
  120485. /**
  120486. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120487. */
  120488. private _lightingInfos;
  120489. /**
  120490. * Debug Control allowing disabling the bump map on this material.
  120491. */
  120492. protected _disableBumpMap: boolean;
  120493. /**
  120494. * AKA Diffuse Texture in standard nomenclature.
  120495. */
  120496. protected _albedoTexture: Nullable<BaseTexture>;
  120497. /**
  120498. * AKA Occlusion Texture in other nomenclature.
  120499. */
  120500. protected _ambientTexture: Nullable<BaseTexture>;
  120501. /**
  120502. * AKA Occlusion Texture Intensity in other nomenclature.
  120503. */
  120504. protected _ambientTextureStrength: number;
  120505. /**
  120506. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120507. * 1 means it completely occludes it
  120508. * 0 mean it has no impact
  120509. */
  120510. protected _ambientTextureImpactOnAnalyticalLights: number;
  120511. /**
  120512. * Stores the alpha values in a texture.
  120513. */
  120514. protected _opacityTexture: Nullable<BaseTexture>;
  120515. /**
  120516. * Stores the reflection values in a texture.
  120517. */
  120518. protected _reflectionTexture: Nullable<BaseTexture>;
  120519. /**
  120520. * Stores the emissive values in a texture.
  120521. */
  120522. protected _emissiveTexture: Nullable<BaseTexture>;
  120523. /**
  120524. * AKA Specular texture in other nomenclature.
  120525. */
  120526. protected _reflectivityTexture: Nullable<BaseTexture>;
  120527. /**
  120528. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120529. */
  120530. protected _metallicTexture: Nullable<BaseTexture>;
  120531. /**
  120532. * Specifies the metallic scalar of the metallic/roughness workflow.
  120533. * Can also be used to scale the metalness values of the metallic texture.
  120534. */
  120535. protected _metallic: Nullable<number>;
  120536. /**
  120537. * Specifies the roughness scalar of the metallic/roughness workflow.
  120538. * Can also be used to scale the roughness values of the metallic texture.
  120539. */
  120540. protected _roughness: Nullable<number>;
  120541. /**
  120542. * Specifies the an F0 factor to help configuring the material F0.
  120543. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120544. * to 0.5 the previously hard coded value stays the same.
  120545. * Can also be used to scale the F0 values of the metallic texture.
  120546. */
  120547. protected _metallicF0Factor: number;
  120548. /**
  120549. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120550. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120551. * your expectation as it multiplies with the texture data.
  120552. */
  120553. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120554. /**
  120555. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120556. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120557. */
  120558. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120559. /**
  120560. * Stores surface normal data used to displace a mesh in a texture.
  120561. */
  120562. protected _bumpTexture: Nullable<BaseTexture>;
  120563. /**
  120564. * Stores the pre-calculated light information of a mesh in a texture.
  120565. */
  120566. protected _lightmapTexture: Nullable<BaseTexture>;
  120567. /**
  120568. * The color of a material in ambient lighting.
  120569. */
  120570. protected _ambientColor: Color3;
  120571. /**
  120572. * AKA Diffuse Color in other nomenclature.
  120573. */
  120574. protected _albedoColor: Color3;
  120575. /**
  120576. * AKA Specular Color in other nomenclature.
  120577. */
  120578. protected _reflectivityColor: Color3;
  120579. /**
  120580. * The color applied when light is reflected from a material.
  120581. */
  120582. protected _reflectionColor: Color3;
  120583. /**
  120584. * The color applied when light is emitted from a material.
  120585. */
  120586. protected _emissiveColor: Color3;
  120587. /**
  120588. * AKA Glossiness in other nomenclature.
  120589. */
  120590. protected _microSurface: number;
  120591. /**
  120592. * Specifies that the material will use the light map as a show map.
  120593. */
  120594. protected _useLightmapAsShadowmap: boolean;
  120595. /**
  120596. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120597. * makes the reflect vector face the model (under horizon).
  120598. */
  120599. protected _useHorizonOcclusion: boolean;
  120600. /**
  120601. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120602. * too much the area relying on ambient texture to define their ambient occlusion.
  120603. */
  120604. protected _useRadianceOcclusion: boolean;
  120605. /**
  120606. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120607. */
  120608. protected _useAlphaFromAlbedoTexture: boolean;
  120609. /**
  120610. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120611. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120612. */
  120613. protected _useSpecularOverAlpha: boolean;
  120614. /**
  120615. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120616. */
  120617. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120618. /**
  120619. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120620. */
  120621. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120622. /**
  120623. * Specifies if the metallic texture contains the roughness information in its green channel.
  120624. */
  120625. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120626. /**
  120627. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120628. */
  120629. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120630. /**
  120631. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120632. */
  120633. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120634. /**
  120635. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120636. */
  120637. protected _useAmbientInGrayScale: boolean;
  120638. /**
  120639. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120640. * The material will try to infer what glossiness each pixel should be.
  120641. */
  120642. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120643. /**
  120644. * Defines the falloff type used in this material.
  120645. * It by default is Physical.
  120646. */
  120647. protected _lightFalloff: number;
  120648. /**
  120649. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120650. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120651. */
  120652. protected _useRadianceOverAlpha: boolean;
  120653. /**
  120654. * Allows using an object space normal map (instead of tangent space).
  120655. */
  120656. protected _useObjectSpaceNormalMap: boolean;
  120657. /**
  120658. * Allows using the bump map in parallax mode.
  120659. */
  120660. protected _useParallax: boolean;
  120661. /**
  120662. * Allows using the bump map in parallax occlusion mode.
  120663. */
  120664. protected _useParallaxOcclusion: boolean;
  120665. /**
  120666. * Controls the scale bias of the parallax mode.
  120667. */
  120668. protected _parallaxScaleBias: number;
  120669. /**
  120670. * If sets to true, disables all the lights affecting the material.
  120671. */
  120672. protected _disableLighting: boolean;
  120673. /**
  120674. * Number of Simultaneous lights allowed on the material.
  120675. */
  120676. protected _maxSimultaneousLights: number;
  120677. /**
  120678. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120679. */
  120680. protected _invertNormalMapX: boolean;
  120681. /**
  120682. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120683. */
  120684. protected _invertNormalMapY: boolean;
  120685. /**
  120686. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120687. */
  120688. protected _twoSidedLighting: boolean;
  120689. /**
  120690. * Defines the alpha limits in alpha test mode.
  120691. */
  120692. protected _alphaCutOff: number;
  120693. /**
  120694. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120695. */
  120696. protected _forceAlphaTest: boolean;
  120697. /**
  120698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120699. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120700. */
  120701. protected _useAlphaFresnel: boolean;
  120702. /**
  120703. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120704. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120705. */
  120706. protected _useLinearAlphaFresnel: boolean;
  120707. /**
  120708. * The transparency mode of the material.
  120709. */
  120710. protected _transparencyMode: Nullable<number>;
  120711. /**
  120712. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120713. * from cos thetav and roughness:
  120714. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120715. */
  120716. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120717. /**
  120718. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120719. */
  120720. protected _forceIrradianceInFragment: boolean;
  120721. /**
  120722. * Force normal to face away from face.
  120723. */
  120724. protected _forceNormalForward: boolean;
  120725. /**
  120726. * Enables specular anti aliasing in the PBR shader.
  120727. * It will both interacts on the Geometry for analytical and IBL lighting.
  120728. * It also prefilter the roughness map based on the bump values.
  120729. */
  120730. protected _enableSpecularAntiAliasing: boolean;
  120731. /**
  120732. * Default configuration related to image processing available in the PBR Material.
  120733. */
  120734. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120735. /**
  120736. * Keep track of the image processing observer to allow dispose and replace.
  120737. */
  120738. private _imageProcessingObserver;
  120739. /**
  120740. * Attaches a new image processing configuration to the PBR Material.
  120741. * @param configuration
  120742. */
  120743. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120744. /**
  120745. * Stores the available render targets.
  120746. */
  120747. private _renderTargets;
  120748. /**
  120749. * Sets the global ambient color for the material used in lighting calculations.
  120750. */
  120751. private _globalAmbientColor;
  120752. /**
  120753. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120754. */
  120755. private _useLogarithmicDepth;
  120756. /**
  120757. * If set to true, no lighting calculations will be applied.
  120758. */
  120759. private _unlit;
  120760. private _debugMode;
  120761. /**
  120762. * @hidden
  120763. * This is reserved for the inspector.
  120764. * Defines the material debug mode.
  120765. * It helps seeing only some components of the material while troubleshooting.
  120766. */
  120767. debugMode: number;
  120768. /**
  120769. * @hidden
  120770. * This is reserved for the inspector.
  120771. * Specify from where on screen the debug mode should start.
  120772. * The value goes from -1 (full screen) to 1 (not visible)
  120773. * It helps with side by side comparison against the final render
  120774. * This defaults to -1
  120775. */
  120776. private debugLimit;
  120777. /**
  120778. * @hidden
  120779. * This is reserved for the inspector.
  120780. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120781. * You can use the factor to better multiply the final value.
  120782. */
  120783. private debugFactor;
  120784. /**
  120785. * Defines the clear coat layer parameters for the material.
  120786. */
  120787. readonly clearCoat: PBRClearCoatConfiguration;
  120788. /**
  120789. * Defines the anisotropic parameters for the material.
  120790. */
  120791. readonly anisotropy: PBRAnisotropicConfiguration;
  120792. /**
  120793. * Defines the BRDF parameters for the material.
  120794. */
  120795. readonly brdf: PBRBRDFConfiguration;
  120796. /**
  120797. * Defines the Sheen parameters for the material.
  120798. */
  120799. readonly sheen: PBRSheenConfiguration;
  120800. /**
  120801. * Defines the SubSurface parameters for the material.
  120802. */
  120803. readonly subSurface: PBRSubSurfaceConfiguration;
  120804. /**
  120805. * Custom callback helping to override the default shader used in the material.
  120806. */
  120807. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120808. protected _rebuildInParallel: boolean;
  120809. /**
  120810. * Instantiates a new PBRMaterial instance.
  120811. *
  120812. * @param name The material name
  120813. * @param scene The scene the material will be use in.
  120814. */
  120815. constructor(name: string, scene: Scene);
  120816. /**
  120817. * Gets a boolean indicating that current material needs to register RTT
  120818. */
  120819. get hasRenderTargetTextures(): boolean;
  120820. /**
  120821. * Gets the name of the material class.
  120822. */
  120823. getClassName(): string;
  120824. /**
  120825. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120826. */
  120827. get useLogarithmicDepth(): boolean;
  120828. /**
  120829. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120830. */
  120831. set useLogarithmicDepth(value: boolean);
  120832. /**
  120833. * Gets the current transparency mode.
  120834. */
  120835. get transparencyMode(): Nullable<number>;
  120836. /**
  120837. * Sets the transparency mode of the material.
  120838. *
  120839. * | Value | Type | Description |
  120840. * | ----- | ----------------------------------- | ----------- |
  120841. * | 0 | OPAQUE | |
  120842. * | 1 | ALPHATEST | |
  120843. * | 2 | ALPHABLEND | |
  120844. * | 3 | ALPHATESTANDBLEND | |
  120845. *
  120846. */
  120847. set transparencyMode(value: Nullable<number>);
  120848. /**
  120849. * Returns true if alpha blending should be disabled.
  120850. */
  120851. private get _disableAlphaBlending();
  120852. /**
  120853. * Specifies whether or not this material should be rendered in alpha blend mode.
  120854. */
  120855. needAlphaBlending(): boolean;
  120856. /**
  120857. * Specifies if the mesh will require alpha blending.
  120858. * @param mesh - BJS mesh.
  120859. */
  120860. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  120861. /**
  120862. * Specifies whether or not this material should be rendered in alpha test mode.
  120863. */
  120864. needAlphaTesting(): boolean;
  120865. /**
  120866. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  120867. */
  120868. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  120869. /**
  120870. * Gets the texture used for the alpha test.
  120871. */
  120872. getAlphaTestTexture(): Nullable<BaseTexture>;
  120873. /**
  120874. * Specifies that the submesh is ready to be used.
  120875. * @param mesh - BJS mesh.
  120876. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  120877. * @param useInstances - Specifies that instances should be used.
  120878. * @returns - boolean indicating that the submesh is ready or not.
  120879. */
  120880. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120881. /**
  120882. * Specifies if the material uses metallic roughness workflow.
  120883. * @returns boolean specifiying if the material uses metallic roughness workflow.
  120884. */
  120885. isMetallicWorkflow(): boolean;
  120886. private _prepareEffect;
  120887. private _prepareDefines;
  120888. /**
  120889. * Force shader compilation
  120890. */
  120891. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  120892. /**
  120893. * Initializes the uniform buffer layout for the shader.
  120894. */
  120895. buildUniformLayout(): void;
  120896. /**
  120897. * Unbinds the material from the mesh
  120898. */
  120899. unbind(): void;
  120900. /**
  120901. * Binds the submesh data.
  120902. * @param world - The world matrix.
  120903. * @param mesh - The BJS mesh.
  120904. * @param subMesh - A submesh of the BJS mesh.
  120905. */
  120906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120907. /**
  120908. * Returns the animatable textures.
  120909. * @returns - Array of animatable textures.
  120910. */
  120911. getAnimatables(): IAnimatable[];
  120912. /**
  120913. * Returns the texture used for reflections.
  120914. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  120915. */
  120916. private _getReflectionTexture;
  120917. /**
  120918. * Returns an array of the actively used textures.
  120919. * @returns - Array of BaseTextures
  120920. */
  120921. getActiveTextures(): BaseTexture[];
  120922. /**
  120923. * Checks to see if a texture is used in the material.
  120924. * @param texture - Base texture to use.
  120925. * @returns - Boolean specifying if a texture is used in the material.
  120926. */
  120927. hasTexture(texture: BaseTexture): boolean;
  120928. /**
  120929. * Disposes the resources of the material.
  120930. * @param forceDisposeEffect - Forces the disposal of effects.
  120931. * @param forceDisposeTextures - Forces the disposal of all textures.
  120932. */
  120933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. /**
  120938. * The Physically based material of BJS.
  120939. *
  120940. * This offers the main features of a standard PBR material.
  120941. * For more information, please refer to the documentation :
  120942. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120943. */
  120944. export class PBRMaterial extends PBRBaseMaterial {
  120945. /**
  120946. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120947. */
  120948. static readonly PBRMATERIAL_OPAQUE: number;
  120949. /**
  120950. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120951. */
  120952. static readonly PBRMATERIAL_ALPHATEST: number;
  120953. /**
  120954. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120955. */
  120956. static readonly PBRMATERIAL_ALPHABLEND: number;
  120957. /**
  120958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120959. * They are also discarded below the alpha cutoff threshold to improve performances.
  120960. */
  120961. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120962. /**
  120963. * Defines the default value of how much AO map is occluding the analytical lights
  120964. * (point spot...).
  120965. */
  120966. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120967. /**
  120968. * Intensity of the direct lights e.g. the four lights available in your scene.
  120969. * This impacts both the direct diffuse and specular highlights.
  120970. */
  120971. directIntensity: number;
  120972. /**
  120973. * Intensity of the emissive part of the material.
  120974. * This helps controlling the emissive effect without modifying the emissive color.
  120975. */
  120976. emissiveIntensity: number;
  120977. /**
  120978. * Intensity of the environment e.g. how much the environment will light the object
  120979. * either through harmonics for rough material or through the refelction for shiny ones.
  120980. */
  120981. environmentIntensity: number;
  120982. /**
  120983. * This is a special control allowing the reduction of the specular highlights coming from the
  120984. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120985. */
  120986. specularIntensity: number;
  120987. /**
  120988. * Debug Control allowing disabling the bump map on this material.
  120989. */
  120990. disableBumpMap: boolean;
  120991. /**
  120992. * AKA Diffuse Texture in standard nomenclature.
  120993. */
  120994. albedoTexture: BaseTexture;
  120995. /**
  120996. * AKA Occlusion Texture in other nomenclature.
  120997. */
  120998. ambientTexture: BaseTexture;
  120999. /**
  121000. * AKA Occlusion Texture Intensity in other nomenclature.
  121001. */
  121002. ambientTextureStrength: number;
  121003. /**
  121004. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121005. * 1 means it completely occludes it
  121006. * 0 mean it has no impact
  121007. */
  121008. ambientTextureImpactOnAnalyticalLights: number;
  121009. /**
  121010. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121011. */
  121012. opacityTexture: BaseTexture;
  121013. /**
  121014. * Stores the reflection values in a texture.
  121015. */
  121016. reflectionTexture: Nullable<BaseTexture>;
  121017. /**
  121018. * Stores the emissive values in a texture.
  121019. */
  121020. emissiveTexture: BaseTexture;
  121021. /**
  121022. * AKA Specular texture in other nomenclature.
  121023. */
  121024. reflectivityTexture: BaseTexture;
  121025. /**
  121026. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121027. */
  121028. metallicTexture: BaseTexture;
  121029. /**
  121030. * Specifies the metallic scalar of the metallic/roughness workflow.
  121031. * Can also be used to scale the metalness values of the metallic texture.
  121032. */
  121033. metallic: Nullable<number>;
  121034. /**
  121035. * Specifies the roughness scalar of the metallic/roughness workflow.
  121036. * Can also be used to scale the roughness values of the metallic texture.
  121037. */
  121038. roughness: Nullable<number>;
  121039. /**
  121040. * Specifies the an F0 factor to help configuring the material F0.
  121041. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121042. * to 0.5 the previously hard coded value stays the same.
  121043. * Can also be used to scale the F0 values of the metallic texture.
  121044. */
  121045. metallicF0Factor: number;
  121046. /**
  121047. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121048. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121049. * your expectation as it multiplies with the texture data.
  121050. */
  121051. useMetallicF0FactorFromMetallicTexture: boolean;
  121052. /**
  121053. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121054. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121055. */
  121056. microSurfaceTexture: BaseTexture;
  121057. /**
  121058. * Stores surface normal data used to displace a mesh in a texture.
  121059. */
  121060. bumpTexture: BaseTexture;
  121061. /**
  121062. * Stores the pre-calculated light information of a mesh in a texture.
  121063. */
  121064. lightmapTexture: BaseTexture;
  121065. /**
  121066. * Stores the refracted light information in a texture.
  121067. */
  121068. get refractionTexture(): Nullable<BaseTexture>;
  121069. set refractionTexture(value: Nullable<BaseTexture>);
  121070. /**
  121071. * The color of a material in ambient lighting.
  121072. */
  121073. ambientColor: Color3;
  121074. /**
  121075. * AKA Diffuse Color in other nomenclature.
  121076. */
  121077. albedoColor: Color3;
  121078. /**
  121079. * AKA Specular Color in other nomenclature.
  121080. */
  121081. reflectivityColor: Color3;
  121082. /**
  121083. * The color reflected from the material.
  121084. */
  121085. reflectionColor: Color3;
  121086. /**
  121087. * The color emitted from the material.
  121088. */
  121089. emissiveColor: Color3;
  121090. /**
  121091. * AKA Glossiness in other nomenclature.
  121092. */
  121093. microSurface: number;
  121094. /**
  121095. * source material index of refraction (IOR)' / 'destination material IOR.
  121096. */
  121097. get indexOfRefraction(): number;
  121098. set indexOfRefraction(value: number);
  121099. /**
  121100. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121101. */
  121102. get invertRefractionY(): boolean;
  121103. set invertRefractionY(value: boolean);
  121104. /**
  121105. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121106. * Materials half opaque for instance using refraction could benefit from this control.
  121107. */
  121108. get linkRefractionWithTransparency(): boolean;
  121109. set linkRefractionWithTransparency(value: boolean);
  121110. /**
  121111. * If true, the light map contains occlusion information instead of lighting info.
  121112. */
  121113. useLightmapAsShadowmap: boolean;
  121114. /**
  121115. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121116. */
  121117. useAlphaFromAlbedoTexture: boolean;
  121118. /**
  121119. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121120. */
  121121. forceAlphaTest: boolean;
  121122. /**
  121123. * Defines the alpha limits in alpha test mode.
  121124. */
  121125. alphaCutOff: number;
  121126. /**
  121127. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121128. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121129. */
  121130. useSpecularOverAlpha: boolean;
  121131. /**
  121132. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121133. */
  121134. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121135. /**
  121136. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121137. */
  121138. useRoughnessFromMetallicTextureAlpha: boolean;
  121139. /**
  121140. * Specifies if the metallic texture contains the roughness information in its green channel.
  121141. */
  121142. useRoughnessFromMetallicTextureGreen: boolean;
  121143. /**
  121144. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121145. */
  121146. useMetallnessFromMetallicTextureBlue: boolean;
  121147. /**
  121148. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121149. */
  121150. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121151. /**
  121152. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121153. */
  121154. useAmbientInGrayScale: boolean;
  121155. /**
  121156. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121157. * The material will try to infer what glossiness each pixel should be.
  121158. */
  121159. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121160. /**
  121161. * BJS is using an harcoded light falloff based on a manually sets up range.
  121162. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121163. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121164. */
  121165. get usePhysicalLightFalloff(): boolean;
  121166. /**
  121167. * BJS is using an harcoded light falloff based on a manually sets up range.
  121168. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121169. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121170. */
  121171. set usePhysicalLightFalloff(value: boolean);
  121172. /**
  121173. * In order to support the falloff compatibility with gltf, a special mode has been added
  121174. * to reproduce the gltf light falloff.
  121175. */
  121176. get useGLTFLightFalloff(): boolean;
  121177. /**
  121178. * In order to support the falloff compatibility with gltf, a special mode has been added
  121179. * to reproduce the gltf light falloff.
  121180. */
  121181. set useGLTFLightFalloff(value: boolean);
  121182. /**
  121183. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121184. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121185. */
  121186. useRadianceOverAlpha: boolean;
  121187. /**
  121188. * Allows using an object space normal map (instead of tangent space).
  121189. */
  121190. useObjectSpaceNormalMap: boolean;
  121191. /**
  121192. * Allows using the bump map in parallax mode.
  121193. */
  121194. useParallax: boolean;
  121195. /**
  121196. * Allows using the bump map in parallax occlusion mode.
  121197. */
  121198. useParallaxOcclusion: boolean;
  121199. /**
  121200. * Controls the scale bias of the parallax mode.
  121201. */
  121202. parallaxScaleBias: number;
  121203. /**
  121204. * If sets to true, disables all the lights affecting the material.
  121205. */
  121206. disableLighting: boolean;
  121207. /**
  121208. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121209. */
  121210. forceIrradianceInFragment: boolean;
  121211. /**
  121212. * Number of Simultaneous lights allowed on the material.
  121213. */
  121214. maxSimultaneousLights: number;
  121215. /**
  121216. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121217. */
  121218. invertNormalMapX: boolean;
  121219. /**
  121220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121221. */
  121222. invertNormalMapY: boolean;
  121223. /**
  121224. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121225. */
  121226. twoSidedLighting: boolean;
  121227. /**
  121228. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121229. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121230. */
  121231. useAlphaFresnel: boolean;
  121232. /**
  121233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121234. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121235. */
  121236. useLinearAlphaFresnel: boolean;
  121237. /**
  121238. * Let user defines the brdf lookup texture used for IBL.
  121239. * A default 8bit version is embedded but you could point at :
  121240. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121241. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121242. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121243. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121244. */
  121245. environmentBRDFTexture: Nullable<BaseTexture>;
  121246. /**
  121247. * Force normal to face away from face.
  121248. */
  121249. forceNormalForward: boolean;
  121250. /**
  121251. * Enables specular anti aliasing in the PBR shader.
  121252. * It will both interacts on the Geometry for analytical and IBL lighting.
  121253. * It also prefilter the roughness map based on the bump values.
  121254. */
  121255. enableSpecularAntiAliasing: boolean;
  121256. /**
  121257. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121258. * makes the reflect vector face the model (under horizon).
  121259. */
  121260. useHorizonOcclusion: boolean;
  121261. /**
  121262. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121263. * too much the area relying on ambient texture to define their ambient occlusion.
  121264. */
  121265. useRadianceOcclusion: boolean;
  121266. /**
  121267. * If set to true, no lighting calculations will be applied.
  121268. */
  121269. unlit: boolean;
  121270. /**
  121271. * Gets the image processing configuration used either in this material.
  121272. */
  121273. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121274. /**
  121275. * Sets the Default image processing configuration used either in the this material.
  121276. *
  121277. * If sets to null, the scene one is in use.
  121278. */
  121279. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121280. /**
  121281. * Gets wether the color curves effect is enabled.
  121282. */
  121283. get cameraColorCurvesEnabled(): boolean;
  121284. /**
  121285. * Sets wether the color curves effect is enabled.
  121286. */
  121287. set cameraColorCurvesEnabled(value: boolean);
  121288. /**
  121289. * Gets wether the color grading effect is enabled.
  121290. */
  121291. get cameraColorGradingEnabled(): boolean;
  121292. /**
  121293. * Gets wether the color grading effect is enabled.
  121294. */
  121295. set cameraColorGradingEnabled(value: boolean);
  121296. /**
  121297. * Gets wether tonemapping is enabled or not.
  121298. */
  121299. get cameraToneMappingEnabled(): boolean;
  121300. /**
  121301. * Sets wether tonemapping is enabled or not
  121302. */
  121303. set cameraToneMappingEnabled(value: boolean);
  121304. /**
  121305. * The camera exposure used on this material.
  121306. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121307. * This corresponds to a photographic exposure.
  121308. */
  121309. get cameraExposure(): number;
  121310. /**
  121311. * The camera exposure used on this material.
  121312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121313. * This corresponds to a photographic exposure.
  121314. */
  121315. set cameraExposure(value: number);
  121316. /**
  121317. * Gets The camera contrast used on this material.
  121318. */
  121319. get cameraContrast(): number;
  121320. /**
  121321. * Sets The camera contrast used on this material.
  121322. */
  121323. set cameraContrast(value: number);
  121324. /**
  121325. * Gets the Color Grading 2D Lookup Texture.
  121326. */
  121327. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121328. /**
  121329. * Sets the Color Grading 2D Lookup Texture.
  121330. */
  121331. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121332. /**
  121333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121335. * 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;
  121336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121337. */
  121338. get cameraColorCurves(): Nullable<ColorCurves>;
  121339. /**
  121340. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121341. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121342. * 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;
  121343. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121344. */
  121345. set cameraColorCurves(value: Nullable<ColorCurves>);
  121346. /**
  121347. * Instantiates a new PBRMaterial instance.
  121348. *
  121349. * @param name The material name
  121350. * @param scene The scene the material will be use in.
  121351. */
  121352. constructor(name: string, scene: Scene);
  121353. /**
  121354. * Returns the name of this material class.
  121355. */
  121356. getClassName(): string;
  121357. /**
  121358. * Makes a duplicate of the current material.
  121359. * @param name - name to use for the new material.
  121360. */
  121361. clone(name: string): PBRMaterial;
  121362. /**
  121363. * Serializes this PBR Material.
  121364. * @returns - An object with the serialized material.
  121365. */
  121366. serialize(): any;
  121367. /**
  121368. * Parses a PBR Material from a serialized object.
  121369. * @param source - Serialized object.
  121370. * @param scene - BJS scene instance.
  121371. * @param rootUrl - url for the scene object
  121372. * @returns - PBRMaterial
  121373. */
  121374. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121375. }
  121376. }
  121377. declare module BABYLON {
  121378. /**
  121379. * Direct draw surface info
  121380. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121381. */
  121382. export interface DDSInfo {
  121383. /**
  121384. * Width of the texture
  121385. */
  121386. width: number;
  121387. /**
  121388. * Width of the texture
  121389. */
  121390. height: number;
  121391. /**
  121392. * Number of Mipmaps for the texture
  121393. * @see https://en.wikipedia.org/wiki/Mipmap
  121394. */
  121395. mipmapCount: number;
  121396. /**
  121397. * If the textures format is a known fourCC format
  121398. * @see https://www.fourcc.org/
  121399. */
  121400. isFourCC: boolean;
  121401. /**
  121402. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121403. */
  121404. isRGB: boolean;
  121405. /**
  121406. * If the texture is a lumincance format
  121407. */
  121408. isLuminance: boolean;
  121409. /**
  121410. * If this is a cube texture
  121411. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121412. */
  121413. isCube: boolean;
  121414. /**
  121415. * If the texture is a compressed format eg. FOURCC_DXT1
  121416. */
  121417. isCompressed: boolean;
  121418. /**
  121419. * The dxgiFormat of the texture
  121420. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121421. */
  121422. dxgiFormat: number;
  121423. /**
  121424. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121425. */
  121426. textureType: number;
  121427. /**
  121428. * Sphericle polynomial created for the dds texture
  121429. */
  121430. sphericalPolynomial?: SphericalPolynomial;
  121431. }
  121432. /**
  121433. * Class used to provide DDS decompression tools
  121434. */
  121435. export class DDSTools {
  121436. /**
  121437. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121438. */
  121439. static StoreLODInAlphaChannel: boolean;
  121440. /**
  121441. * Gets DDS information from an array buffer
  121442. * @param arrayBuffer defines the array buffer to read data from
  121443. * @returns the DDS information
  121444. */
  121445. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121446. private static _FloatView;
  121447. private static _Int32View;
  121448. private static _ToHalfFloat;
  121449. private static _FromHalfFloat;
  121450. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121451. private static _GetHalfFloatRGBAArrayBuffer;
  121452. private static _GetFloatRGBAArrayBuffer;
  121453. private static _GetFloatAsUIntRGBAArrayBuffer;
  121454. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121455. private static _GetRGBAArrayBuffer;
  121456. private static _ExtractLongWordOrder;
  121457. private static _GetRGBArrayBuffer;
  121458. private static _GetLuminanceArrayBuffer;
  121459. /**
  121460. * Uploads DDS Levels to a Babylon Texture
  121461. * @hidden
  121462. */
  121463. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121464. }
  121465. interface ThinEngine {
  121466. /**
  121467. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121468. * @param rootUrl defines the url where the file to load is located
  121469. * @param scene defines the current scene
  121470. * @param lodScale defines scale to apply to the mip map selection
  121471. * @param lodOffset defines offset to apply to the mip map selection
  121472. * @param onLoad defines an optional callback raised when the texture is loaded
  121473. * @param onError defines an optional callback raised if there is an issue to load the texture
  121474. * @param format defines the format of the data
  121475. * @param forcedExtension defines the extension to use to pick the right loader
  121476. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121477. * @returns the cube texture as an InternalTexture
  121478. */
  121479. 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;
  121480. }
  121481. }
  121482. declare module BABYLON {
  121483. /**
  121484. * Implementation of the DDS Texture Loader.
  121485. * @hidden
  121486. */
  121487. export class _DDSTextureLoader implements IInternalTextureLoader {
  121488. /**
  121489. * Defines wether the loader supports cascade loading the different faces.
  121490. */
  121491. readonly supportCascades: boolean;
  121492. /**
  121493. * This returns if the loader support the current file information.
  121494. * @param extension defines the file extension of the file being loaded
  121495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121496. * @param fallback defines the fallback internal texture if any
  121497. * @param isBase64 defines whether the texture is encoded as a base64
  121498. * @param isBuffer defines whether the texture data are stored as a buffer
  121499. * @returns true if the loader can load the specified file
  121500. */
  121501. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121502. /**
  121503. * Transform the url before loading if required.
  121504. * @param rootUrl the url of the texture
  121505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121506. * @returns the transformed texture
  121507. */
  121508. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121509. /**
  121510. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121511. * @param rootUrl the url of the texture
  121512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121513. * @returns the fallback texture
  121514. */
  121515. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121516. /**
  121517. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121518. * @param data contains the texture data
  121519. * @param texture defines the BabylonJS internal texture
  121520. * @param createPolynomials will be true if polynomials have been requested
  121521. * @param onLoad defines the callback to trigger once the texture is ready
  121522. * @param onError defines the callback to trigger in case of error
  121523. */
  121524. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121525. /**
  121526. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121527. * @param data contains the texture data
  121528. * @param texture defines the BabylonJS internal texture
  121529. * @param callback defines the method to call once ready to upload
  121530. */
  121531. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121532. }
  121533. }
  121534. declare module BABYLON {
  121535. /**
  121536. * Implementation of the ENV Texture Loader.
  121537. * @hidden
  121538. */
  121539. export class _ENVTextureLoader implements IInternalTextureLoader {
  121540. /**
  121541. * Defines wether the loader supports cascade loading the different faces.
  121542. */
  121543. readonly supportCascades: boolean;
  121544. /**
  121545. * This returns if the loader support the current file information.
  121546. * @param extension defines the file extension of the file being loaded
  121547. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121548. * @param fallback defines the fallback internal texture if any
  121549. * @param isBase64 defines whether the texture is encoded as a base64
  121550. * @param isBuffer defines whether the texture data are stored as a buffer
  121551. * @returns true if the loader can load the specified file
  121552. */
  121553. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121554. /**
  121555. * Transform the url before loading if required.
  121556. * @param rootUrl the url of the texture
  121557. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121558. * @returns the transformed texture
  121559. */
  121560. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121561. /**
  121562. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121563. * @param rootUrl the url of the texture
  121564. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121565. * @returns the fallback texture
  121566. */
  121567. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121568. /**
  121569. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121570. * @param data contains the texture data
  121571. * @param texture defines the BabylonJS internal texture
  121572. * @param createPolynomials will be true if polynomials have been requested
  121573. * @param onLoad defines the callback to trigger once the texture is ready
  121574. * @param onError defines the callback to trigger in case of error
  121575. */
  121576. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121577. /**
  121578. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121579. * @param data contains the texture data
  121580. * @param texture defines the BabylonJS internal texture
  121581. * @param callback defines the method to call once ready to upload
  121582. */
  121583. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121584. }
  121585. }
  121586. declare module BABYLON {
  121587. /**
  121588. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121589. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121590. */
  121591. export class KhronosTextureContainer {
  121592. /** contents of the KTX container file */
  121593. arrayBuffer: any;
  121594. private static HEADER_LEN;
  121595. private static COMPRESSED_2D;
  121596. private static COMPRESSED_3D;
  121597. private static TEX_2D;
  121598. private static TEX_3D;
  121599. /**
  121600. * Gets the openGL type
  121601. */
  121602. glType: number;
  121603. /**
  121604. * Gets the openGL type size
  121605. */
  121606. glTypeSize: number;
  121607. /**
  121608. * Gets the openGL format
  121609. */
  121610. glFormat: number;
  121611. /**
  121612. * Gets the openGL internal format
  121613. */
  121614. glInternalFormat: number;
  121615. /**
  121616. * Gets the base internal format
  121617. */
  121618. glBaseInternalFormat: number;
  121619. /**
  121620. * Gets image width in pixel
  121621. */
  121622. pixelWidth: number;
  121623. /**
  121624. * Gets image height in pixel
  121625. */
  121626. pixelHeight: number;
  121627. /**
  121628. * Gets image depth in pixels
  121629. */
  121630. pixelDepth: number;
  121631. /**
  121632. * Gets the number of array elements
  121633. */
  121634. numberOfArrayElements: number;
  121635. /**
  121636. * Gets the number of faces
  121637. */
  121638. numberOfFaces: number;
  121639. /**
  121640. * Gets the number of mipmap levels
  121641. */
  121642. numberOfMipmapLevels: number;
  121643. /**
  121644. * Gets the bytes of key value data
  121645. */
  121646. bytesOfKeyValueData: number;
  121647. /**
  121648. * Gets the load type
  121649. */
  121650. loadType: number;
  121651. /**
  121652. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121653. */
  121654. isInvalid: boolean;
  121655. /**
  121656. * Creates a new KhronosTextureContainer
  121657. * @param arrayBuffer contents of the KTX container file
  121658. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121659. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121660. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121661. */
  121662. constructor(
  121663. /** contents of the KTX container file */
  121664. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121665. /**
  121666. * Uploads KTX content to a Babylon Texture.
  121667. * It is assumed that the texture has already been created & is currently bound
  121668. * @hidden
  121669. */
  121670. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121671. private _upload2DCompressedLevels;
  121672. }
  121673. }
  121674. declare module BABYLON {
  121675. /**
  121676. * Implementation of the KTX Texture Loader.
  121677. * @hidden
  121678. */
  121679. export class _KTXTextureLoader implements IInternalTextureLoader {
  121680. /**
  121681. * Defines wether the loader supports cascade loading the different faces.
  121682. */
  121683. readonly supportCascades: boolean;
  121684. /**
  121685. * This returns if the loader support the current file information.
  121686. * @param extension defines the file extension of the file being loaded
  121687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121688. * @param fallback defines the fallback internal texture if any
  121689. * @param isBase64 defines whether the texture is encoded as a base64
  121690. * @param isBuffer defines whether the texture data are stored as a buffer
  121691. * @returns true if the loader can load the specified file
  121692. */
  121693. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121694. /**
  121695. * Transform the url before loading if required.
  121696. * @param rootUrl the url of the texture
  121697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121698. * @returns the transformed texture
  121699. */
  121700. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121701. /**
  121702. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121703. * @param rootUrl the url of the texture
  121704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121705. * @returns the fallback texture
  121706. */
  121707. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121708. /**
  121709. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121710. * @param data contains the texture data
  121711. * @param texture defines the BabylonJS internal texture
  121712. * @param createPolynomials will be true if polynomials have been requested
  121713. * @param onLoad defines the callback to trigger once the texture is ready
  121714. * @param onError defines the callback to trigger in case of error
  121715. */
  121716. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121717. /**
  121718. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121719. * @param data contains the texture data
  121720. * @param texture defines the BabylonJS internal texture
  121721. * @param callback defines the method to call once ready to upload
  121722. */
  121723. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121724. }
  121725. }
  121726. declare module BABYLON {
  121727. /** @hidden */
  121728. export var _forceSceneHelpersToBundle: boolean;
  121729. interface Scene {
  121730. /**
  121731. * Creates a default light for the scene.
  121732. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121733. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121734. */
  121735. createDefaultLight(replace?: boolean): void;
  121736. /**
  121737. * Creates a default camera for the scene.
  121738. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121739. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121740. * @param replace has default false, when true replaces the active camera in the scene
  121741. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121742. */
  121743. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121744. /**
  121745. * Creates a default camera and a default light.
  121746. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121747. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121748. * @param replace has the default false, when true replaces the active camera/light in the scene
  121749. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121750. */
  121751. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121752. /**
  121753. * Creates a new sky box
  121754. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121755. * @param environmentTexture defines the texture to use as environment texture
  121756. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121757. * @param scale defines the overall scale of the skybox
  121758. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121759. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121760. * @returns a new mesh holding the sky box
  121761. */
  121762. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121763. /**
  121764. * Creates a new environment
  121765. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121766. * @param options defines the options you can use to configure the environment
  121767. * @returns the new EnvironmentHelper
  121768. */
  121769. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121770. /**
  121771. * Creates a new VREXperienceHelper
  121772. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121773. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121774. * @returns a new VREXperienceHelper
  121775. */
  121776. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121777. /**
  121778. * Creates a new WebXRDefaultExperience
  121779. * @see http://doc.babylonjs.com/how_to/webxr
  121780. * @param options experience options
  121781. * @returns a promise for a new WebXRDefaultExperience
  121782. */
  121783. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121784. }
  121785. }
  121786. declare module BABYLON {
  121787. /**
  121788. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121789. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121790. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121791. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121792. */
  121793. export class VideoDome extends TransformNode {
  121794. /**
  121795. * Define the video source as a Monoscopic panoramic 360 video.
  121796. */
  121797. static readonly MODE_MONOSCOPIC: number;
  121798. /**
  121799. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121800. */
  121801. static readonly MODE_TOPBOTTOM: number;
  121802. /**
  121803. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121804. */
  121805. static readonly MODE_SIDEBYSIDE: number;
  121806. private _halfDome;
  121807. private _useDirectMapping;
  121808. /**
  121809. * The video texture being displayed on the sphere
  121810. */
  121811. protected _videoTexture: VideoTexture;
  121812. /**
  121813. * Gets the video texture being displayed on the sphere
  121814. */
  121815. get videoTexture(): VideoTexture;
  121816. /**
  121817. * The skybox material
  121818. */
  121819. protected _material: BackgroundMaterial;
  121820. /**
  121821. * The surface used for the skybox
  121822. */
  121823. protected _mesh: Mesh;
  121824. /**
  121825. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121826. */
  121827. private _halfDomeMask;
  121828. /**
  121829. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121830. * Also see the options.resolution property.
  121831. */
  121832. get fovMultiplier(): number;
  121833. set fovMultiplier(value: number);
  121834. private _videoMode;
  121835. /**
  121836. * Gets or set the current video mode for the video. It can be:
  121837. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121838. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121839. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121840. */
  121841. get videoMode(): number;
  121842. set videoMode(value: number);
  121843. /**
  121844. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121845. *
  121846. */
  121847. get halfDome(): boolean;
  121848. /**
  121849. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  121850. */
  121851. set halfDome(enabled: boolean);
  121852. /**
  121853. * Oberserver used in Stereoscopic VR Mode.
  121854. */
  121855. private _onBeforeCameraRenderObserver;
  121856. /**
  121857. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  121858. * @param name Element's name, child elements will append suffixes for their own names.
  121859. * @param urlsOrVideo defines the url(s) or the video element to use
  121860. * @param options An object containing optional or exposed sub element properties
  121861. */
  121862. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  121863. resolution?: number;
  121864. clickToPlay?: boolean;
  121865. autoPlay?: boolean;
  121866. loop?: boolean;
  121867. size?: number;
  121868. poster?: string;
  121869. faceForward?: boolean;
  121870. useDirectMapping?: boolean;
  121871. halfDomeMode?: boolean;
  121872. }, scene: Scene);
  121873. private _changeVideoMode;
  121874. /**
  121875. * Releases resources associated with this node.
  121876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121878. */
  121879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121880. }
  121881. }
  121882. declare module BABYLON {
  121883. /**
  121884. * This class can be used to get instrumentation data from a Babylon engine
  121885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121886. */
  121887. export class EngineInstrumentation implements IDisposable {
  121888. /**
  121889. * Define the instrumented engine.
  121890. */
  121891. engine: Engine;
  121892. private _captureGPUFrameTime;
  121893. private _gpuFrameTimeToken;
  121894. private _gpuFrameTime;
  121895. private _captureShaderCompilationTime;
  121896. private _shaderCompilationTime;
  121897. private _onBeginFrameObserver;
  121898. private _onEndFrameObserver;
  121899. private _onBeforeShaderCompilationObserver;
  121900. private _onAfterShaderCompilationObserver;
  121901. /**
  121902. * Gets the perf counter used for GPU frame time
  121903. */
  121904. get gpuFrameTimeCounter(): PerfCounter;
  121905. /**
  121906. * Gets the GPU frame time capture status
  121907. */
  121908. get captureGPUFrameTime(): boolean;
  121909. /**
  121910. * Enable or disable the GPU frame time capture
  121911. */
  121912. set captureGPUFrameTime(value: boolean);
  121913. /**
  121914. * Gets the perf counter used for shader compilation time
  121915. */
  121916. get shaderCompilationTimeCounter(): PerfCounter;
  121917. /**
  121918. * Gets the shader compilation time capture status
  121919. */
  121920. get captureShaderCompilationTime(): boolean;
  121921. /**
  121922. * Enable or disable the shader compilation time capture
  121923. */
  121924. set captureShaderCompilationTime(value: boolean);
  121925. /**
  121926. * Instantiates a new engine instrumentation.
  121927. * This class can be used to get instrumentation data from a Babylon engine
  121928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121929. * @param engine Defines the engine to instrument
  121930. */
  121931. constructor(
  121932. /**
  121933. * Define the instrumented engine.
  121934. */
  121935. engine: Engine);
  121936. /**
  121937. * Dispose and release associated resources.
  121938. */
  121939. dispose(): void;
  121940. }
  121941. }
  121942. declare module BABYLON {
  121943. /**
  121944. * This class can be used to get instrumentation data from a Babylon engine
  121945. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  121946. */
  121947. export class SceneInstrumentation implements IDisposable {
  121948. /**
  121949. * Defines the scene to instrument
  121950. */
  121951. scene: Scene;
  121952. private _captureActiveMeshesEvaluationTime;
  121953. private _activeMeshesEvaluationTime;
  121954. private _captureRenderTargetsRenderTime;
  121955. private _renderTargetsRenderTime;
  121956. private _captureFrameTime;
  121957. private _frameTime;
  121958. private _captureRenderTime;
  121959. private _renderTime;
  121960. private _captureInterFrameTime;
  121961. private _interFrameTime;
  121962. private _captureParticlesRenderTime;
  121963. private _particlesRenderTime;
  121964. private _captureSpritesRenderTime;
  121965. private _spritesRenderTime;
  121966. private _capturePhysicsTime;
  121967. private _physicsTime;
  121968. private _captureAnimationsTime;
  121969. private _animationsTime;
  121970. private _captureCameraRenderTime;
  121971. private _cameraRenderTime;
  121972. private _onBeforeActiveMeshesEvaluationObserver;
  121973. private _onAfterActiveMeshesEvaluationObserver;
  121974. private _onBeforeRenderTargetsRenderObserver;
  121975. private _onAfterRenderTargetsRenderObserver;
  121976. private _onAfterRenderObserver;
  121977. private _onBeforeDrawPhaseObserver;
  121978. private _onAfterDrawPhaseObserver;
  121979. private _onBeforeAnimationsObserver;
  121980. private _onBeforeParticlesRenderingObserver;
  121981. private _onAfterParticlesRenderingObserver;
  121982. private _onBeforeSpritesRenderingObserver;
  121983. private _onAfterSpritesRenderingObserver;
  121984. private _onBeforePhysicsObserver;
  121985. private _onAfterPhysicsObserver;
  121986. private _onAfterAnimationsObserver;
  121987. private _onBeforeCameraRenderObserver;
  121988. private _onAfterCameraRenderObserver;
  121989. /**
  121990. * Gets the perf counter used for active meshes evaluation time
  121991. */
  121992. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  121993. /**
  121994. * Gets the active meshes evaluation time capture status
  121995. */
  121996. get captureActiveMeshesEvaluationTime(): boolean;
  121997. /**
  121998. * Enable or disable the active meshes evaluation time capture
  121999. */
  122000. set captureActiveMeshesEvaluationTime(value: boolean);
  122001. /**
  122002. * Gets the perf counter used for render targets render time
  122003. */
  122004. get renderTargetsRenderTimeCounter(): PerfCounter;
  122005. /**
  122006. * Gets the render targets render time capture status
  122007. */
  122008. get captureRenderTargetsRenderTime(): boolean;
  122009. /**
  122010. * Enable or disable the render targets render time capture
  122011. */
  122012. set captureRenderTargetsRenderTime(value: boolean);
  122013. /**
  122014. * Gets the perf counter used for particles render time
  122015. */
  122016. get particlesRenderTimeCounter(): PerfCounter;
  122017. /**
  122018. * Gets the particles render time capture status
  122019. */
  122020. get captureParticlesRenderTime(): boolean;
  122021. /**
  122022. * Enable or disable the particles render time capture
  122023. */
  122024. set captureParticlesRenderTime(value: boolean);
  122025. /**
  122026. * Gets the perf counter used for sprites render time
  122027. */
  122028. get spritesRenderTimeCounter(): PerfCounter;
  122029. /**
  122030. * Gets the sprites render time capture status
  122031. */
  122032. get captureSpritesRenderTime(): boolean;
  122033. /**
  122034. * Enable or disable the sprites render time capture
  122035. */
  122036. set captureSpritesRenderTime(value: boolean);
  122037. /**
  122038. * Gets the perf counter used for physics time
  122039. */
  122040. get physicsTimeCounter(): PerfCounter;
  122041. /**
  122042. * Gets the physics time capture status
  122043. */
  122044. get capturePhysicsTime(): boolean;
  122045. /**
  122046. * Enable or disable the physics time capture
  122047. */
  122048. set capturePhysicsTime(value: boolean);
  122049. /**
  122050. * Gets the perf counter used for animations time
  122051. */
  122052. get animationsTimeCounter(): PerfCounter;
  122053. /**
  122054. * Gets the animations time capture status
  122055. */
  122056. get captureAnimationsTime(): boolean;
  122057. /**
  122058. * Enable or disable the animations time capture
  122059. */
  122060. set captureAnimationsTime(value: boolean);
  122061. /**
  122062. * Gets the perf counter used for frame time capture
  122063. */
  122064. get frameTimeCounter(): PerfCounter;
  122065. /**
  122066. * Gets the frame time capture status
  122067. */
  122068. get captureFrameTime(): boolean;
  122069. /**
  122070. * Enable or disable the frame time capture
  122071. */
  122072. set captureFrameTime(value: boolean);
  122073. /**
  122074. * Gets the perf counter used for inter-frames time capture
  122075. */
  122076. get interFrameTimeCounter(): PerfCounter;
  122077. /**
  122078. * Gets the inter-frames time capture status
  122079. */
  122080. get captureInterFrameTime(): boolean;
  122081. /**
  122082. * Enable or disable the inter-frames time capture
  122083. */
  122084. set captureInterFrameTime(value: boolean);
  122085. /**
  122086. * Gets the perf counter used for render time capture
  122087. */
  122088. get renderTimeCounter(): PerfCounter;
  122089. /**
  122090. * Gets the render time capture status
  122091. */
  122092. get captureRenderTime(): boolean;
  122093. /**
  122094. * Enable or disable the render time capture
  122095. */
  122096. set captureRenderTime(value: boolean);
  122097. /**
  122098. * Gets the perf counter used for camera render time capture
  122099. */
  122100. get cameraRenderTimeCounter(): PerfCounter;
  122101. /**
  122102. * Gets the camera render time capture status
  122103. */
  122104. get captureCameraRenderTime(): boolean;
  122105. /**
  122106. * Enable or disable the camera render time capture
  122107. */
  122108. set captureCameraRenderTime(value: boolean);
  122109. /**
  122110. * Gets the perf counter used for draw calls
  122111. */
  122112. get drawCallsCounter(): PerfCounter;
  122113. /**
  122114. * Instantiates a new scene instrumentation.
  122115. * This class can be used to get instrumentation data from a Babylon engine
  122116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122117. * @param scene Defines the scene to instrument
  122118. */
  122119. constructor(
  122120. /**
  122121. * Defines the scene to instrument
  122122. */
  122123. scene: Scene);
  122124. /**
  122125. * Dispose and release associated resources.
  122126. */
  122127. dispose(): void;
  122128. }
  122129. }
  122130. declare module BABYLON {
  122131. /** @hidden */
  122132. export var glowMapGenerationPixelShader: {
  122133. name: string;
  122134. shader: string;
  122135. };
  122136. }
  122137. declare module BABYLON {
  122138. /** @hidden */
  122139. export var glowMapGenerationVertexShader: {
  122140. name: string;
  122141. shader: string;
  122142. };
  122143. }
  122144. declare module BABYLON {
  122145. /**
  122146. * Effect layer options. This helps customizing the behaviour
  122147. * of the effect layer.
  122148. */
  122149. export interface IEffectLayerOptions {
  122150. /**
  122151. * Multiplication factor apply to the canvas size to compute the render target size
  122152. * used to generated the objects (the smaller the faster).
  122153. */
  122154. mainTextureRatio: number;
  122155. /**
  122156. * Enforces a fixed size texture to ensure effect stability across devices.
  122157. */
  122158. mainTextureFixedSize?: number;
  122159. /**
  122160. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122161. */
  122162. alphaBlendingMode: number;
  122163. /**
  122164. * The camera attached to the layer.
  122165. */
  122166. camera: Nullable<Camera>;
  122167. /**
  122168. * The rendering group to draw the layer in.
  122169. */
  122170. renderingGroupId: number;
  122171. }
  122172. /**
  122173. * The effect layer Helps adding post process effect blended with the main pass.
  122174. *
  122175. * This can be for instance use to generate glow or higlight effects on the scene.
  122176. *
  122177. * The effect layer class can not be used directly and is intented to inherited from to be
  122178. * customized per effects.
  122179. */
  122180. export abstract class EffectLayer {
  122181. private _vertexBuffers;
  122182. private _indexBuffer;
  122183. private _cachedDefines;
  122184. private _effectLayerMapGenerationEffect;
  122185. private _effectLayerOptions;
  122186. private _mergeEffect;
  122187. protected _scene: Scene;
  122188. protected _engine: Engine;
  122189. protected _maxSize: number;
  122190. protected _mainTextureDesiredSize: ISize;
  122191. protected _mainTexture: RenderTargetTexture;
  122192. protected _shouldRender: boolean;
  122193. protected _postProcesses: PostProcess[];
  122194. protected _textures: BaseTexture[];
  122195. protected _emissiveTextureAndColor: {
  122196. texture: Nullable<BaseTexture>;
  122197. color: Color4;
  122198. };
  122199. /**
  122200. * The name of the layer
  122201. */
  122202. name: string;
  122203. /**
  122204. * The clear color of the texture used to generate the glow map.
  122205. */
  122206. neutralColor: Color4;
  122207. /**
  122208. * Specifies wether the highlight layer is enabled or not.
  122209. */
  122210. isEnabled: boolean;
  122211. /**
  122212. * Gets the camera attached to the layer.
  122213. */
  122214. get camera(): Nullable<Camera>;
  122215. /**
  122216. * Gets the rendering group id the layer should render in.
  122217. */
  122218. get renderingGroupId(): number;
  122219. set renderingGroupId(renderingGroupId: number);
  122220. /**
  122221. * An event triggered when the effect layer has been disposed.
  122222. */
  122223. onDisposeObservable: Observable<EffectLayer>;
  122224. /**
  122225. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122226. */
  122227. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122228. /**
  122229. * An event triggered when the generated texture is being merged in the scene.
  122230. */
  122231. onBeforeComposeObservable: Observable<EffectLayer>;
  122232. /**
  122233. * An event triggered when the mesh is rendered into the effect render target.
  122234. */
  122235. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122236. /**
  122237. * An event triggered after the mesh has been rendered into the effect render target.
  122238. */
  122239. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122240. /**
  122241. * An event triggered when the generated texture has been merged in the scene.
  122242. */
  122243. onAfterComposeObservable: Observable<EffectLayer>;
  122244. /**
  122245. * An event triggered when the efffect layer changes its size.
  122246. */
  122247. onSizeChangedObservable: Observable<EffectLayer>;
  122248. /** @hidden */
  122249. static _SceneComponentInitialization: (scene: Scene) => void;
  122250. /**
  122251. * Instantiates a new effect Layer and references it in the scene.
  122252. * @param name The name of the layer
  122253. * @param scene The scene to use the layer in
  122254. */
  122255. constructor(
  122256. /** The Friendly of the effect in the scene */
  122257. name: string, scene: Scene);
  122258. /**
  122259. * Get the effect name of the layer.
  122260. * @return The effect name
  122261. */
  122262. abstract getEffectName(): string;
  122263. /**
  122264. * Checks for the readiness of the element composing the layer.
  122265. * @param subMesh the mesh to check for
  122266. * @param useInstances specify wether or not to use instances to render the mesh
  122267. * @return true if ready otherwise, false
  122268. */
  122269. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122270. /**
  122271. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122272. * @returns true if the effect requires stencil during the main canvas render pass.
  122273. */
  122274. abstract needStencil(): boolean;
  122275. /**
  122276. * Create the merge effect. This is the shader use to blit the information back
  122277. * to the main canvas at the end of the scene rendering.
  122278. * @returns The effect containing the shader used to merge the effect on the main canvas
  122279. */
  122280. protected abstract _createMergeEffect(): Effect;
  122281. /**
  122282. * Creates the render target textures and post processes used in the effect layer.
  122283. */
  122284. protected abstract _createTextureAndPostProcesses(): void;
  122285. /**
  122286. * Implementation specific of rendering the generating effect on the main canvas.
  122287. * @param effect The effect used to render through
  122288. */
  122289. protected abstract _internalRender(effect: Effect): void;
  122290. /**
  122291. * Sets the required values for both the emissive texture and and the main color.
  122292. */
  122293. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122294. /**
  122295. * Free any resources and references associated to a mesh.
  122296. * Internal use
  122297. * @param mesh The mesh to free.
  122298. */
  122299. abstract _disposeMesh(mesh: Mesh): void;
  122300. /**
  122301. * Serializes this layer (Glow or Highlight for example)
  122302. * @returns a serialized layer object
  122303. */
  122304. abstract serialize?(): any;
  122305. /**
  122306. * Initializes the effect layer with the required options.
  122307. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122308. */
  122309. protected _init(options: Partial<IEffectLayerOptions>): void;
  122310. /**
  122311. * Generates the index buffer of the full screen quad blending to the main canvas.
  122312. */
  122313. private _generateIndexBuffer;
  122314. /**
  122315. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122316. */
  122317. private _generateVertexBuffer;
  122318. /**
  122319. * Sets the main texture desired size which is the closest power of two
  122320. * of the engine canvas size.
  122321. */
  122322. private _setMainTextureSize;
  122323. /**
  122324. * Creates the main texture for the effect layer.
  122325. */
  122326. protected _createMainTexture(): void;
  122327. /**
  122328. * Adds specific effects defines.
  122329. * @param defines The defines to add specifics to.
  122330. */
  122331. protected _addCustomEffectDefines(defines: string[]): void;
  122332. /**
  122333. * Checks for the readiness of the element composing the layer.
  122334. * @param subMesh the mesh to check for
  122335. * @param useInstances specify wether or not to use instances to render the mesh
  122336. * @param emissiveTexture the associated emissive texture used to generate the glow
  122337. * @return true if ready otherwise, false
  122338. */
  122339. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122340. /**
  122341. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122342. */
  122343. render(): void;
  122344. /**
  122345. * Determine if a given mesh will be used in the current effect.
  122346. * @param mesh mesh to test
  122347. * @returns true if the mesh will be used
  122348. */
  122349. hasMesh(mesh: AbstractMesh): boolean;
  122350. /**
  122351. * Returns true if the layer contains information to display, otherwise false.
  122352. * @returns true if the glow layer should be rendered
  122353. */
  122354. shouldRender(): boolean;
  122355. /**
  122356. * Returns true if the mesh should render, otherwise false.
  122357. * @param mesh The mesh to render
  122358. * @returns true if it should render otherwise false
  122359. */
  122360. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122361. /**
  122362. * Returns true if the mesh can be rendered, otherwise false.
  122363. * @param mesh The mesh to render
  122364. * @param material The material used on the mesh
  122365. * @returns true if it can be rendered otherwise false
  122366. */
  122367. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122368. /**
  122369. * Returns true if the mesh should render, otherwise false.
  122370. * @param mesh The mesh to render
  122371. * @returns true if it should render otherwise false
  122372. */
  122373. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122374. /**
  122375. * Renders the submesh passed in parameter to the generation map.
  122376. */
  122377. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122378. /**
  122379. * Defines wether the current material of the mesh should be use to render the effect.
  122380. * @param mesh defines the current mesh to render
  122381. */
  122382. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122383. /**
  122384. * Rebuild the required buffers.
  122385. * @hidden Internal use only.
  122386. */
  122387. _rebuild(): void;
  122388. /**
  122389. * Dispose only the render target textures and post process.
  122390. */
  122391. private _disposeTextureAndPostProcesses;
  122392. /**
  122393. * Dispose the highlight layer and free resources.
  122394. */
  122395. dispose(): void;
  122396. /**
  122397. * Gets the class name of the effect layer
  122398. * @returns the string with the class name of the effect layer
  122399. */
  122400. getClassName(): string;
  122401. /**
  122402. * Creates an effect layer from parsed effect layer data
  122403. * @param parsedEffectLayer defines effect layer data
  122404. * @param scene defines the current scene
  122405. * @param rootUrl defines the root URL containing the effect layer information
  122406. * @returns a parsed effect Layer
  122407. */
  122408. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122409. }
  122410. }
  122411. declare module BABYLON {
  122412. interface AbstractScene {
  122413. /**
  122414. * The list of effect layers (highlights/glow) added to the scene
  122415. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122416. * @see http://doc.babylonjs.com/how_to/glow_layer
  122417. */
  122418. effectLayers: Array<EffectLayer>;
  122419. /**
  122420. * Removes the given effect layer from this scene.
  122421. * @param toRemove defines the effect layer to remove
  122422. * @returns the index of the removed effect layer
  122423. */
  122424. removeEffectLayer(toRemove: EffectLayer): number;
  122425. /**
  122426. * Adds the given effect layer to this scene
  122427. * @param newEffectLayer defines the effect layer to add
  122428. */
  122429. addEffectLayer(newEffectLayer: EffectLayer): void;
  122430. }
  122431. /**
  122432. * Defines the layer scene component responsible to manage any effect layers
  122433. * in a given scene.
  122434. */
  122435. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122436. /**
  122437. * The component name helpfull to identify the component in the list of scene components.
  122438. */
  122439. readonly name: string;
  122440. /**
  122441. * The scene the component belongs to.
  122442. */
  122443. scene: Scene;
  122444. private _engine;
  122445. private _renderEffects;
  122446. private _needStencil;
  122447. private _previousStencilState;
  122448. /**
  122449. * Creates a new instance of the component for the given scene
  122450. * @param scene Defines the scene to register the component in
  122451. */
  122452. constructor(scene: Scene);
  122453. /**
  122454. * Registers the component in a given scene
  122455. */
  122456. register(): void;
  122457. /**
  122458. * Rebuilds the elements related to this component in case of
  122459. * context lost for instance.
  122460. */
  122461. rebuild(): void;
  122462. /**
  122463. * Serializes the component data to the specified json object
  122464. * @param serializationObject The object to serialize to
  122465. */
  122466. serialize(serializationObject: any): void;
  122467. /**
  122468. * Adds all the elements from the container to the scene
  122469. * @param container the container holding the elements
  122470. */
  122471. addFromContainer(container: AbstractScene): void;
  122472. /**
  122473. * Removes all the elements in the container from the scene
  122474. * @param container contains the elements to remove
  122475. * @param dispose if the removed element should be disposed (default: false)
  122476. */
  122477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122478. /**
  122479. * Disposes the component and the associated ressources.
  122480. */
  122481. dispose(): void;
  122482. private _isReadyForMesh;
  122483. private _renderMainTexture;
  122484. private _setStencil;
  122485. private _setStencilBack;
  122486. private _draw;
  122487. private _drawCamera;
  122488. private _drawRenderingGroup;
  122489. }
  122490. }
  122491. declare module BABYLON {
  122492. /** @hidden */
  122493. export var glowMapMergePixelShader: {
  122494. name: string;
  122495. shader: string;
  122496. };
  122497. }
  122498. declare module BABYLON {
  122499. /** @hidden */
  122500. export var glowMapMergeVertexShader: {
  122501. name: string;
  122502. shader: string;
  122503. };
  122504. }
  122505. declare module BABYLON {
  122506. interface AbstractScene {
  122507. /**
  122508. * Return a the first highlight layer of the scene with a given name.
  122509. * @param name The name of the highlight layer to look for.
  122510. * @return The highlight layer if found otherwise null.
  122511. */
  122512. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122513. }
  122514. /**
  122515. * Glow layer options. This helps customizing the behaviour
  122516. * of the glow layer.
  122517. */
  122518. export interface IGlowLayerOptions {
  122519. /**
  122520. * Multiplication factor apply to the canvas size to compute the render target size
  122521. * used to generated the glowing objects (the smaller the faster).
  122522. */
  122523. mainTextureRatio: number;
  122524. /**
  122525. * Enforces a fixed size texture to ensure resize independant blur.
  122526. */
  122527. mainTextureFixedSize?: number;
  122528. /**
  122529. * How big is the kernel of the blur texture.
  122530. */
  122531. blurKernelSize: number;
  122532. /**
  122533. * The camera attached to the layer.
  122534. */
  122535. camera: Nullable<Camera>;
  122536. /**
  122537. * Enable MSAA by chosing the number of samples.
  122538. */
  122539. mainTextureSamples?: number;
  122540. /**
  122541. * The rendering group to draw the layer in.
  122542. */
  122543. renderingGroupId: number;
  122544. }
  122545. /**
  122546. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122547. *
  122548. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122549. *
  122550. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122551. */
  122552. export class GlowLayer extends EffectLayer {
  122553. /**
  122554. * Effect Name of the layer.
  122555. */
  122556. static readonly EffectName: string;
  122557. /**
  122558. * The default blur kernel size used for the glow.
  122559. */
  122560. static DefaultBlurKernelSize: number;
  122561. /**
  122562. * The default texture size ratio used for the glow.
  122563. */
  122564. static DefaultTextureRatio: number;
  122565. /**
  122566. * Sets the kernel size of the blur.
  122567. */
  122568. set blurKernelSize(value: number);
  122569. /**
  122570. * Gets the kernel size of the blur.
  122571. */
  122572. get blurKernelSize(): number;
  122573. /**
  122574. * Sets the glow intensity.
  122575. */
  122576. set intensity(value: number);
  122577. /**
  122578. * Gets the glow intensity.
  122579. */
  122580. get intensity(): number;
  122581. private _options;
  122582. private _intensity;
  122583. private _horizontalBlurPostprocess1;
  122584. private _verticalBlurPostprocess1;
  122585. private _horizontalBlurPostprocess2;
  122586. private _verticalBlurPostprocess2;
  122587. private _blurTexture1;
  122588. private _blurTexture2;
  122589. private _postProcesses1;
  122590. private _postProcesses2;
  122591. private _includedOnlyMeshes;
  122592. private _excludedMeshes;
  122593. private _meshesUsingTheirOwnMaterials;
  122594. /**
  122595. * Callback used to let the user override the color selection on a per mesh basis
  122596. */
  122597. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122598. /**
  122599. * Callback used to let the user override the texture selection on a per mesh basis
  122600. */
  122601. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122602. /**
  122603. * Instantiates a new glow Layer and references it to the scene.
  122604. * @param name The name of the layer
  122605. * @param scene The scene to use the layer in
  122606. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122607. */
  122608. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122609. /**
  122610. * Get the effect name of the layer.
  122611. * @return The effect name
  122612. */
  122613. getEffectName(): string;
  122614. /**
  122615. * Create the merge effect. This is the shader use to blit the information back
  122616. * to the main canvas at the end of the scene rendering.
  122617. */
  122618. protected _createMergeEffect(): Effect;
  122619. /**
  122620. * Creates the render target textures and post processes used in the glow layer.
  122621. */
  122622. protected _createTextureAndPostProcesses(): void;
  122623. /**
  122624. * Checks for the readiness of the element composing the layer.
  122625. * @param subMesh the mesh to check for
  122626. * @param useInstances specify wether or not to use instances to render the mesh
  122627. * @param emissiveTexture the associated emissive texture used to generate the glow
  122628. * @return true if ready otherwise, false
  122629. */
  122630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122631. /**
  122632. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122633. */
  122634. needStencil(): boolean;
  122635. /**
  122636. * Returns true if the mesh can be rendered, otherwise false.
  122637. * @param mesh The mesh to render
  122638. * @param material The material used on the mesh
  122639. * @returns true if it can be rendered otherwise false
  122640. */
  122641. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122642. /**
  122643. * Implementation specific of rendering the generating effect on the main canvas.
  122644. * @param effect The effect used to render through
  122645. */
  122646. protected _internalRender(effect: Effect): void;
  122647. /**
  122648. * Sets the required values for both the emissive texture and and the main color.
  122649. */
  122650. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122651. /**
  122652. * Returns true if the mesh should render, otherwise false.
  122653. * @param mesh The mesh to render
  122654. * @returns true if it should render otherwise false
  122655. */
  122656. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122657. /**
  122658. * Adds specific effects defines.
  122659. * @param defines The defines to add specifics to.
  122660. */
  122661. protected _addCustomEffectDefines(defines: string[]): void;
  122662. /**
  122663. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122664. * @param mesh The mesh to exclude from the glow layer
  122665. */
  122666. addExcludedMesh(mesh: Mesh): void;
  122667. /**
  122668. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122669. * @param mesh The mesh to remove
  122670. */
  122671. removeExcludedMesh(mesh: Mesh): void;
  122672. /**
  122673. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122674. * @param mesh The mesh to include in the glow layer
  122675. */
  122676. addIncludedOnlyMesh(mesh: Mesh): void;
  122677. /**
  122678. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122679. * @param mesh The mesh to remove
  122680. */
  122681. removeIncludedOnlyMesh(mesh: Mesh): void;
  122682. /**
  122683. * Determine if a given mesh will be used in the glow layer
  122684. * @param mesh The mesh to test
  122685. * @returns true if the mesh will be highlighted by the current glow layer
  122686. */
  122687. hasMesh(mesh: AbstractMesh): boolean;
  122688. /**
  122689. * Defines wether the current material of the mesh should be use to render the effect.
  122690. * @param mesh defines the current mesh to render
  122691. */
  122692. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122693. /**
  122694. * Add a mesh to be rendered through its own material and not with emissive only.
  122695. * @param mesh The mesh for which we need to use its material
  122696. */
  122697. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122698. /**
  122699. * Remove a mesh from being rendered through its own material and not with emissive only.
  122700. * @param mesh The mesh for which we need to not use its material
  122701. */
  122702. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122703. /**
  122704. * Free any resources and references associated to a mesh.
  122705. * Internal use
  122706. * @param mesh The mesh to free.
  122707. * @hidden
  122708. */
  122709. _disposeMesh(mesh: Mesh): void;
  122710. /**
  122711. * Gets the class name of the effect layer
  122712. * @returns the string with the class name of the effect layer
  122713. */
  122714. getClassName(): string;
  122715. /**
  122716. * Serializes this glow layer
  122717. * @returns a serialized glow layer object
  122718. */
  122719. serialize(): any;
  122720. /**
  122721. * Creates a Glow Layer from parsed glow layer data
  122722. * @param parsedGlowLayer defines glow layer data
  122723. * @param scene defines the current scene
  122724. * @param rootUrl defines the root URL containing the glow layer information
  122725. * @returns a parsed Glow Layer
  122726. */
  122727. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122728. }
  122729. }
  122730. declare module BABYLON {
  122731. /** @hidden */
  122732. export var glowBlurPostProcessPixelShader: {
  122733. name: string;
  122734. shader: string;
  122735. };
  122736. }
  122737. declare module BABYLON {
  122738. interface AbstractScene {
  122739. /**
  122740. * Return a the first highlight layer of the scene with a given name.
  122741. * @param name The name of the highlight layer to look for.
  122742. * @return The highlight layer if found otherwise null.
  122743. */
  122744. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122745. }
  122746. /**
  122747. * Highlight layer options. This helps customizing the behaviour
  122748. * of the highlight layer.
  122749. */
  122750. export interface IHighlightLayerOptions {
  122751. /**
  122752. * Multiplication factor apply to the canvas size to compute the render target size
  122753. * used to generated the glowing objects (the smaller the faster).
  122754. */
  122755. mainTextureRatio: number;
  122756. /**
  122757. * Enforces a fixed size texture to ensure resize independant blur.
  122758. */
  122759. mainTextureFixedSize?: number;
  122760. /**
  122761. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122762. * of the picture to blur (the smaller the faster).
  122763. */
  122764. blurTextureSizeRatio: number;
  122765. /**
  122766. * How big in texel of the blur texture is the vertical blur.
  122767. */
  122768. blurVerticalSize: number;
  122769. /**
  122770. * How big in texel of the blur texture is the horizontal blur.
  122771. */
  122772. blurHorizontalSize: number;
  122773. /**
  122774. * Alpha blending mode used to apply the blur. Default is combine.
  122775. */
  122776. alphaBlendingMode: number;
  122777. /**
  122778. * The camera attached to the layer.
  122779. */
  122780. camera: Nullable<Camera>;
  122781. /**
  122782. * Should we display highlight as a solid stroke?
  122783. */
  122784. isStroke?: boolean;
  122785. /**
  122786. * The rendering group to draw the layer in.
  122787. */
  122788. renderingGroupId: number;
  122789. }
  122790. /**
  122791. * The highlight layer Helps adding a glow effect around a mesh.
  122792. *
  122793. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122794. * glowy meshes to your scene.
  122795. *
  122796. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122797. */
  122798. export class HighlightLayer extends EffectLayer {
  122799. name: string;
  122800. /**
  122801. * Effect Name of the highlight layer.
  122802. */
  122803. static readonly EffectName: string;
  122804. /**
  122805. * The neutral color used during the preparation of the glow effect.
  122806. * This is black by default as the blend operation is a blend operation.
  122807. */
  122808. static NeutralColor: Color4;
  122809. /**
  122810. * Stencil value used for glowing meshes.
  122811. */
  122812. static GlowingMeshStencilReference: number;
  122813. /**
  122814. * Stencil value used for the other meshes in the scene.
  122815. */
  122816. static NormalMeshStencilReference: number;
  122817. /**
  122818. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122819. */
  122820. innerGlow: boolean;
  122821. /**
  122822. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122823. */
  122824. outerGlow: boolean;
  122825. /**
  122826. * Specifies the horizontal size of the blur.
  122827. */
  122828. set blurHorizontalSize(value: number);
  122829. /**
  122830. * Specifies the vertical size of the blur.
  122831. */
  122832. set blurVerticalSize(value: number);
  122833. /**
  122834. * Gets the horizontal size of the blur.
  122835. */
  122836. get blurHorizontalSize(): number;
  122837. /**
  122838. * Gets the vertical size of the blur.
  122839. */
  122840. get blurVerticalSize(): number;
  122841. /**
  122842. * An event triggered when the highlight layer is being blurred.
  122843. */
  122844. onBeforeBlurObservable: Observable<HighlightLayer>;
  122845. /**
  122846. * An event triggered when the highlight layer has been blurred.
  122847. */
  122848. onAfterBlurObservable: Observable<HighlightLayer>;
  122849. private _instanceGlowingMeshStencilReference;
  122850. private _options;
  122851. private _downSamplePostprocess;
  122852. private _horizontalBlurPostprocess;
  122853. private _verticalBlurPostprocess;
  122854. private _blurTexture;
  122855. private _meshes;
  122856. private _excludedMeshes;
  122857. /**
  122858. * Instantiates a new highlight Layer and references it to the scene..
  122859. * @param name The name of the layer
  122860. * @param scene The scene to use the layer in
  122861. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  122862. */
  122863. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  122864. /**
  122865. * Get the effect name of the layer.
  122866. * @return The effect name
  122867. */
  122868. getEffectName(): string;
  122869. /**
  122870. * Create the merge effect. This is the shader use to blit the information back
  122871. * to the main canvas at the end of the scene rendering.
  122872. */
  122873. protected _createMergeEffect(): Effect;
  122874. /**
  122875. * Creates the render target textures and post processes used in the highlight layer.
  122876. */
  122877. protected _createTextureAndPostProcesses(): void;
  122878. /**
  122879. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122880. */
  122881. needStencil(): boolean;
  122882. /**
  122883. * Checks for the readiness of the element composing the layer.
  122884. * @param subMesh the mesh to check for
  122885. * @param useInstances specify wether or not to use instances to render the mesh
  122886. * @param emissiveTexture the associated emissive texture used to generate the glow
  122887. * @return true if ready otherwise, false
  122888. */
  122889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122890. /**
  122891. * Implementation specific of rendering the generating effect on the main canvas.
  122892. * @param effect The effect used to render through
  122893. */
  122894. protected _internalRender(effect: Effect): void;
  122895. /**
  122896. * Returns true if the layer contains information to display, otherwise false.
  122897. */
  122898. shouldRender(): boolean;
  122899. /**
  122900. * Returns true if the mesh should render, otherwise false.
  122901. * @param mesh The mesh to render
  122902. * @returns true if it should render otherwise false
  122903. */
  122904. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122905. /**
  122906. * Sets the required values for both the emissive texture and and the main color.
  122907. */
  122908. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122909. /**
  122910. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  122911. * @param mesh The mesh to exclude from the highlight layer
  122912. */
  122913. addExcludedMesh(mesh: Mesh): void;
  122914. /**
  122915. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  122916. * @param mesh The mesh to highlight
  122917. */
  122918. removeExcludedMesh(mesh: Mesh): void;
  122919. /**
  122920. * Determine if a given mesh will be highlighted by the current HighlightLayer
  122921. * @param mesh mesh to test
  122922. * @returns true if the mesh will be highlighted by the current HighlightLayer
  122923. */
  122924. hasMesh(mesh: AbstractMesh): boolean;
  122925. /**
  122926. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  122927. * @param mesh The mesh to highlight
  122928. * @param color The color of the highlight
  122929. * @param glowEmissiveOnly Extract the glow from the emissive texture
  122930. */
  122931. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  122932. /**
  122933. * Remove a mesh from the highlight layer in order to make it stop glowing.
  122934. * @param mesh The mesh to highlight
  122935. */
  122936. removeMesh(mesh: Mesh): void;
  122937. /**
  122938. * Force the stencil to the normal expected value for none glowing parts
  122939. */
  122940. private _defaultStencilReference;
  122941. /**
  122942. * Free any resources and references associated to a mesh.
  122943. * Internal use
  122944. * @param mesh The mesh to free.
  122945. * @hidden
  122946. */
  122947. _disposeMesh(mesh: Mesh): void;
  122948. /**
  122949. * Dispose the highlight layer and free resources.
  122950. */
  122951. dispose(): void;
  122952. /**
  122953. * Gets the class name of the effect layer
  122954. * @returns the string with the class name of the effect layer
  122955. */
  122956. getClassName(): string;
  122957. /**
  122958. * Serializes this Highlight layer
  122959. * @returns a serialized Highlight layer object
  122960. */
  122961. serialize(): any;
  122962. /**
  122963. * Creates a Highlight layer from parsed Highlight layer data
  122964. * @param parsedHightlightLayer defines the Highlight layer data
  122965. * @param scene defines the current scene
  122966. * @param rootUrl defines the root URL containing the Highlight layer information
  122967. * @returns a parsed Highlight layer
  122968. */
  122969. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  122970. }
  122971. }
  122972. declare module BABYLON {
  122973. interface AbstractScene {
  122974. /**
  122975. * The list of layers (background and foreground) of the scene
  122976. */
  122977. layers: Array<Layer>;
  122978. }
  122979. /**
  122980. * Defines the layer scene component responsible to manage any layers
  122981. * in a given scene.
  122982. */
  122983. export class LayerSceneComponent implements ISceneComponent {
  122984. /**
  122985. * The component name helpfull to identify the component in the list of scene components.
  122986. */
  122987. readonly name: string;
  122988. /**
  122989. * The scene the component belongs to.
  122990. */
  122991. scene: Scene;
  122992. private _engine;
  122993. /**
  122994. * Creates a new instance of the component for the given scene
  122995. * @param scene Defines the scene to register the component in
  122996. */
  122997. constructor(scene: Scene);
  122998. /**
  122999. * Registers the component in a given scene
  123000. */
  123001. register(): void;
  123002. /**
  123003. * Rebuilds the elements related to this component in case of
  123004. * context lost for instance.
  123005. */
  123006. rebuild(): void;
  123007. /**
  123008. * Disposes the component and the associated ressources.
  123009. */
  123010. dispose(): void;
  123011. private _draw;
  123012. private _drawCameraPredicate;
  123013. private _drawCameraBackground;
  123014. private _drawCameraForeground;
  123015. private _drawRenderTargetPredicate;
  123016. private _drawRenderTargetBackground;
  123017. private _drawRenderTargetForeground;
  123018. /**
  123019. * Adds all the elements from the container to the scene
  123020. * @param container the container holding the elements
  123021. */
  123022. addFromContainer(container: AbstractScene): void;
  123023. /**
  123024. * Removes all the elements in the container from the scene
  123025. * @param container contains the elements to remove
  123026. * @param dispose if the removed element should be disposed (default: false)
  123027. */
  123028. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /** @hidden */
  123033. export var layerPixelShader: {
  123034. name: string;
  123035. shader: string;
  123036. };
  123037. }
  123038. declare module BABYLON {
  123039. /** @hidden */
  123040. export var layerVertexShader: {
  123041. name: string;
  123042. shader: string;
  123043. };
  123044. }
  123045. declare module BABYLON {
  123046. /**
  123047. * This represents a full screen 2d layer.
  123048. * This can be useful to display a picture in the background of your scene for instance.
  123049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123050. */
  123051. export class Layer {
  123052. /**
  123053. * Define the name of the layer.
  123054. */
  123055. name: string;
  123056. /**
  123057. * Define the texture the layer should display.
  123058. */
  123059. texture: Nullable<Texture>;
  123060. /**
  123061. * Is the layer in background or foreground.
  123062. */
  123063. isBackground: boolean;
  123064. /**
  123065. * Define the color of the layer (instead of texture).
  123066. */
  123067. color: Color4;
  123068. /**
  123069. * Define the scale of the layer in order to zoom in out of the texture.
  123070. */
  123071. scale: Vector2;
  123072. /**
  123073. * Define an offset for the layer in order to shift the texture.
  123074. */
  123075. offset: Vector2;
  123076. /**
  123077. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123078. */
  123079. alphaBlendingMode: number;
  123080. /**
  123081. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123082. * Alpha test will not mix with the background color in case of transparency.
  123083. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123084. */
  123085. alphaTest: boolean;
  123086. /**
  123087. * Define a mask to restrict the layer to only some of the scene cameras.
  123088. */
  123089. layerMask: number;
  123090. /**
  123091. * Define the list of render target the layer is visible into.
  123092. */
  123093. renderTargetTextures: RenderTargetTexture[];
  123094. /**
  123095. * Define if the layer is only used in renderTarget or if it also
  123096. * renders in the main frame buffer of the canvas.
  123097. */
  123098. renderOnlyInRenderTargetTextures: boolean;
  123099. private _scene;
  123100. private _vertexBuffers;
  123101. private _indexBuffer;
  123102. private _effect;
  123103. private _previousDefines;
  123104. /**
  123105. * An event triggered when the layer is disposed.
  123106. */
  123107. onDisposeObservable: Observable<Layer>;
  123108. private _onDisposeObserver;
  123109. /**
  123110. * Back compatibility with callback before the onDisposeObservable existed.
  123111. * The set callback will be triggered when the layer has been disposed.
  123112. */
  123113. set onDispose(callback: () => void);
  123114. /**
  123115. * An event triggered before rendering the scene
  123116. */
  123117. onBeforeRenderObservable: Observable<Layer>;
  123118. private _onBeforeRenderObserver;
  123119. /**
  123120. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123121. * The set callback will be triggered just before rendering the layer.
  123122. */
  123123. set onBeforeRender(callback: () => void);
  123124. /**
  123125. * An event triggered after rendering the scene
  123126. */
  123127. onAfterRenderObservable: Observable<Layer>;
  123128. private _onAfterRenderObserver;
  123129. /**
  123130. * Back compatibility with callback before the onAfterRenderObservable existed.
  123131. * The set callback will be triggered just after rendering the layer.
  123132. */
  123133. set onAfterRender(callback: () => void);
  123134. /**
  123135. * Instantiates a new layer.
  123136. * This represents a full screen 2d layer.
  123137. * This can be useful to display a picture in the background of your scene for instance.
  123138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123139. * @param name Define the name of the layer in the scene
  123140. * @param imgUrl Define the url of the texture to display in the layer
  123141. * @param scene Define the scene the layer belongs to
  123142. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123143. * @param color Defines a color for the layer
  123144. */
  123145. constructor(
  123146. /**
  123147. * Define the name of the layer.
  123148. */
  123149. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123150. private _createIndexBuffer;
  123151. /** @hidden */
  123152. _rebuild(): void;
  123153. /**
  123154. * Renders the layer in the scene.
  123155. */
  123156. render(): void;
  123157. /**
  123158. * Disposes and releases the associated ressources.
  123159. */
  123160. dispose(): void;
  123161. }
  123162. }
  123163. declare module BABYLON {
  123164. /** @hidden */
  123165. export var lensFlarePixelShader: {
  123166. name: string;
  123167. shader: string;
  123168. };
  123169. }
  123170. declare module BABYLON {
  123171. /** @hidden */
  123172. export var lensFlareVertexShader: {
  123173. name: string;
  123174. shader: string;
  123175. };
  123176. }
  123177. declare module BABYLON {
  123178. /**
  123179. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123180. * It is usually composed of several `lensFlare`.
  123181. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123182. */
  123183. export class LensFlareSystem {
  123184. /**
  123185. * Define the name of the lens flare system
  123186. */
  123187. name: string;
  123188. /**
  123189. * List of lens flares used in this system.
  123190. */
  123191. lensFlares: LensFlare[];
  123192. /**
  123193. * Define a limit from the border the lens flare can be visible.
  123194. */
  123195. borderLimit: number;
  123196. /**
  123197. * Define a viewport border we do not want to see the lens flare in.
  123198. */
  123199. viewportBorder: number;
  123200. /**
  123201. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123202. */
  123203. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123204. /**
  123205. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123206. */
  123207. layerMask: number;
  123208. /**
  123209. * Define the id of the lens flare system in the scene.
  123210. * (equal to name by default)
  123211. */
  123212. id: string;
  123213. private _scene;
  123214. private _emitter;
  123215. private _vertexBuffers;
  123216. private _indexBuffer;
  123217. private _effect;
  123218. private _positionX;
  123219. private _positionY;
  123220. private _isEnabled;
  123221. /** @hidden */
  123222. static _SceneComponentInitialization: (scene: Scene) => void;
  123223. /**
  123224. * Instantiates a lens flare system.
  123225. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123226. * It is usually composed of several `lensFlare`.
  123227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123228. * @param name Define the name of the lens flare system in the scene
  123229. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123230. * @param scene Define the scene the lens flare system belongs to
  123231. */
  123232. constructor(
  123233. /**
  123234. * Define the name of the lens flare system
  123235. */
  123236. name: string, emitter: any, scene: Scene);
  123237. /**
  123238. * Define if the lens flare system is enabled.
  123239. */
  123240. get isEnabled(): boolean;
  123241. set isEnabled(value: boolean);
  123242. /**
  123243. * Get the scene the effects belongs to.
  123244. * @returns the scene holding the lens flare system
  123245. */
  123246. getScene(): Scene;
  123247. /**
  123248. * Get the emitter of the lens flare system.
  123249. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123250. * @returns the emitter of the lens flare system
  123251. */
  123252. getEmitter(): any;
  123253. /**
  123254. * Set the emitter of the lens flare system.
  123255. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123256. * @param newEmitter Define the new emitter of the system
  123257. */
  123258. setEmitter(newEmitter: any): void;
  123259. /**
  123260. * Get the lens flare system emitter position.
  123261. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123262. * @returns the position
  123263. */
  123264. getEmitterPosition(): Vector3;
  123265. /**
  123266. * @hidden
  123267. */
  123268. computeEffectivePosition(globalViewport: Viewport): boolean;
  123269. /** @hidden */
  123270. _isVisible(): boolean;
  123271. /**
  123272. * @hidden
  123273. */
  123274. render(): boolean;
  123275. /**
  123276. * Dispose and release the lens flare with its associated resources.
  123277. */
  123278. dispose(): void;
  123279. /**
  123280. * Parse a lens flare system from a JSON repressentation
  123281. * @param parsedLensFlareSystem Define the JSON to parse
  123282. * @param scene Define the scene the parsed system should be instantiated in
  123283. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123284. * @returns the parsed system
  123285. */
  123286. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123287. /**
  123288. * Serialize the current Lens Flare System into a JSON representation.
  123289. * @returns the serialized JSON
  123290. */
  123291. serialize(): any;
  123292. }
  123293. }
  123294. declare module BABYLON {
  123295. /**
  123296. * This represents one of the lens effect in a `lensFlareSystem`.
  123297. * It controls one of the indiviual texture used in the effect.
  123298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123299. */
  123300. export class LensFlare {
  123301. /**
  123302. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123303. */
  123304. size: number;
  123305. /**
  123306. * 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.
  123307. */
  123308. position: number;
  123309. /**
  123310. * Define the lens color.
  123311. */
  123312. color: Color3;
  123313. /**
  123314. * Define the lens texture.
  123315. */
  123316. texture: Nullable<Texture>;
  123317. /**
  123318. * Define the alpha mode to render this particular lens.
  123319. */
  123320. alphaMode: number;
  123321. private _system;
  123322. /**
  123323. * Creates a new Lens Flare.
  123324. * This represents one of the lens effect in a `lensFlareSystem`.
  123325. * It controls one of the indiviual texture used in the effect.
  123326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123327. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123328. * @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.
  123329. * @param color Define the lens color
  123330. * @param imgUrl Define the lens texture url
  123331. * @param system Define the `lensFlareSystem` this flare is part of
  123332. * @returns The newly created Lens Flare
  123333. */
  123334. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123335. /**
  123336. * Instantiates a new Lens Flare.
  123337. * This represents one of the lens effect in a `lensFlareSystem`.
  123338. * It controls one of the indiviual texture used in the effect.
  123339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123340. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123341. * @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.
  123342. * @param color Define the lens color
  123343. * @param imgUrl Define the lens texture url
  123344. * @param system Define the `lensFlareSystem` this flare is part of
  123345. */
  123346. constructor(
  123347. /**
  123348. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123349. */
  123350. size: number,
  123351. /**
  123352. * 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.
  123353. */
  123354. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123355. /**
  123356. * Dispose and release the lens flare with its associated resources.
  123357. */
  123358. dispose(): void;
  123359. }
  123360. }
  123361. declare module BABYLON {
  123362. interface AbstractScene {
  123363. /**
  123364. * The list of lens flare system added to the scene
  123365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123366. */
  123367. lensFlareSystems: Array<LensFlareSystem>;
  123368. /**
  123369. * Removes the given lens flare system from this scene.
  123370. * @param toRemove The lens flare system to remove
  123371. * @returns The index of the removed lens flare system
  123372. */
  123373. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123374. /**
  123375. * Adds the given lens flare system to this scene
  123376. * @param newLensFlareSystem The lens flare system to add
  123377. */
  123378. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123379. /**
  123380. * Gets a lens flare system using its name
  123381. * @param name defines the name to look for
  123382. * @returns the lens flare system or null if not found
  123383. */
  123384. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123385. /**
  123386. * Gets a lens flare system using its id
  123387. * @param id defines the id to look for
  123388. * @returns the lens flare system or null if not found
  123389. */
  123390. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123391. }
  123392. /**
  123393. * Defines the lens flare scene component responsible to manage any lens flares
  123394. * in a given scene.
  123395. */
  123396. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123397. /**
  123398. * The component name helpfull to identify the component in the list of scene components.
  123399. */
  123400. readonly name: string;
  123401. /**
  123402. * The scene the component belongs to.
  123403. */
  123404. scene: Scene;
  123405. /**
  123406. * Creates a new instance of the component for the given scene
  123407. * @param scene Defines the scene to register the component in
  123408. */
  123409. constructor(scene: Scene);
  123410. /**
  123411. * Registers the component in a given scene
  123412. */
  123413. register(): void;
  123414. /**
  123415. * Rebuilds the elements related to this component in case of
  123416. * context lost for instance.
  123417. */
  123418. rebuild(): void;
  123419. /**
  123420. * Adds all the elements from the container to the scene
  123421. * @param container the container holding the elements
  123422. */
  123423. addFromContainer(container: AbstractScene): void;
  123424. /**
  123425. * Removes all the elements in the container from the scene
  123426. * @param container contains the elements to remove
  123427. * @param dispose if the removed element should be disposed (default: false)
  123428. */
  123429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123430. /**
  123431. * Serializes the component data to the specified json object
  123432. * @param serializationObject The object to serialize to
  123433. */
  123434. serialize(serializationObject: any): void;
  123435. /**
  123436. * Disposes the component and the associated ressources.
  123437. */
  123438. dispose(): void;
  123439. private _draw;
  123440. }
  123441. }
  123442. declare module BABYLON {
  123443. /**
  123444. * Defines the shadow generator component responsible to manage any shadow generators
  123445. * in a given scene.
  123446. */
  123447. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123448. /**
  123449. * The component name helpfull to identify the component in the list of scene components.
  123450. */
  123451. readonly name: string;
  123452. /**
  123453. * The scene the component belongs to.
  123454. */
  123455. scene: Scene;
  123456. /**
  123457. * Creates a new instance of the component for the given scene
  123458. * @param scene Defines the scene to register the component in
  123459. */
  123460. constructor(scene: Scene);
  123461. /**
  123462. * Registers the component in a given scene
  123463. */
  123464. register(): void;
  123465. /**
  123466. * Rebuilds the elements related to this component in case of
  123467. * context lost for instance.
  123468. */
  123469. rebuild(): void;
  123470. /**
  123471. * Serializes the component data to the specified json object
  123472. * @param serializationObject The object to serialize to
  123473. */
  123474. serialize(serializationObject: any): void;
  123475. /**
  123476. * Adds all the elements from the container to the scene
  123477. * @param container the container holding the elements
  123478. */
  123479. addFromContainer(container: AbstractScene): void;
  123480. /**
  123481. * Removes all the elements in the container from the scene
  123482. * @param container contains the elements to remove
  123483. * @param dispose if the removed element should be disposed (default: false)
  123484. */
  123485. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123486. /**
  123487. * Rebuilds the elements related to this component in case of
  123488. * context lost for instance.
  123489. */
  123490. dispose(): void;
  123491. private _gatherRenderTargets;
  123492. }
  123493. }
  123494. declare module BABYLON {
  123495. /**
  123496. * A point light is a light defined by an unique point in world space.
  123497. * The light is emitted in every direction from this point.
  123498. * A good example of a point light is a standard light bulb.
  123499. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123500. */
  123501. export class PointLight extends ShadowLight {
  123502. private _shadowAngle;
  123503. /**
  123504. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123505. * This specifies what angle the shadow will use to be created.
  123506. *
  123507. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123508. */
  123509. get shadowAngle(): number;
  123510. /**
  123511. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123512. * This specifies what angle the shadow will use to be created.
  123513. *
  123514. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123515. */
  123516. set shadowAngle(value: number);
  123517. /**
  123518. * Gets the direction if it has been set.
  123519. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123520. */
  123521. get direction(): Vector3;
  123522. /**
  123523. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123524. */
  123525. set direction(value: Vector3);
  123526. /**
  123527. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123528. * A PointLight emits the light in every direction.
  123529. * It can cast shadows.
  123530. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123531. * ```javascript
  123532. * var pointLight = new PointLight("pl", camera.position, scene);
  123533. * ```
  123534. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123535. * @param name The light friendly name
  123536. * @param position The position of the point light in the scene
  123537. * @param scene The scene the lights belongs to
  123538. */
  123539. constructor(name: string, position: Vector3, scene: Scene);
  123540. /**
  123541. * Returns the string "PointLight"
  123542. * @returns the class name
  123543. */
  123544. getClassName(): string;
  123545. /**
  123546. * Returns the integer 0.
  123547. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123548. */
  123549. getTypeID(): number;
  123550. /**
  123551. * Specifies wether or not the shadowmap should be a cube texture.
  123552. * @returns true if the shadowmap needs to be a cube texture.
  123553. */
  123554. needCube(): boolean;
  123555. /**
  123556. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123557. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123558. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123559. */
  123560. getShadowDirection(faceIndex?: number): Vector3;
  123561. /**
  123562. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123563. * - fov = PI / 2
  123564. * - aspect ratio : 1.0
  123565. * - z-near and far equal to the active camera minZ and maxZ.
  123566. * Returns the PointLight.
  123567. */
  123568. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123569. protected _buildUniformLayout(): void;
  123570. /**
  123571. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123572. * @param effect The effect to update
  123573. * @param lightIndex The index of the light in the effect to update
  123574. * @returns The point light
  123575. */
  123576. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123577. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123578. /**
  123579. * Prepares the list of defines specific to the light type.
  123580. * @param defines the list of defines
  123581. * @param lightIndex defines the index of the light for the effect
  123582. */
  123583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123584. }
  123585. }
  123586. declare module BABYLON {
  123587. /**
  123588. * Header information of HDR texture files.
  123589. */
  123590. export interface HDRInfo {
  123591. /**
  123592. * The height of the texture in pixels.
  123593. */
  123594. height: number;
  123595. /**
  123596. * The width of the texture in pixels.
  123597. */
  123598. width: number;
  123599. /**
  123600. * The index of the beginning of the data in the binary file.
  123601. */
  123602. dataPosition: number;
  123603. }
  123604. /**
  123605. * This groups tools to convert HDR texture to native colors array.
  123606. */
  123607. export class HDRTools {
  123608. private static Ldexp;
  123609. private static Rgbe2float;
  123610. private static readStringLine;
  123611. /**
  123612. * Reads header information from an RGBE texture stored in a native array.
  123613. * More information on this format are available here:
  123614. * https://en.wikipedia.org/wiki/RGBE_image_format
  123615. *
  123616. * @param uint8array The binary file stored in native array.
  123617. * @return The header information.
  123618. */
  123619. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123620. /**
  123621. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123622. * This RGBE texture needs to store the information as a panorama.
  123623. *
  123624. * More information on this format are available here:
  123625. * https://en.wikipedia.org/wiki/RGBE_image_format
  123626. *
  123627. * @param buffer The binary file stored in an array buffer.
  123628. * @param size The expected size of the extracted cubemap.
  123629. * @return The Cube Map information.
  123630. */
  123631. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123632. /**
  123633. * Returns the pixels data extracted from an RGBE texture.
  123634. * This pixels will be stored left to right up to down in the R G B order in one array.
  123635. *
  123636. * More information on this format are available here:
  123637. * https://en.wikipedia.org/wiki/RGBE_image_format
  123638. *
  123639. * @param uint8array The binary file stored in an array buffer.
  123640. * @param hdrInfo The header information of the file.
  123641. * @return The pixels data in RGB right to left up to down order.
  123642. */
  123643. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123644. private static RGBE_ReadPixels_RLE;
  123645. }
  123646. }
  123647. declare module BABYLON {
  123648. /**
  123649. * This represents a texture coming from an HDR input.
  123650. *
  123651. * The only supported format is currently panorama picture stored in RGBE format.
  123652. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123653. */
  123654. export class HDRCubeTexture extends BaseTexture {
  123655. private static _facesMapping;
  123656. private _generateHarmonics;
  123657. private _noMipmap;
  123658. private _textureMatrix;
  123659. private _size;
  123660. private _onLoad;
  123661. private _onError;
  123662. /**
  123663. * The texture URL.
  123664. */
  123665. url: string;
  123666. /**
  123667. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123668. */
  123669. coordinatesMode: number;
  123670. protected _isBlocking: boolean;
  123671. /**
  123672. * Sets wether or not the texture is blocking during loading.
  123673. */
  123674. set isBlocking(value: boolean);
  123675. /**
  123676. * Gets wether or not the texture is blocking during loading.
  123677. */
  123678. get isBlocking(): boolean;
  123679. protected _rotationY: number;
  123680. /**
  123681. * Sets texture matrix rotation angle around Y axis in radians.
  123682. */
  123683. set rotationY(value: number);
  123684. /**
  123685. * Gets texture matrix rotation angle around Y axis radians.
  123686. */
  123687. get rotationY(): number;
  123688. /**
  123689. * Gets or sets the center of the bounding box associated with the cube texture
  123690. * It must define where the camera used to render the texture was set
  123691. */
  123692. boundingBoxPosition: Vector3;
  123693. private _boundingBoxSize;
  123694. /**
  123695. * Gets or sets the size of the bounding box associated with the cube texture
  123696. * When defined, the cubemap will switch to local mode
  123697. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123698. * @example https://www.babylonjs-playground.com/#RNASML
  123699. */
  123700. set boundingBoxSize(value: Vector3);
  123701. get boundingBoxSize(): Vector3;
  123702. /**
  123703. * Instantiates an HDRTexture from the following parameters.
  123704. *
  123705. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123706. * @param scene The scene the texture will be used in
  123707. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123708. * @param noMipmap Forces to not generate the mipmap if true
  123709. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123710. * @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)
  123711. * @param reserved Reserved flag for internal use.
  123712. */
  123713. 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>);
  123714. /**
  123715. * Get the current class name of the texture useful for serialization or dynamic coding.
  123716. * @returns "HDRCubeTexture"
  123717. */
  123718. getClassName(): string;
  123719. /**
  123720. * Occurs when the file is raw .hdr file.
  123721. */
  123722. private loadTexture;
  123723. clone(): HDRCubeTexture;
  123724. delayLoad(): void;
  123725. /**
  123726. * Get the texture reflection matrix used to rotate/transform the reflection.
  123727. * @returns the reflection matrix
  123728. */
  123729. getReflectionTextureMatrix(): Matrix;
  123730. /**
  123731. * Set the texture reflection matrix used to rotate/transform the reflection.
  123732. * @param value Define the reflection matrix to set
  123733. */
  123734. setReflectionTextureMatrix(value: Matrix): void;
  123735. /**
  123736. * Parses a JSON representation of an HDR Texture in order to create the texture
  123737. * @param parsedTexture Define the JSON representation
  123738. * @param scene Define the scene the texture should be created in
  123739. * @param rootUrl Define the root url in case we need to load relative dependencies
  123740. * @returns the newly created texture after parsing
  123741. */
  123742. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123743. serialize(): any;
  123744. }
  123745. }
  123746. declare module BABYLON {
  123747. /**
  123748. * Class used to control physics engine
  123749. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123750. */
  123751. export class PhysicsEngine implements IPhysicsEngine {
  123752. private _physicsPlugin;
  123753. /**
  123754. * Global value used to control the smallest number supported by the simulation
  123755. */
  123756. static Epsilon: number;
  123757. private _impostors;
  123758. private _joints;
  123759. private _subTimeStep;
  123760. /**
  123761. * Gets the gravity vector used by the simulation
  123762. */
  123763. gravity: Vector3;
  123764. /**
  123765. * Factory used to create the default physics plugin.
  123766. * @returns The default physics plugin
  123767. */
  123768. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123769. /**
  123770. * Creates a new Physics Engine
  123771. * @param gravity defines the gravity vector used by the simulation
  123772. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123773. */
  123774. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123775. /**
  123776. * Sets the gravity vector used by the simulation
  123777. * @param gravity defines the gravity vector to use
  123778. */
  123779. setGravity(gravity: Vector3): void;
  123780. /**
  123781. * Set the time step of the physics engine.
  123782. * Default is 1/60.
  123783. * To slow it down, enter 1/600 for example.
  123784. * To speed it up, 1/30
  123785. * @param newTimeStep defines the new timestep to apply to this world.
  123786. */
  123787. setTimeStep(newTimeStep?: number): void;
  123788. /**
  123789. * Get the time step of the physics engine.
  123790. * @returns the current time step
  123791. */
  123792. getTimeStep(): number;
  123793. /**
  123794. * Set the sub time step of the physics engine.
  123795. * Default is 0 meaning there is no sub steps
  123796. * To increase physics resolution precision, set a small value (like 1 ms)
  123797. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123798. */
  123799. setSubTimeStep(subTimeStep?: number): void;
  123800. /**
  123801. * Get the sub time step of the physics engine.
  123802. * @returns the current sub time step
  123803. */
  123804. getSubTimeStep(): number;
  123805. /**
  123806. * Release all resources
  123807. */
  123808. dispose(): void;
  123809. /**
  123810. * Gets the name of the current physics plugin
  123811. * @returns the name of the plugin
  123812. */
  123813. getPhysicsPluginName(): string;
  123814. /**
  123815. * Adding a new impostor for the impostor tracking.
  123816. * This will be done by the impostor itself.
  123817. * @param impostor the impostor to add
  123818. */
  123819. addImpostor(impostor: PhysicsImpostor): void;
  123820. /**
  123821. * Remove an impostor from the engine.
  123822. * This impostor and its mesh will not longer be updated by the physics engine.
  123823. * @param impostor the impostor to remove
  123824. */
  123825. removeImpostor(impostor: PhysicsImpostor): void;
  123826. /**
  123827. * Add a joint to the physics engine
  123828. * @param mainImpostor defines the main impostor to which the joint is added.
  123829. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123830. * @param joint defines the joint that will connect both impostors.
  123831. */
  123832. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123833. /**
  123834. * Removes a joint from the simulation
  123835. * @param mainImpostor defines the impostor used with the joint
  123836. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123837. * @param joint defines the joint to remove
  123838. */
  123839. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123840. /**
  123841. * Called by the scene. No need to call it.
  123842. * @param delta defines the timespam between frames
  123843. */
  123844. _step(delta: number): void;
  123845. /**
  123846. * Gets the current plugin used to run the simulation
  123847. * @returns current plugin
  123848. */
  123849. getPhysicsPlugin(): IPhysicsEnginePlugin;
  123850. /**
  123851. * Gets the list of physic impostors
  123852. * @returns an array of PhysicsImpostor
  123853. */
  123854. getImpostors(): Array<PhysicsImpostor>;
  123855. /**
  123856. * Gets the impostor for a physics enabled object
  123857. * @param object defines the object impersonated by the impostor
  123858. * @returns the PhysicsImpostor or null if not found
  123859. */
  123860. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  123861. /**
  123862. * Gets the impostor for a physics body object
  123863. * @param body defines physics body used by the impostor
  123864. * @returns the PhysicsImpostor or null if not found
  123865. */
  123866. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  123867. /**
  123868. * Does a raycast in the physics world
  123869. * @param from when should the ray start?
  123870. * @param to when should the ray end?
  123871. * @returns PhysicsRaycastResult
  123872. */
  123873. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123874. }
  123875. }
  123876. declare module BABYLON {
  123877. /** @hidden */
  123878. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  123879. private _useDeltaForWorldStep;
  123880. world: any;
  123881. name: string;
  123882. private _physicsMaterials;
  123883. private _fixedTimeStep;
  123884. private _cannonRaycastResult;
  123885. private _raycastResult;
  123886. private _physicsBodysToRemoveAfterStep;
  123887. BJSCANNON: any;
  123888. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  123889. setGravity(gravity: Vector3): void;
  123890. setTimeStep(timeStep: number): void;
  123891. getTimeStep(): number;
  123892. executeStep(delta: number): void;
  123893. private _removeMarkedPhysicsBodiesFromWorld;
  123894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123896. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123897. private _processChildMeshes;
  123898. removePhysicsBody(impostor: PhysicsImpostor): void;
  123899. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123900. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123901. private _addMaterial;
  123902. private _checkWithEpsilon;
  123903. private _createShape;
  123904. private _createHeightmap;
  123905. private _minus90X;
  123906. private _plus90X;
  123907. private _tmpPosition;
  123908. private _tmpDeltaPosition;
  123909. private _tmpUnityRotation;
  123910. private _updatePhysicsBodyTransformation;
  123911. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123912. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123913. isSupported(): boolean;
  123914. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123915. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123916. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123917. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123918. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123919. getBodyMass(impostor: PhysicsImpostor): number;
  123920. getBodyFriction(impostor: PhysicsImpostor): number;
  123921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123922. getBodyRestitution(impostor: PhysicsImpostor): number;
  123923. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123924. sleepBody(impostor: PhysicsImpostor): void;
  123925. wakeUpBody(impostor: PhysicsImpostor): void;
  123926. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  123927. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  123928. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  123929. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123930. getRadius(impostor: PhysicsImpostor): number;
  123931. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123932. dispose(): void;
  123933. private _extendNamespace;
  123934. /**
  123935. * Does a raycast in the physics world
  123936. * @param from when should the ray start?
  123937. * @param to when should the ray end?
  123938. * @returns PhysicsRaycastResult
  123939. */
  123940. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123941. }
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  123946. world: any;
  123947. name: string;
  123948. BJSOIMO: any;
  123949. private _raycastResult;
  123950. constructor(iterations?: number, oimoInjection?: any);
  123951. setGravity(gravity: Vector3): void;
  123952. setTimeStep(timeStep: number): void;
  123953. getTimeStep(): number;
  123954. private _tmpImpostorsArray;
  123955. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  123956. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123957. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123958. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123959. private _tmpPositionVector;
  123960. removePhysicsBody(impostor: PhysicsImpostor): void;
  123961. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123962. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123963. isSupported(): boolean;
  123964. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123966. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123967. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123968. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123969. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123970. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123971. getBodyMass(impostor: PhysicsImpostor): number;
  123972. getBodyFriction(impostor: PhysicsImpostor): number;
  123973. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123974. getBodyRestitution(impostor: PhysicsImpostor): number;
  123975. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123976. sleepBody(impostor: PhysicsImpostor): void;
  123977. wakeUpBody(impostor: PhysicsImpostor): void;
  123978. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  123979. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  123980. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  123981. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123982. getRadius(impostor: PhysicsImpostor): number;
  123983. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123984. dispose(): void;
  123985. /**
  123986. * Does a raycast in the physics world
  123987. * @param from when should the ray start?
  123988. * @param to when should the ray end?
  123989. * @returns PhysicsRaycastResult
  123990. */
  123991. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123992. }
  123993. }
  123994. declare module BABYLON {
  123995. /**
  123996. * Class containing static functions to help procedurally build meshes
  123997. */
  123998. export class RibbonBuilder {
  123999. /**
  124000. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124001. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124002. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124003. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124004. * * 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
  124005. * * 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
  124006. * * 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
  124007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124009. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124010. * * 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
  124011. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124012. * * 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
  124013. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124015. * @param name defines the name of the mesh
  124016. * @param options defines the options used to create the mesh
  124017. * @param scene defines the hosting scene
  124018. * @returns the ribbon mesh
  124019. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124021. */
  124022. static CreateRibbon(name: string, options: {
  124023. pathArray: Vector3[][];
  124024. closeArray?: boolean;
  124025. closePath?: boolean;
  124026. offset?: number;
  124027. updatable?: boolean;
  124028. sideOrientation?: number;
  124029. frontUVs?: Vector4;
  124030. backUVs?: Vector4;
  124031. instance?: Mesh;
  124032. invertUV?: boolean;
  124033. uvs?: Vector2[];
  124034. colors?: Color4[];
  124035. }, scene?: Nullable<Scene>): Mesh;
  124036. }
  124037. }
  124038. declare module BABYLON {
  124039. /**
  124040. * Class containing static functions to help procedurally build meshes
  124041. */
  124042. export class ShapeBuilder {
  124043. /**
  124044. * 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.
  124045. * * 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.
  124046. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124047. * * 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.
  124048. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124049. * * 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
  124050. * * 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
  124051. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124056. * @param name defines the name of the mesh
  124057. * @param options defines the options used to create the mesh
  124058. * @param scene defines the hosting scene
  124059. * @returns the extruded shape mesh
  124060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124062. */
  124063. static ExtrudeShape(name: string, options: {
  124064. shape: Vector3[];
  124065. path: Vector3[];
  124066. scale?: number;
  124067. rotation?: number;
  124068. cap?: number;
  124069. updatable?: boolean;
  124070. sideOrientation?: number;
  124071. frontUVs?: Vector4;
  124072. backUVs?: Vector4;
  124073. instance?: Mesh;
  124074. invertUV?: boolean;
  124075. }, scene?: Nullable<Scene>): Mesh;
  124076. /**
  124077. * Creates an custom extruded shape mesh.
  124078. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124079. * * 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.
  124080. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124081. * * 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
  124082. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124083. * * 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
  124084. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124085. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124086. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124087. * * 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
  124088. * * 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
  124089. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124094. * @param name defines the name of the mesh
  124095. * @param options defines the options used to create the mesh
  124096. * @param scene defines the hosting scene
  124097. * @returns the custom extruded shape mesh
  124098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124101. */
  124102. static ExtrudeShapeCustom(name: string, options: {
  124103. shape: Vector3[];
  124104. path: Vector3[];
  124105. scaleFunction?: any;
  124106. rotationFunction?: any;
  124107. ribbonCloseArray?: boolean;
  124108. ribbonClosePath?: boolean;
  124109. cap?: number;
  124110. updatable?: boolean;
  124111. sideOrientation?: number;
  124112. frontUVs?: Vector4;
  124113. backUVs?: Vector4;
  124114. instance?: Mesh;
  124115. invertUV?: boolean;
  124116. }, scene?: Nullable<Scene>): Mesh;
  124117. private static _ExtrudeShapeGeneric;
  124118. }
  124119. }
  124120. declare module BABYLON {
  124121. /**
  124122. * AmmoJS Physics plugin
  124123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124124. * @see https://github.com/kripken/ammo.js/
  124125. */
  124126. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124127. private _useDeltaForWorldStep;
  124128. /**
  124129. * Reference to the Ammo library
  124130. */
  124131. bjsAMMO: any;
  124132. /**
  124133. * Created ammoJS world which physics bodies are added to
  124134. */
  124135. world: any;
  124136. /**
  124137. * Name of the plugin
  124138. */
  124139. name: string;
  124140. private _timeStep;
  124141. private _fixedTimeStep;
  124142. private _maxSteps;
  124143. private _tmpQuaternion;
  124144. private _tmpAmmoTransform;
  124145. private _tmpAmmoQuaternion;
  124146. private _tmpAmmoConcreteContactResultCallback;
  124147. private _collisionConfiguration;
  124148. private _dispatcher;
  124149. private _overlappingPairCache;
  124150. private _solver;
  124151. private _softBodySolver;
  124152. private _tmpAmmoVectorA;
  124153. private _tmpAmmoVectorB;
  124154. private _tmpAmmoVectorC;
  124155. private _tmpAmmoVectorD;
  124156. private _tmpContactCallbackResult;
  124157. private _tmpAmmoVectorRCA;
  124158. private _tmpAmmoVectorRCB;
  124159. private _raycastResult;
  124160. private static readonly DISABLE_COLLISION_FLAG;
  124161. private static readonly KINEMATIC_FLAG;
  124162. private static readonly DISABLE_DEACTIVATION_FLAG;
  124163. /**
  124164. * Initializes the ammoJS plugin
  124165. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124166. * @param ammoInjection can be used to inject your own ammo reference
  124167. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124168. */
  124169. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124170. /**
  124171. * Sets the gravity of the physics world (m/(s^2))
  124172. * @param gravity Gravity to set
  124173. */
  124174. setGravity(gravity: Vector3): void;
  124175. /**
  124176. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124177. * @param timeStep timestep to use in seconds
  124178. */
  124179. setTimeStep(timeStep: number): void;
  124180. /**
  124181. * 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)
  124182. * @param fixedTimeStep fixedTimeStep to use in seconds
  124183. */
  124184. setFixedTimeStep(fixedTimeStep: number): void;
  124185. /**
  124186. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124187. * @param maxSteps the maximum number of steps by the physics engine per frame
  124188. */
  124189. setMaxSteps(maxSteps: number): void;
  124190. /**
  124191. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124192. * @returns the current timestep in seconds
  124193. */
  124194. getTimeStep(): number;
  124195. /**
  124196. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124197. */
  124198. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124199. private _isImpostorInContact;
  124200. private _isImpostorPairInContact;
  124201. private _stepSimulation;
  124202. /**
  124203. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124204. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124205. * After the step the babylon meshes are set to the position of the physics imposters
  124206. * @param delta amount of time to step forward
  124207. * @param impostors array of imposters to update before/after the step
  124208. */
  124209. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124210. /**
  124211. * Update babylon mesh to match physics world object
  124212. * @param impostor imposter to match
  124213. */
  124214. private _afterSoftStep;
  124215. /**
  124216. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124217. * @param impostor imposter to match
  124218. */
  124219. private _ropeStep;
  124220. /**
  124221. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124222. * @param impostor imposter to match
  124223. */
  124224. private _softbodyOrClothStep;
  124225. private _tmpVector;
  124226. private _tmpMatrix;
  124227. /**
  124228. * Applies an impulse on the imposter
  124229. * @param impostor imposter to apply impulse to
  124230. * @param force amount of force to be applied to the imposter
  124231. * @param contactPoint the location to apply the impulse on the imposter
  124232. */
  124233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124234. /**
  124235. * Applies a force on the imposter
  124236. * @param impostor imposter to apply force
  124237. * @param force amount of force to be applied to the imposter
  124238. * @param contactPoint the location to apply the force on the imposter
  124239. */
  124240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124241. /**
  124242. * Creates a physics body using the plugin
  124243. * @param impostor the imposter to create the physics body on
  124244. */
  124245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124246. /**
  124247. * Removes the physics body from the imposter and disposes of the body's memory
  124248. * @param impostor imposter to remove the physics body from
  124249. */
  124250. removePhysicsBody(impostor: PhysicsImpostor): void;
  124251. /**
  124252. * Generates a joint
  124253. * @param impostorJoint the imposter joint to create the joint with
  124254. */
  124255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124256. /**
  124257. * Removes a joint
  124258. * @param impostorJoint the imposter joint to remove the joint from
  124259. */
  124260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124261. private _addMeshVerts;
  124262. /**
  124263. * Initialise the soft body vertices to match its object's (mesh) vertices
  124264. * Softbody vertices (nodes) are in world space and to match this
  124265. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124266. * @param impostor to create the softbody for
  124267. */
  124268. private _softVertexData;
  124269. /**
  124270. * Create an impostor's soft body
  124271. * @param impostor to create the softbody for
  124272. */
  124273. private _createSoftbody;
  124274. /**
  124275. * Create cloth for an impostor
  124276. * @param impostor to create the softbody for
  124277. */
  124278. private _createCloth;
  124279. /**
  124280. * Create rope for an impostor
  124281. * @param impostor to create the softbody for
  124282. */
  124283. private _createRope;
  124284. /**
  124285. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124286. * @param impostor to create the custom physics shape for
  124287. */
  124288. private _createCustom;
  124289. private _addHullVerts;
  124290. private _createShape;
  124291. /**
  124292. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124293. * @param impostor imposter containing the physics body and babylon object
  124294. */
  124295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124296. /**
  124297. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124298. * @param impostor imposter containing the physics body and babylon object
  124299. * @param newPosition new position
  124300. * @param newRotation new rotation
  124301. */
  124302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124303. /**
  124304. * If this plugin is supported
  124305. * @returns true if its supported
  124306. */
  124307. isSupported(): boolean;
  124308. /**
  124309. * Sets the linear velocity of the physics body
  124310. * @param impostor imposter to set the velocity on
  124311. * @param velocity velocity to set
  124312. */
  124313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124314. /**
  124315. * Sets the angular velocity of the physics body
  124316. * @param impostor imposter to set the velocity on
  124317. * @param velocity velocity to set
  124318. */
  124319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124320. /**
  124321. * gets the linear velocity
  124322. * @param impostor imposter to get linear velocity from
  124323. * @returns linear velocity
  124324. */
  124325. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124326. /**
  124327. * gets the angular velocity
  124328. * @param impostor imposter to get angular velocity from
  124329. * @returns angular velocity
  124330. */
  124331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124332. /**
  124333. * Sets the mass of physics body
  124334. * @param impostor imposter to set the mass on
  124335. * @param mass mass to set
  124336. */
  124337. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124338. /**
  124339. * Gets the mass of the physics body
  124340. * @param impostor imposter to get the mass from
  124341. * @returns mass
  124342. */
  124343. getBodyMass(impostor: PhysicsImpostor): number;
  124344. /**
  124345. * Gets friction of the impostor
  124346. * @param impostor impostor to get friction from
  124347. * @returns friction value
  124348. */
  124349. getBodyFriction(impostor: PhysicsImpostor): number;
  124350. /**
  124351. * Sets friction of the impostor
  124352. * @param impostor impostor to set friction on
  124353. * @param friction friction value
  124354. */
  124355. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124356. /**
  124357. * Gets restitution of the impostor
  124358. * @param impostor impostor to get restitution from
  124359. * @returns restitution value
  124360. */
  124361. getBodyRestitution(impostor: PhysicsImpostor): number;
  124362. /**
  124363. * Sets resitution of the impostor
  124364. * @param impostor impostor to set resitution on
  124365. * @param restitution resitution value
  124366. */
  124367. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124368. /**
  124369. * Gets pressure inside the impostor
  124370. * @param impostor impostor to get pressure from
  124371. * @returns pressure value
  124372. */
  124373. getBodyPressure(impostor: PhysicsImpostor): number;
  124374. /**
  124375. * Sets pressure inside a soft body impostor
  124376. * Cloth and rope must remain 0 pressure
  124377. * @param impostor impostor to set pressure on
  124378. * @param pressure pressure value
  124379. */
  124380. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124381. /**
  124382. * Gets stiffness of the impostor
  124383. * @param impostor impostor to get stiffness from
  124384. * @returns pressure value
  124385. */
  124386. getBodyStiffness(impostor: PhysicsImpostor): number;
  124387. /**
  124388. * Sets stiffness of the impostor
  124389. * @param impostor impostor to set stiffness on
  124390. * @param stiffness stiffness value from 0 to 1
  124391. */
  124392. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124393. /**
  124394. * Gets velocityIterations of the impostor
  124395. * @param impostor impostor to get velocity iterations from
  124396. * @returns velocityIterations value
  124397. */
  124398. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124399. /**
  124400. * Sets velocityIterations of the impostor
  124401. * @param impostor impostor to set velocity iterations on
  124402. * @param velocityIterations velocityIterations value
  124403. */
  124404. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124405. /**
  124406. * Gets positionIterations of the impostor
  124407. * @param impostor impostor to get position iterations from
  124408. * @returns positionIterations value
  124409. */
  124410. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124411. /**
  124412. * Sets positionIterations of the impostor
  124413. * @param impostor impostor to set position on
  124414. * @param positionIterations positionIterations value
  124415. */
  124416. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124417. /**
  124418. * Append an anchor to a cloth object
  124419. * @param impostor is the cloth impostor to add anchor to
  124420. * @param otherImpostor is the rigid impostor to anchor to
  124421. * @param width ratio across width from 0 to 1
  124422. * @param height ratio up height from 0 to 1
  124423. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124424. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124425. */
  124426. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124427. /**
  124428. * Append an hook to a rope object
  124429. * @param impostor is the rope impostor to add hook to
  124430. * @param otherImpostor is the rigid impostor to hook to
  124431. * @param length ratio along the rope from 0 to 1
  124432. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124433. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124434. */
  124435. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124436. /**
  124437. * Sleeps the physics body and stops it from being active
  124438. * @param impostor impostor to sleep
  124439. */
  124440. sleepBody(impostor: PhysicsImpostor): void;
  124441. /**
  124442. * Activates the physics body
  124443. * @param impostor impostor to activate
  124444. */
  124445. wakeUpBody(impostor: PhysicsImpostor): void;
  124446. /**
  124447. * Updates the distance parameters of the joint
  124448. * @param joint joint to update
  124449. * @param maxDistance maximum distance of the joint
  124450. * @param minDistance minimum distance of the joint
  124451. */
  124452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124453. /**
  124454. * Sets a motor on the joint
  124455. * @param joint joint to set motor on
  124456. * @param speed speed of the motor
  124457. * @param maxForce maximum force of the motor
  124458. * @param motorIndex index of the motor
  124459. */
  124460. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124461. /**
  124462. * Sets the motors limit
  124463. * @param joint joint to set limit on
  124464. * @param upperLimit upper limit
  124465. * @param lowerLimit lower limit
  124466. */
  124467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124468. /**
  124469. * Syncs the position and rotation of a mesh with the impostor
  124470. * @param mesh mesh to sync
  124471. * @param impostor impostor to update the mesh with
  124472. */
  124473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124474. /**
  124475. * Gets the radius of the impostor
  124476. * @param impostor impostor to get radius from
  124477. * @returns the radius
  124478. */
  124479. getRadius(impostor: PhysicsImpostor): number;
  124480. /**
  124481. * Gets the box size of the impostor
  124482. * @param impostor impostor to get box size from
  124483. * @param result the resulting box size
  124484. */
  124485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124486. /**
  124487. * Disposes of the impostor
  124488. */
  124489. dispose(): void;
  124490. /**
  124491. * Does a raycast in the physics world
  124492. * @param from when should the ray start?
  124493. * @param to when should the ray end?
  124494. * @returns PhysicsRaycastResult
  124495. */
  124496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124497. }
  124498. }
  124499. declare module BABYLON {
  124500. interface AbstractScene {
  124501. /**
  124502. * The list of reflection probes added to the scene
  124503. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124504. */
  124505. reflectionProbes: Array<ReflectionProbe>;
  124506. /**
  124507. * Removes the given reflection probe from this scene.
  124508. * @param toRemove The reflection probe to remove
  124509. * @returns The index of the removed reflection probe
  124510. */
  124511. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124512. /**
  124513. * Adds the given reflection probe to this scene.
  124514. * @param newReflectionProbe The reflection probe to add
  124515. */
  124516. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124517. }
  124518. /**
  124519. * Class used to generate realtime reflection / refraction cube textures
  124520. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124521. */
  124522. export class ReflectionProbe {
  124523. /** defines the name of the probe */
  124524. name: string;
  124525. private _scene;
  124526. private _renderTargetTexture;
  124527. private _projectionMatrix;
  124528. private _viewMatrix;
  124529. private _target;
  124530. private _add;
  124531. private _attachedMesh;
  124532. private _invertYAxis;
  124533. /** Gets or sets probe position (center of the cube map) */
  124534. position: Vector3;
  124535. /**
  124536. * Creates a new reflection probe
  124537. * @param name defines the name of the probe
  124538. * @param size defines the texture resolution (for each face)
  124539. * @param scene defines the hosting scene
  124540. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124541. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124542. */
  124543. constructor(
  124544. /** defines the name of the probe */
  124545. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124546. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124547. get samples(): number;
  124548. set samples(value: number);
  124549. /** Gets or sets the refresh rate to use (on every frame by default) */
  124550. get refreshRate(): number;
  124551. set refreshRate(value: number);
  124552. /**
  124553. * Gets the hosting scene
  124554. * @returns a Scene
  124555. */
  124556. getScene(): Scene;
  124557. /** Gets the internal CubeTexture used to render to */
  124558. get cubeTexture(): RenderTargetTexture;
  124559. /** Gets the list of meshes to render */
  124560. get renderList(): Nullable<AbstractMesh[]>;
  124561. /**
  124562. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124563. * @param mesh defines the mesh to attach to
  124564. */
  124565. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124566. /**
  124567. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124568. * @param renderingGroupId The rendering group id corresponding to its index
  124569. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124570. */
  124571. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124572. /**
  124573. * Clean all associated resources
  124574. */
  124575. dispose(): void;
  124576. /**
  124577. * Converts the reflection probe information to a readable string for debug purpose.
  124578. * @param fullDetails Supports for multiple levels of logging within scene loading
  124579. * @returns the human readable reflection probe info
  124580. */
  124581. toString(fullDetails?: boolean): string;
  124582. /**
  124583. * Get the class name of the relfection probe.
  124584. * @returns "ReflectionProbe"
  124585. */
  124586. getClassName(): string;
  124587. /**
  124588. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124589. * @returns The JSON representation of the texture
  124590. */
  124591. serialize(): any;
  124592. /**
  124593. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124594. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124595. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124596. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124597. * @returns The parsed reflection probe if successful
  124598. */
  124599. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124600. }
  124601. }
  124602. declare module BABYLON {
  124603. /** @hidden */
  124604. export var _BabylonLoaderRegistered: boolean;
  124605. /**
  124606. * Helps setting up some configuration for the babylon file loader.
  124607. */
  124608. export class BabylonFileLoaderConfiguration {
  124609. /**
  124610. * The loader does not allow injecting custom physix engine into the plugins.
  124611. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124612. * So you could set this variable to your engine import to make it work.
  124613. */
  124614. static LoaderInjectedPhysicsEngine: any;
  124615. }
  124616. }
  124617. declare module BABYLON {
  124618. /**
  124619. * The Physically based simple base material of BJS.
  124620. *
  124621. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124622. * It is used as the base class for both the specGloss and metalRough conventions.
  124623. */
  124624. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124625. /**
  124626. * Number of Simultaneous lights allowed on the material.
  124627. */
  124628. maxSimultaneousLights: number;
  124629. /**
  124630. * If sets to true, disables all the lights affecting the material.
  124631. */
  124632. disableLighting: boolean;
  124633. /**
  124634. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124635. */
  124636. environmentTexture: BaseTexture;
  124637. /**
  124638. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124639. */
  124640. invertNormalMapX: boolean;
  124641. /**
  124642. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124643. */
  124644. invertNormalMapY: boolean;
  124645. /**
  124646. * Normal map used in the model.
  124647. */
  124648. normalTexture: BaseTexture;
  124649. /**
  124650. * Emissivie color used to self-illuminate the model.
  124651. */
  124652. emissiveColor: Color3;
  124653. /**
  124654. * Emissivie texture used to self-illuminate the model.
  124655. */
  124656. emissiveTexture: BaseTexture;
  124657. /**
  124658. * Occlusion Channel Strenght.
  124659. */
  124660. occlusionStrength: number;
  124661. /**
  124662. * Occlusion Texture of the material (adding extra occlusion effects).
  124663. */
  124664. occlusionTexture: BaseTexture;
  124665. /**
  124666. * Defines the alpha limits in alpha test mode.
  124667. */
  124668. alphaCutOff: number;
  124669. /**
  124670. * Gets the current double sided mode.
  124671. */
  124672. get doubleSided(): boolean;
  124673. /**
  124674. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124675. */
  124676. set doubleSided(value: boolean);
  124677. /**
  124678. * Stores the pre-calculated light information of a mesh in a texture.
  124679. */
  124680. lightmapTexture: BaseTexture;
  124681. /**
  124682. * If true, the light map contains occlusion information instead of lighting info.
  124683. */
  124684. useLightmapAsShadowmap: boolean;
  124685. /**
  124686. * Instantiates a new PBRMaterial instance.
  124687. *
  124688. * @param name The material name
  124689. * @param scene The scene the material will be use in.
  124690. */
  124691. constructor(name: string, scene: Scene);
  124692. getClassName(): string;
  124693. }
  124694. }
  124695. declare module BABYLON {
  124696. /**
  124697. * The PBR material of BJS following the metal roughness convention.
  124698. *
  124699. * This fits to the PBR convention in the GLTF definition:
  124700. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124701. */
  124702. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124703. /**
  124704. * The base color has two different interpretations depending on the value of metalness.
  124705. * When the material is a metal, the base color is the specific measured reflectance value
  124706. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124707. * of the material.
  124708. */
  124709. baseColor: Color3;
  124710. /**
  124711. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124712. * well as opacity information in the alpha channel.
  124713. */
  124714. baseTexture: BaseTexture;
  124715. /**
  124716. * Specifies the metallic scalar value of the material.
  124717. * Can also be used to scale the metalness values of the metallic texture.
  124718. */
  124719. metallic: number;
  124720. /**
  124721. * Specifies the roughness scalar value of the material.
  124722. * Can also be used to scale the roughness values of the metallic texture.
  124723. */
  124724. roughness: number;
  124725. /**
  124726. * Texture containing both the metallic value in the B channel and the
  124727. * roughness value in the G channel to keep better precision.
  124728. */
  124729. metallicRoughnessTexture: BaseTexture;
  124730. /**
  124731. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124732. *
  124733. * @param name The material name
  124734. * @param scene The scene the material will be use in.
  124735. */
  124736. constructor(name: string, scene: Scene);
  124737. /**
  124738. * Return the currrent class name of the material.
  124739. */
  124740. getClassName(): string;
  124741. /**
  124742. * Makes a duplicate of the current material.
  124743. * @param name - name to use for the new material.
  124744. */
  124745. clone(name: string): PBRMetallicRoughnessMaterial;
  124746. /**
  124747. * Serialize the material to a parsable JSON object.
  124748. */
  124749. serialize(): any;
  124750. /**
  124751. * Parses a JSON object correponding to the serialize function.
  124752. */
  124753. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124754. }
  124755. }
  124756. declare module BABYLON {
  124757. /**
  124758. * The PBR material of BJS following the specular glossiness convention.
  124759. *
  124760. * This fits to the PBR convention in the GLTF definition:
  124761. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124762. */
  124763. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124764. /**
  124765. * Specifies the diffuse color of the material.
  124766. */
  124767. diffuseColor: Color3;
  124768. /**
  124769. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124770. * channel.
  124771. */
  124772. diffuseTexture: BaseTexture;
  124773. /**
  124774. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124775. */
  124776. specularColor: Color3;
  124777. /**
  124778. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124779. */
  124780. glossiness: number;
  124781. /**
  124782. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124783. */
  124784. specularGlossinessTexture: BaseTexture;
  124785. /**
  124786. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124787. *
  124788. * @param name The material name
  124789. * @param scene The scene the material will be use in.
  124790. */
  124791. constructor(name: string, scene: Scene);
  124792. /**
  124793. * Return the currrent class name of the material.
  124794. */
  124795. getClassName(): string;
  124796. /**
  124797. * Makes a duplicate of the current material.
  124798. * @param name - name to use for the new material.
  124799. */
  124800. clone(name: string): PBRSpecularGlossinessMaterial;
  124801. /**
  124802. * Serialize the material to a parsable JSON object.
  124803. */
  124804. serialize(): any;
  124805. /**
  124806. * Parses a JSON object correponding to the serialize function.
  124807. */
  124808. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124809. }
  124810. }
  124811. declare module BABYLON {
  124812. /**
  124813. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124814. * It can help converting any input color in a desired output one. This can then be used to create effects
  124815. * from sepia, black and white to sixties or futuristic rendering...
  124816. *
  124817. * The only supported format is currently 3dl.
  124818. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124819. */
  124820. export class ColorGradingTexture extends BaseTexture {
  124821. /**
  124822. * The current texture matrix. (will always be identity in color grading texture)
  124823. */
  124824. private _textureMatrix;
  124825. /**
  124826. * The texture URL.
  124827. */
  124828. url: string;
  124829. /**
  124830. * Empty line regex stored for GC.
  124831. */
  124832. private static _noneEmptyLineRegex;
  124833. private _engine;
  124834. /**
  124835. * Instantiates a ColorGradingTexture from the following parameters.
  124836. *
  124837. * @param url The location of the color gradind data (currently only supporting 3dl)
  124838. * @param scene The scene the texture will be used in
  124839. */
  124840. constructor(url: string, scene: Scene);
  124841. /**
  124842. * Returns the texture matrix used in most of the material.
  124843. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124844. */
  124845. getTextureMatrix(): Matrix;
  124846. /**
  124847. * Occurs when the file being loaded is a .3dl LUT file.
  124848. */
  124849. private load3dlTexture;
  124850. /**
  124851. * Starts the loading process of the texture.
  124852. */
  124853. private loadTexture;
  124854. /**
  124855. * Clones the color gradind texture.
  124856. */
  124857. clone(): ColorGradingTexture;
  124858. /**
  124859. * Called during delayed load for textures.
  124860. */
  124861. delayLoad(): void;
  124862. /**
  124863. * Parses a color grading texture serialized by Babylon.
  124864. * @param parsedTexture The texture information being parsedTexture
  124865. * @param scene The scene to load the texture in
  124866. * @param rootUrl The root url of the data assets to load
  124867. * @return A color gradind texture
  124868. */
  124869. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  124870. /**
  124871. * Serializes the LUT texture to json format.
  124872. */
  124873. serialize(): any;
  124874. }
  124875. }
  124876. declare module BABYLON {
  124877. /**
  124878. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  124879. */
  124880. export class EquiRectangularCubeTexture extends BaseTexture {
  124881. /** The six faces of the cube. */
  124882. private static _FacesMapping;
  124883. private _noMipmap;
  124884. private _onLoad;
  124885. private _onError;
  124886. /** The size of the cubemap. */
  124887. private _size;
  124888. /** The buffer of the image. */
  124889. private _buffer;
  124890. /** The width of the input image. */
  124891. private _width;
  124892. /** The height of the input image. */
  124893. private _height;
  124894. /** The URL to the image. */
  124895. url: string;
  124896. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  124897. coordinatesMode: number;
  124898. /**
  124899. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  124900. * @param url The location of the image
  124901. * @param scene The scene the texture will be used in
  124902. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  124903. * @param noMipmap Forces to not generate the mipmap if true
  124904. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124905. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124906. * @param onLoad — defines a callback called when texture is loaded
  124907. * @param onError — defines a callback called if there is an error
  124908. */
  124909. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  124910. /**
  124911. * Load the image data, by putting the image on a canvas and extracting its buffer.
  124912. */
  124913. private loadImage;
  124914. /**
  124915. * Convert the image buffer into a cubemap and create a CubeTexture.
  124916. */
  124917. private loadTexture;
  124918. /**
  124919. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  124920. * @param buffer The ArrayBuffer that should be converted.
  124921. * @returns The buffer as Float32Array.
  124922. */
  124923. private getFloat32ArrayFromArrayBuffer;
  124924. /**
  124925. * Get the current class name of the texture useful for serialization or dynamic coding.
  124926. * @returns "EquiRectangularCubeTexture"
  124927. */
  124928. getClassName(): string;
  124929. /**
  124930. * Create a clone of the current EquiRectangularCubeTexture and return it.
  124931. * @returns A clone of the current EquiRectangularCubeTexture.
  124932. */
  124933. clone(): EquiRectangularCubeTexture;
  124934. }
  124935. }
  124936. declare module BABYLON {
  124937. /**
  124938. * Based on jsTGALoader - Javascript loader for TGA file
  124939. * By Vincent Thibault
  124940. * @see http://blog.robrowser.com/javascript-tga-loader.html
  124941. */
  124942. export class TGATools {
  124943. private static _TYPE_INDEXED;
  124944. private static _TYPE_RGB;
  124945. private static _TYPE_GREY;
  124946. private static _TYPE_RLE_INDEXED;
  124947. private static _TYPE_RLE_RGB;
  124948. private static _TYPE_RLE_GREY;
  124949. private static _ORIGIN_MASK;
  124950. private static _ORIGIN_SHIFT;
  124951. private static _ORIGIN_BL;
  124952. private static _ORIGIN_BR;
  124953. private static _ORIGIN_UL;
  124954. private static _ORIGIN_UR;
  124955. /**
  124956. * Gets the header of a TGA file
  124957. * @param data defines the TGA data
  124958. * @returns the header
  124959. */
  124960. static GetTGAHeader(data: Uint8Array): any;
  124961. /**
  124962. * Uploads TGA content to a Babylon Texture
  124963. * @hidden
  124964. */
  124965. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  124966. /** @hidden */
  124967. 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;
  124968. /** @hidden */
  124969. 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;
  124970. /** @hidden */
  124971. 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;
  124972. /** @hidden */
  124973. 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;
  124974. /** @hidden */
  124975. 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;
  124976. /** @hidden */
  124977. 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;
  124978. }
  124979. }
  124980. declare module BABYLON {
  124981. /**
  124982. * Implementation of the TGA Texture Loader.
  124983. * @hidden
  124984. */
  124985. export class _TGATextureLoader implements IInternalTextureLoader {
  124986. /**
  124987. * Defines wether the loader supports cascade loading the different faces.
  124988. */
  124989. readonly supportCascades: boolean;
  124990. /**
  124991. * This returns if the loader support the current file information.
  124992. * @param extension defines the file extension of the file being loaded
  124993. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124994. * @param fallback defines the fallback internal texture if any
  124995. * @param isBase64 defines whether the texture is encoded as a base64
  124996. * @param isBuffer defines whether the texture data are stored as a buffer
  124997. * @returns true if the loader can load the specified file
  124998. */
  124999. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125000. /**
  125001. * Transform the url before loading if required.
  125002. * @param rootUrl the url of the texture
  125003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125004. * @returns the transformed texture
  125005. */
  125006. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125007. /**
  125008. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125009. * @param rootUrl the url of the texture
  125010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125011. * @returns the fallback texture
  125012. */
  125013. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125014. /**
  125015. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125016. * @param data contains the texture data
  125017. * @param texture defines the BabylonJS internal texture
  125018. * @param createPolynomials will be true if polynomials have been requested
  125019. * @param onLoad defines the callback to trigger once the texture is ready
  125020. * @param onError defines the callback to trigger in case of error
  125021. */
  125022. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125023. /**
  125024. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125025. * @param data contains the texture data
  125026. * @param texture defines the BabylonJS internal texture
  125027. * @param callback defines the method to call once ready to upload
  125028. */
  125029. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125030. }
  125031. }
  125032. declare module BABYLON {
  125033. /**
  125034. * Info about the .basis files
  125035. */
  125036. class BasisFileInfo {
  125037. /**
  125038. * If the file has alpha
  125039. */
  125040. hasAlpha: boolean;
  125041. /**
  125042. * Info about each image of the basis file
  125043. */
  125044. images: Array<{
  125045. levels: Array<{
  125046. width: number;
  125047. height: number;
  125048. transcodedPixels: ArrayBufferView;
  125049. }>;
  125050. }>;
  125051. }
  125052. /**
  125053. * Result of transcoding a basis file
  125054. */
  125055. class TranscodeResult {
  125056. /**
  125057. * Info about the .basis file
  125058. */
  125059. fileInfo: BasisFileInfo;
  125060. /**
  125061. * Format to use when loading the file
  125062. */
  125063. format: number;
  125064. }
  125065. /**
  125066. * Configuration options for the Basis transcoder
  125067. */
  125068. export class BasisTranscodeConfiguration {
  125069. /**
  125070. * Supported compression formats used to determine the supported output format of the transcoder
  125071. */
  125072. supportedCompressionFormats?: {
  125073. /**
  125074. * etc1 compression format
  125075. */
  125076. etc1?: boolean;
  125077. /**
  125078. * s3tc compression format
  125079. */
  125080. s3tc?: boolean;
  125081. /**
  125082. * pvrtc compression format
  125083. */
  125084. pvrtc?: boolean;
  125085. /**
  125086. * etc2 compression format
  125087. */
  125088. etc2?: boolean;
  125089. };
  125090. /**
  125091. * If mipmap levels should be loaded for transcoded images (Default: true)
  125092. */
  125093. loadMipmapLevels?: boolean;
  125094. /**
  125095. * Index of a single image to load (Default: all images)
  125096. */
  125097. loadSingleImage?: number;
  125098. }
  125099. /**
  125100. * Used to load .Basis files
  125101. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125102. */
  125103. export class BasisTools {
  125104. private static _IgnoreSupportedFormats;
  125105. /**
  125106. * URL to use when loading the basis transcoder
  125107. */
  125108. static JSModuleURL: string;
  125109. /**
  125110. * URL to use when loading the wasm module for the transcoder
  125111. */
  125112. static WasmModuleURL: string;
  125113. /**
  125114. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125115. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125116. * @returns internal format corresponding to the Basis format
  125117. */
  125118. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125119. private static _WorkerPromise;
  125120. private static _Worker;
  125121. private static _actionId;
  125122. private static _CreateWorkerAsync;
  125123. /**
  125124. * Transcodes a loaded image file to compressed pixel data
  125125. * @param imageData image data to transcode
  125126. * @param config configuration options for the transcoding
  125127. * @returns a promise resulting in the transcoded image
  125128. */
  125129. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125130. /**
  125131. * Loads a texture from the transcode result
  125132. * @param texture texture load to
  125133. * @param transcodeResult the result of transcoding the basis file to load from
  125134. */
  125135. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125136. }
  125137. }
  125138. declare module BABYLON {
  125139. /**
  125140. * Loader for .basis file format
  125141. */
  125142. export class _BasisTextureLoader implements IInternalTextureLoader {
  125143. /**
  125144. * Defines whether the loader supports cascade loading the different faces.
  125145. */
  125146. readonly supportCascades: boolean;
  125147. /**
  125148. * This returns if the loader support the current file information.
  125149. * @param extension defines the file extension of the file being loaded
  125150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125151. * @param fallback defines the fallback internal texture if any
  125152. * @param isBase64 defines whether the texture is encoded as a base64
  125153. * @param isBuffer defines whether the texture data are stored as a buffer
  125154. * @returns true if the loader can load the specified file
  125155. */
  125156. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125157. /**
  125158. * Transform the url before loading if required.
  125159. * @param rootUrl the url of the texture
  125160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125161. * @returns the transformed texture
  125162. */
  125163. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125164. /**
  125165. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125166. * @param rootUrl the url of the texture
  125167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125168. * @returns the fallback texture
  125169. */
  125170. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125171. /**
  125172. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125173. * @param data contains the texture data
  125174. * @param texture defines the BabylonJS internal texture
  125175. * @param createPolynomials will be true if polynomials have been requested
  125176. * @param onLoad defines the callback to trigger once the texture is ready
  125177. * @param onError defines the callback to trigger in case of error
  125178. */
  125179. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125180. /**
  125181. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125182. * @param data contains the texture data
  125183. * @param texture defines the BabylonJS internal texture
  125184. * @param callback defines the method to call once ready to upload
  125185. */
  125186. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125187. }
  125188. }
  125189. declare module BABYLON {
  125190. /**
  125191. * 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.
  125192. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125193. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125194. */
  125195. export class CustomProceduralTexture extends ProceduralTexture {
  125196. private _animate;
  125197. private _time;
  125198. private _config;
  125199. private _texturePath;
  125200. /**
  125201. * Instantiates a new Custom Procedural Texture.
  125202. * 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.
  125203. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125204. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125205. * @param name Define the name of the texture
  125206. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125207. * @param size Define the size of the texture to create
  125208. * @param scene Define the scene the texture belongs to
  125209. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125210. * @param generateMipMaps Define if the texture should creates mip maps or not
  125211. */
  125212. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125213. private _loadJson;
  125214. /**
  125215. * Is the texture ready to be used ? (rendered at least once)
  125216. * @returns true if ready, otherwise, false.
  125217. */
  125218. isReady(): boolean;
  125219. /**
  125220. * Render the texture to its associated render target.
  125221. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125222. */
  125223. render(useCameraPostProcess?: boolean): void;
  125224. /**
  125225. * Update the list of dependant textures samplers in the shader.
  125226. */
  125227. updateTextures(): void;
  125228. /**
  125229. * Update the uniform values of the procedural texture in the shader.
  125230. */
  125231. updateShaderUniforms(): void;
  125232. /**
  125233. * Define if the texture animates or not.
  125234. */
  125235. get animate(): boolean;
  125236. set animate(value: boolean);
  125237. }
  125238. }
  125239. declare module BABYLON {
  125240. /** @hidden */
  125241. export var noisePixelShader: {
  125242. name: string;
  125243. shader: string;
  125244. };
  125245. }
  125246. declare module BABYLON {
  125247. /**
  125248. * Class used to generate noise procedural textures
  125249. */
  125250. export class NoiseProceduralTexture extends ProceduralTexture {
  125251. private _time;
  125252. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125253. brightness: number;
  125254. /** Defines the number of octaves to process */
  125255. octaves: number;
  125256. /** Defines the level of persistence (0.8 by default) */
  125257. persistence: number;
  125258. /** Gets or sets animation speed factor (default is 1) */
  125259. animationSpeedFactor: number;
  125260. /**
  125261. * Creates a new NoiseProceduralTexture
  125262. * @param name defines the name fo the texture
  125263. * @param size defines the size of the texture (default is 256)
  125264. * @param scene defines the hosting scene
  125265. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125266. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125267. */
  125268. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125269. private _updateShaderUniforms;
  125270. protected _getDefines(): string;
  125271. /** Generate the current state of the procedural texture */
  125272. render(useCameraPostProcess?: boolean): void;
  125273. /**
  125274. * Serializes this noise procedural texture
  125275. * @returns a serialized noise procedural texture object
  125276. */
  125277. serialize(): any;
  125278. /**
  125279. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125280. * @param parsedTexture defines parsed texture data
  125281. * @param scene defines the current scene
  125282. * @param rootUrl defines the root URL containing noise procedural texture information
  125283. * @returns a parsed NoiseProceduralTexture
  125284. */
  125285. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125286. }
  125287. }
  125288. declare module BABYLON {
  125289. /**
  125290. * Raw cube texture where the raw buffers are passed in
  125291. */
  125292. export class RawCubeTexture extends CubeTexture {
  125293. /**
  125294. * Creates a cube texture where the raw buffers are passed in.
  125295. * @param scene defines the scene the texture is attached to
  125296. * @param data defines the array of data to use to create each face
  125297. * @param size defines the size of the textures
  125298. * @param format defines the format of the data
  125299. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125300. * @param generateMipMaps defines if the engine should generate the mip levels
  125301. * @param invertY defines if data must be stored with Y axis inverted
  125302. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125303. * @param compression defines the compression used (null by default)
  125304. */
  125305. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125306. /**
  125307. * Updates the raw cube texture.
  125308. * @param data defines the data to store
  125309. * @param format defines the data format
  125310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125311. * @param invertY defines if data must be stored with Y axis inverted
  125312. * @param compression defines the compression used (null by default)
  125313. * @param level defines which level of the texture to update
  125314. */
  125315. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125316. /**
  125317. * Updates a raw cube texture with RGBD encoded data.
  125318. * @param data defines the array of data [mipmap][face] to use to create each face
  125319. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125320. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125321. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125322. * @returns a promsie that resolves when the operation is complete
  125323. */
  125324. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125325. /**
  125326. * Clones the raw cube texture.
  125327. * @return a new cube texture
  125328. */
  125329. clone(): CubeTexture;
  125330. /** @hidden */
  125331. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125332. }
  125333. }
  125334. declare module BABYLON {
  125335. /**
  125336. * Class used to store 3D textures containing user data
  125337. */
  125338. export class RawTexture3D extends Texture {
  125339. /** Gets or sets the texture format to use */
  125340. format: number;
  125341. private _engine;
  125342. /**
  125343. * Create a new RawTexture3D
  125344. * @param data defines the data of the texture
  125345. * @param width defines the width of the texture
  125346. * @param height defines the height of the texture
  125347. * @param depth defines the depth of the texture
  125348. * @param format defines the texture format to use
  125349. * @param scene defines the hosting scene
  125350. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125351. * @param invertY defines if texture must be stored with Y axis inverted
  125352. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125353. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125354. */
  125355. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125356. /** Gets or sets the texture format to use */
  125357. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125358. /**
  125359. * Update the texture with new data
  125360. * @param data defines the data to store in the texture
  125361. */
  125362. update(data: ArrayBufferView): void;
  125363. }
  125364. }
  125365. declare module BABYLON {
  125366. /**
  125367. * Class used to store 2D array textures containing user data
  125368. */
  125369. export class RawTexture2DArray extends Texture {
  125370. /** Gets or sets the texture format to use */
  125371. format: number;
  125372. private _engine;
  125373. /**
  125374. * Create a new RawTexture2DArray
  125375. * @param data defines the data of the texture
  125376. * @param width defines the width of the texture
  125377. * @param height defines the height of the texture
  125378. * @param depth defines the number of layers of the texture
  125379. * @param format defines the texture format to use
  125380. * @param scene defines the hosting scene
  125381. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125382. * @param invertY defines if texture must be stored with Y axis inverted
  125383. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125384. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125385. */
  125386. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125387. /** Gets or sets the texture format to use */
  125388. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125389. /**
  125390. * Update the texture with new data
  125391. * @param data defines the data to store in the texture
  125392. */
  125393. update(data: ArrayBufferView): void;
  125394. }
  125395. }
  125396. declare module BABYLON {
  125397. /**
  125398. * Creates a refraction texture used by refraction channel of the standard material.
  125399. * It is like a mirror but to see through a material.
  125400. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125401. */
  125402. export class RefractionTexture extends RenderTargetTexture {
  125403. /**
  125404. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125405. * 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.
  125406. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125407. */
  125408. refractionPlane: Plane;
  125409. /**
  125410. * Define how deep under the surface we should see.
  125411. */
  125412. depth: number;
  125413. /**
  125414. * Creates a refraction texture used by refraction channel of the standard material.
  125415. * It is like a mirror but to see through a material.
  125416. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125417. * @param name Define the texture name
  125418. * @param size Define the size of the underlying texture
  125419. * @param scene Define the scene the refraction belongs to
  125420. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125421. */
  125422. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125423. /**
  125424. * Clone the refraction texture.
  125425. * @returns the cloned texture
  125426. */
  125427. clone(): RefractionTexture;
  125428. /**
  125429. * Serialize the texture to a JSON representation you could use in Parse later on
  125430. * @returns the serialized JSON representation
  125431. */
  125432. serialize(): any;
  125433. }
  125434. }
  125435. declare module BABYLON {
  125436. /**
  125437. * Defines the options related to the creation of an HtmlElementTexture
  125438. */
  125439. export interface IHtmlElementTextureOptions {
  125440. /**
  125441. * Defines wether mip maps should be created or not.
  125442. */
  125443. generateMipMaps?: boolean;
  125444. /**
  125445. * Defines the sampling mode of the texture.
  125446. */
  125447. samplingMode?: number;
  125448. /**
  125449. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125450. */
  125451. engine: Nullable<ThinEngine>;
  125452. /**
  125453. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125454. */
  125455. scene: Nullable<Scene>;
  125456. }
  125457. /**
  125458. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125459. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125460. * is automatically managed.
  125461. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125462. * in your application.
  125463. *
  125464. * As the update is not automatic, you need to call them manually.
  125465. */
  125466. export class HtmlElementTexture extends BaseTexture {
  125467. /**
  125468. * The texture URL.
  125469. */
  125470. element: HTMLVideoElement | HTMLCanvasElement;
  125471. private static readonly DefaultOptions;
  125472. private _textureMatrix;
  125473. private _engine;
  125474. private _isVideo;
  125475. private _generateMipMaps;
  125476. private _samplingMode;
  125477. /**
  125478. * Instantiates a HtmlElementTexture from the following parameters.
  125479. *
  125480. * @param name Defines the name of the texture
  125481. * @param element Defines the video or canvas the texture is filled with
  125482. * @param options Defines the other none mandatory texture creation options
  125483. */
  125484. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125485. private _createInternalTexture;
  125486. /**
  125487. * Returns the texture matrix used in most of the material.
  125488. */
  125489. getTextureMatrix(): Matrix;
  125490. /**
  125491. * Updates the content of the texture.
  125492. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125493. */
  125494. update(invertY?: Nullable<boolean>): void;
  125495. }
  125496. }
  125497. declare module BABYLON {
  125498. /**
  125499. * Enum used to define the target of a block
  125500. */
  125501. export enum NodeMaterialBlockTargets {
  125502. /** Vertex shader */
  125503. Vertex = 1,
  125504. /** Fragment shader */
  125505. Fragment = 2,
  125506. /** Neutral */
  125507. Neutral = 4,
  125508. /** Vertex and Fragment */
  125509. VertexAndFragment = 3
  125510. }
  125511. }
  125512. declare module BABYLON {
  125513. /**
  125514. * Defines the kind of connection point for node based material
  125515. */
  125516. export enum NodeMaterialBlockConnectionPointTypes {
  125517. /** Float */
  125518. Float = 1,
  125519. /** Int */
  125520. Int = 2,
  125521. /** Vector2 */
  125522. Vector2 = 4,
  125523. /** Vector3 */
  125524. Vector3 = 8,
  125525. /** Vector4 */
  125526. Vector4 = 16,
  125527. /** Color3 */
  125528. Color3 = 32,
  125529. /** Color4 */
  125530. Color4 = 64,
  125531. /** Matrix */
  125532. Matrix = 128,
  125533. /** Detect type based on connection */
  125534. AutoDetect = 1024,
  125535. /** Output type that will be defined by input type */
  125536. BasedOnInput = 2048
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125542. */
  125543. export enum NodeMaterialBlockConnectionPointMode {
  125544. /** Value is an uniform */
  125545. Uniform = 0,
  125546. /** Value is a mesh attribute */
  125547. Attribute = 1,
  125548. /** Value is a varying between vertex and fragment shaders */
  125549. Varying = 2,
  125550. /** Mode is undefined */
  125551. Undefined = 3
  125552. }
  125553. }
  125554. declare module BABYLON {
  125555. /**
  125556. * Enum used to define system values e.g. values automatically provided by the system
  125557. */
  125558. export enum NodeMaterialSystemValues {
  125559. /** World */
  125560. World = 1,
  125561. /** View */
  125562. View = 2,
  125563. /** Projection */
  125564. Projection = 3,
  125565. /** ViewProjection */
  125566. ViewProjection = 4,
  125567. /** WorldView */
  125568. WorldView = 5,
  125569. /** WorldViewProjection */
  125570. WorldViewProjection = 6,
  125571. /** CameraPosition */
  125572. CameraPosition = 7,
  125573. /** Fog Color */
  125574. FogColor = 8,
  125575. /** Delta time */
  125576. DeltaTime = 9
  125577. }
  125578. }
  125579. declare module BABYLON {
  125580. /**
  125581. * Root class for all node material optimizers
  125582. */
  125583. export class NodeMaterialOptimizer {
  125584. /**
  125585. * Function used to optimize a NodeMaterial graph
  125586. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125587. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125588. */
  125589. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125590. }
  125591. }
  125592. declare module BABYLON {
  125593. /**
  125594. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125595. */
  125596. export class TransformBlock extends NodeMaterialBlock {
  125597. /**
  125598. * Defines the value to use to complement W value to transform it to a Vector4
  125599. */
  125600. complementW: number;
  125601. /**
  125602. * Defines the value to use to complement z value to transform it to a Vector4
  125603. */
  125604. complementZ: number;
  125605. /**
  125606. * Creates a new TransformBlock
  125607. * @param name defines the block name
  125608. */
  125609. constructor(name: string);
  125610. /**
  125611. * Gets the current class name
  125612. * @returns the class name
  125613. */
  125614. getClassName(): string;
  125615. /**
  125616. * Gets the vector input
  125617. */
  125618. get vector(): NodeMaterialConnectionPoint;
  125619. /**
  125620. * Gets the output component
  125621. */
  125622. get output(): NodeMaterialConnectionPoint;
  125623. /**
  125624. * Gets the matrix transform input
  125625. */
  125626. get transform(): NodeMaterialConnectionPoint;
  125627. protected _buildBlock(state: NodeMaterialBuildState): this;
  125628. serialize(): any;
  125629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125630. protected _dumpPropertiesCode(): string;
  125631. }
  125632. }
  125633. declare module BABYLON {
  125634. /**
  125635. * Block used to output the vertex position
  125636. */
  125637. export class VertexOutputBlock extends NodeMaterialBlock {
  125638. /**
  125639. * Creates a new VertexOutputBlock
  125640. * @param name defines the block name
  125641. */
  125642. constructor(name: string);
  125643. /**
  125644. * Gets the current class name
  125645. * @returns the class name
  125646. */
  125647. getClassName(): string;
  125648. /**
  125649. * Gets the vector input component
  125650. */
  125651. get vector(): NodeMaterialConnectionPoint;
  125652. protected _buildBlock(state: NodeMaterialBuildState): this;
  125653. }
  125654. }
  125655. declare module BABYLON {
  125656. /**
  125657. * Block used to output the final color
  125658. */
  125659. export class FragmentOutputBlock extends NodeMaterialBlock {
  125660. /**
  125661. * Create a new FragmentOutputBlock
  125662. * @param name defines the block name
  125663. */
  125664. constructor(name: string);
  125665. /**
  125666. * Gets the current class name
  125667. * @returns the class name
  125668. */
  125669. getClassName(): string;
  125670. /**
  125671. * Gets the rgba input component
  125672. */
  125673. get rgba(): NodeMaterialConnectionPoint;
  125674. /**
  125675. * Gets the rgb input component
  125676. */
  125677. get rgb(): NodeMaterialConnectionPoint;
  125678. /**
  125679. * Gets the a input component
  125680. */
  125681. get a(): NodeMaterialConnectionPoint;
  125682. protected _buildBlock(state: NodeMaterialBuildState): this;
  125683. }
  125684. }
  125685. declare module BABYLON {
  125686. /**
  125687. * Block used to read a reflection texture from a sampler
  125688. */
  125689. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125690. private _define3DName;
  125691. private _defineCubicName;
  125692. private _defineExplicitName;
  125693. private _defineProjectionName;
  125694. private _defineLocalCubicName;
  125695. private _defineSphericalName;
  125696. private _definePlanarName;
  125697. private _defineEquirectangularName;
  125698. private _defineMirroredEquirectangularFixedName;
  125699. private _defineEquirectangularFixedName;
  125700. private _defineSkyboxName;
  125701. private _cubeSamplerName;
  125702. private _2DSamplerName;
  125703. private _positionUVWName;
  125704. private _directionWName;
  125705. private _reflectionCoordsName;
  125706. private _reflection2DCoordsName;
  125707. private _reflectionColorName;
  125708. private _reflectionMatrixName;
  125709. /**
  125710. * Gets or sets the texture associated with the node
  125711. */
  125712. texture: Nullable<BaseTexture>;
  125713. /**
  125714. * Create a new TextureBlock
  125715. * @param name defines the block name
  125716. */
  125717. constructor(name: string);
  125718. /**
  125719. * Gets the current class name
  125720. * @returns the class name
  125721. */
  125722. getClassName(): string;
  125723. /**
  125724. * Gets the world position input component
  125725. */
  125726. get position(): NodeMaterialConnectionPoint;
  125727. /**
  125728. * Gets the world position input component
  125729. */
  125730. get worldPosition(): NodeMaterialConnectionPoint;
  125731. /**
  125732. * Gets the world normal input component
  125733. */
  125734. get worldNormal(): NodeMaterialConnectionPoint;
  125735. /**
  125736. * Gets the world input component
  125737. */
  125738. get world(): NodeMaterialConnectionPoint;
  125739. /**
  125740. * Gets the camera (or eye) position component
  125741. */
  125742. get cameraPosition(): NodeMaterialConnectionPoint;
  125743. /**
  125744. * Gets the view input component
  125745. */
  125746. get view(): NodeMaterialConnectionPoint;
  125747. /**
  125748. * Gets the rgb output component
  125749. */
  125750. get rgb(): NodeMaterialConnectionPoint;
  125751. /**
  125752. * Gets the r output component
  125753. */
  125754. get r(): NodeMaterialConnectionPoint;
  125755. /**
  125756. * Gets the g output component
  125757. */
  125758. get g(): NodeMaterialConnectionPoint;
  125759. /**
  125760. * Gets the b output component
  125761. */
  125762. get b(): NodeMaterialConnectionPoint;
  125763. autoConfigure(material: NodeMaterial): void;
  125764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125765. isReady(): boolean;
  125766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125767. private _injectVertexCode;
  125768. private _writeOutput;
  125769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125770. protected _dumpPropertiesCode(): string;
  125771. serialize(): any;
  125772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125773. }
  125774. }
  125775. declare module BABYLON {
  125776. /**
  125777. * Interface used to configure the node material editor
  125778. */
  125779. export interface INodeMaterialEditorOptions {
  125780. /** Define the URl to load node editor script */
  125781. editorURL?: string;
  125782. }
  125783. /** @hidden */
  125784. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125785. /** BONES */
  125786. NUM_BONE_INFLUENCERS: number;
  125787. BonesPerMesh: number;
  125788. BONETEXTURE: boolean;
  125789. /** MORPH TARGETS */
  125790. MORPHTARGETS: boolean;
  125791. MORPHTARGETS_NORMAL: boolean;
  125792. MORPHTARGETS_TANGENT: boolean;
  125793. MORPHTARGETS_UV: boolean;
  125794. NUM_MORPH_INFLUENCERS: number;
  125795. /** IMAGE PROCESSING */
  125796. IMAGEPROCESSING: boolean;
  125797. VIGNETTE: boolean;
  125798. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125799. VIGNETTEBLENDMODEOPAQUE: boolean;
  125800. TONEMAPPING: boolean;
  125801. TONEMAPPING_ACES: boolean;
  125802. CONTRAST: boolean;
  125803. EXPOSURE: boolean;
  125804. COLORCURVES: boolean;
  125805. COLORGRADING: boolean;
  125806. COLORGRADING3D: boolean;
  125807. SAMPLER3DGREENDEPTH: boolean;
  125808. SAMPLER3DBGRMAP: boolean;
  125809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125810. /** MISC. */
  125811. BUMPDIRECTUV: number;
  125812. constructor();
  125813. setValue(name: string, value: boolean): void;
  125814. }
  125815. /**
  125816. * Class used to configure NodeMaterial
  125817. */
  125818. export interface INodeMaterialOptions {
  125819. /**
  125820. * Defines if blocks should emit comments
  125821. */
  125822. emitComments: boolean;
  125823. }
  125824. /**
  125825. * Class used to create a node based material built by assembling shader blocks
  125826. */
  125827. export class NodeMaterial extends PushMaterial {
  125828. private static _BuildIdGenerator;
  125829. private _options;
  125830. private _vertexCompilationState;
  125831. private _fragmentCompilationState;
  125832. private _sharedData;
  125833. private _buildId;
  125834. private _buildWasSuccessful;
  125835. private _cachedWorldViewMatrix;
  125836. private _cachedWorldViewProjectionMatrix;
  125837. private _optimizers;
  125838. private _animationFrame;
  125839. /** Define the URl to load node editor script */
  125840. static EditorURL: string;
  125841. private BJSNODEMATERIALEDITOR;
  125842. /** Get the inspector from bundle or global */
  125843. private _getGlobalNodeMaterialEditor;
  125844. /**
  125845. * Gets or sets data used by visual editor
  125846. * @see https://nme.babylonjs.com
  125847. */
  125848. editorData: any;
  125849. /**
  125850. * 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)
  125851. */
  125852. ignoreAlpha: boolean;
  125853. /**
  125854. * Defines the maximum number of lights that can be used in the material
  125855. */
  125856. maxSimultaneousLights: number;
  125857. /**
  125858. * Observable raised when the material is built
  125859. */
  125860. onBuildObservable: Observable<NodeMaterial>;
  125861. /**
  125862. * Gets or sets the root nodes of the material vertex shader
  125863. */
  125864. _vertexOutputNodes: NodeMaterialBlock[];
  125865. /**
  125866. * Gets or sets the root nodes of the material fragment (pixel) shader
  125867. */
  125868. _fragmentOutputNodes: NodeMaterialBlock[];
  125869. /** Gets or sets options to control the node material overall behavior */
  125870. get options(): INodeMaterialOptions;
  125871. set options(options: INodeMaterialOptions);
  125872. /**
  125873. * Default configuration related to image processing available in the standard Material.
  125874. */
  125875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125876. /**
  125877. * Gets the image processing configuration used either in this material.
  125878. */
  125879. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125880. /**
  125881. * Sets the Default image processing configuration used either in the this material.
  125882. *
  125883. * If sets to null, the scene one is in use.
  125884. */
  125885. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125886. /**
  125887. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  125888. */
  125889. attachedBlocks: NodeMaterialBlock[];
  125890. /**
  125891. * Create a new node based material
  125892. * @param name defines the material name
  125893. * @param scene defines the hosting scene
  125894. * @param options defines creation option
  125895. */
  125896. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  125897. /**
  125898. * Gets the current class name of the material e.g. "NodeMaterial"
  125899. * @returns the class name
  125900. */
  125901. getClassName(): string;
  125902. /**
  125903. * Keep track of the image processing observer to allow dispose and replace.
  125904. */
  125905. private _imageProcessingObserver;
  125906. /**
  125907. * Attaches a new image processing configuration to the Standard Material.
  125908. * @param configuration
  125909. */
  125910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125911. /**
  125912. * Get a block by its name
  125913. * @param name defines the name of the block to retrieve
  125914. * @returns the required block or null if not found
  125915. */
  125916. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  125917. /**
  125918. * Get a block by its name
  125919. * @param predicate defines the predicate used to find the good candidate
  125920. * @returns the required block or null if not found
  125921. */
  125922. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  125923. /**
  125924. * Get an input block by its name
  125925. * @param predicate defines the predicate used to find the good candidate
  125926. * @returns the required input block or null if not found
  125927. */
  125928. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  125929. /**
  125930. * Gets the list of input blocks attached to this material
  125931. * @returns an array of InputBlocks
  125932. */
  125933. getInputBlocks(): InputBlock[];
  125934. /**
  125935. * Adds a new optimizer to the list of optimizers
  125936. * @param optimizer defines the optimizers to add
  125937. * @returns the current material
  125938. */
  125939. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125940. /**
  125941. * Remove an optimizer from the list of optimizers
  125942. * @param optimizer defines the optimizers to remove
  125943. * @returns the current material
  125944. */
  125945. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125946. /**
  125947. * Add a new block to the list of output nodes
  125948. * @param node defines the node to add
  125949. * @returns the current material
  125950. */
  125951. addOutputNode(node: NodeMaterialBlock): this;
  125952. /**
  125953. * Remove a block from the list of root nodes
  125954. * @param node defines the node to remove
  125955. * @returns the current material
  125956. */
  125957. removeOutputNode(node: NodeMaterialBlock): this;
  125958. private _addVertexOutputNode;
  125959. private _removeVertexOutputNode;
  125960. private _addFragmentOutputNode;
  125961. private _removeFragmentOutputNode;
  125962. /**
  125963. * Specifies if the material will require alpha blending
  125964. * @returns a boolean specifying if alpha blending is needed
  125965. */
  125966. needAlphaBlending(): boolean;
  125967. /**
  125968. * Specifies if this material should be rendered in alpha test mode
  125969. * @returns a boolean specifying if an alpha test is needed.
  125970. */
  125971. needAlphaTesting(): boolean;
  125972. private _initializeBlock;
  125973. private _resetDualBlocks;
  125974. /**
  125975. * Remove a block from the current node material
  125976. * @param block defines the block to remove
  125977. */
  125978. removeBlock(block: NodeMaterialBlock): void;
  125979. /**
  125980. * Build the material and generates the inner effect
  125981. * @param verbose defines if the build should log activity
  125982. */
  125983. build(verbose?: boolean): void;
  125984. /**
  125985. * Runs an otpimization phase to try to improve the shader code
  125986. */
  125987. optimize(): void;
  125988. private _prepareDefinesForAttributes;
  125989. /**
  125990. * Get if the submesh is ready to be used and all its information available.
  125991. * Child classes can use it to update shaders
  125992. * @param mesh defines the mesh to check
  125993. * @param subMesh defines which submesh to check
  125994. * @param useInstances specifies that instances should be used
  125995. * @returns a boolean indicating that the submesh is ready or not
  125996. */
  125997. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125998. /**
  125999. * Get a string representing the shaders built by the current node graph
  126000. */
  126001. get compiledShaders(): string;
  126002. /**
  126003. * Binds the world matrix to the material
  126004. * @param world defines the world transformation matrix
  126005. */
  126006. bindOnlyWorldMatrix(world: Matrix): void;
  126007. /**
  126008. * Binds the submesh to this material by preparing the effect and shader to draw
  126009. * @param world defines the world transformation matrix
  126010. * @param mesh defines the mesh containing the submesh
  126011. * @param subMesh defines the submesh to bind the material to
  126012. */
  126013. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126014. /**
  126015. * Gets the active textures from the material
  126016. * @returns an array of textures
  126017. */
  126018. getActiveTextures(): BaseTexture[];
  126019. /**
  126020. * Gets the list of texture blocks
  126021. * @returns an array of texture blocks
  126022. */
  126023. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126024. /**
  126025. * Specifies if the material uses a texture
  126026. * @param texture defines the texture to check against the material
  126027. * @returns a boolean specifying if the material uses the texture
  126028. */
  126029. hasTexture(texture: BaseTexture): boolean;
  126030. /**
  126031. * Disposes the material
  126032. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126033. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126034. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126035. */
  126036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126037. /** Creates the node editor window. */
  126038. private _createNodeEditor;
  126039. /**
  126040. * Launch the node material editor
  126041. * @param config Define the configuration of the editor
  126042. * @return a promise fulfilled when the node editor is visible
  126043. */
  126044. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126045. /**
  126046. * Clear the current material
  126047. */
  126048. clear(): void;
  126049. /**
  126050. * Clear the current material and set it to a default state
  126051. */
  126052. setToDefault(): void;
  126053. /**
  126054. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126055. * @param url defines the url to load from
  126056. * @returns a promise that will fullfil when the material is fully loaded
  126057. */
  126058. loadAsync(url: string): Promise<void>;
  126059. private _gatherBlocks;
  126060. /**
  126061. * Generate a string containing the code declaration required to create an equivalent of this material
  126062. * @returns a string
  126063. */
  126064. generateCode(): string;
  126065. /**
  126066. * Serializes this material in a JSON representation
  126067. * @returns the serialized material object
  126068. */
  126069. serialize(): any;
  126070. private _restoreConnections;
  126071. /**
  126072. * Clear the current graph and load a new one from a serialization object
  126073. * @param source defines the JSON representation of the material
  126074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126075. */
  126076. loadFromSerialization(source: any, rootUrl?: string): void;
  126077. /**
  126078. * Creates a node material from parsed material data
  126079. * @param source defines the JSON representation of the material
  126080. * @param scene defines the hosting scene
  126081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126082. * @returns a new node material
  126083. */
  126084. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126085. /**
  126086. * Creates a new node material set to default basic configuration
  126087. * @param name defines the name of the material
  126088. * @param scene defines the hosting scene
  126089. * @returns a new NodeMaterial
  126090. */
  126091. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126092. }
  126093. }
  126094. declare module BABYLON {
  126095. /**
  126096. * Block used to read a texture from a sampler
  126097. */
  126098. export class TextureBlock extends NodeMaterialBlock {
  126099. private _defineName;
  126100. private _linearDefineName;
  126101. private _tempTextureRead;
  126102. private _samplerName;
  126103. private _transformedUVName;
  126104. private _textureTransformName;
  126105. private _textureInfoName;
  126106. private _mainUVName;
  126107. private _mainUVDefineName;
  126108. /**
  126109. * Gets or sets the texture associated with the node
  126110. */
  126111. texture: Nullable<Texture>;
  126112. /**
  126113. * Create a new TextureBlock
  126114. * @param name defines the block name
  126115. */
  126116. constructor(name: string);
  126117. /**
  126118. * Gets the current class name
  126119. * @returns the class name
  126120. */
  126121. getClassName(): string;
  126122. /**
  126123. * Gets the uv input component
  126124. */
  126125. get uv(): NodeMaterialConnectionPoint;
  126126. /**
  126127. * Gets the rgba output component
  126128. */
  126129. get rgba(): NodeMaterialConnectionPoint;
  126130. /**
  126131. * Gets the rgb output component
  126132. */
  126133. get rgb(): NodeMaterialConnectionPoint;
  126134. /**
  126135. * Gets the r output component
  126136. */
  126137. get r(): NodeMaterialConnectionPoint;
  126138. /**
  126139. * Gets the g output component
  126140. */
  126141. get g(): NodeMaterialConnectionPoint;
  126142. /**
  126143. * Gets the b output component
  126144. */
  126145. get b(): NodeMaterialConnectionPoint;
  126146. /**
  126147. * Gets the a output component
  126148. */
  126149. get a(): NodeMaterialConnectionPoint;
  126150. get target(): NodeMaterialBlockTargets;
  126151. autoConfigure(material: NodeMaterial): void;
  126152. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126154. private _getTextureBase;
  126155. isReady(): boolean;
  126156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126157. private get _isMixed();
  126158. private _injectVertexCode;
  126159. private _writeTextureRead;
  126160. private _writeOutput;
  126161. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126162. protected _dumpPropertiesCode(): string;
  126163. serialize(): any;
  126164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126165. }
  126166. }
  126167. declare module BABYLON {
  126168. /**
  126169. * Class used to store shared data between 2 NodeMaterialBuildState
  126170. */
  126171. export class NodeMaterialBuildStateSharedData {
  126172. /**
  126173. * Gets the list of emitted varyings
  126174. */
  126175. temps: string[];
  126176. /**
  126177. * Gets the list of emitted varyings
  126178. */
  126179. varyings: string[];
  126180. /**
  126181. * Gets the varying declaration string
  126182. */
  126183. varyingDeclaration: string;
  126184. /**
  126185. * Input blocks
  126186. */
  126187. inputBlocks: InputBlock[];
  126188. /**
  126189. * Input blocks
  126190. */
  126191. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126192. /**
  126193. * Bindable blocks (Blocks that need to set data to the effect)
  126194. */
  126195. bindableBlocks: NodeMaterialBlock[];
  126196. /**
  126197. * List of blocks that can provide a compilation fallback
  126198. */
  126199. blocksWithFallbacks: NodeMaterialBlock[];
  126200. /**
  126201. * List of blocks that can provide a define update
  126202. */
  126203. blocksWithDefines: NodeMaterialBlock[];
  126204. /**
  126205. * List of blocks that can provide a repeatable content
  126206. */
  126207. repeatableContentBlocks: NodeMaterialBlock[];
  126208. /**
  126209. * List of blocks that can provide a dynamic list of uniforms
  126210. */
  126211. dynamicUniformBlocks: NodeMaterialBlock[];
  126212. /**
  126213. * List of blocks that can block the isReady function for the material
  126214. */
  126215. blockingBlocks: NodeMaterialBlock[];
  126216. /**
  126217. * Gets the list of animated inputs
  126218. */
  126219. animatedInputs: InputBlock[];
  126220. /**
  126221. * Build Id used to avoid multiple recompilations
  126222. */
  126223. buildId: number;
  126224. /** List of emitted variables */
  126225. variableNames: {
  126226. [key: string]: number;
  126227. };
  126228. /** List of emitted defines */
  126229. defineNames: {
  126230. [key: string]: number;
  126231. };
  126232. /** Should emit comments? */
  126233. emitComments: boolean;
  126234. /** Emit build activity */
  126235. verbose: boolean;
  126236. /** Gets or sets the hosting scene */
  126237. scene: Scene;
  126238. /**
  126239. * Gets the compilation hints emitted at compilation time
  126240. */
  126241. hints: {
  126242. needWorldViewMatrix: boolean;
  126243. needWorldViewProjectionMatrix: boolean;
  126244. needAlphaBlending: boolean;
  126245. needAlphaTesting: boolean;
  126246. };
  126247. /**
  126248. * List of compilation checks
  126249. */
  126250. checks: {
  126251. emitVertex: boolean;
  126252. emitFragment: boolean;
  126253. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126254. };
  126255. /** Creates a new shared data */
  126256. constructor();
  126257. /**
  126258. * Emits console errors and exceptions if there is a failing check
  126259. */
  126260. emitErrors(): void;
  126261. }
  126262. }
  126263. declare module BABYLON {
  126264. /**
  126265. * Class used to store node based material build state
  126266. */
  126267. export class NodeMaterialBuildState {
  126268. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126269. supportUniformBuffers: boolean;
  126270. /**
  126271. * Gets the list of emitted attributes
  126272. */
  126273. attributes: string[];
  126274. /**
  126275. * Gets the list of emitted uniforms
  126276. */
  126277. uniforms: string[];
  126278. /**
  126279. * Gets the list of emitted constants
  126280. */
  126281. constants: string[];
  126282. /**
  126283. * Gets the list of emitted samplers
  126284. */
  126285. samplers: string[];
  126286. /**
  126287. * Gets the list of emitted functions
  126288. */
  126289. functions: {
  126290. [key: string]: string;
  126291. };
  126292. /**
  126293. * Gets the list of emitted extensions
  126294. */
  126295. extensions: {
  126296. [key: string]: string;
  126297. };
  126298. /**
  126299. * Gets the target of the compilation state
  126300. */
  126301. target: NodeMaterialBlockTargets;
  126302. /**
  126303. * Gets the list of emitted counters
  126304. */
  126305. counters: {
  126306. [key: string]: number;
  126307. };
  126308. /**
  126309. * Shared data between multiple NodeMaterialBuildState instances
  126310. */
  126311. sharedData: NodeMaterialBuildStateSharedData;
  126312. /** @hidden */
  126313. _vertexState: NodeMaterialBuildState;
  126314. /** @hidden */
  126315. _attributeDeclaration: string;
  126316. /** @hidden */
  126317. _uniformDeclaration: string;
  126318. /** @hidden */
  126319. _constantDeclaration: string;
  126320. /** @hidden */
  126321. _samplerDeclaration: string;
  126322. /** @hidden */
  126323. _varyingTransfer: string;
  126324. private _repeatableContentAnchorIndex;
  126325. /** @hidden */
  126326. _builtCompilationString: string;
  126327. /**
  126328. * Gets the emitted compilation strings
  126329. */
  126330. compilationString: string;
  126331. /**
  126332. * Finalize the compilation strings
  126333. * @param state defines the current compilation state
  126334. */
  126335. finalize(state: NodeMaterialBuildState): void;
  126336. /** @hidden */
  126337. get _repeatableContentAnchor(): string;
  126338. /** @hidden */
  126339. _getFreeVariableName(prefix: string): string;
  126340. /** @hidden */
  126341. _getFreeDefineName(prefix: string): string;
  126342. /** @hidden */
  126343. _excludeVariableName(name: string): void;
  126344. /** @hidden */
  126345. _emit2DSampler(name: string): void;
  126346. /** @hidden */
  126347. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126348. /** @hidden */
  126349. _emitExtension(name: string, extension: string): void;
  126350. /** @hidden */
  126351. _emitFunction(name: string, code: string, comments: string): void;
  126352. /** @hidden */
  126353. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126354. replaceStrings?: {
  126355. search: RegExp;
  126356. replace: string;
  126357. }[];
  126358. repeatKey?: string;
  126359. }): string;
  126360. /** @hidden */
  126361. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126362. repeatKey?: string;
  126363. removeAttributes?: boolean;
  126364. removeUniforms?: boolean;
  126365. removeVaryings?: boolean;
  126366. removeIfDef?: boolean;
  126367. replaceStrings?: {
  126368. search: RegExp;
  126369. replace: string;
  126370. }[];
  126371. }, storeKey?: string): void;
  126372. /** @hidden */
  126373. _registerTempVariable(name: string): boolean;
  126374. /** @hidden */
  126375. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126376. /** @hidden */
  126377. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126378. /** @hidden */
  126379. _emitFloat(value: number): string;
  126380. }
  126381. }
  126382. declare module BABYLON {
  126383. /**
  126384. * Defines a block that can be used inside a node based material
  126385. */
  126386. export class NodeMaterialBlock {
  126387. private _buildId;
  126388. private _buildTarget;
  126389. private _target;
  126390. private _isFinalMerger;
  126391. private _isInput;
  126392. protected _isUnique: boolean;
  126393. /** @hidden */
  126394. _codeVariableName: string;
  126395. /** @hidden */
  126396. _inputs: NodeMaterialConnectionPoint[];
  126397. /** @hidden */
  126398. _outputs: NodeMaterialConnectionPoint[];
  126399. /** @hidden */
  126400. _preparationId: number;
  126401. /**
  126402. * Gets or sets the name of the block
  126403. */
  126404. name: string;
  126405. /**
  126406. * Gets or sets the unique id of the node
  126407. */
  126408. uniqueId: number;
  126409. /**
  126410. * Gets or sets the comments associated with this block
  126411. */
  126412. comments: string;
  126413. /**
  126414. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126415. */
  126416. get isUnique(): boolean;
  126417. /**
  126418. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126419. */
  126420. get isFinalMerger(): boolean;
  126421. /**
  126422. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126423. */
  126424. get isInput(): boolean;
  126425. /**
  126426. * Gets or sets the build Id
  126427. */
  126428. get buildId(): number;
  126429. set buildId(value: number);
  126430. /**
  126431. * Gets or sets the target of the block
  126432. */
  126433. get target(): NodeMaterialBlockTargets;
  126434. set target(value: NodeMaterialBlockTargets);
  126435. /**
  126436. * Gets the list of input points
  126437. */
  126438. get inputs(): NodeMaterialConnectionPoint[];
  126439. /** Gets the list of output points */
  126440. get outputs(): NodeMaterialConnectionPoint[];
  126441. /**
  126442. * Find an input by its name
  126443. * @param name defines the name of the input to look for
  126444. * @returns the input or null if not found
  126445. */
  126446. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126447. /**
  126448. * Find an output by its name
  126449. * @param name defines the name of the outputto look for
  126450. * @returns the output or null if not found
  126451. */
  126452. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126453. /**
  126454. * Creates a new NodeMaterialBlock
  126455. * @param name defines the block name
  126456. * @param target defines the target of that block (Vertex by default)
  126457. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126458. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126459. */
  126460. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126461. /**
  126462. * Initialize the block and prepare the context for build
  126463. * @param state defines the state that will be used for the build
  126464. */
  126465. initialize(state: NodeMaterialBuildState): void;
  126466. /**
  126467. * Bind data to effect. Will only be called for blocks with isBindable === true
  126468. * @param effect defines the effect to bind data to
  126469. * @param nodeMaterial defines the hosting NodeMaterial
  126470. * @param mesh defines the mesh that will be rendered
  126471. */
  126472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126473. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126474. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126475. protected _writeFloat(value: number): string;
  126476. /**
  126477. * Gets the current class name e.g. "NodeMaterialBlock"
  126478. * @returns the class name
  126479. */
  126480. getClassName(): string;
  126481. /**
  126482. * Register a new input. Must be called inside a block constructor
  126483. * @param name defines the connection point name
  126484. * @param type defines the connection point type
  126485. * @param isOptional defines a boolean indicating that this input can be omitted
  126486. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126487. * @returns the current block
  126488. */
  126489. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126490. /**
  126491. * Register a new output. Must be called inside a block constructor
  126492. * @param name defines the connection point name
  126493. * @param type defines the connection point type
  126494. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126495. * @returns the current block
  126496. */
  126497. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126498. /**
  126499. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126500. * @param forOutput defines an optional connection point to check compatibility with
  126501. * @returns the first available input or null
  126502. */
  126503. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126504. /**
  126505. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126506. * @param forBlock defines an optional block to check compatibility with
  126507. * @returns the first available input or null
  126508. */
  126509. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126510. /**
  126511. * Gets the sibling of the given output
  126512. * @param current defines the current output
  126513. * @returns the next output in the list or null
  126514. */
  126515. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126516. /**
  126517. * Connect current block with another block
  126518. * @param other defines the block to connect with
  126519. * @param options define the various options to help pick the right connections
  126520. * @returns the current block
  126521. */
  126522. connectTo(other: NodeMaterialBlock, options?: {
  126523. input?: string;
  126524. output?: string;
  126525. outputSwizzle?: string;
  126526. }): this | undefined;
  126527. protected _buildBlock(state: NodeMaterialBuildState): void;
  126528. /**
  126529. * Add uniforms, samplers and uniform buffers at compilation time
  126530. * @param state defines the state to update
  126531. * @param nodeMaterial defines the node material requesting the update
  126532. * @param defines defines the material defines to update
  126533. * @param uniformBuffers defines the list of uniform buffer names
  126534. */
  126535. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126536. /**
  126537. * Add potential fallbacks if shader compilation fails
  126538. * @param mesh defines the mesh to be rendered
  126539. * @param fallbacks defines the current prioritized list of fallbacks
  126540. */
  126541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126542. /**
  126543. * Initialize defines for shader compilation
  126544. * @param mesh defines the mesh to be rendered
  126545. * @param nodeMaterial defines the node material requesting the update
  126546. * @param defines defines the material defines to update
  126547. * @param useInstances specifies that instances should be used
  126548. */
  126549. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126550. /**
  126551. * Update defines for shader compilation
  126552. * @param mesh defines the mesh to be rendered
  126553. * @param nodeMaterial defines the node material requesting the update
  126554. * @param defines defines the material defines to update
  126555. * @param useInstances specifies that instances should be used
  126556. */
  126557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126558. /**
  126559. * Lets the block try to connect some inputs automatically
  126560. * @param material defines the hosting NodeMaterial
  126561. */
  126562. autoConfigure(material: NodeMaterial): void;
  126563. /**
  126564. * Function called when a block is declared as repeatable content generator
  126565. * @param vertexShaderState defines the current compilation state for the vertex shader
  126566. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126567. * @param mesh defines the mesh to be rendered
  126568. * @param defines defines the material defines to update
  126569. */
  126570. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126571. /**
  126572. * Checks if the block is ready
  126573. * @param mesh defines the mesh to be rendered
  126574. * @param nodeMaterial defines the node material requesting the update
  126575. * @param defines defines the material defines to update
  126576. * @param useInstances specifies that instances should be used
  126577. * @returns true if the block is ready
  126578. */
  126579. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126580. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126581. private _processBuild;
  126582. /**
  126583. * Compile the current node and generate the shader code
  126584. * @param state defines the current compilation state (uniforms, samplers, current string)
  126585. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126586. * @returns true if already built
  126587. */
  126588. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126589. protected _inputRename(name: string): string;
  126590. protected _outputRename(name: string): string;
  126591. protected _dumpPropertiesCode(): string;
  126592. /** @hidden */
  126593. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126594. /** @hidden */
  126595. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126596. /**
  126597. * Clone the current block to a new identical block
  126598. * @param scene defines the hosting scene
  126599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126600. * @returns a copy of the current block
  126601. */
  126602. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126603. /**
  126604. * Serializes this block in a JSON representation
  126605. * @returns the serialized block object
  126606. */
  126607. serialize(): any;
  126608. /** @hidden */
  126609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126610. /**
  126611. * Release resources
  126612. */
  126613. dispose(): void;
  126614. }
  126615. }
  126616. declare module BABYLON {
  126617. /**
  126618. * Enum defining the type of animations supported by InputBlock
  126619. */
  126620. export enum AnimatedInputBlockTypes {
  126621. /** No animation */
  126622. None = 0,
  126623. /** Time based animation. Will only work for floats */
  126624. Time = 1
  126625. }
  126626. }
  126627. declare module BABYLON {
  126628. /**
  126629. * Block used to expose an input value
  126630. */
  126631. export class InputBlock extends NodeMaterialBlock {
  126632. private _mode;
  126633. private _associatedVariableName;
  126634. private _storedValue;
  126635. private _valueCallback;
  126636. private _type;
  126637. private _animationType;
  126638. /** Gets or set a value used to limit the range of float values */
  126639. min: number;
  126640. /** Gets or set a value used to limit the range of float values */
  126641. max: number;
  126642. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126643. matrixMode: number;
  126644. /** @hidden */
  126645. _systemValue: Nullable<NodeMaterialSystemValues>;
  126646. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126647. visibleInInspector: boolean;
  126648. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126649. isConstant: boolean;
  126650. /** Gets or sets the group to use to display this block in the Inspector */
  126651. groupInInspector: string;
  126652. /**
  126653. * Gets or sets the connection point type (default is float)
  126654. */
  126655. get type(): NodeMaterialBlockConnectionPointTypes;
  126656. /**
  126657. * Creates a new InputBlock
  126658. * @param name defines the block name
  126659. * @param target defines the target of that block (Vertex by default)
  126660. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126661. */
  126662. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126663. /**
  126664. * Gets the output component
  126665. */
  126666. get output(): NodeMaterialConnectionPoint;
  126667. /**
  126668. * Set the source of this connection point to a vertex attribute
  126669. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126670. * @returns the current connection point
  126671. */
  126672. setAsAttribute(attributeName?: string): InputBlock;
  126673. /**
  126674. * Set the source of this connection point to a system value
  126675. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126676. * @returns the current connection point
  126677. */
  126678. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126679. /**
  126680. * Gets or sets the value of that point.
  126681. * Please note that this value will be ignored if valueCallback is defined
  126682. */
  126683. get value(): any;
  126684. set value(value: any);
  126685. /**
  126686. * Gets or sets a callback used to get the value of that point.
  126687. * Please note that setting this value will force the connection point to ignore the value property
  126688. */
  126689. get valueCallback(): () => any;
  126690. set valueCallback(value: () => any);
  126691. /**
  126692. * Gets or sets the associated variable name in the shader
  126693. */
  126694. get associatedVariableName(): string;
  126695. set associatedVariableName(value: string);
  126696. /** Gets or sets the type of animation applied to the input */
  126697. get animationType(): AnimatedInputBlockTypes;
  126698. set animationType(value: AnimatedInputBlockTypes);
  126699. /**
  126700. * Gets a boolean indicating that this connection point not defined yet
  126701. */
  126702. get isUndefined(): boolean;
  126703. /**
  126704. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126705. * In this case the connection point name must be the name of the uniform to use.
  126706. * Can only be set on inputs
  126707. */
  126708. get isUniform(): boolean;
  126709. set isUniform(value: boolean);
  126710. /**
  126711. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126712. * In this case the connection point name must be the name of the attribute to use
  126713. * Can only be set on inputs
  126714. */
  126715. get isAttribute(): boolean;
  126716. set isAttribute(value: boolean);
  126717. /**
  126718. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126719. * Can only be set on exit points
  126720. */
  126721. get isVarying(): boolean;
  126722. set isVarying(value: boolean);
  126723. /**
  126724. * Gets a boolean indicating that the current connection point is a system value
  126725. */
  126726. get isSystemValue(): boolean;
  126727. /**
  126728. * Gets or sets the current well known value or null if not defined as a system value
  126729. */
  126730. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126731. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126732. /**
  126733. * Gets the current class name
  126734. * @returns the class name
  126735. */
  126736. getClassName(): string;
  126737. /**
  126738. * Animate the input if animationType !== None
  126739. * @param scene defines the rendering scene
  126740. */
  126741. animate(scene: Scene): void;
  126742. private _emitDefine;
  126743. initialize(state: NodeMaterialBuildState): void;
  126744. /**
  126745. * Set the input block to its default value (based on its type)
  126746. */
  126747. setDefaultValue(): void;
  126748. private _emitConstant;
  126749. private _emit;
  126750. /** @hidden */
  126751. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126752. /** @hidden */
  126753. _transmit(effect: Effect, scene: Scene): void;
  126754. protected _buildBlock(state: NodeMaterialBuildState): void;
  126755. protected _dumpPropertiesCode(): string;
  126756. serialize(): any;
  126757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126758. }
  126759. }
  126760. declare module BABYLON {
  126761. /**
  126762. * Enum used to define the compatibility state between two connection points
  126763. */
  126764. export enum NodeMaterialConnectionPointCompatibilityStates {
  126765. /** Points are compatibles */
  126766. Compatible = 0,
  126767. /** Points are incompatible because of their types */
  126768. TypeIncompatible = 1,
  126769. /** Points are incompatible because of their targets (vertex vs fragment) */
  126770. TargetIncompatible = 2
  126771. }
  126772. /**
  126773. * Defines the direction of a connection point
  126774. */
  126775. export enum NodeMaterialConnectionPointDirection {
  126776. /** Input */
  126777. Input = 0,
  126778. /** Output */
  126779. Output = 1
  126780. }
  126781. /**
  126782. * Defines a connection point for a block
  126783. */
  126784. export class NodeMaterialConnectionPoint {
  126785. /** @hidden */
  126786. _ownerBlock: NodeMaterialBlock;
  126787. /** @hidden */
  126788. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126789. private _endpoints;
  126790. private _associatedVariableName;
  126791. private _direction;
  126792. /** @hidden */
  126793. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126794. /** @hidden */
  126795. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126796. private _type;
  126797. /** @hidden */
  126798. _enforceAssociatedVariableName: boolean;
  126799. /** Gets the direction of the point */
  126800. get direction(): NodeMaterialConnectionPointDirection;
  126801. /**
  126802. * Gets or sets the additional types supported by this connection point
  126803. */
  126804. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126805. /**
  126806. * Gets or sets the additional types excluded by this connection point
  126807. */
  126808. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126809. /**
  126810. * Observable triggered when this point is connected
  126811. */
  126812. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126813. /**
  126814. * Gets or sets the associated variable name in the shader
  126815. */
  126816. get associatedVariableName(): string;
  126817. set associatedVariableName(value: string);
  126818. /**
  126819. * Gets or sets the connection point type (default is float)
  126820. */
  126821. get type(): NodeMaterialBlockConnectionPointTypes;
  126822. set type(value: NodeMaterialBlockConnectionPointTypes);
  126823. /**
  126824. * Gets or sets the connection point name
  126825. */
  126826. name: string;
  126827. /**
  126828. * Gets or sets a boolean indicating that this connection point can be omitted
  126829. */
  126830. isOptional: boolean;
  126831. /**
  126832. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126833. */
  126834. define: string;
  126835. /** @hidden */
  126836. _prioritizeVertex: boolean;
  126837. private _target;
  126838. /** Gets or sets the target of that connection point */
  126839. get target(): NodeMaterialBlockTargets;
  126840. set target(value: NodeMaterialBlockTargets);
  126841. /**
  126842. * Gets a boolean indicating that the current point is connected
  126843. */
  126844. get isConnected(): boolean;
  126845. /**
  126846. * Gets a boolean indicating that the current point is connected to an input block
  126847. */
  126848. get isConnectedToInputBlock(): boolean;
  126849. /**
  126850. * Gets a the connected input block (if any)
  126851. */
  126852. get connectInputBlock(): Nullable<InputBlock>;
  126853. /** Get the other side of the connection (if any) */
  126854. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  126855. /** Get the block that owns this connection point */
  126856. get ownerBlock(): NodeMaterialBlock;
  126857. /** Get the block connected on the other side of this connection (if any) */
  126858. get sourceBlock(): Nullable<NodeMaterialBlock>;
  126859. /** Get the block connected on the endpoints of this connection (if any) */
  126860. get connectedBlocks(): Array<NodeMaterialBlock>;
  126861. /** Gets the list of connected endpoints */
  126862. get endpoints(): NodeMaterialConnectionPoint[];
  126863. /** Gets a boolean indicating if that output point is connected to at least one input */
  126864. get hasEndpoints(): boolean;
  126865. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  126866. get isConnectedInVertexShader(): boolean;
  126867. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  126868. get isConnectedInFragmentShader(): boolean;
  126869. /**
  126870. * Creates a new connection point
  126871. * @param name defines the connection point name
  126872. * @param ownerBlock defines the block hosting this connection point
  126873. * @param direction defines the direction of the connection point
  126874. */
  126875. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  126876. /**
  126877. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  126878. * @returns the class name
  126879. */
  126880. getClassName(): string;
  126881. /**
  126882. * Gets a boolean indicating if the current point can be connected to another point
  126883. * @param connectionPoint defines the other connection point
  126884. * @returns a boolean
  126885. */
  126886. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  126887. /**
  126888. * Gets a number indicating if the current point can be connected to another point
  126889. * @param connectionPoint defines the other connection point
  126890. * @returns a number defining the compatibility state
  126891. */
  126892. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  126893. /**
  126894. * Connect this point to another connection point
  126895. * @param connectionPoint defines the other connection point
  126896. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  126897. * @returns the current connection point
  126898. */
  126899. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  126900. /**
  126901. * Disconnect this point from one of his endpoint
  126902. * @param endpoint defines the other connection point
  126903. * @returns the current connection point
  126904. */
  126905. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  126906. /**
  126907. * Serializes this point in a JSON representation
  126908. * @returns the serialized point object
  126909. */
  126910. serialize(): any;
  126911. /**
  126912. * Release resources
  126913. */
  126914. dispose(): void;
  126915. }
  126916. }
  126917. declare module BABYLON {
  126918. /**
  126919. * Block used to add support for vertex skinning (bones)
  126920. */
  126921. export class BonesBlock extends NodeMaterialBlock {
  126922. /**
  126923. * Creates a new BonesBlock
  126924. * @param name defines the block name
  126925. */
  126926. constructor(name: string);
  126927. /**
  126928. * Initialize the block and prepare the context for build
  126929. * @param state defines the state that will be used for the build
  126930. */
  126931. initialize(state: NodeMaterialBuildState): void;
  126932. /**
  126933. * Gets the current class name
  126934. * @returns the class name
  126935. */
  126936. getClassName(): string;
  126937. /**
  126938. * Gets the matrix indices input component
  126939. */
  126940. get matricesIndices(): NodeMaterialConnectionPoint;
  126941. /**
  126942. * Gets the matrix weights input component
  126943. */
  126944. get matricesWeights(): NodeMaterialConnectionPoint;
  126945. /**
  126946. * Gets the extra matrix indices input component
  126947. */
  126948. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  126949. /**
  126950. * Gets the extra matrix weights input component
  126951. */
  126952. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  126953. /**
  126954. * Gets the world input component
  126955. */
  126956. get world(): NodeMaterialConnectionPoint;
  126957. /**
  126958. * Gets the output component
  126959. */
  126960. get output(): NodeMaterialConnectionPoint;
  126961. autoConfigure(material: NodeMaterial): void;
  126962. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126965. protected _buildBlock(state: NodeMaterialBuildState): this;
  126966. }
  126967. }
  126968. declare module BABYLON {
  126969. /**
  126970. * Block used to add support for instances
  126971. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  126972. */
  126973. export class InstancesBlock extends NodeMaterialBlock {
  126974. /**
  126975. * Creates a new InstancesBlock
  126976. * @param name defines the block name
  126977. */
  126978. constructor(name: string);
  126979. /**
  126980. * Gets the current class name
  126981. * @returns the class name
  126982. */
  126983. getClassName(): string;
  126984. /**
  126985. * Gets the first world row input component
  126986. */
  126987. get world0(): NodeMaterialConnectionPoint;
  126988. /**
  126989. * Gets the second world row input component
  126990. */
  126991. get world1(): NodeMaterialConnectionPoint;
  126992. /**
  126993. * Gets the third world row input component
  126994. */
  126995. get world2(): NodeMaterialConnectionPoint;
  126996. /**
  126997. * Gets the forth world row input component
  126998. */
  126999. get world3(): NodeMaterialConnectionPoint;
  127000. /**
  127001. * Gets the world input component
  127002. */
  127003. get world(): NodeMaterialConnectionPoint;
  127004. /**
  127005. * Gets the output component
  127006. */
  127007. get output(): NodeMaterialConnectionPoint;
  127008. autoConfigure(material: NodeMaterial): void;
  127009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127010. protected _buildBlock(state: NodeMaterialBuildState): this;
  127011. }
  127012. }
  127013. declare module BABYLON {
  127014. /**
  127015. * Block used to add morph targets support to vertex shader
  127016. */
  127017. export class MorphTargetsBlock extends NodeMaterialBlock {
  127018. private _repeatableContentAnchor;
  127019. private _repeatebleContentGenerated;
  127020. /**
  127021. * Create a new MorphTargetsBlock
  127022. * @param name defines the block name
  127023. */
  127024. constructor(name: string);
  127025. /**
  127026. * Gets the current class name
  127027. * @returns the class name
  127028. */
  127029. getClassName(): string;
  127030. /**
  127031. * Gets the position input component
  127032. */
  127033. get position(): NodeMaterialConnectionPoint;
  127034. /**
  127035. * Gets the normal input component
  127036. */
  127037. get normal(): NodeMaterialConnectionPoint;
  127038. /**
  127039. * Gets the tangent input component
  127040. */
  127041. get tangent(): NodeMaterialConnectionPoint;
  127042. /**
  127043. * Gets the tangent input component
  127044. */
  127045. get uv(): NodeMaterialConnectionPoint;
  127046. /**
  127047. * Gets the position output component
  127048. */
  127049. get positionOutput(): NodeMaterialConnectionPoint;
  127050. /**
  127051. * Gets the normal output component
  127052. */
  127053. get normalOutput(): NodeMaterialConnectionPoint;
  127054. /**
  127055. * Gets the tangent output component
  127056. */
  127057. get tangentOutput(): NodeMaterialConnectionPoint;
  127058. /**
  127059. * Gets the tangent output component
  127060. */
  127061. get uvOutput(): NodeMaterialConnectionPoint;
  127062. initialize(state: NodeMaterialBuildState): void;
  127063. autoConfigure(material: NodeMaterial): void;
  127064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127066. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127067. protected _buildBlock(state: NodeMaterialBuildState): this;
  127068. }
  127069. }
  127070. declare module BABYLON {
  127071. /**
  127072. * Block used to get data information from a light
  127073. */
  127074. export class LightInformationBlock extends NodeMaterialBlock {
  127075. private _lightDataUniformName;
  127076. private _lightColorUniformName;
  127077. private _lightTypeDefineName;
  127078. /**
  127079. * Gets or sets the light associated with this block
  127080. */
  127081. light: Nullable<Light>;
  127082. /**
  127083. * Creates a new LightInformationBlock
  127084. * @param name defines the block name
  127085. */
  127086. constructor(name: string);
  127087. /**
  127088. * Gets the current class name
  127089. * @returns the class name
  127090. */
  127091. getClassName(): string;
  127092. /**
  127093. * Gets the world position input component
  127094. */
  127095. get worldPosition(): NodeMaterialConnectionPoint;
  127096. /**
  127097. * Gets the direction output component
  127098. */
  127099. get direction(): NodeMaterialConnectionPoint;
  127100. /**
  127101. * Gets the direction output component
  127102. */
  127103. get color(): NodeMaterialConnectionPoint;
  127104. /**
  127105. * Gets the direction output component
  127106. */
  127107. get intensity(): NodeMaterialConnectionPoint;
  127108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127110. protected _buildBlock(state: NodeMaterialBuildState): this;
  127111. serialize(): any;
  127112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127113. }
  127114. }
  127115. declare module BABYLON {
  127116. /**
  127117. * Block used to add image processing support to fragment shader
  127118. */
  127119. export class ImageProcessingBlock extends NodeMaterialBlock {
  127120. /**
  127121. * Create a new ImageProcessingBlock
  127122. * @param name defines the block name
  127123. */
  127124. constructor(name: string);
  127125. /**
  127126. * Gets the current class name
  127127. * @returns the class name
  127128. */
  127129. getClassName(): string;
  127130. /**
  127131. * Gets the color input component
  127132. */
  127133. get color(): NodeMaterialConnectionPoint;
  127134. /**
  127135. * Gets the output component
  127136. */
  127137. get output(): NodeMaterialConnectionPoint;
  127138. /**
  127139. * Initialize the block and prepare the context for build
  127140. * @param state defines the state that will be used for the build
  127141. */
  127142. initialize(state: NodeMaterialBuildState): void;
  127143. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127146. protected _buildBlock(state: NodeMaterialBuildState): this;
  127147. }
  127148. }
  127149. declare module BABYLON {
  127150. /**
  127151. * Block used to pertub normals based on a normal map
  127152. */
  127153. export class PerturbNormalBlock extends NodeMaterialBlock {
  127154. private _tangentSpaceParameterName;
  127155. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127156. invertX: boolean;
  127157. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127158. invertY: boolean;
  127159. /**
  127160. * Create a new PerturbNormalBlock
  127161. * @param name defines the block name
  127162. */
  127163. constructor(name: string);
  127164. /**
  127165. * Gets the current class name
  127166. * @returns the class name
  127167. */
  127168. getClassName(): string;
  127169. /**
  127170. * Gets the world position input component
  127171. */
  127172. get worldPosition(): NodeMaterialConnectionPoint;
  127173. /**
  127174. * Gets the world normal input component
  127175. */
  127176. get worldNormal(): NodeMaterialConnectionPoint;
  127177. /**
  127178. * Gets the uv input component
  127179. */
  127180. get uv(): NodeMaterialConnectionPoint;
  127181. /**
  127182. * Gets the normal map color input component
  127183. */
  127184. get normalMapColor(): NodeMaterialConnectionPoint;
  127185. /**
  127186. * Gets the strength input component
  127187. */
  127188. get strength(): NodeMaterialConnectionPoint;
  127189. /**
  127190. * Gets the output component
  127191. */
  127192. get output(): NodeMaterialConnectionPoint;
  127193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127194. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127195. autoConfigure(material: NodeMaterial): void;
  127196. protected _buildBlock(state: NodeMaterialBuildState): this;
  127197. protected _dumpPropertiesCode(): string;
  127198. serialize(): any;
  127199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127200. }
  127201. }
  127202. declare module BABYLON {
  127203. /**
  127204. * Block used to discard a pixel if a value is smaller than a cutoff
  127205. */
  127206. export class DiscardBlock extends NodeMaterialBlock {
  127207. /**
  127208. * Create a new DiscardBlock
  127209. * @param name defines the block name
  127210. */
  127211. constructor(name: string);
  127212. /**
  127213. * Gets the current class name
  127214. * @returns the class name
  127215. */
  127216. getClassName(): string;
  127217. /**
  127218. * Gets the color input component
  127219. */
  127220. get value(): NodeMaterialConnectionPoint;
  127221. /**
  127222. * Gets the cutoff input component
  127223. */
  127224. get cutoff(): NodeMaterialConnectionPoint;
  127225. protected _buildBlock(state: NodeMaterialBuildState): this;
  127226. }
  127227. }
  127228. declare module BABYLON {
  127229. /**
  127230. * Block used to test if the fragment shader is front facing
  127231. */
  127232. export class FrontFacingBlock extends NodeMaterialBlock {
  127233. /**
  127234. * Creates a new FrontFacingBlock
  127235. * @param name defines the block name
  127236. */
  127237. constructor(name: string);
  127238. /**
  127239. * Gets the current class name
  127240. * @returns the class name
  127241. */
  127242. getClassName(): string;
  127243. /**
  127244. * Gets the output component
  127245. */
  127246. get output(): NodeMaterialConnectionPoint;
  127247. protected _buildBlock(state: NodeMaterialBuildState): this;
  127248. }
  127249. }
  127250. declare module BABYLON {
  127251. /**
  127252. * Block used to get the derivative value on x and y of a given input
  127253. */
  127254. export class DerivativeBlock extends NodeMaterialBlock {
  127255. /**
  127256. * Create a new DerivativeBlock
  127257. * @param name defines the block name
  127258. */
  127259. constructor(name: string);
  127260. /**
  127261. * Gets the current class name
  127262. * @returns the class name
  127263. */
  127264. getClassName(): string;
  127265. /**
  127266. * Gets the input component
  127267. */
  127268. get input(): NodeMaterialConnectionPoint;
  127269. /**
  127270. * Gets the derivative output on x
  127271. */
  127272. get dx(): NodeMaterialConnectionPoint;
  127273. /**
  127274. * Gets the derivative output on y
  127275. */
  127276. get dy(): NodeMaterialConnectionPoint;
  127277. protected _buildBlock(state: NodeMaterialBuildState): this;
  127278. }
  127279. }
  127280. declare module BABYLON {
  127281. /**
  127282. * Block used to add support for scene fog
  127283. */
  127284. export class FogBlock extends NodeMaterialBlock {
  127285. private _fogDistanceName;
  127286. private _fogParameters;
  127287. /**
  127288. * Create a new FogBlock
  127289. * @param name defines the block name
  127290. */
  127291. constructor(name: string);
  127292. /**
  127293. * Gets the current class name
  127294. * @returns the class name
  127295. */
  127296. getClassName(): string;
  127297. /**
  127298. * Gets the world position input component
  127299. */
  127300. get worldPosition(): NodeMaterialConnectionPoint;
  127301. /**
  127302. * Gets the view input component
  127303. */
  127304. get view(): NodeMaterialConnectionPoint;
  127305. /**
  127306. * Gets the color input component
  127307. */
  127308. get input(): NodeMaterialConnectionPoint;
  127309. /**
  127310. * Gets the fog color input component
  127311. */
  127312. get fogColor(): NodeMaterialConnectionPoint;
  127313. /**
  127314. * Gets the output component
  127315. */
  127316. get output(): NodeMaterialConnectionPoint;
  127317. autoConfigure(material: NodeMaterial): void;
  127318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127319. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127320. protected _buildBlock(state: NodeMaterialBuildState): this;
  127321. }
  127322. }
  127323. declare module BABYLON {
  127324. /**
  127325. * Block used to add light in the fragment shader
  127326. */
  127327. export class LightBlock extends NodeMaterialBlock {
  127328. private _lightId;
  127329. /**
  127330. * Gets or sets the light associated with this block
  127331. */
  127332. light: Nullable<Light>;
  127333. /**
  127334. * Create a new LightBlock
  127335. * @param name defines the block name
  127336. */
  127337. constructor(name: string);
  127338. /**
  127339. * Gets the current class name
  127340. * @returns the class name
  127341. */
  127342. getClassName(): string;
  127343. /**
  127344. * Gets the world position input component
  127345. */
  127346. get worldPosition(): NodeMaterialConnectionPoint;
  127347. /**
  127348. * Gets the world normal input component
  127349. */
  127350. get worldNormal(): NodeMaterialConnectionPoint;
  127351. /**
  127352. * Gets the camera (or eye) position component
  127353. */
  127354. get cameraPosition(): NodeMaterialConnectionPoint;
  127355. /**
  127356. * Gets the glossiness component
  127357. */
  127358. get glossiness(): NodeMaterialConnectionPoint;
  127359. /**
  127360. * Gets the glossinness power component
  127361. */
  127362. get glossPower(): NodeMaterialConnectionPoint;
  127363. /**
  127364. * Gets the diffuse color component
  127365. */
  127366. get diffuseColor(): NodeMaterialConnectionPoint;
  127367. /**
  127368. * Gets the specular color component
  127369. */
  127370. get specularColor(): NodeMaterialConnectionPoint;
  127371. /**
  127372. * Gets the diffuse output component
  127373. */
  127374. get diffuseOutput(): NodeMaterialConnectionPoint;
  127375. /**
  127376. * Gets the specular output component
  127377. */
  127378. get specularOutput(): NodeMaterialConnectionPoint;
  127379. autoConfigure(material: NodeMaterial): void;
  127380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127381. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127383. private _injectVertexCode;
  127384. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127385. serialize(): any;
  127386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127387. }
  127388. }
  127389. declare module BABYLON {
  127390. /**
  127391. * Block used to multiply 2 values
  127392. */
  127393. export class MultiplyBlock extends NodeMaterialBlock {
  127394. /**
  127395. * Creates a new MultiplyBlock
  127396. * @param name defines the block name
  127397. */
  127398. constructor(name: string);
  127399. /**
  127400. * Gets the current class name
  127401. * @returns the class name
  127402. */
  127403. getClassName(): string;
  127404. /**
  127405. * Gets the left operand input component
  127406. */
  127407. get left(): NodeMaterialConnectionPoint;
  127408. /**
  127409. * Gets the right operand input component
  127410. */
  127411. get right(): NodeMaterialConnectionPoint;
  127412. /**
  127413. * Gets the output component
  127414. */
  127415. get output(): NodeMaterialConnectionPoint;
  127416. protected _buildBlock(state: NodeMaterialBuildState): this;
  127417. }
  127418. }
  127419. declare module BABYLON {
  127420. /**
  127421. * Block used to add 2 vectors
  127422. */
  127423. export class AddBlock extends NodeMaterialBlock {
  127424. /**
  127425. * Creates a new AddBlock
  127426. * @param name defines the block name
  127427. */
  127428. constructor(name: string);
  127429. /**
  127430. * Gets the current class name
  127431. * @returns the class name
  127432. */
  127433. getClassName(): string;
  127434. /**
  127435. * Gets the left operand input component
  127436. */
  127437. get left(): NodeMaterialConnectionPoint;
  127438. /**
  127439. * Gets the right operand input component
  127440. */
  127441. get right(): NodeMaterialConnectionPoint;
  127442. /**
  127443. * Gets the output component
  127444. */
  127445. get output(): NodeMaterialConnectionPoint;
  127446. protected _buildBlock(state: NodeMaterialBuildState): this;
  127447. }
  127448. }
  127449. declare module BABYLON {
  127450. /**
  127451. * Block used to scale a vector by a float
  127452. */
  127453. export class ScaleBlock extends NodeMaterialBlock {
  127454. /**
  127455. * Creates a new ScaleBlock
  127456. * @param name defines the block name
  127457. */
  127458. constructor(name: string);
  127459. /**
  127460. * Gets the current class name
  127461. * @returns the class name
  127462. */
  127463. getClassName(): string;
  127464. /**
  127465. * Gets the input component
  127466. */
  127467. get input(): NodeMaterialConnectionPoint;
  127468. /**
  127469. * Gets the factor input component
  127470. */
  127471. get factor(): NodeMaterialConnectionPoint;
  127472. /**
  127473. * Gets the output component
  127474. */
  127475. get output(): NodeMaterialConnectionPoint;
  127476. protected _buildBlock(state: NodeMaterialBuildState): this;
  127477. }
  127478. }
  127479. declare module BABYLON {
  127480. /**
  127481. * Block used to clamp a float
  127482. */
  127483. export class ClampBlock extends NodeMaterialBlock {
  127484. /** Gets or sets the minimum range */
  127485. minimum: number;
  127486. /** Gets or sets the maximum range */
  127487. maximum: number;
  127488. /**
  127489. * Creates a new ClampBlock
  127490. * @param name defines the block name
  127491. */
  127492. constructor(name: string);
  127493. /**
  127494. * Gets the current class name
  127495. * @returns the class name
  127496. */
  127497. getClassName(): string;
  127498. /**
  127499. * Gets the value input component
  127500. */
  127501. get value(): NodeMaterialConnectionPoint;
  127502. /**
  127503. * Gets the output component
  127504. */
  127505. get output(): NodeMaterialConnectionPoint;
  127506. protected _buildBlock(state: NodeMaterialBuildState): this;
  127507. protected _dumpPropertiesCode(): string;
  127508. serialize(): any;
  127509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127510. }
  127511. }
  127512. declare module BABYLON {
  127513. /**
  127514. * Block used to apply a cross product between 2 vectors
  127515. */
  127516. export class CrossBlock extends NodeMaterialBlock {
  127517. /**
  127518. * Creates a new CrossBlock
  127519. * @param name defines the block name
  127520. */
  127521. constructor(name: string);
  127522. /**
  127523. * Gets the current class name
  127524. * @returns the class name
  127525. */
  127526. getClassName(): string;
  127527. /**
  127528. * Gets the left operand input component
  127529. */
  127530. get left(): NodeMaterialConnectionPoint;
  127531. /**
  127532. * Gets the right operand input component
  127533. */
  127534. get right(): NodeMaterialConnectionPoint;
  127535. /**
  127536. * Gets the output component
  127537. */
  127538. get output(): NodeMaterialConnectionPoint;
  127539. protected _buildBlock(state: NodeMaterialBuildState): this;
  127540. }
  127541. }
  127542. declare module BABYLON {
  127543. /**
  127544. * Block used to apply a dot product between 2 vectors
  127545. */
  127546. export class DotBlock extends NodeMaterialBlock {
  127547. /**
  127548. * Creates a new DotBlock
  127549. * @param name defines the block name
  127550. */
  127551. constructor(name: string);
  127552. /**
  127553. * Gets the current class name
  127554. * @returns the class name
  127555. */
  127556. getClassName(): string;
  127557. /**
  127558. * Gets the left operand input component
  127559. */
  127560. get left(): NodeMaterialConnectionPoint;
  127561. /**
  127562. * Gets the right operand input component
  127563. */
  127564. get right(): NodeMaterialConnectionPoint;
  127565. /**
  127566. * Gets the output component
  127567. */
  127568. get output(): NodeMaterialConnectionPoint;
  127569. protected _buildBlock(state: NodeMaterialBuildState): this;
  127570. }
  127571. }
  127572. declare module BABYLON {
  127573. /**
  127574. * Block used to remap a float from a range to a new one
  127575. */
  127576. export class RemapBlock extends NodeMaterialBlock {
  127577. /**
  127578. * Gets or sets the source range
  127579. */
  127580. sourceRange: Vector2;
  127581. /**
  127582. * Gets or sets the target range
  127583. */
  127584. targetRange: Vector2;
  127585. /**
  127586. * Creates a new RemapBlock
  127587. * @param name defines the block name
  127588. */
  127589. constructor(name: string);
  127590. /**
  127591. * Gets the current class name
  127592. * @returns the class name
  127593. */
  127594. getClassName(): string;
  127595. /**
  127596. * Gets the input component
  127597. */
  127598. get input(): NodeMaterialConnectionPoint;
  127599. /**
  127600. * Gets the source min input component
  127601. */
  127602. get sourceMin(): NodeMaterialConnectionPoint;
  127603. /**
  127604. * Gets the source max input component
  127605. */
  127606. get sourceMax(): NodeMaterialConnectionPoint;
  127607. /**
  127608. * Gets the target min input component
  127609. */
  127610. get targetMin(): NodeMaterialConnectionPoint;
  127611. /**
  127612. * Gets the target max input component
  127613. */
  127614. get targetMax(): NodeMaterialConnectionPoint;
  127615. /**
  127616. * Gets the output component
  127617. */
  127618. get output(): NodeMaterialConnectionPoint;
  127619. protected _buildBlock(state: NodeMaterialBuildState): this;
  127620. protected _dumpPropertiesCode(): string;
  127621. serialize(): any;
  127622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127623. }
  127624. }
  127625. declare module BABYLON {
  127626. /**
  127627. * Block used to normalize a vector
  127628. */
  127629. export class NormalizeBlock extends NodeMaterialBlock {
  127630. /**
  127631. * Creates a new NormalizeBlock
  127632. * @param name defines the block name
  127633. */
  127634. constructor(name: string);
  127635. /**
  127636. * Gets the current class name
  127637. * @returns the class name
  127638. */
  127639. getClassName(): string;
  127640. /**
  127641. * Gets the input component
  127642. */
  127643. get input(): NodeMaterialConnectionPoint;
  127644. /**
  127645. * Gets the output component
  127646. */
  127647. get output(): NodeMaterialConnectionPoint;
  127648. protected _buildBlock(state: NodeMaterialBuildState): this;
  127649. }
  127650. }
  127651. declare module BABYLON {
  127652. /**
  127653. * Operations supported by the Trigonometry block
  127654. */
  127655. export enum TrigonometryBlockOperations {
  127656. /** Cos */
  127657. Cos = 0,
  127658. /** Sin */
  127659. Sin = 1,
  127660. /** Abs */
  127661. Abs = 2,
  127662. /** Exp */
  127663. Exp = 3,
  127664. /** Exp2 */
  127665. Exp2 = 4,
  127666. /** Round */
  127667. Round = 5,
  127668. /** Floor */
  127669. Floor = 6,
  127670. /** Ceiling */
  127671. Ceiling = 7,
  127672. /** Square root */
  127673. Sqrt = 8,
  127674. /** Log */
  127675. Log = 9,
  127676. /** Tangent */
  127677. Tan = 10,
  127678. /** Arc tangent */
  127679. ArcTan = 11,
  127680. /** Arc cosinus */
  127681. ArcCos = 12,
  127682. /** Arc sinus */
  127683. ArcSin = 13,
  127684. /** Fraction */
  127685. Fract = 14,
  127686. /** Sign */
  127687. Sign = 15,
  127688. /** To radians (from degrees) */
  127689. Radians = 16,
  127690. /** To degrees (from radians) */
  127691. Degrees = 17
  127692. }
  127693. /**
  127694. * Block used to apply trigonometry operation to floats
  127695. */
  127696. export class TrigonometryBlock extends NodeMaterialBlock {
  127697. /**
  127698. * Gets or sets the operation applied by the block
  127699. */
  127700. operation: TrigonometryBlockOperations;
  127701. /**
  127702. * Creates a new TrigonometryBlock
  127703. * @param name defines the block name
  127704. */
  127705. constructor(name: string);
  127706. /**
  127707. * Gets the current class name
  127708. * @returns the class name
  127709. */
  127710. getClassName(): string;
  127711. /**
  127712. * Gets the input component
  127713. */
  127714. get input(): NodeMaterialConnectionPoint;
  127715. /**
  127716. * Gets the output component
  127717. */
  127718. get output(): NodeMaterialConnectionPoint;
  127719. protected _buildBlock(state: NodeMaterialBuildState): this;
  127720. serialize(): any;
  127721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127722. protected _dumpPropertiesCode(): string;
  127723. }
  127724. }
  127725. declare module BABYLON {
  127726. /**
  127727. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127728. */
  127729. export class ColorMergerBlock extends NodeMaterialBlock {
  127730. /**
  127731. * Create a new ColorMergerBlock
  127732. * @param name defines the block name
  127733. */
  127734. constructor(name: string);
  127735. /**
  127736. * Gets the current class name
  127737. * @returns the class name
  127738. */
  127739. getClassName(): string;
  127740. /**
  127741. * Gets the rgb component (input)
  127742. */
  127743. get rgbIn(): NodeMaterialConnectionPoint;
  127744. /**
  127745. * Gets the r component (input)
  127746. */
  127747. get r(): NodeMaterialConnectionPoint;
  127748. /**
  127749. * Gets the g component (input)
  127750. */
  127751. get g(): NodeMaterialConnectionPoint;
  127752. /**
  127753. * Gets the b component (input)
  127754. */
  127755. get b(): NodeMaterialConnectionPoint;
  127756. /**
  127757. * Gets the a component (input)
  127758. */
  127759. get a(): NodeMaterialConnectionPoint;
  127760. /**
  127761. * Gets the rgba component (output)
  127762. */
  127763. get rgba(): NodeMaterialConnectionPoint;
  127764. /**
  127765. * Gets the rgb component (output)
  127766. */
  127767. get rgbOut(): NodeMaterialConnectionPoint;
  127768. /**
  127769. * Gets the rgb component (output)
  127770. * @deprecated Please use rgbOut instead.
  127771. */
  127772. get rgb(): NodeMaterialConnectionPoint;
  127773. protected _buildBlock(state: NodeMaterialBuildState): this;
  127774. }
  127775. }
  127776. declare module BABYLON {
  127777. /**
  127778. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127779. */
  127780. export class VectorMergerBlock extends NodeMaterialBlock {
  127781. /**
  127782. * Create a new VectorMergerBlock
  127783. * @param name defines the block name
  127784. */
  127785. constructor(name: string);
  127786. /**
  127787. * Gets the current class name
  127788. * @returns the class name
  127789. */
  127790. getClassName(): string;
  127791. /**
  127792. * Gets the xyz component (input)
  127793. */
  127794. get xyzIn(): NodeMaterialConnectionPoint;
  127795. /**
  127796. * Gets the xy component (input)
  127797. */
  127798. get xyIn(): NodeMaterialConnectionPoint;
  127799. /**
  127800. * Gets the x component (input)
  127801. */
  127802. get x(): NodeMaterialConnectionPoint;
  127803. /**
  127804. * Gets the y component (input)
  127805. */
  127806. get y(): NodeMaterialConnectionPoint;
  127807. /**
  127808. * Gets the z component (input)
  127809. */
  127810. get z(): NodeMaterialConnectionPoint;
  127811. /**
  127812. * Gets the w component (input)
  127813. */
  127814. get w(): NodeMaterialConnectionPoint;
  127815. /**
  127816. * Gets the xyzw component (output)
  127817. */
  127818. get xyzw(): NodeMaterialConnectionPoint;
  127819. /**
  127820. * Gets the xyz component (output)
  127821. */
  127822. get xyzOut(): NodeMaterialConnectionPoint;
  127823. /**
  127824. * Gets the xy component (output)
  127825. */
  127826. get xyOut(): NodeMaterialConnectionPoint;
  127827. /**
  127828. * Gets the xy component (output)
  127829. * @deprecated Please use xyOut instead.
  127830. */
  127831. get xy(): NodeMaterialConnectionPoint;
  127832. /**
  127833. * Gets the xyz component (output)
  127834. * @deprecated Please use xyzOut instead.
  127835. */
  127836. get xyz(): NodeMaterialConnectionPoint;
  127837. protected _buildBlock(state: NodeMaterialBuildState): this;
  127838. }
  127839. }
  127840. declare module BABYLON {
  127841. /**
  127842. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  127843. */
  127844. export class ColorSplitterBlock extends NodeMaterialBlock {
  127845. /**
  127846. * Create a new ColorSplitterBlock
  127847. * @param name defines the block name
  127848. */
  127849. constructor(name: string);
  127850. /**
  127851. * Gets the current class name
  127852. * @returns the class name
  127853. */
  127854. getClassName(): string;
  127855. /**
  127856. * Gets the rgba component (input)
  127857. */
  127858. get rgba(): NodeMaterialConnectionPoint;
  127859. /**
  127860. * Gets the rgb component (input)
  127861. */
  127862. get rgbIn(): NodeMaterialConnectionPoint;
  127863. /**
  127864. * Gets the rgb component (output)
  127865. */
  127866. get rgbOut(): NodeMaterialConnectionPoint;
  127867. /**
  127868. * Gets the r component (output)
  127869. */
  127870. get r(): NodeMaterialConnectionPoint;
  127871. /**
  127872. * Gets the g component (output)
  127873. */
  127874. get g(): NodeMaterialConnectionPoint;
  127875. /**
  127876. * Gets the b component (output)
  127877. */
  127878. get b(): NodeMaterialConnectionPoint;
  127879. /**
  127880. * Gets the a component (output)
  127881. */
  127882. get a(): NodeMaterialConnectionPoint;
  127883. protected _inputRename(name: string): string;
  127884. protected _outputRename(name: string): string;
  127885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /**
  127890. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  127891. */
  127892. export class VectorSplitterBlock extends NodeMaterialBlock {
  127893. /**
  127894. * Create a new VectorSplitterBlock
  127895. * @param name defines the block name
  127896. */
  127897. constructor(name: string);
  127898. /**
  127899. * Gets the current class name
  127900. * @returns the class name
  127901. */
  127902. getClassName(): string;
  127903. /**
  127904. * Gets the xyzw component (input)
  127905. */
  127906. get xyzw(): NodeMaterialConnectionPoint;
  127907. /**
  127908. * Gets the xyz component (input)
  127909. */
  127910. get xyzIn(): NodeMaterialConnectionPoint;
  127911. /**
  127912. * Gets the xy component (input)
  127913. */
  127914. get xyIn(): NodeMaterialConnectionPoint;
  127915. /**
  127916. * Gets the xyz component (output)
  127917. */
  127918. get xyzOut(): NodeMaterialConnectionPoint;
  127919. /**
  127920. * Gets the xy component (output)
  127921. */
  127922. get xyOut(): NodeMaterialConnectionPoint;
  127923. /**
  127924. * Gets the x component (output)
  127925. */
  127926. get x(): NodeMaterialConnectionPoint;
  127927. /**
  127928. * Gets the y component (output)
  127929. */
  127930. get y(): NodeMaterialConnectionPoint;
  127931. /**
  127932. * Gets the z component (output)
  127933. */
  127934. get z(): NodeMaterialConnectionPoint;
  127935. /**
  127936. * Gets the w component (output)
  127937. */
  127938. get w(): NodeMaterialConnectionPoint;
  127939. protected _inputRename(name: string): string;
  127940. protected _outputRename(name: string): string;
  127941. protected _buildBlock(state: NodeMaterialBuildState): this;
  127942. }
  127943. }
  127944. declare module BABYLON {
  127945. /**
  127946. * Block used to lerp between 2 values
  127947. */
  127948. export class LerpBlock extends NodeMaterialBlock {
  127949. /**
  127950. * Creates a new LerpBlock
  127951. * @param name defines the block name
  127952. */
  127953. constructor(name: string);
  127954. /**
  127955. * Gets the current class name
  127956. * @returns the class name
  127957. */
  127958. getClassName(): string;
  127959. /**
  127960. * Gets the left operand input component
  127961. */
  127962. get left(): NodeMaterialConnectionPoint;
  127963. /**
  127964. * Gets the right operand input component
  127965. */
  127966. get right(): NodeMaterialConnectionPoint;
  127967. /**
  127968. * Gets the gradient operand input component
  127969. */
  127970. get gradient(): NodeMaterialConnectionPoint;
  127971. /**
  127972. * Gets the output component
  127973. */
  127974. get output(): NodeMaterialConnectionPoint;
  127975. protected _buildBlock(state: NodeMaterialBuildState): this;
  127976. }
  127977. }
  127978. declare module BABYLON {
  127979. /**
  127980. * Block used to divide 2 vectors
  127981. */
  127982. export class DivideBlock extends NodeMaterialBlock {
  127983. /**
  127984. * Creates a new DivideBlock
  127985. * @param name defines the block name
  127986. */
  127987. constructor(name: string);
  127988. /**
  127989. * Gets the current class name
  127990. * @returns the class name
  127991. */
  127992. getClassName(): string;
  127993. /**
  127994. * Gets the left operand input component
  127995. */
  127996. get left(): NodeMaterialConnectionPoint;
  127997. /**
  127998. * Gets the right operand input component
  127999. */
  128000. get right(): NodeMaterialConnectionPoint;
  128001. /**
  128002. * Gets the output component
  128003. */
  128004. get output(): NodeMaterialConnectionPoint;
  128005. protected _buildBlock(state: NodeMaterialBuildState): this;
  128006. }
  128007. }
  128008. declare module BABYLON {
  128009. /**
  128010. * Block used to subtract 2 vectors
  128011. */
  128012. export class SubtractBlock extends NodeMaterialBlock {
  128013. /**
  128014. * Creates a new SubtractBlock
  128015. * @param name defines the block name
  128016. */
  128017. constructor(name: string);
  128018. /**
  128019. * Gets the current class name
  128020. * @returns the class name
  128021. */
  128022. getClassName(): string;
  128023. /**
  128024. * Gets the left operand input component
  128025. */
  128026. get left(): NodeMaterialConnectionPoint;
  128027. /**
  128028. * Gets the right operand input component
  128029. */
  128030. get right(): NodeMaterialConnectionPoint;
  128031. /**
  128032. * Gets the output component
  128033. */
  128034. get output(): NodeMaterialConnectionPoint;
  128035. protected _buildBlock(state: NodeMaterialBuildState): this;
  128036. }
  128037. }
  128038. declare module BABYLON {
  128039. /**
  128040. * Block used to step a value
  128041. */
  128042. export class StepBlock extends NodeMaterialBlock {
  128043. /**
  128044. * Creates a new StepBlock
  128045. * @param name defines the block name
  128046. */
  128047. constructor(name: string);
  128048. /**
  128049. * Gets the current class name
  128050. * @returns the class name
  128051. */
  128052. getClassName(): string;
  128053. /**
  128054. * Gets the value operand input component
  128055. */
  128056. get value(): NodeMaterialConnectionPoint;
  128057. /**
  128058. * Gets the edge operand input component
  128059. */
  128060. get edge(): NodeMaterialConnectionPoint;
  128061. /**
  128062. * Gets the output component
  128063. */
  128064. get output(): NodeMaterialConnectionPoint;
  128065. protected _buildBlock(state: NodeMaterialBuildState): this;
  128066. }
  128067. }
  128068. declare module BABYLON {
  128069. /**
  128070. * Block used to get the opposite (1 - x) of a value
  128071. */
  128072. export class OneMinusBlock extends NodeMaterialBlock {
  128073. /**
  128074. * Creates a new OneMinusBlock
  128075. * @param name defines the block name
  128076. */
  128077. constructor(name: string);
  128078. /**
  128079. * Gets the current class name
  128080. * @returns the class name
  128081. */
  128082. getClassName(): string;
  128083. /**
  128084. * Gets the input component
  128085. */
  128086. get input(): NodeMaterialConnectionPoint;
  128087. /**
  128088. * Gets the output component
  128089. */
  128090. get output(): NodeMaterialConnectionPoint;
  128091. protected _buildBlock(state: NodeMaterialBuildState): this;
  128092. }
  128093. }
  128094. declare module BABYLON {
  128095. /**
  128096. * Block used to get the view direction
  128097. */
  128098. export class ViewDirectionBlock extends NodeMaterialBlock {
  128099. /**
  128100. * Creates a new ViewDirectionBlock
  128101. * @param name defines the block name
  128102. */
  128103. constructor(name: string);
  128104. /**
  128105. * Gets the current class name
  128106. * @returns the class name
  128107. */
  128108. getClassName(): string;
  128109. /**
  128110. * Gets the world position component
  128111. */
  128112. get worldPosition(): NodeMaterialConnectionPoint;
  128113. /**
  128114. * Gets the camera position component
  128115. */
  128116. get cameraPosition(): NodeMaterialConnectionPoint;
  128117. /**
  128118. * Gets the output component
  128119. */
  128120. get output(): NodeMaterialConnectionPoint;
  128121. autoConfigure(material: NodeMaterial): void;
  128122. protected _buildBlock(state: NodeMaterialBuildState): this;
  128123. }
  128124. }
  128125. declare module BABYLON {
  128126. /**
  128127. * Block used to compute fresnel value
  128128. */
  128129. export class FresnelBlock extends NodeMaterialBlock {
  128130. /**
  128131. * Create a new FresnelBlock
  128132. * @param name defines the block name
  128133. */
  128134. constructor(name: string);
  128135. /**
  128136. * Gets the current class name
  128137. * @returns the class name
  128138. */
  128139. getClassName(): string;
  128140. /**
  128141. * Gets the world normal input component
  128142. */
  128143. get worldNormal(): NodeMaterialConnectionPoint;
  128144. /**
  128145. * Gets the view direction input component
  128146. */
  128147. get viewDirection(): NodeMaterialConnectionPoint;
  128148. /**
  128149. * Gets the bias input component
  128150. */
  128151. get bias(): NodeMaterialConnectionPoint;
  128152. /**
  128153. * Gets the camera (or eye) position component
  128154. */
  128155. get power(): NodeMaterialConnectionPoint;
  128156. /**
  128157. * Gets the fresnel output component
  128158. */
  128159. get fresnel(): NodeMaterialConnectionPoint;
  128160. autoConfigure(material: NodeMaterial): void;
  128161. protected _buildBlock(state: NodeMaterialBuildState): this;
  128162. }
  128163. }
  128164. declare module BABYLON {
  128165. /**
  128166. * Block used to get the max of 2 values
  128167. */
  128168. export class MaxBlock extends NodeMaterialBlock {
  128169. /**
  128170. * Creates a new MaxBlock
  128171. * @param name defines the block name
  128172. */
  128173. constructor(name: string);
  128174. /**
  128175. * Gets the current class name
  128176. * @returns the class name
  128177. */
  128178. getClassName(): string;
  128179. /**
  128180. * Gets the left operand input component
  128181. */
  128182. get left(): NodeMaterialConnectionPoint;
  128183. /**
  128184. * Gets the right operand input component
  128185. */
  128186. get right(): NodeMaterialConnectionPoint;
  128187. /**
  128188. * Gets the output component
  128189. */
  128190. get output(): NodeMaterialConnectionPoint;
  128191. protected _buildBlock(state: NodeMaterialBuildState): this;
  128192. }
  128193. }
  128194. declare module BABYLON {
  128195. /**
  128196. * Block used to get the min of 2 values
  128197. */
  128198. export class MinBlock extends NodeMaterialBlock {
  128199. /**
  128200. * Creates a new MinBlock
  128201. * @param name defines the block name
  128202. */
  128203. constructor(name: string);
  128204. /**
  128205. * Gets the current class name
  128206. * @returns the class name
  128207. */
  128208. getClassName(): string;
  128209. /**
  128210. * Gets the left operand input component
  128211. */
  128212. get left(): NodeMaterialConnectionPoint;
  128213. /**
  128214. * Gets the right operand input component
  128215. */
  128216. get right(): NodeMaterialConnectionPoint;
  128217. /**
  128218. * Gets the output component
  128219. */
  128220. get output(): NodeMaterialConnectionPoint;
  128221. protected _buildBlock(state: NodeMaterialBuildState): this;
  128222. }
  128223. }
  128224. declare module BABYLON {
  128225. /**
  128226. * Block used to get the distance between 2 values
  128227. */
  128228. export class DistanceBlock extends NodeMaterialBlock {
  128229. /**
  128230. * Creates a new DistanceBlock
  128231. * @param name defines the block name
  128232. */
  128233. constructor(name: string);
  128234. /**
  128235. * Gets the current class name
  128236. * @returns the class name
  128237. */
  128238. getClassName(): string;
  128239. /**
  128240. * Gets the left operand input component
  128241. */
  128242. get left(): NodeMaterialConnectionPoint;
  128243. /**
  128244. * Gets the right operand input component
  128245. */
  128246. get right(): NodeMaterialConnectionPoint;
  128247. /**
  128248. * Gets the output component
  128249. */
  128250. get output(): NodeMaterialConnectionPoint;
  128251. protected _buildBlock(state: NodeMaterialBuildState): this;
  128252. }
  128253. }
  128254. declare module BABYLON {
  128255. /**
  128256. * Block used to get the length of a vector
  128257. */
  128258. export class LengthBlock extends NodeMaterialBlock {
  128259. /**
  128260. * Creates a new LengthBlock
  128261. * @param name defines the block name
  128262. */
  128263. constructor(name: string);
  128264. /**
  128265. * Gets the current class name
  128266. * @returns the class name
  128267. */
  128268. getClassName(): string;
  128269. /**
  128270. * Gets the value input component
  128271. */
  128272. get value(): NodeMaterialConnectionPoint;
  128273. /**
  128274. * Gets the output component
  128275. */
  128276. get output(): NodeMaterialConnectionPoint;
  128277. protected _buildBlock(state: NodeMaterialBuildState): this;
  128278. }
  128279. }
  128280. declare module BABYLON {
  128281. /**
  128282. * Block used to get negative version of a value (i.e. x * -1)
  128283. */
  128284. export class NegateBlock extends NodeMaterialBlock {
  128285. /**
  128286. * Creates a new NegateBlock
  128287. * @param name defines the block name
  128288. */
  128289. constructor(name: string);
  128290. /**
  128291. * Gets the current class name
  128292. * @returns the class name
  128293. */
  128294. getClassName(): string;
  128295. /**
  128296. * Gets the value input component
  128297. */
  128298. get value(): NodeMaterialConnectionPoint;
  128299. /**
  128300. * Gets the output component
  128301. */
  128302. get output(): NodeMaterialConnectionPoint;
  128303. protected _buildBlock(state: NodeMaterialBuildState): this;
  128304. }
  128305. }
  128306. declare module BABYLON {
  128307. /**
  128308. * Block used to get the value of the first parameter raised to the power of the second
  128309. */
  128310. export class PowBlock extends NodeMaterialBlock {
  128311. /**
  128312. * Creates a new PowBlock
  128313. * @param name defines the block name
  128314. */
  128315. constructor(name: string);
  128316. /**
  128317. * Gets the current class name
  128318. * @returns the class name
  128319. */
  128320. getClassName(): string;
  128321. /**
  128322. * Gets the value operand input component
  128323. */
  128324. get value(): NodeMaterialConnectionPoint;
  128325. /**
  128326. * Gets the power operand input component
  128327. */
  128328. get power(): NodeMaterialConnectionPoint;
  128329. /**
  128330. * Gets the output component
  128331. */
  128332. get output(): NodeMaterialConnectionPoint;
  128333. protected _buildBlock(state: NodeMaterialBuildState): this;
  128334. }
  128335. }
  128336. declare module BABYLON {
  128337. /**
  128338. * Block used to get a random number
  128339. */
  128340. export class RandomNumberBlock extends NodeMaterialBlock {
  128341. /**
  128342. * Creates a new RandomNumberBlock
  128343. * @param name defines the block name
  128344. */
  128345. constructor(name: string);
  128346. /**
  128347. * Gets the current class name
  128348. * @returns the class name
  128349. */
  128350. getClassName(): string;
  128351. /**
  128352. * Gets the seed input component
  128353. */
  128354. get seed(): NodeMaterialConnectionPoint;
  128355. /**
  128356. * Gets the output component
  128357. */
  128358. get output(): NodeMaterialConnectionPoint;
  128359. protected _buildBlock(state: NodeMaterialBuildState): this;
  128360. }
  128361. }
  128362. declare module BABYLON {
  128363. /**
  128364. * Block used to compute arc tangent of 2 values
  128365. */
  128366. export class ArcTan2Block extends NodeMaterialBlock {
  128367. /**
  128368. * Creates a new ArcTan2Block
  128369. * @param name defines the block name
  128370. */
  128371. constructor(name: string);
  128372. /**
  128373. * Gets the current class name
  128374. * @returns the class name
  128375. */
  128376. getClassName(): string;
  128377. /**
  128378. * Gets the x operand input component
  128379. */
  128380. get x(): NodeMaterialConnectionPoint;
  128381. /**
  128382. * Gets the y operand input component
  128383. */
  128384. get y(): NodeMaterialConnectionPoint;
  128385. /**
  128386. * Gets the output component
  128387. */
  128388. get output(): NodeMaterialConnectionPoint;
  128389. protected _buildBlock(state: NodeMaterialBuildState): this;
  128390. }
  128391. }
  128392. declare module BABYLON {
  128393. /**
  128394. * Block used to smooth step a value
  128395. */
  128396. export class SmoothStepBlock extends NodeMaterialBlock {
  128397. /**
  128398. * Creates a new SmoothStepBlock
  128399. * @param name defines the block name
  128400. */
  128401. constructor(name: string);
  128402. /**
  128403. * Gets the current class name
  128404. * @returns the class name
  128405. */
  128406. getClassName(): string;
  128407. /**
  128408. * Gets the value operand input component
  128409. */
  128410. get value(): NodeMaterialConnectionPoint;
  128411. /**
  128412. * Gets the first edge operand input component
  128413. */
  128414. get edge0(): NodeMaterialConnectionPoint;
  128415. /**
  128416. * Gets the second edge operand input component
  128417. */
  128418. get edge1(): NodeMaterialConnectionPoint;
  128419. /**
  128420. * Gets the output component
  128421. */
  128422. get output(): NodeMaterialConnectionPoint;
  128423. protected _buildBlock(state: NodeMaterialBuildState): this;
  128424. }
  128425. }
  128426. declare module BABYLON {
  128427. /**
  128428. * Block used to get the reciprocal (1 / x) of a value
  128429. */
  128430. export class ReciprocalBlock extends NodeMaterialBlock {
  128431. /**
  128432. * Creates a new ReciprocalBlock
  128433. * @param name defines the block name
  128434. */
  128435. constructor(name: string);
  128436. /**
  128437. * Gets the current class name
  128438. * @returns the class name
  128439. */
  128440. getClassName(): string;
  128441. /**
  128442. * Gets the input component
  128443. */
  128444. get input(): NodeMaterialConnectionPoint;
  128445. /**
  128446. * Gets the output component
  128447. */
  128448. get output(): NodeMaterialConnectionPoint;
  128449. protected _buildBlock(state: NodeMaterialBuildState): this;
  128450. }
  128451. }
  128452. declare module BABYLON {
  128453. /**
  128454. * Block used to replace a color by another one
  128455. */
  128456. export class ReplaceColorBlock extends NodeMaterialBlock {
  128457. /**
  128458. * Creates a new ReplaceColorBlock
  128459. * @param name defines the block name
  128460. */
  128461. constructor(name: string);
  128462. /**
  128463. * Gets the current class name
  128464. * @returns the class name
  128465. */
  128466. getClassName(): string;
  128467. /**
  128468. * Gets the value input component
  128469. */
  128470. get value(): NodeMaterialConnectionPoint;
  128471. /**
  128472. * Gets the reference input component
  128473. */
  128474. get reference(): NodeMaterialConnectionPoint;
  128475. /**
  128476. * Gets the distance input component
  128477. */
  128478. get distance(): NodeMaterialConnectionPoint;
  128479. /**
  128480. * Gets the replacement input component
  128481. */
  128482. get replacement(): NodeMaterialConnectionPoint;
  128483. /**
  128484. * Gets the output component
  128485. */
  128486. get output(): NodeMaterialConnectionPoint;
  128487. protected _buildBlock(state: NodeMaterialBuildState): this;
  128488. }
  128489. }
  128490. declare module BABYLON {
  128491. /**
  128492. * Block used to posterize a value
  128493. * @see https://en.wikipedia.org/wiki/Posterization
  128494. */
  128495. export class PosterizeBlock extends NodeMaterialBlock {
  128496. /**
  128497. * Creates a new PosterizeBlock
  128498. * @param name defines the block name
  128499. */
  128500. constructor(name: string);
  128501. /**
  128502. * Gets the current class name
  128503. * @returns the class name
  128504. */
  128505. getClassName(): string;
  128506. /**
  128507. * Gets the value input component
  128508. */
  128509. get value(): NodeMaterialConnectionPoint;
  128510. /**
  128511. * Gets the steps input component
  128512. */
  128513. get steps(): NodeMaterialConnectionPoint;
  128514. /**
  128515. * Gets the output component
  128516. */
  128517. get output(): NodeMaterialConnectionPoint;
  128518. protected _buildBlock(state: NodeMaterialBuildState): this;
  128519. }
  128520. }
  128521. declare module BABYLON {
  128522. /**
  128523. * Operations supported by the Wave block
  128524. */
  128525. export enum WaveBlockKind {
  128526. /** SawTooth */
  128527. SawTooth = 0,
  128528. /** Square */
  128529. Square = 1,
  128530. /** Triangle */
  128531. Triangle = 2
  128532. }
  128533. /**
  128534. * Block used to apply wave operation to floats
  128535. */
  128536. export class WaveBlock extends NodeMaterialBlock {
  128537. /**
  128538. * Gets or sets the kibnd of wave to be applied by the block
  128539. */
  128540. kind: WaveBlockKind;
  128541. /**
  128542. * Creates a new WaveBlock
  128543. * @param name defines the block name
  128544. */
  128545. constructor(name: string);
  128546. /**
  128547. * Gets the current class name
  128548. * @returns the class name
  128549. */
  128550. getClassName(): string;
  128551. /**
  128552. * Gets the input component
  128553. */
  128554. get input(): NodeMaterialConnectionPoint;
  128555. /**
  128556. * Gets the output component
  128557. */
  128558. get output(): NodeMaterialConnectionPoint;
  128559. protected _buildBlock(state: NodeMaterialBuildState): this;
  128560. serialize(): any;
  128561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128562. }
  128563. }
  128564. declare module BABYLON {
  128565. /**
  128566. * Class used to store a color step for the GradientBlock
  128567. */
  128568. export class GradientBlockColorStep {
  128569. /**
  128570. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128571. */
  128572. step: number;
  128573. /**
  128574. * Gets or sets the color associated with this step
  128575. */
  128576. color: Color3;
  128577. /**
  128578. * Creates a new GradientBlockColorStep
  128579. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128580. * @param color defines the color associated with this step
  128581. */
  128582. constructor(
  128583. /**
  128584. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128585. */
  128586. step: number,
  128587. /**
  128588. * Gets or sets the color associated with this step
  128589. */
  128590. color: Color3);
  128591. }
  128592. /**
  128593. * Block used to return a color from a gradient based on an input value between 0 and 1
  128594. */
  128595. export class GradientBlock extends NodeMaterialBlock {
  128596. /**
  128597. * Gets or sets the list of color steps
  128598. */
  128599. colorSteps: GradientBlockColorStep[];
  128600. /**
  128601. * Creates a new GradientBlock
  128602. * @param name defines the block name
  128603. */
  128604. constructor(name: string);
  128605. /**
  128606. * Gets the current class name
  128607. * @returns the class name
  128608. */
  128609. getClassName(): string;
  128610. /**
  128611. * Gets the gradient input component
  128612. */
  128613. get gradient(): NodeMaterialConnectionPoint;
  128614. /**
  128615. * Gets the output component
  128616. */
  128617. get output(): NodeMaterialConnectionPoint;
  128618. private _writeColorConstant;
  128619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128620. serialize(): any;
  128621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128622. protected _dumpPropertiesCode(): string;
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /**
  128627. * Block used to normalize lerp between 2 values
  128628. */
  128629. export class NLerpBlock extends NodeMaterialBlock {
  128630. /**
  128631. * Creates a new NLerpBlock
  128632. * @param name defines the block name
  128633. */
  128634. constructor(name: string);
  128635. /**
  128636. * Gets the current class name
  128637. * @returns the class name
  128638. */
  128639. getClassName(): string;
  128640. /**
  128641. * Gets the left operand input component
  128642. */
  128643. get left(): NodeMaterialConnectionPoint;
  128644. /**
  128645. * Gets the right operand input component
  128646. */
  128647. get right(): NodeMaterialConnectionPoint;
  128648. /**
  128649. * Gets the gradient operand input component
  128650. */
  128651. get gradient(): NodeMaterialConnectionPoint;
  128652. /**
  128653. * Gets the output component
  128654. */
  128655. get output(): NodeMaterialConnectionPoint;
  128656. protected _buildBlock(state: NodeMaterialBuildState): this;
  128657. }
  128658. }
  128659. declare module BABYLON {
  128660. /**
  128661. * block used to Generate a Worley Noise 3D Noise Pattern
  128662. */
  128663. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128664. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128665. manhattanDistance: boolean;
  128666. /**
  128667. * Creates a new WorleyNoise3DBlock
  128668. * @param name defines the block name
  128669. */
  128670. constructor(name: string);
  128671. /**
  128672. * Gets the current class name
  128673. * @returns the class name
  128674. */
  128675. getClassName(): string;
  128676. /**
  128677. * Gets the seed input component
  128678. */
  128679. get seed(): NodeMaterialConnectionPoint;
  128680. /**
  128681. * Gets the jitter input component
  128682. */
  128683. get jitter(): NodeMaterialConnectionPoint;
  128684. /**
  128685. * Gets the output component
  128686. */
  128687. get output(): NodeMaterialConnectionPoint;
  128688. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128689. /**
  128690. * Exposes the properties to the UI?
  128691. */
  128692. protected _dumpPropertiesCode(): string;
  128693. /**
  128694. * Exposes the properties to the Seralize?
  128695. */
  128696. serialize(): any;
  128697. /**
  128698. * Exposes the properties to the deseralize?
  128699. */
  128700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128701. }
  128702. }
  128703. declare module BABYLON {
  128704. /**
  128705. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128706. */
  128707. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128708. /**
  128709. * Creates a new SimplexPerlin3DBlock
  128710. * @param name defines the block name
  128711. */
  128712. constructor(name: string);
  128713. /**
  128714. * Gets the current class name
  128715. * @returns the class name
  128716. */
  128717. getClassName(): string;
  128718. /**
  128719. * Gets the seed operand input component
  128720. */
  128721. get seed(): NodeMaterialConnectionPoint;
  128722. /**
  128723. * Gets the output component
  128724. */
  128725. get output(): NodeMaterialConnectionPoint;
  128726. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128727. }
  128728. }
  128729. declare module BABYLON {
  128730. /**
  128731. * Block used to blend normals
  128732. */
  128733. export class NormalBlendBlock extends NodeMaterialBlock {
  128734. /**
  128735. * Creates a new NormalBlendBlock
  128736. * @param name defines the block name
  128737. */
  128738. constructor(name: string);
  128739. /**
  128740. * Gets the current class name
  128741. * @returns the class name
  128742. */
  128743. getClassName(): string;
  128744. /**
  128745. * Gets the first input component
  128746. */
  128747. get normalMap0(): NodeMaterialConnectionPoint;
  128748. /**
  128749. * Gets the second input component
  128750. */
  128751. get normalMap1(): NodeMaterialConnectionPoint;
  128752. /**
  128753. * Gets the output component
  128754. */
  128755. get output(): NodeMaterialConnectionPoint;
  128756. protected _buildBlock(state: NodeMaterialBuildState): this;
  128757. }
  128758. }
  128759. declare module BABYLON {
  128760. /**
  128761. * Block used to rotate a 2d vector by a given angle
  128762. */
  128763. export class Rotate2dBlock extends NodeMaterialBlock {
  128764. /**
  128765. * Creates a new Rotate2dBlock
  128766. * @param name defines the block name
  128767. */
  128768. constructor(name: string);
  128769. /**
  128770. * Gets the current class name
  128771. * @returns the class name
  128772. */
  128773. getClassName(): string;
  128774. /**
  128775. * Gets the input vector
  128776. */
  128777. get input(): NodeMaterialConnectionPoint;
  128778. /**
  128779. * Gets the input angle
  128780. */
  128781. get angle(): NodeMaterialConnectionPoint;
  128782. /**
  128783. * Gets the output component
  128784. */
  128785. get output(): NodeMaterialConnectionPoint;
  128786. autoConfigure(material: NodeMaterial): void;
  128787. protected _buildBlock(state: NodeMaterialBuildState): this;
  128788. }
  128789. }
  128790. declare module BABYLON {
  128791. /**
  128792. * Block used to get the reflected vector from a direction and a normal
  128793. */
  128794. export class ReflectBlock extends NodeMaterialBlock {
  128795. /**
  128796. * Creates a new ReflectBlock
  128797. * @param name defines the block name
  128798. */
  128799. constructor(name: string);
  128800. /**
  128801. * Gets the current class name
  128802. * @returns the class name
  128803. */
  128804. getClassName(): string;
  128805. /**
  128806. * Gets the incident component
  128807. */
  128808. get incident(): NodeMaterialConnectionPoint;
  128809. /**
  128810. * Gets the normal component
  128811. */
  128812. get normal(): NodeMaterialConnectionPoint;
  128813. /**
  128814. * Gets the output component
  128815. */
  128816. get output(): NodeMaterialConnectionPoint;
  128817. protected _buildBlock(state: NodeMaterialBuildState): this;
  128818. }
  128819. }
  128820. declare module BABYLON {
  128821. /**
  128822. * Block used to get the refracted vector from a direction and a normal
  128823. */
  128824. export class RefractBlock extends NodeMaterialBlock {
  128825. /**
  128826. * Creates a new RefractBlock
  128827. * @param name defines the block name
  128828. */
  128829. constructor(name: string);
  128830. /**
  128831. * Gets the current class name
  128832. * @returns the class name
  128833. */
  128834. getClassName(): string;
  128835. /**
  128836. * Gets the incident component
  128837. */
  128838. get incident(): NodeMaterialConnectionPoint;
  128839. /**
  128840. * Gets the normal component
  128841. */
  128842. get normal(): NodeMaterialConnectionPoint;
  128843. /**
  128844. * Gets the index of refraction component
  128845. */
  128846. get ior(): NodeMaterialConnectionPoint;
  128847. /**
  128848. * Gets the output component
  128849. */
  128850. get output(): NodeMaterialConnectionPoint;
  128851. protected _buildBlock(state: NodeMaterialBuildState): this;
  128852. }
  128853. }
  128854. declare module BABYLON {
  128855. /**
  128856. * Block used to desaturate a color
  128857. */
  128858. export class DesaturateBlock extends NodeMaterialBlock {
  128859. /**
  128860. * Creates a new DesaturateBlock
  128861. * @param name defines the block name
  128862. */
  128863. constructor(name: string);
  128864. /**
  128865. * Gets the current class name
  128866. * @returns the class name
  128867. */
  128868. getClassName(): string;
  128869. /**
  128870. * Gets the color operand input component
  128871. */
  128872. get color(): NodeMaterialConnectionPoint;
  128873. /**
  128874. * Gets the level operand input component
  128875. */
  128876. get level(): NodeMaterialConnectionPoint;
  128877. /**
  128878. * Gets the output component
  128879. */
  128880. get output(): NodeMaterialConnectionPoint;
  128881. protected _buildBlock(state: NodeMaterialBuildState): this;
  128882. }
  128883. }
  128884. declare module BABYLON {
  128885. /**
  128886. * Effect Render Options
  128887. */
  128888. export interface IEffectRendererOptions {
  128889. /**
  128890. * Defines the vertices positions.
  128891. */
  128892. positions?: number[];
  128893. /**
  128894. * Defines the indices.
  128895. */
  128896. indices?: number[];
  128897. }
  128898. /**
  128899. * Helper class to render one or more effects
  128900. */
  128901. export class EffectRenderer {
  128902. private engine;
  128903. private static _DefaultOptions;
  128904. private _vertexBuffers;
  128905. private _indexBuffer;
  128906. private _ringBufferIndex;
  128907. private _ringScreenBuffer;
  128908. private _fullscreenViewport;
  128909. private _getNextFrameBuffer;
  128910. /**
  128911. * Creates an effect renderer
  128912. * @param engine the engine to use for rendering
  128913. * @param options defines the options of the effect renderer
  128914. */
  128915. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  128916. /**
  128917. * Sets the current viewport in normalized coordinates 0-1
  128918. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  128919. */
  128920. setViewport(viewport?: Viewport): void;
  128921. /**
  128922. * Binds the embedded attributes buffer to the effect.
  128923. * @param effect Defines the effect to bind the attributes for
  128924. */
  128925. bindBuffers(effect: Effect): void;
  128926. /**
  128927. * Sets the current effect wrapper to use during draw.
  128928. * The effect needs to be ready before calling this api.
  128929. * This also sets the default full screen position attribute.
  128930. * @param effectWrapper Defines the effect to draw with
  128931. */
  128932. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  128933. /**
  128934. * Draws a full screen quad.
  128935. */
  128936. draw(): void;
  128937. /**
  128938. * renders one or more effects to a specified texture
  128939. * @param effectWrappers list of effects to renderer
  128940. * @param outputTexture texture to draw to, if null it will render to the screen
  128941. */
  128942. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  128943. /**
  128944. * Disposes of the effect renderer
  128945. */
  128946. dispose(): void;
  128947. }
  128948. /**
  128949. * Options to create an EffectWrapper
  128950. */
  128951. interface EffectWrapperCreationOptions {
  128952. /**
  128953. * Engine to use to create the effect
  128954. */
  128955. engine: ThinEngine;
  128956. /**
  128957. * Fragment shader for the effect
  128958. */
  128959. fragmentShader: string;
  128960. /**
  128961. * Vertex shader for the effect
  128962. */
  128963. vertexShader?: string;
  128964. /**
  128965. * Attributes to use in the shader
  128966. */
  128967. attributeNames?: Array<string>;
  128968. /**
  128969. * Uniforms to use in the shader
  128970. */
  128971. uniformNames?: Array<string>;
  128972. /**
  128973. * Texture sampler names to use in the shader
  128974. */
  128975. samplerNames?: Array<string>;
  128976. /**
  128977. * The friendly name of the effect displayed in Spector.
  128978. */
  128979. name?: string;
  128980. }
  128981. /**
  128982. * Wraps an effect to be used for rendering
  128983. */
  128984. export class EffectWrapper {
  128985. /**
  128986. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  128987. */
  128988. onApplyObservable: Observable<{}>;
  128989. /**
  128990. * The underlying effect
  128991. */
  128992. effect: Effect;
  128993. /**
  128994. * Creates an effect to be renderer
  128995. * @param creationOptions options to create the effect
  128996. */
  128997. constructor(creationOptions: EffectWrapperCreationOptions);
  128998. /**
  128999. * Disposes of the effect wrapper
  129000. */
  129001. dispose(): void;
  129002. }
  129003. }
  129004. declare module BABYLON {
  129005. /**
  129006. * Helper class to push actions to a pool of workers.
  129007. */
  129008. export class WorkerPool implements IDisposable {
  129009. private _workerInfos;
  129010. private _pendingActions;
  129011. /**
  129012. * Constructor
  129013. * @param workers Array of workers to use for actions
  129014. */
  129015. constructor(workers: Array<Worker>);
  129016. /**
  129017. * Terminates all workers and clears any pending actions.
  129018. */
  129019. dispose(): void;
  129020. /**
  129021. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129022. * pended until a worker has completed its action.
  129023. * @param action The action to perform. Call onComplete when the action is complete.
  129024. */
  129025. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129026. private _execute;
  129027. }
  129028. }
  129029. declare module BABYLON {
  129030. /**
  129031. * Configuration for Draco compression
  129032. */
  129033. export interface IDracoCompressionConfiguration {
  129034. /**
  129035. * Configuration for the decoder.
  129036. */
  129037. decoder: {
  129038. /**
  129039. * The url to the WebAssembly module.
  129040. */
  129041. wasmUrl?: string;
  129042. /**
  129043. * The url to the WebAssembly binary.
  129044. */
  129045. wasmBinaryUrl?: string;
  129046. /**
  129047. * The url to the fallback JavaScript module.
  129048. */
  129049. fallbackUrl?: string;
  129050. };
  129051. }
  129052. /**
  129053. * Draco compression (https://google.github.io/draco/)
  129054. *
  129055. * This class wraps the Draco module.
  129056. *
  129057. * **Encoder**
  129058. *
  129059. * The encoder is not currently implemented.
  129060. *
  129061. * **Decoder**
  129062. *
  129063. * 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.
  129064. *
  129065. * To update the configuration, use the following code:
  129066. * ```javascript
  129067. * DracoCompression.Configuration = {
  129068. * decoder: {
  129069. * wasmUrl: "<url to the WebAssembly library>",
  129070. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129071. * fallbackUrl: "<url to the fallback JavaScript library>",
  129072. * }
  129073. * };
  129074. * ```
  129075. *
  129076. * 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.
  129077. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129078. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129079. *
  129080. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129081. * ```javascript
  129082. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129083. * ```
  129084. *
  129085. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129086. */
  129087. export class DracoCompression implements IDisposable {
  129088. private _workerPoolPromise?;
  129089. private _decoderModulePromise?;
  129090. /**
  129091. * The configuration. Defaults to the following urls:
  129092. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129093. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129094. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129095. */
  129096. static Configuration: IDracoCompressionConfiguration;
  129097. /**
  129098. * Returns true if the decoder configuration is available.
  129099. */
  129100. static get DecoderAvailable(): boolean;
  129101. /**
  129102. * Default number of workers to create when creating the draco compression object.
  129103. */
  129104. static DefaultNumWorkers: number;
  129105. private static GetDefaultNumWorkers;
  129106. private static _Default;
  129107. /**
  129108. * Default instance for the draco compression object.
  129109. */
  129110. static get Default(): DracoCompression;
  129111. /**
  129112. * Constructor
  129113. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129114. */
  129115. constructor(numWorkers?: number);
  129116. /**
  129117. * Stop all async operations and release resources.
  129118. */
  129119. dispose(): void;
  129120. /**
  129121. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129122. * @returns a promise that resolves when ready
  129123. */
  129124. whenReadyAsync(): Promise<void>;
  129125. /**
  129126. * Decode Draco compressed mesh data to vertex data.
  129127. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129128. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129129. * @returns A promise that resolves with the decoded vertex data
  129130. */
  129131. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129132. [kind: string]: number;
  129133. }): Promise<VertexData>;
  129134. }
  129135. }
  129136. declare module BABYLON {
  129137. /**
  129138. * Class for building Constructive Solid Geometry
  129139. */
  129140. export class CSG {
  129141. private polygons;
  129142. /**
  129143. * The world matrix
  129144. */
  129145. matrix: Matrix;
  129146. /**
  129147. * Stores the position
  129148. */
  129149. position: Vector3;
  129150. /**
  129151. * Stores the rotation
  129152. */
  129153. rotation: Vector3;
  129154. /**
  129155. * Stores the rotation quaternion
  129156. */
  129157. rotationQuaternion: Nullable<Quaternion>;
  129158. /**
  129159. * Stores the scaling vector
  129160. */
  129161. scaling: Vector3;
  129162. /**
  129163. * Convert the Mesh to CSG
  129164. * @param mesh The Mesh to convert to CSG
  129165. * @returns A new CSG from the Mesh
  129166. */
  129167. static FromMesh(mesh: Mesh): CSG;
  129168. /**
  129169. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129170. * @param polygons Polygons used to construct a CSG solid
  129171. */
  129172. private static FromPolygons;
  129173. /**
  129174. * Clones, or makes a deep copy, of the CSG
  129175. * @returns A new CSG
  129176. */
  129177. clone(): CSG;
  129178. /**
  129179. * Unions this CSG with another CSG
  129180. * @param csg The CSG to union against this CSG
  129181. * @returns The unioned CSG
  129182. */
  129183. union(csg: CSG): CSG;
  129184. /**
  129185. * Unions this CSG with another CSG in place
  129186. * @param csg The CSG to union against this CSG
  129187. */
  129188. unionInPlace(csg: CSG): void;
  129189. /**
  129190. * Subtracts this CSG with another CSG
  129191. * @param csg The CSG to subtract against this CSG
  129192. * @returns A new CSG
  129193. */
  129194. subtract(csg: CSG): CSG;
  129195. /**
  129196. * Subtracts this CSG with another CSG in place
  129197. * @param csg The CSG to subtact against this CSG
  129198. */
  129199. subtractInPlace(csg: CSG): void;
  129200. /**
  129201. * Intersect this CSG with another CSG
  129202. * @param csg The CSG to intersect against this CSG
  129203. * @returns A new CSG
  129204. */
  129205. intersect(csg: CSG): CSG;
  129206. /**
  129207. * Intersects this CSG with another CSG in place
  129208. * @param csg The CSG to intersect against this CSG
  129209. */
  129210. intersectInPlace(csg: CSG): void;
  129211. /**
  129212. * Return a new CSG solid with solid and empty space switched. This solid is
  129213. * not modified.
  129214. * @returns A new CSG solid with solid and empty space switched
  129215. */
  129216. inverse(): CSG;
  129217. /**
  129218. * Inverses the CSG in place
  129219. */
  129220. inverseInPlace(): void;
  129221. /**
  129222. * This is used to keep meshes transformations so they can be restored
  129223. * when we build back a Babylon Mesh
  129224. * NB : All CSG operations are performed in world coordinates
  129225. * @param csg The CSG to copy the transform attributes from
  129226. * @returns This CSG
  129227. */
  129228. copyTransformAttributes(csg: CSG): CSG;
  129229. /**
  129230. * Build Raw mesh from CSG
  129231. * Coordinates here are in world space
  129232. * @param name The name of the mesh geometry
  129233. * @param scene The Scene
  129234. * @param keepSubMeshes Specifies if the submeshes should be kept
  129235. * @returns A new Mesh
  129236. */
  129237. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129238. /**
  129239. * Build Mesh from CSG taking material and transforms into account
  129240. * @param name The name of the Mesh
  129241. * @param material The material of the Mesh
  129242. * @param scene The Scene
  129243. * @param keepSubMeshes Specifies if submeshes should be kept
  129244. * @returns The new Mesh
  129245. */
  129246. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129247. }
  129248. }
  129249. declare module BABYLON {
  129250. /**
  129251. * Class used to create a trail following a mesh
  129252. */
  129253. export class TrailMesh extends Mesh {
  129254. private _generator;
  129255. private _autoStart;
  129256. private _running;
  129257. private _diameter;
  129258. private _length;
  129259. private _sectionPolygonPointsCount;
  129260. private _sectionVectors;
  129261. private _sectionNormalVectors;
  129262. private _beforeRenderObserver;
  129263. /**
  129264. * @constructor
  129265. * @param name The value used by scene.getMeshByName() to do a lookup.
  129266. * @param generator The mesh to generate a trail.
  129267. * @param scene The scene to add this mesh to.
  129268. * @param diameter Diameter of trailing mesh. Default is 1.
  129269. * @param length Length of trailing mesh. Default is 60.
  129270. * @param autoStart Automatically start trailing mesh. Default true.
  129271. */
  129272. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129273. /**
  129274. * "TrailMesh"
  129275. * @returns "TrailMesh"
  129276. */
  129277. getClassName(): string;
  129278. private _createMesh;
  129279. /**
  129280. * Start trailing mesh.
  129281. */
  129282. start(): void;
  129283. /**
  129284. * Stop trailing mesh.
  129285. */
  129286. stop(): void;
  129287. /**
  129288. * Update trailing mesh geometry.
  129289. */
  129290. update(): void;
  129291. /**
  129292. * Returns a new TrailMesh object.
  129293. * @param name is a string, the name given to the new mesh
  129294. * @param newGenerator use new generator object for cloned trail mesh
  129295. * @returns a new mesh
  129296. */
  129297. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129298. /**
  129299. * Serializes this trail mesh
  129300. * @param serializationObject object to write serialization to
  129301. */
  129302. serialize(serializationObject: any): void;
  129303. /**
  129304. * Parses a serialized trail mesh
  129305. * @param parsedMesh the serialized mesh
  129306. * @param scene the scene to create the trail mesh in
  129307. * @returns the created trail mesh
  129308. */
  129309. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129310. }
  129311. }
  129312. declare module BABYLON {
  129313. /**
  129314. * Class containing static functions to help procedurally build meshes
  129315. */
  129316. export class TiledBoxBuilder {
  129317. /**
  129318. * Creates a box mesh
  129319. * 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)
  129320. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129324. * @param name defines the name of the mesh
  129325. * @param options defines the options used to create the mesh
  129326. * @param scene defines the hosting scene
  129327. * @returns the box mesh
  129328. */
  129329. static CreateTiledBox(name: string, options: {
  129330. pattern?: number;
  129331. width?: number;
  129332. height?: number;
  129333. depth?: number;
  129334. tileSize?: number;
  129335. tileWidth?: number;
  129336. tileHeight?: number;
  129337. alignHorizontal?: number;
  129338. alignVertical?: number;
  129339. faceUV?: Vector4[];
  129340. faceColors?: Color4[];
  129341. sideOrientation?: number;
  129342. updatable?: boolean;
  129343. }, scene?: Nullable<Scene>): Mesh;
  129344. }
  129345. }
  129346. declare module BABYLON {
  129347. /**
  129348. * Class containing static functions to help procedurally build meshes
  129349. */
  129350. export class TorusKnotBuilder {
  129351. /**
  129352. * Creates a torus knot mesh
  129353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129360. * @param name defines the name of the mesh
  129361. * @param options defines the options used to create the mesh
  129362. * @param scene defines the hosting scene
  129363. * @returns the torus knot mesh
  129364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129365. */
  129366. static CreateTorusKnot(name: string, options: {
  129367. radius?: number;
  129368. tube?: number;
  129369. radialSegments?: number;
  129370. tubularSegments?: number;
  129371. p?: number;
  129372. q?: number;
  129373. updatable?: boolean;
  129374. sideOrientation?: number;
  129375. frontUVs?: Vector4;
  129376. backUVs?: Vector4;
  129377. }, scene: any): Mesh;
  129378. }
  129379. }
  129380. declare module BABYLON {
  129381. /**
  129382. * Polygon
  129383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129384. */
  129385. export class Polygon {
  129386. /**
  129387. * Creates a rectangle
  129388. * @param xmin bottom X coord
  129389. * @param ymin bottom Y coord
  129390. * @param xmax top X coord
  129391. * @param ymax top Y coord
  129392. * @returns points that make the resulting rectation
  129393. */
  129394. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129395. /**
  129396. * Creates a circle
  129397. * @param radius radius of circle
  129398. * @param cx scale in x
  129399. * @param cy scale in y
  129400. * @param numberOfSides number of sides that make up the circle
  129401. * @returns points that make the resulting circle
  129402. */
  129403. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129404. /**
  129405. * Creates a polygon from input string
  129406. * @param input Input polygon data
  129407. * @returns the parsed points
  129408. */
  129409. static Parse(input: string): Vector2[];
  129410. /**
  129411. * Starts building a polygon from x and y coordinates
  129412. * @param x x coordinate
  129413. * @param y y coordinate
  129414. * @returns the started path2
  129415. */
  129416. static StartingAt(x: number, y: number): Path2;
  129417. }
  129418. /**
  129419. * Builds a polygon
  129420. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129421. */
  129422. export class PolygonMeshBuilder {
  129423. private _points;
  129424. private _outlinepoints;
  129425. private _holes;
  129426. private _name;
  129427. private _scene;
  129428. private _epoints;
  129429. private _eholes;
  129430. private _addToepoint;
  129431. /**
  129432. * Babylon reference to the earcut plugin.
  129433. */
  129434. bjsEarcut: any;
  129435. /**
  129436. * Creates a PolygonMeshBuilder
  129437. * @param name name of the builder
  129438. * @param contours Path of the polygon
  129439. * @param scene scene to add to when creating the mesh
  129440. * @param earcutInjection can be used to inject your own earcut reference
  129441. */
  129442. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129443. /**
  129444. * Adds a whole within the polygon
  129445. * @param hole Array of points defining the hole
  129446. * @returns this
  129447. */
  129448. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129449. /**
  129450. * Creates the polygon
  129451. * @param updatable If the mesh should be updatable
  129452. * @param depth The depth of the mesh created
  129453. * @returns the created mesh
  129454. */
  129455. build(updatable?: boolean, depth?: number): Mesh;
  129456. /**
  129457. * Creates the polygon
  129458. * @param depth The depth of the mesh created
  129459. * @returns the created VertexData
  129460. */
  129461. buildVertexData(depth?: number): VertexData;
  129462. /**
  129463. * Adds a side to the polygon
  129464. * @param positions points that make the polygon
  129465. * @param normals normals of the polygon
  129466. * @param uvs uvs of the polygon
  129467. * @param indices indices of the polygon
  129468. * @param bounds bounds of the polygon
  129469. * @param points points of the polygon
  129470. * @param depth depth of the polygon
  129471. * @param flip flip of the polygon
  129472. */
  129473. private addSide;
  129474. }
  129475. }
  129476. declare module BABYLON {
  129477. /**
  129478. * Class containing static functions to help procedurally build meshes
  129479. */
  129480. export class PolygonBuilder {
  129481. /**
  129482. * Creates a polygon mesh
  129483. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129484. * * 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
  129485. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129488. * * Remember you can only change the shape positions, not their number when updating a polygon
  129489. * @param name defines the name of the mesh
  129490. * @param options defines the options used to create the mesh
  129491. * @param scene defines the hosting scene
  129492. * @param earcutInjection can be used to inject your own earcut reference
  129493. * @returns the polygon mesh
  129494. */
  129495. static CreatePolygon(name: string, options: {
  129496. shape: Vector3[];
  129497. holes?: Vector3[][];
  129498. depth?: number;
  129499. faceUV?: Vector4[];
  129500. faceColors?: Color4[];
  129501. updatable?: boolean;
  129502. sideOrientation?: number;
  129503. frontUVs?: Vector4;
  129504. backUVs?: Vector4;
  129505. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129506. /**
  129507. * Creates an extruded polygon mesh, with depth in the Y direction.
  129508. * * 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)
  129509. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129510. * @param name defines the name of the mesh
  129511. * @param options defines the options used to create the mesh
  129512. * @param scene defines the hosting scene
  129513. * @param earcutInjection can be used to inject your own earcut reference
  129514. * @returns the polygon mesh
  129515. */
  129516. static ExtrudePolygon(name: string, options: {
  129517. shape: Vector3[];
  129518. holes?: Vector3[][];
  129519. depth?: number;
  129520. faceUV?: Vector4[];
  129521. faceColors?: Color4[];
  129522. updatable?: boolean;
  129523. sideOrientation?: number;
  129524. frontUVs?: Vector4;
  129525. backUVs?: Vector4;
  129526. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129527. }
  129528. }
  129529. declare module BABYLON {
  129530. /**
  129531. * Class containing static functions to help procedurally build meshes
  129532. */
  129533. export class LatheBuilder {
  129534. /**
  129535. * Creates lathe mesh.
  129536. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129537. * * 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
  129538. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129539. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129540. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129541. * * 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
  129542. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129543. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  129544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129548. * @param name defines the name of the mesh
  129549. * @param options defines the options used to create the mesh
  129550. * @param scene defines the hosting scene
  129551. * @returns the lathe mesh
  129552. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129553. */
  129554. static CreateLathe(name: string, options: {
  129555. shape: Vector3[];
  129556. radius?: number;
  129557. tessellation?: number;
  129558. clip?: number;
  129559. arc?: number;
  129560. closed?: boolean;
  129561. updatable?: boolean;
  129562. sideOrientation?: number;
  129563. frontUVs?: Vector4;
  129564. backUVs?: Vector4;
  129565. cap?: number;
  129566. invertUV?: boolean;
  129567. }, scene?: Nullable<Scene>): Mesh;
  129568. }
  129569. }
  129570. declare module BABYLON {
  129571. /**
  129572. * Class containing static functions to help procedurally build meshes
  129573. */
  129574. export class TiledPlaneBuilder {
  129575. /**
  129576. * Creates a tiled plane mesh
  129577. * * The parameter `pattern` will, depending on value, do nothing or
  129578. * * * flip (reflect about central vertical) alternate tiles across and up
  129579. * * * flip every tile on alternate rows
  129580. * * * rotate (180 degs) alternate tiles across and up
  129581. * * * rotate every tile on alternate rows
  129582. * * * flip and rotate alternate tiles across and up
  129583. * * * flip and rotate every tile on alternate rows
  129584. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129585. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129588. * * 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)
  129589. * * 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)
  129590. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129591. * @param name defines the name of the mesh
  129592. * @param options defines the options used to create the mesh
  129593. * @param scene defines the hosting scene
  129594. * @returns the box mesh
  129595. */
  129596. static CreateTiledPlane(name: string, options: {
  129597. pattern?: number;
  129598. tileSize?: number;
  129599. tileWidth?: number;
  129600. tileHeight?: number;
  129601. size?: number;
  129602. width?: number;
  129603. height?: number;
  129604. alignHorizontal?: number;
  129605. alignVertical?: number;
  129606. sideOrientation?: number;
  129607. frontUVs?: Vector4;
  129608. backUVs?: Vector4;
  129609. updatable?: boolean;
  129610. }, scene?: Nullable<Scene>): Mesh;
  129611. }
  129612. }
  129613. declare module BABYLON {
  129614. /**
  129615. * Class containing static functions to help procedurally build meshes
  129616. */
  129617. export class TubeBuilder {
  129618. /**
  129619. * Creates a tube mesh.
  129620. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129621. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129622. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129623. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129624. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129625. * * 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)
  129626. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129627. * * 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
  129628. * * 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
  129629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129633. * @param name defines the name of the mesh
  129634. * @param options defines the options used to create the mesh
  129635. * @param scene defines the hosting scene
  129636. * @returns the tube mesh
  129637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129638. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129639. */
  129640. static CreateTube(name: string, options: {
  129641. path: Vector3[];
  129642. radius?: number;
  129643. tessellation?: number;
  129644. radiusFunction?: {
  129645. (i: number, distance: number): number;
  129646. };
  129647. cap?: number;
  129648. arc?: number;
  129649. updatable?: boolean;
  129650. sideOrientation?: number;
  129651. frontUVs?: Vector4;
  129652. backUVs?: Vector4;
  129653. instance?: Mesh;
  129654. invertUV?: boolean;
  129655. }, scene?: Nullable<Scene>): Mesh;
  129656. }
  129657. }
  129658. declare module BABYLON {
  129659. /**
  129660. * Class containing static functions to help procedurally build meshes
  129661. */
  129662. export class IcoSphereBuilder {
  129663. /**
  129664. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129665. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129666. * * 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`)
  129667. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129668. * * 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
  129669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129672. * @param name defines the name of the mesh
  129673. * @param options defines the options used to create the mesh
  129674. * @param scene defines the hosting scene
  129675. * @returns the icosahedron mesh
  129676. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129677. */
  129678. static CreateIcoSphere(name: string, options: {
  129679. radius?: number;
  129680. radiusX?: number;
  129681. radiusY?: number;
  129682. radiusZ?: number;
  129683. flat?: boolean;
  129684. subdivisions?: number;
  129685. sideOrientation?: number;
  129686. frontUVs?: Vector4;
  129687. backUVs?: Vector4;
  129688. updatable?: boolean;
  129689. }, scene?: Nullable<Scene>): Mesh;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /**
  129694. * Class containing static functions to help procedurally build meshes
  129695. */
  129696. export class DecalBuilder {
  129697. /**
  129698. * Creates a decal mesh.
  129699. * 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
  129700. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129701. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129702. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129703. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129704. * @param name defines the name of the mesh
  129705. * @param sourceMesh defines the mesh where the decal must be applied
  129706. * @param options defines the options used to create the mesh
  129707. * @param scene defines the hosting scene
  129708. * @returns the decal mesh
  129709. * @see https://doc.babylonjs.com/how_to/decals
  129710. */
  129711. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129712. position?: Vector3;
  129713. normal?: Vector3;
  129714. size?: Vector3;
  129715. angle?: number;
  129716. }): Mesh;
  129717. }
  129718. }
  129719. declare module BABYLON {
  129720. /**
  129721. * Class containing static functions to help procedurally build meshes
  129722. */
  129723. export class MeshBuilder {
  129724. /**
  129725. * Creates a box mesh
  129726. * * The parameter `size` sets the size (float) of each box side (default 1)
  129727. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129728. * * 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)
  129729. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129733. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129734. * @param name defines the name of the mesh
  129735. * @param options defines the options used to create the mesh
  129736. * @param scene defines the hosting scene
  129737. * @returns the box mesh
  129738. */
  129739. static CreateBox(name: string, options: {
  129740. size?: number;
  129741. width?: number;
  129742. height?: number;
  129743. depth?: number;
  129744. faceUV?: Vector4[];
  129745. faceColors?: Color4[];
  129746. sideOrientation?: number;
  129747. frontUVs?: Vector4;
  129748. backUVs?: Vector4;
  129749. updatable?: boolean;
  129750. }, scene?: Nullable<Scene>): Mesh;
  129751. /**
  129752. * Creates a tiled box mesh
  129753. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129755. * @param name defines the name of the mesh
  129756. * @param options defines the options used to create the mesh
  129757. * @param scene defines the hosting scene
  129758. * @returns the tiled box mesh
  129759. */
  129760. static CreateTiledBox(name: string, options: {
  129761. pattern?: number;
  129762. size?: number;
  129763. width?: number;
  129764. height?: number;
  129765. depth: number;
  129766. tileSize?: number;
  129767. tileWidth?: number;
  129768. tileHeight?: number;
  129769. faceUV?: Vector4[];
  129770. faceColors?: Color4[];
  129771. alignHorizontal?: number;
  129772. alignVertical?: number;
  129773. sideOrientation?: number;
  129774. updatable?: boolean;
  129775. }, scene?: Nullable<Scene>): Mesh;
  129776. /**
  129777. * Creates a sphere mesh
  129778. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129779. * * 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`)
  129780. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129781. * * 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
  129782. * * 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)
  129783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129786. * @param name defines the name of the mesh
  129787. * @param options defines the options used to create the mesh
  129788. * @param scene defines the hosting scene
  129789. * @returns the sphere mesh
  129790. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129791. */
  129792. static CreateSphere(name: string, options: {
  129793. segments?: number;
  129794. diameter?: number;
  129795. diameterX?: number;
  129796. diameterY?: number;
  129797. diameterZ?: number;
  129798. arc?: number;
  129799. slice?: number;
  129800. sideOrientation?: number;
  129801. frontUVs?: Vector4;
  129802. backUVs?: Vector4;
  129803. updatable?: boolean;
  129804. }, scene?: Nullable<Scene>): Mesh;
  129805. /**
  129806. * Creates a plane polygonal mesh. By default, this is a disc
  129807. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129808. * * 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
  129809. * * 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
  129810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129813. * @param name defines the name of the mesh
  129814. * @param options defines the options used to create the mesh
  129815. * @param scene defines the hosting scene
  129816. * @returns the plane polygonal mesh
  129817. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129818. */
  129819. static CreateDisc(name: string, options: {
  129820. radius?: number;
  129821. tessellation?: number;
  129822. arc?: number;
  129823. updatable?: boolean;
  129824. sideOrientation?: number;
  129825. frontUVs?: Vector4;
  129826. backUVs?: Vector4;
  129827. }, scene?: Nullable<Scene>): Mesh;
  129828. /**
  129829. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129830. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129831. * * 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`)
  129832. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129833. * * 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
  129834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129837. * @param name defines the name of the mesh
  129838. * @param options defines the options used to create the mesh
  129839. * @param scene defines the hosting scene
  129840. * @returns the icosahedron mesh
  129841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129842. */
  129843. static CreateIcoSphere(name: string, options: {
  129844. radius?: number;
  129845. radiusX?: number;
  129846. radiusY?: number;
  129847. radiusZ?: number;
  129848. flat?: boolean;
  129849. subdivisions?: number;
  129850. sideOrientation?: number;
  129851. frontUVs?: Vector4;
  129852. backUVs?: Vector4;
  129853. updatable?: boolean;
  129854. }, scene?: Nullable<Scene>): Mesh;
  129855. /**
  129856. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129857. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129858. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129859. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129860. * * 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
  129861. * * 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
  129862. * * 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
  129863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129866. * * 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
  129867. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129868. * * 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
  129869. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129871. * @param name defines the name of the mesh
  129872. * @param options defines the options used to create the mesh
  129873. * @param scene defines the hosting scene
  129874. * @returns the ribbon mesh
  129875. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129877. */
  129878. static CreateRibbon(name: string, options: {
  129879. pathArray: Vector3[][];
  129880. closeArray?: boolean;
  129881. closePath?: boolean;
  129882. offset?: number;
  129883. updatable?: boolean;
  129884. sideOrientation?: number;
  129885. frontUVs?: Vector4;
  129886. backUVs?: Vector4;
  129887. instance?: Mesh;
  129888. invertUV?: boolean;
  129889. uvs?: Vector2[];
  129890. colors?: Color4[];
  129891. }, scene?: Nullable<Scene>): Mesh;
  129892. /**
  129893. * Creates a cylinder or a cone mesh
  129894. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  129895. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  129896. * * 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.
  129897. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  129898. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  129899. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  129900. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  129901. * * 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).
  129902. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  129903. * * 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).
  129904. * * 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
  129905. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  129906. * * 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
  129907. * * 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.
  129908. * * If `enclose` is false, a ring surface is one element.
  129909. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  129910. * * 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
  129911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129914. * @param name defines the name of the mesh
  129915. * @param options defines the options used to create the mesh
  129916. * @param scene defines the hosting scene
  129917. * @returns the cylinder mesh
  129918. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  129919. */
  129920. static CreateCylinder(name: string, options: {
  129921. height?: number;
  129922. diameterTop?: number;
  129923. diameterBottom?: number;
  129924. diameter?: number;
  129925. tessellation?: number;
  129926. subdivisions?: number;
  129927. arc?: number;
  129928. faceColors?: Color4[];
  129929. faceUV?: Vector4[];
  129930. updatable?: boolean;
  129931. hasRings?: boolean;
  129932. enclose?: boolean;
  129933. cap?: number;
  129934. sideOrientation?: number;
  129935. frontUVs?: Vector4;
  129936. backUVs?: Vector4;
  129937. }, scene?: Nullable<Scene>): Mesh;
  129938. /**
  129939. * Creates a torus mesh
  129940. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  129941. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  129942. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  129943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129946. * @param name defines the name of the mesh
  129947. * @param options defines the options used to create the mesh
  129948. * @param scene defines the hosting scene
  129949. * @returns the torus mesh
  129950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  129951. */
  129952. static CreateTorus(name: string, options: {
  129953. diameter?: number;
  129954. thickness?: number;
  129955. tessellation?: number;
  129956. updatable?: boolean;
  129957. sideOrientation?: number;
  129958. frontUVs?: Vector4;
  129959. backUVs?: Vector4;
  129960. }, scene?: Nullable<Scene>): Mesh;
  129961. /**
  129962. * Creates a torus knot mesh
  129963. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129964. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129965. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129966. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129970. * @param name defines the name of the mesh
  129971. * @param options defines the options used to create the mesh
  129972. * @param scene defines the hosting scene
  129973. * @returns the torus knot mesh
  129974. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129975. */
  129976. static CreateTorusKnot(name: string, options: {
  129977. radius?: number;
  129978. tube?: number;
  129979. radialSegments?: number;
  129980. tubularSegments?: number;
  129981. p?: number;
  129982. q?: number;
  129983. updatable?: boolean;
  129984. sideOrientation?: number;
  129985. frontUVs?: Vector4;
  129986. backUVs?: Vector4;
  129987. }, scene?: Nullable<Scene>): Mesh;
  129988. /**
  129989. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129990. * * 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
  129991. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129992. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129993. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129994. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129995. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129996. * * 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
  129997. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129999. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130000. * @param name defines the name of the new line system
  130001. * @param options defines the options used to create the line system
  130002. * @param scene defines the hosting scene
  130003. * @returns a new line system mesh
  130004. */
  130005. static CreateLineSystem(name: string, options: {
  130006. lines: Vector3[][];
  130007. updatable?: boolean;
  130008. instance?: Nullable<LinesMesh>;
  130009. colors?: Nullable<Color4[][]>;
  130010. useVertexAlpha?: boolean;
  130011. }, scene: Nullable<Scene>): LinesMesh;
  130012. /**
  130013. * Creates a line mesh
  130014. * 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
  130015. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130016. * * The parameter `points` is an array successive Vector3
  130017. * * 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
  130018. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130019. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130020. * * When updating an instance, remember that only point positions can change, not the number of points
  130021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130023. * @param name defines the name of the new line system
  130024. * @param options defines the options used to create the line system
  130025. * @param scene defines the hosting scene
  130026. * @returns a new line mesh
  130027. */
  130028. static CreateLines(name: string, options: {
  130029. points: Vector3[];
  130030. updatable?: boolean;
  130031. instance?: Nullable<LinesMesh>;
  130032. colors?: Color4[];
  130033. useVertexAlpha?: boolean;
  130034. }, scene?: Nullable<Scene>): LinesMesh;
  130035. /**
  130036. * Creates a dashed line mesh
  130037. * * 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
  130038. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130039. * * The parameter `points` is an array successive Vector3
  130040. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130041. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130042. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130043. * * 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
  130044. * * When updating an instance, remember that only point positions can change, not the number of points
  130045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130046. * @param name defines the name of the mesh
  130047. * @param options defines the options used to create the mesh
  130048. * @param scene defines the hosting scene
  130049. * @returns the dashed line mesh
  130050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130051. */
  130052. static CreateDashedLines(name: string, options: {
  130053. points: Vector3[];
  130054. dashSize?: number;
  130055. gapSize?: number;
  130056. dashNb?: number;
  130057. updatable?: boolean;
  130058. instance?: LinesMesh;
  130059. }, scene?: Nullable<Scene>): LinesMesh;
  130060. /**
  130061. * 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.
  130062. * * 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.
  130063. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130064. * * 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.
  130065. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130066. * * 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
  130067. * * 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
  130068. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130071. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130073. * @param name defines the name of the mesh
  130074. * @param options defines the options used to create the mesh
  130075. * @param scene defines the hosting scene
  130076. * @returns the extruded shape mesh
  130077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130079. */
  130080. static ExtrudeShape(name: string, options: {
  130081. shape: Vector3[];
  130082. path: Vector3[];
  130083. scale?: number;
  130084. rotation?: number;
  130085. cap?: number;
  130086. updatable?: boolean;
  130087. sideOrientation?: number;
  130088. frontUVs?: Vector4;
  130089. backUVs?: Vector4;
  130090. instance?: Mesh;
  130091. invertUV?: boolean;
  130092. }, scene?: Nullable<Scene>): Mesh;
  130093. /**
  130094. * Creates an custom extruded shape mesh.
  130095. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130096. * * 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.
  130097. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130098. * * 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
  130099. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130100. * * 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
  130101. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130102. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130103. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130104. * * 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
  130105. * * 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
  130106. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130111. * @param name defines the name of the mesh
  130112. * @param options defines the options used to create the mesh
  130113. * @param scene defines the hosting scene
  130114. * @returns the custom extruded shape mesh
  130115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130116. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130118. */
  130119. static ExtrudeShapeCustom(name: string, options: {
  130120. shape: Vector3[];
  130121. path: Vector3[];
  130122. scaleFunction?: any;
  130123. rotationFunction?: any;
  130124. ribbonCloseArray?: boolean;
  130125. ribbonClosePath?: boolean;
  130126. cap?: number;
  130127. updatable?: boolean;
  130128. sideOrientation?: number;
  130129. frontUVs?: Vector4;
  130130. backUVs?: Vector4;
  130131. instance?: Mesh;
  130132. invertUV?: boolean;
  130133. }, scene?: Nullable<Scene>): Mesh;
  130134. /**
  130135. * Creates lathe mesh.
  130136. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130137. * * 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
  130138. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130139. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130140. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130141. * * 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
  130142. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130143. * * 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
  130144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130148. * @param name defines the name of the mesh
  130149. * @param options defines the options used to create the mesh
  130150. * @param scene defines the hosting scene
  130151. * @returns the lathe mesh
  130152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130153. */
  130154. static CreateLathe(name: string, options: {
  130155. shape: Vector3[];
  130156. radius?: number;
  130157. tessellation?: number;
  130158. clip?: number;
  130159. arc?: number;
  130160. closed?: boolean;
  130161. updatable?: boolean;
  130162. sideOrientation?: number;
  130163. frontUVs?: Vector4;
  130164. backUVs?: Vector4;
  130165. cap?: number;
  130166. invertUV?: boolean;
  130167. }, scene?: Nullable<Scene>): Mesh;
  130168. /**
  130169. * Creates a tiled plane mesh
  130170. * * You can set a limited pattern arrangement with the tiles
  130171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130174. * @param name defines the name of the mesh
  130175. * @param options defines the options used to create the mesh
  130176. * @param scene defines the hosting scene
  130177. * @returns the plane mesh
  130178. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130179. */
  130180. static CreateTiledPlane(name: string, options: {
  130181. pattern?: number;
  130182. tileSize?: number;
  130183. tileWidth?: number;
  130184. tileHeight?: number;
  130185. size?: number;
  130186. width?: number;
  130187. height?: number;
  130188. alignHorizontal?: number;
  130189. alignVertical?: number;
  130190. sideOrientation?: number;
  130191. frontUVs?: Vector4;
  130192. backUVs?: Vector4;
  130193. updatable?: boolean;
  130194. }, scene?: Nullable<Scene>): Mesh;
  130195. /**
  130196. * Creates a plane mesh
  130197. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130198. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130199. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130203. * @param name defines the name of the mesh
  130204. * @param options defines the options used to create the mesh
  130205. * @param scene defines the hosting scene
  130206. * @returns the plane mesh
  130207. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130208. */
  130209. static CreatePlane(name: string, options: {
  130210. size?: number;
  130211. width?: number;
  130212. height?: number;
  130213. sideOrientation?: number;
  130214. frontUVs?: Vector4;
  130215. backUVs?: Vector4;
  130216. updatable?: boolean;
  130217. sourcePlane?: Plane;
  130218. }, scene?: Nullable<Scene>): Mesh;
  130219. /**
  130220. * Creates a ground mesh
  130221. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130222. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130224. * @param name defines the name of the mesh
  130225. * @param options defines the options used to create the mesh
  130226. * @param scene defines the hosting scene
  130227. * @returns the ground mesh
  130228. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130229. */
  130230. static CreateGround(name: string, options: {
  130231. width?: number;
  130232. height?: number;
  130233. subdivisions?: number;
  130234. subdivisionsX?: number;
  130235. subdivisionsY?: number;
  130236. updatable?: boolean;
  130237. }, scene?: Nullable<Scene>): Mesh;
  130238. /**
  130239. * Creates a tiled ground mesh
  130240. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130241. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130242. * * 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
  130243. * * 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
  130244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130245. * @param name defines the name of the mesh
  130246. * @param options defines the options used to create the mesh
  130247. * @param scene defines the hosting scene
  130248. * @returns the tiled ground mesh
  130249. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130250. */
  130251. static CreateTiledGround(name: string, options: {
  130252. xmin: number;
  130253. zmin: number;
  130254. xmax: number;
  130255. zmax: number;
  130256. subdivisions?: {
  130257. w: number;
  130258. h: number;
  130259. };
  130260. precision?: {
  130261. w: number;
  130262. h: number;
  130263. };
  130264. updatable?: boolean;
  130265. }, scene?: Nullable<Scene>): Mesh;
  130266. /**
  130267. * Creates a ground mesh from a height map
  130268. * * The parameter `url` sets the URL of the height map image resource.
  130269. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130270. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130271. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130272. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130273. * * 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.
  130274. * * 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).
  130275. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130277. * @param name defines the name of the mesh
  130278. * @param url defines the url to the height map
  130279. * @param options defines the options used to create the mesh
  130280. * @param scene defines the hosting scene
  130281. * @returns the ground mesh
  130282. * @see https://doc.babylonjs.com/babylon101/height_map
  130283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130284. */
  130285. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130286. width?: number;
  130287. height?: number;
  130288. subdivisions?: number;
  130289. minHeight?: number;
  130290. maxHeight?: number;
  130291. colorFilter?: Color3;
  130292. alphaFilter?: number;
  130293. updatable?: boolean;
  130294. onReady?: (mesh: GroundMesh) => void;
  130295. }, scene?: Nullable<Scene>): GroundMesh;
  130296. /**
  130297. * Creates a polygon mesh
  130298. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130299. * * 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
  130300. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130303. * * Remember you can only change the shape positions, not their number when updating a polygon
  130304. * @param name defines the name of the mesh
  130305. * @param options defines the options used to create the mesh
  130306. * @param scene defines the hosting scene
  130307. * @param earcutInjection can be used to inject your own earcut reference
  130308. * @returns the polygon mesh
  130309. */
  130310. static CreatePolygon(name: string, options: {
  130311. shape: Vector3[];
  130312. holes?: Vector3[][];
  130313. depth?: number;
  130314. faceUV?: Vector4[];
  130315. faceColors?: Color4[];
  130316. updatable?: boolean;
  130317. sideOrientation?: number;
  130318. frontUVs?: Vector4;
  130319. backUVs?: Vector4;
  130320. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130321. /**
  130322. * Creates an extruded polygon mesh, with depth in the Y direction.
  130323. * * 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)
  130324. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130325. * @param name defines the name of the mesh
  130326. * @param options defines the options used to create the mesh
  130327. * @param scene defines the hosting scene
  130328. * @param earcutInjection can be used to inject your own earcut reference
  130329. * @returns the polygon mesh
  130330. */
  130331. static ExtrudePolygon(name: string, options: {
  130332. shape: Vector3[];
  130333. holes?: Vector3[][];
  130334. depth?: number;
  130335. faceUV?: Vector4[];
  130336. faceColors?: Color4[];
  130337. updatable?: boolean;
  130338. sideOrientation?: number;
  130339. frontUVs?: Vector4;
  130340. backUVs?: Vector4;
  130341. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130342. /**
  130343. * Creates a tube mesh.
  130344. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130345. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130346. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130347. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130348. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130349. * * 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)
  130350. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130351. * * 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
  130352. * * 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
  130353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130357. * @param name defines the name of the mesh
  130358. * @param options defines the options used to create the mesh
  130359. * @param scene defines the hosting scene
  130360. * @returns the tube mesh
  130361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130362. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130363. */
  130364. static CreateTube(name: string, options: {
  130365. path: Vector3[];
  130366. radius?: number;
  130367. tessellation?: number;
  130368. radiusFunction?: {
  130369. (i: number, distance: number): number;
  130370. };
  130371. cap?: number;
  130372. arc?: number;
  130373. updatable?: boolean;
  130374. sideOrientation?: number;
  130375. frontUVs?: Vector4;
  130376. backUVs?: Vector4;
  130377. instance?: Mesh;
  130378. invertUV?: boolean;
  130379. }, scene?: Nullable<Scene>): Mesh;
  130380. /**
  130381. * Creates a polyhedron mesh
  130382. * * 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
  130383. * * The parameter `size` (positive float, default 1) sets the polygon size
  130384. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130385. * * 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`
  130386. * * 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
  130387. * * 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)`)
  130388. * * 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
  130389. * * 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
  130390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130393. * @param name defines the name of the mesh
  130394. * @param options defines the options used to create the mesh
  130395. * @param scene defines the hosting scene
  130396. * @returns the polyhedron mesh
  130397. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130398. */
  130399. static CreatePolyhedron(name: string, options: {
  130400. type?: number;
  130401. size?: number;
  130402. sizeX?: number;
  130403. sizeY?: number;
  130404. sizeZ?: number;
  130405. custom?: any;
  130406. faceUV?: Vector4[];
  130407. faceColors?: Color4[];
  130408. flat?: boolean;
  130409. updatable?: boolean;
  130410. sideOrientation?: number;
  130411. frontUVs?: Vector4;
  130412. backUVs?: Vector4;
  130413. }, scene?: Nullable<Scene>): Mesh;
  130414. /**
  130415. * Creates a decal mesh.
  130416. * 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
  130417. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130418. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130419. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130420. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130421. * @param name defines the name of the mesh
  130422. * @param sourceMesh defines the mesh where the decal must be applied
  130423. * @param options defines the options used to create the mesh
  130424. * @param scene defines the hosting scene
  130425. * @returns the decal mesh
  130426. * @see https://doc.babylonjs.com/how_to/decals
  130427. */
  130428. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130429. position?: Vector3;
  130430. normal?: Vector3;
  130431. size?: Vector3;
  130432. angle?: number;
  130433. }): Mesh;
  130434. }
  130435. }
  130436. declare module BABYLON {
  130437. /**
  130438. * A simplifier interface for future simplification implementations
  130439. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130440. */
  130441. export interface ISimplifier {
  130442. /**
  130443. * Simplification of a given mesh according to the given settings.
  130444. * Since this requires computation, it is assumed that the function runs async.
  130445. * @param settings The settings of the simplification, including quality and distance
  130446. * @param successCallback A callback that will be called after the mesh was simplified.
  130447. * @param errorCallback in case of an error, this callback will be called. optional.
  130448. */
  130449. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130450. }
  130451. /**
  130452. * Expected simplification settings.
  130453. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130454. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130455. */
  130456. export interface ISimplificationSettings {
  130457. /**
  130458. * Gets or sets the expected quality
  130459. */
  130460. quality: number;
  130461. /**
  130462. * Gets or sets the distance when this optimized version should be used
  130463. */
  130464. distance: number;
  130465. /**
  130466. * Gets an already optimized mesh
  130467. */
  130468. optimizeMesh?: boolean;
  130469. }
  130470. /**
  130471. * Class used to specify simplification options
  130472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130473. */
  130474. export class SimplificationSettings implements ISimplificationSettings {
  130475. /** expected quality */
  130476. quality: number;
  130477. /** distance when this optimized version should be used */
  130478. distance: number;
  130479. /** already optimized mesh */
  130480. optimizeMesh?: boolean | undefined;
  130481. /**
  130482. * Creates a SimplificationSettings
  130483. * @param quality expected quality
  130484. * @param distance distance when this optimized version should be used
  130485. * @param optimizeMesh already optimized mesh
  130486. */
  130487. constructor(
  130488. /** expected quality */
  130489. quality: number,
  130490. /** distance when this optimized version should be used */
  130491. distance: number,
  130492. /** already optimized mesh */
  130493. optimizeMesh?: boolean | undefined);
  130494. }
  130495. /**
  130496. * Interface used to define a simplification task
  130497. */
  130498. export interface ISimplificationTask {
  130499. /**
  130500. * Array of settings
  130501. */
  130502. settings: Array<ISimplificationSettings>;
  130503. /**
  130504. * Simplification type
  130505. */
  130506. simplificationType: SimplificationType;
  130507. /**
  130508. * Mesh to simplify
  130509. */
  130510. mesh: Mesh;
  130511. /**
  130512. * Callback called on success
  130513. */
  130514. successCallback?: () => void;
  130515. /**
  130516. * Defines if parallel processing can be used
  130517. */
  130518. parallelProcessing: boolean;
  130519. }
  130520. /**
  130521. * Queue used to order the simplification tasks
  130522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130523. */
  130524. export class SimplificationQueue {
  130525. private _simplificationArray;
  130526. /**
  130527. * Gets a boolean indicating that the process is still running
  130528. */
  130529. running: boolean;
  130530. /**
  130531. * Creates a new queue
  130532. */
  130533. constructor();
  130534. /**
  130535. * Adds a new simplification task
  130536. * @param task defines a task to add
  130537. */
  130538. addTask(task: ISimplificationTask): void;
  130539. /**
  130540. * Execute next task
  130541. */
  130542. executeNext(): void;
  130543. /**
  130544. * Execute a simplification task
  130545. * @param task defines the task to run
  130546. */
  130547. runSimplification(task: ISimplificationTask): void;
  130548. private getSimplifier;
  130549. }
  130550. /**
  130551. * The implemented types of simplification
  130552. * At the moment only Quadratic Error Decimation is implemented
  130553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130554. */
  130555. export enum SimplificationType {
  130556. /** Quadratic error decimation */
  130557. QUADRATIC = 0
  130558. }
  130559. }
  130560. declare module BABYLON {
  130561. interface Scene {
  130562. /** @hidden (Backing field) */
  130563. _simplificationQueue: SimplificationQueue;
  130564. /**
  130565. * Gets or sets the simplification queue attached to the scene
  130566. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130567. */
  130568. simplificationQueue: SimplificationQueue;
  130569. }
  130570. interface Mesh {
  130571. /**
  130572. * Simplify the mesh according to the given array of settings.
  130573. * Function will return immediately and will simplify async
  130574. * @param settings a collection of simplification settings
  130575. * @param parallelProcessing should all levels calculate parallel or one after the other
  130576. * @param simplificationType the type of simplification to run
  130577. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130578. * @returns the current mesh
  130579. */
  130580. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130581. }
  130582. /**
  130583. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130584. * created in a scene
  130585. */
  130586. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130587. /**
  130588. * The component name helpfull to identify the component in the list of scene components.
  130589. */
  130590. readonly name: string;
  130591. /**
  130592. * The scene the component belongs to.
  130593. */
  130594. scene: Scene;
  130595. /**
  130596. * Creates a new instance of the component for the given scene
  130597. * @param scene Defines the scene to register the component in
  130598. */
  130599. constructor(scene: Scene);
  130600. /**
  130601. * Registers the component in a given scene
  130602. */
  130603. register(): void;
  130604. /**
  130605. * Rebuilds the elements related to this component in case of
  130606. * context lost for instance.
  130607. */
  130608. rebuild(): void;
  130609. /**
  130610. * Disposes the component and the associated ressources
  130611. */
  130612. dispose(): void;
  130613. private _beforeCameraUpdate;
  130614. }
  130615. }
  130616. declare module BABYLON {
  130617. /**
  130618. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130619. */
  130620. export interface INavigationEnginePlugin {
  130621. /**
  130622. * plugin name
  130623. */
  130624. name: string;
  130625. /**
  130626. * Creates a navigation mesh
  130627. * @param meshes array of all the geometry used to compute the navigatio mesh
  130628. * @param parameters bunch of parameters used to filter geometry
  130629. */
  130630. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130631. /**
  130632. * Create a navigation mesh debug mesh
  130633. * @param scene is where the mesh will be added
  130634. * @returns debug display mesh
  130635. */
  130636. createDebugNavMesh(scene: Scene): Mesh;
  130637. /**
  130638. * Get a navigation mesh constrained position, closest to the parameter position
  130639. * @param position world position
  130640. * @returns the closest point to position constrained by the navigation mesh
  130641. */
  130642. getClosestPoint(position: Vector3): Vector3;
  130643. /**
  130644. * Get a navigation mesh constrained position, within a particular radius
  130645. * @param position world position
  130646. * @param maxRadius the maximum distance to the constrained world position
  130647. * @returns the closest point to position constrained by the navigation mesh
  130648. */
  130649. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130650. /**
  130651. * Compute the final position from a segment made of destination-position
  130652. * @param position world position
  130653. * @param destination world position
  130654. * @returns the resulting point along the navmesh
  130655. */
  130656. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130657. /**
  130658. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130659. * @param start world position
  130660. * @param end world position
  130661. * @returns array containing world position composing the path
  130662. */
  130663. computePath(start: Vector3, end: Vector3): Vector3[];
  130664. /**
  130665. * If this plugin is supported
  130666. * @returns true if plugin is supported
  130667. */
  130668. isSupported(): boolean;
  130669. /**
  130670. * Create a new Crowd so you can add agents
  130671. * @param maxAgents the maximum agent count in the crowd
  130672. * @param maxAgentRadius the maximum radius an agent can have
  130673. * @param scene to attach the crowd to
  130674. * @returns the crowd you can add agents to
  130675. */
  130676. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130677. /**
  130678. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130679. * The queries will try to find a solution within those bounds
  130680. * default is (1,1,1)
  130681. * @param extent x,y,z value that define the extent around the queries point of reference
  130682. */
  130683. setDefaultQueryExtent(extent: Vector3): void;
  130684. /**
  130685. * Get the Bounding box extent specified by setDefaultQueryExtent
  130686. * @returns the box extent values
  130687. */
  130688. getDefaultQueryExtent(): Vector3;
  130689. /**
  130690. * Release all resources
  130691. */
  130692. dispose(): void;
  130693. }
  130694. /**
  130695. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130696. */
  130697. export interface ICrowd {
  130698. /**
  130699. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130700. * You can attach anything to that node. The node position is updated in the scene update tick.
  130701. * @param pos world position that will be constrained by the navigation mesh
  130702. * @param parameters agent parameters
  130703. * @param transform hooked to the agent that will be update by the scene
  130704. * @returns agent index
  130705. */
  130706. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130707. /**
  130708. * Returns the agent position in world space
  130709. * @param index agent index returned by addAgent
  130710. * @returns world space position
  130711. */
  130712. getAgentPosition(index: number): Vector3;
  130713. /**
  130714. * Gets the agent velocity in world space
  130715. * @param index agent index returned by addAgent
  130716. * @returns world space velocity
  130717. */
  130718. getAgentVelocity(index: number): Vector3;
  130719. /**
  130720. * remove a particular agent previously created
  130721. * @param index agent index returned by addAgent
  130722. */
  130723. removeAgent(index: number): void;
  130724. /**
  130725. * get the list of all agents attached to this crowd
  130726. * @returns list of agent indices
  130727. */
  130728. getAgents(): number[];
  130729. /**
  130730. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130731. * @param deltaTime in seconds
  130732. */
  130733. update(deltaTime: number): void;
  130734. /**
  130735. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130736. * @param index agent index returned by addAgent
  130737. * @param destination targeted world position
  130738. */
  130739. agentGoto(index: number, destination: Vector3): void;
  130740. /**
  130741. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130742. * The queries will try to find a solution within those bounds
  130743. * default is (1,1,1)
  130744. * @param extent x,y,z value that define the extent around the queries point of reference
  130745. */
  130746. setDefaultQueryExtent(extent: Vector3): void;
  130747. /**
  130748. * Get the Bounding box extent specified by setDefaultQueryExtent
  130749. * @returns the box extent values
  130750. */
  130751. getDefaultQueryExtent(): Vector3;
  130752. /**
  130753. * Release all resources
  130754. */
  130755. dispose(): void;
  130756. }
  130757. /**
  130758. * Configures an agent
  130759. */
  130760. export interface IAgentParameters {
  130761. /**
  130762. * Agent radius. [Limit: >= 0]
  130763. */
  130764. radius: number;
  130765. /**
  130766. * Agent height. [Limit: > 0]
  130767. */
  130768. height: number;
  130769. /**
  130770. * Maximum allowed acceleration. [Limit: >= 0]
  130771. */
  130772. maxAcceleration: number;
  130773. /**
  130774. * Maximum allowed speed. [Limit: >= 0]
  130775. */
  130776. maxSpeed: number;
  130777. /**
  130778. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130779. */
  130780. collisionQueryRange: number;
  130781. /**
  130782. * The path visibility optimization range. [Limit: > 0]
  130783. */
  130784. pathOptimizationRange: number;
  130785. /**
  130786. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130787. */
  130788. separationWeight: number;
  130789. }
  130790. /**
  130791. * Configures the navigation mesh creation
  130792. */
  130793. export interface INavMeshParameters {
  130794. /**
  130795. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130796. */
  130797. cs: number;
  130798. /**
  130799. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130800. */
  130801. ch: number;
  130802. /**
  130803. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130804. */
  130805. walkableSlopeAngle: number;
  130806. /**
  130807. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130808. * be considered walkable. [Limit: >= 3] [Units: vx]
  130809. */
  130810. walkableHeight: number;
  130811. /**
  130812. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130813. */
  130814. walkableClimb: number;
  130815. /**
  130816. * The distance to erode/shrink the walkable area of the heightfield away from
  130817. * obstructions. [Limit: >=0] [Units: vx]
  130818. */
  130819. walkableRadius: number;
  130820. /**
  130821. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130822. */
  130823. maxEdgeLen: number;
  130824. /**
  130825. * The maximum distance a simplfied contour's border edges should deviate
  130826. * the original raw contour. [Limit: >=0] [Units: vx]
  130827. */
  130828. maxSimplificationError: number;
  130829. /**
  130830. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130831. */
  130832. minRegionArea: number;
  130833. /**
  130834. * Any regions with a span count smaller than this value will, if possible,
  130835. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130836. */
  130837. mergeRegionArea: number;
  130838. /**
  130839. * The maximum number of vertices allowed for polygons generated during the
  130840. * contour to polygon conversion process. [Limit: >= 3]
  130841. */
  130842. maxVertsPerPoly: number;
  130843. /**
  130844. * Sets the sampling distance to use when generating the detail mesh.
  130845. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  130846. */
  130847. detailSampleDist: number;
  130848. /**
  130849. * The maximum distance the detail mesh surface should deviate from heightfield
  130850. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  130851. */
  130852. detailSampleMaxError: number;
  130853. }
  130854. }
  130855. declare module BABYLON {
  130856. /**
  130857. * RecastJS navigation plugin
  130858. */
  130859. export class RecastJSPlugin implements INavigationEnginePlugin {
  130860. /**
  130861. * Reference to the Recast library
  130862. */
  130863. bjsRECAST: any;
  130864. /**
  130865. * plugin name
  130866. */
  130867. name: string;
  130868. /**
  130869. * the first navmesh created. We might extend this to support multiple navmeshes
  130870. */
  130871. navMesh: any;
  130872. /**
  130873. * Initializes the recastJS plugin
  130874. * @param recastInjection can be used to inject your own recast reference
  130875. */
  130876. constructor(recastInjection?: any);
  130877. /**
  130878. * Creates a navigation mesh
  130879. * @param meshes array of all the geometry used to compute the navigatio mesh
  130880. * @param parameters bunch of parameters used to filter geometry
  130881. */
  130882. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130883. /**
  130884. * Create a navigation mesh debug mesh
  130885. * @param scene is where the mesh will be added
  130886. * @returns debug display mesh
  130887. */
  130888. createDebugNavMesh(scene: Scene): Mesh;
  130889. /**
  130890. * Get a navigation mesh constrained position, closest to the parameter position
  130891. * @param position world position
  130892. * @returns the closest point to position constrained by the navigation mesh
  130893. */
  130894. getClosestPoint(position: Vector3): Vector3;
  130895. /**
  130896. * Get a navigation mesh constrained position, within a particular radius
  130897. * @param position world position
  130898. * @param maxRadius the maximum distance to the constrained world position
  130899. * @returns the closest point to position constrained by the navigation mesh
  130900. */
  130901. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130902. /**
  130903. * Compute the final position from a segment made of destination-position
  130904. * @param position world position
  130905. * @param destination world position
  130906. * @returns the resulting point along the navmesh
  130907. */
  130908. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130909. /**
  130910. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130911. * @param start world position
  130912. * @param end world position
  130913. * @returns array containing world position composing the path
  130914. */
  130915. computePath(start: Vector3, end: Vector3): Vector3[];
  130916. /**
  130917. * Create a new Crowd so you can add agents
  130918. * @param maxAgents the maximum agent count in the crowd
  130919. * @param maxAgentRadius the maximum radius an agent can have
  130920. * @param scene to attach the crowd to
  130921. * @returns the crowd you can add agents to
  130922. */
  130923. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130924. /**
  130925. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130926. * The queries will try to find a solution within those bounds
  130927. * default is (1,1,1)
  130928. * @param extent x,y,z value that define the extent around the queries point of reference
  130929. */
  130930. setDefaultQueryExtent(extent: Vector3): void;
  130931. /**
  130932. * Get the Bounding box extent specified by setDefaultQueryExtent
  130933. * @returns the box extent values
  130934. */
  130935. getDefaultQueryExtent(): Vector3;
  130936. /**
  130937. * Disposes
  130938. */
  130939. dispose(): void;
  130940. /**
  130941. * If this plugin is supported
  130942. * @returns true if plugin is supported
  130943. */
  130944. isSupported(): boolean;
  130945. }
  130946. /**
  130947. * Recast detour crowd implementation
  130948. */
  130949. export class RecastJSCrowd implements ICrowd {
  130950. /**
  130951. * Recast/detour plugin
  130952. */
  130953. bjsRECASTPlugin: RecastJSPlugin;
  130954. /**
  130955. * Link to the detour crowd
  130956. */
  130957. recastCrowd: any;
  130958. /**
  130959. * One transform per agent
  130960. */
  130961. transforms: TransformNode[];
  130962. /**
  130963. * All agents created
  130964. */
  130965. agents: number[];
  130966. /**
  130967. * Link to the scene is kept to unregister the crowd from the scene
  130968. */
  130969. private _scene;
  130970. /**
  130971. * Observer for crowd updates
  130972. */
  130973. private _onBeforeAnimationsObserver;
  130974. /**
  130975. * Constructor
  130976. * @param plugin recastJS plugin
  130977. * @param maxAgents the maximum agent count in the crowd
  130978. * @param maxAgentRadius the maximum radius an agent can have
  130979. * @param scene to attach the crowd to
  130980. * @returns the crowd you can add agents to
  130981. */
  130982. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  130983. /**
  130984. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130985. * You can attach anything to that node. The node position is updated in the scene update tick.
  130986. * @param pos world position that will be constrained by the navigation mesh
  130987. * @param parameters agent parameters
  130988. * @param transform hooked to the agent that will be update by the scene
  130989. * @returns agent index
  130990. */
  130991. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130992. /**
  130993. * Returns the agent position in world space
  130994. * @param index agent index returned by addAgent
  130995. * @returns world space position
  130996. */
  130997. getAgentPosition(index: number): Vector3;
  130998. /**
  130999. * Returns the agent velocity in world space
  131000. * @param index agent index returned by addAgent
  131001. * @returns world space velocity
  131002. */
  131003. getAgentVelocity(index: number): Vector3;
  131004. /**
  131005. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131006. * @param index agent index returned by addAgent
  131007. * @param destination targeted world position
  131008. */
  131009. agentGoto(index: number, destination: Vector3): void;
  131010. /**
  131011. * remove a particular agent previously created
  131012. * @param index agent index returned by addAgent
  131013. */
  131014. removeAgent(index: number): void;
  131015. /**
  131016. * get the list of all agents attached to this crowd
  131017. * @returns list of agent indices
  131018. */
  131019. getAgents(): number[];
  131020. /**
  131021. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131022. * @param deltaTime in seconds
  131023. */
  131024. update(deltaTime: number): void;
  131025. /**
  131026. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131027. * The queries will try to find a solution within those bounds
  131028. * default is (1,1,1)
  131029. * @param extent x,y,z value that define the extent around the queries point of reference
  131030. */
  131031. setDefaultQueryExtent(extent: Vector3): void;
  131032. /**
  131033. * Get the Bounding box extent specified by setDefaultQueryExtent
  131034. * @returns the box extent values
  131035. */
  131036. getDefaultQueryExtent(): Vector3;
  131037. /**
  131038. * Release all resources
  131039. */
  131040. dispose(): void;
  131041. }
  131042. }
  131043. declare module BABYLON {
  131044. /**
  131045. * Class used to enable access to IndexedDB
  131046. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131047. */
  131048. export class Database implements IOfflineProvider {
  131049. private _callbackManifestChecked;
  131050. private _currentSceneUrl;
  131051. private _db;
  131052. private _enableSceneOffline;
  131053. private _enableTexturesOffline;
  131054. private _manifestVersionFound;
  131055. private _mustUpdateRessources;
  131056. private _hasReachedQuota;
  131057. private _isSupported;
  131058. private _idbFactory;
  131059. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131060. private static IsUASupportingBlobStorage;
  131061. /**
  131062. * Gets a boolean indicating if Database storate is enabled (off by default)
  131063. */
  131064. static IDBStorageEnabled: boolean;
  131065. /**
  131066. * Gets a boolean indicating if scene must be saved in the database
  131067. */
  131068. get enableSceneOffline(): boolean;
  131069. /**
  131070. * Gets a boolean indicating if textures must be saved in the database
  131071. */
  131072. get enableTexturesOffline(): boolean;
  131073. /**
  131074. * Creates a new Database
  131075. * @param urlToScene defines the url to load the scene
  131076. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131077. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131078. */
  131079. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131080. private static _ParseURL;
  131081. private static _ReturnFullUrlLocation;
  131082. private _checkManifestFile;
  131083. /**
  131084. * Open the database and make it available
  131085. * @param successCallback defines the callback to call on success
  131086. * @param errorCallback defines the callback to call on error
  131087. */
  131088. open(successCallback: () => void, errorCallback: () => void): void;
  131089. /**
  131090. * Loads an image from the database
  131091. * @param url defines the url to load from
  131092. * @param image defines the target DOM image
  131093. */
  131094. loadImage(url: string, image: HTMLImageElement): void;
  131095. private _loadImageFromDBAsync;
  131096. private _saveImageIntoDBAsync;
  131097. private _checkVersionFromDB;
  131098. private _loadVersionFromDBAsync;
  131099. private _saveVersionIntoDBAsync;
  131100. /**
  131101. * Loads a file from database
  131102. * @param url defines the URL to load from
  131103. * @param sceneLoaded defines a callback to call on success
  131104. * @param progressCallBack defines a callback to call when progress changed
  131105. * @param errorCallback defines a callback to call on error
  131106. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131107. */
  131108. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131109. private _loadFileAsync;
  131110. private _saveFileAsync;
  131111. /**
  131112. * Validates if xhr data is correct
  131113. * @param xhr defines the request to validate
  131114. * @param dataType defines the expected data type
  131115. * @returns true if data is correct
  131116. */
  131117. private static _ValidateXHRData;
  131118. }
  131119. }
  131120. declare module BABYLON {
  131121. /** @hidden */
  131122. export var gpuUpdateParticlesPixelShader: {
  131123. name: string;
  131124. shader: string;
  131125. };
  131126. }
  131127. declare module BABYLON {
  131128. /** @hidden */
  131129. export var gpuUpdateParticlesVertexShader: {
  131130. name: string;
  131131. shader: string;
  131132. };
  131133. }
  131134. declare module BABYLON {
  131135. /** @hidden */
  131136. export var clipPlaneFragmentDeclaration2: {
  131137. name: string;
  131138. shader: string;
  131139. };
  131140. }
  131141. declare module BABYLON {
  131142. /** @hidden */
  131143. export var gpuRenderParticlesPixelShader: {
  131144. name: string;
  131145. shader: string;
  131146. };
  131147. }
  131148. declare module BABYLON {
  131149. /** @hidden */
  131150. export var clipPlaneVertexDeclaration2: {
  131151. name: string;
  131152. shader: string;
  131153. };
  131154. }
  131155. declare module BABYLON {
  131156. /** @hidden */
  131157. export var gpuRenderParticlesVertexShader: {
  131158. name: string;
  131159. shader: string;
  131160. };
  131161. }
  131162. declare module BABYLON {
  131163. /**
  131164. * This represents a GPU particle system in Babylon
  131165. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131166. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131167. */
  131168. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131169. /**
  131170. * The layer mask we are rendering the particles through.
  131171. */
  131172. layerMask: number;
  131173. private _capacity;
  131174. private _activeCount;
  131175. private _currentActiveCount;
  131176. private _accumulatedCount;
  131177. private _renderEffect;
  131178. private _updateEffect;
  131179. private _buffer0;
  131180. private _buffer1;
  131181. private _spriteBuffer;
  131182. private _updateVAO;
  131183. private _renderVAO;
  131184. private _targetIndex;
  131185. private _sourceBuffer;
  131186. private _targetBuffer;
  131187. private _engine;
  131188. private _currentRenderId;
  131189. private _started;
  131190. private _stopped;
  131191. private _timeDelta;
  131192. private _randomTexture;
  131193. private _randomTexture2;
  131194. private _attributesStrideSize;
  131195. private _updateEffectOptions;
  131196. private _randomTextureSize;
  131197. private _actualFrame;
  131198. private readonly _rawTextureWidth;
  131199. /**
  131200. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131201. */
  131202. static get IsSupported(): boolean;
  131203. /**
  131204. * An event triggered when the system is disposed.
  131205. */
  131206. onDisposeObservable: Observable<GPUParticleSystem>;
  131207. /**
  131208. * Gets the maximum number of particles active at the same time.
  131209. * @returns The max number of active particles.
  131210. */
  131211. getCapacity(): number;
  131212. /**
  131213. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131214. * to override the particles.
  131215. */
  131216. forceDepthWrite: boolean;
  131217. /**
  131218. * Gets or set the number of active particles
  131219. */
  131220. get activeParticleCount(): number;
  131221. set activeParticleCount(value: number);
  131222. private _preWarmDone;
  131223. /**
  131224. * Is this system ready to be used/rendered
  131225. * @return true if the system is ready
  131226. */
  131227. isReady(): boolean;
  131228. /**
  131229. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131230. * @returns True if it has been started, otherwise false.
  131231. */
  131232. isStarted(): boolean;
  131233. /**
  131234. * Starts the particle system and begins to emit
  131235. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131236. */
  131237. start(delay?: number): void;
  131238. /**
  131239. * Stops the particle system.
  131240. */
  131241. stop(): void;
  131242. /**
  131243. * Remove all active particles
  131244. */
  131245. reset(): void;
  131246. /**
  131247. * Returns the string "GPUParticleSystem"
  131248. * @returns a string containing the class name
  131249. */
  131250. getClassName(): string;
  131251. private _colorGradientsTexture;
  131252. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131253. /**
  131254. * Adds a new color gradient
  131255. * @param gradient defines the gradient to use (between 0 and 1)
  131256. * @param color1 defines the color to affect to the specified gradient
  131257. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131258. * @returns the current particle system
  131259. */
  131260. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131261. /**
  131262. * Remove a specific color gradient
  131263. * @param gradient defines the gradient to remove
  131264. * @returns the current particle system
  131265. */
  131266. removeColorGradient(gradient: number): GPUParticleSystem;
  131267. private _angularSpeedGradientsTexture;
  131268. private _sizeGradientsTexture;
  131269. private _velocityGradientsTexture;
  131270. private _limitVelocityGradientsTexture;
  131271. private _dragGradientsTexture;
  131272. private _addFactorGradient;
  131273. /**
  131274. * Adds a new size gradient
  131275. * @param gradient defines the gradient to use (between 0 and 1)
  131276. * @param factor defines the size factor to affect to the specified gradient
  131277. * @returns the current particle system
  131278. */
  131279. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131280. /**
  131281. * Remove a specific size gradient
  131282. * @param gradient defines the gradient to remove
  131283. * @returns the current particle system
  131284. */
  131285. removeSizeGradient(gradient: number): GPUParticleSystem;
  131286. /**
  131287. * Adds a new angular speed gradient
  131288. * @param gradient defines the gradient to use (between 0 and 1)
  131289. * @param factor defines the angular speed to affect to the specified gradient
  131290. * @returns the current particle system
  131291. */
  131292. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131293. /**
  131294. * Remove a specific angular speed gradient
  131295. * @param gradient defines the gradient to remove
  131296. * @returns the current particle system
  131297. */
  131298. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131299. /**
  131300. * Adds a new velocity gradient
  131301. * @param gradient defines the gradient to use (between 0 and 1)
  131302. * @param factor defines the velocity to affect to the specified gradient
  131303. * @returns the current particle system
  131304. */
  131305. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131306. /**
  131307. * Remove a specific velocity gradient
  131308. * @param gradient defines the gradient to remove
  131309. * @returns the current particle system
  131310. */
  131311. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131312. /**
  131313. * Adds a new limit velocity gradient
  131314. * @param gradient defines the gradient to use (between 0 and 1)
  131315. * @param factor defines the limit velocity value to affect to the specified gradient
  131316. * @returns the current particle system
  131317. */
  131318. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131319. /**
  131320. * Remove a specific limit velocity gradient
  131321. * @param gradient defines the gradient to remove
  131322. * @returns the current particle system
  131323. */
  131324. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131325. /**
  131326. * Adds a new drag gradient
  131327. * @param gradient defines the gradient to use (between 0 and 1)
  131328. * @param factor defines the drag value to affect to the specified gradient
  131329. * @returns the current particle system
  131330. */
  131331. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131332. /**
  131333. * Remove a specific drag gradient
  131334. * @param gradient defines the gradient to remove
  131335. * @returns the current particle system
  131336. */
  131337. removeDragGradient(gradient: number): GPUParticleSystem;
  131338. /**
  131339. * Not supported by GPUParticleSystem
  131340. * @param gradient defines the gradient to use (between 0 and 1)
  131341. * @param factor defines the emit rate value to affect to the specified gradient
  131342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131343. * @returns the current particle system
  131344. */
  131345. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131346. /**
  131347. * Not supported by GPUParticleSystem
  131348. * @param gradient defines the gradient to remove
  131349. * @returns the current particle system
  131350. */
  131351. removeEmitRateGradient(gradient: number): IParticleSystem;
  131352. /**
  131353. * Not supported by GPUParticleSystem
  131354. * @param gradient defines the gradient to use (between 0 and 1)
  131355. * @param factor defines the start size value to affect to the specified gradient
  131356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131357. * @returns the current particle system
  131358. */
  131359. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131360. /**
  131361. * Not supported by GPUParticleSystem
  131362. * @param gradient defines the gradient to remove
  131363. * @returns the current particle system
  131364. */
  131365. removeStartSizeGradient(gradient: number): IParticleSystem;
  131366. /**
  131367. * Not supported by GPUParticleSystem
  131368. * @param gradient defines the gradient to use (between 0 and 1)
  131369. * @param min defines the color remap minimal range
  131370. * @param max defines the color remap maximal range
  131371. * @returns the current particle system
  131372. */
  131373. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131374. /**
  131375. * Not supported by GPUParticleSystem
  131376. * @param gradient defines the gradient to remove
  131377. * @returns the current particle system
  131378. */
  131379. removeColorRemapGradient(): IParticleSystem;
  131380. /**
  131381. * Not supported by GPUParticleSystem
  131382. * @param gradient defines the gradient to use (between 0 and 1)
  131383. * @param min defines the alpha remap minimal range
  131384. * @param max defines the alpha remap maximal range
  131385. * @returns the current particle system
  131386. */
  131387. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131388. /**
  131389. * Not supported by GPUParticleSystem
  131390. * @param gradient defines the gradient to remove
  131391. * @returns the current particle system
  131392. */
  131393. removeAlphaRemapGradient(): IParticleSystem;
  131394. /**
  131395. * Not supported by GPUParticleSystem
  131396. * @param gradient defines the gradient to use (between 0 and 1)
  131397. * @param color defines the color to affect to the specified gradient
  131398. * @returns the current particle system
  131399. */
  131400. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131401. /**
  131402. * Not supported by GPUParticleSystem
  131403. * @param gradient defines the gradient to remove
  131404. * @returns the current particle system
  131405. */
  131406. removeRampGradient(): IParticleSystem;
  131407. /**
  131408. * Not supported by GPUParticleSystem
  131409. * @returns the list of ramp gradients
  131410. */
  131411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131412. /**
  131413. * Not supported by GPUParticleSystem
  131414. * Gets or sets a boolean indicating that ramp gradients must be used
  131415. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131416. */
  131417. get useRampGradients(): boolean;
  131418. set useRampGradients(value: boolean);
  131419. /**
  131420. * Not supported by GPUParticleSystem
  131421. * @param gradient defines the gradient to use (between 0 and 1)
  131422. * @param factor defines the life time factor to affect to the specified gradient
  131423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131424. * @returns the current particle system
  131425. */
  131426. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131427. /**
  131428. * Not supported by GPUParticleSystem
  131429. * @param gradient defines the gradient to remove
  131430. * @returns the current particle system
  131431. */
  131432. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131433. /**
  131434. * Instantiates a GPU particle system.
  131435. * 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.
  131436. * @param name The name of the particle system
  131437. * @param options The options used to create the system
  131438. * @param scene The scene the particle system belongs to
  131439. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131440. */
  131441. constructor(name: string, options: Partial<{
  131442. capacity: number;
  131443. randomTextureSize: number;
  131444. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131445. protected _reset(): void;
  131446. private _createUpdateVAO;
  131447. private _createRenderVAO;
  131448. private _initialize;
  131449. /** @hidden */
  131450. _recreateUpdateEffect(): void;
  131451. /** @hidden */
  131452. _recreateRenderEffect(): void;
  131453. /**
  131454. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131455. * @param preWarm defines if we are in the pre-warmimg phase
  131456. */
  131457. animate(preWarm?: boolean): void;
  131458. private _createFactorGradientTexture;
  131459. private _createSizeGradientTexture;
  131460. private _createAngularSpeedGradientTexture;
  131461. private _createVelocityGradientTexture;
  131462. private _createLimitVelocityGradientTexture;
  131463. private _createDragGradientTexture;
  131464. private _createColorGradientTexture;
  131465. /**
  131466. * Renders the particle system in its current state
  131467. * @param preWarm defines if the system should only update the particles but not render them
  131468. * @returns the current number of particles
  131469. */
  131470. render(preWarm?: boolean): number;
  131471. /**
  131472. * Rebuilds the particle system
  131473. */
  131474. rebuild(): void;
  131475. private _releaseBuffers;
  131476. private _releaseVAOs;
  131477. /**
  131478. * Disposes the particle system and free the associated resources
  131479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131480. */
  131481. dispose(disposeTexture?: boolean): void;
  131482. /**
  131483. * Clones the particle system.
  131484. * @param name The name of the cloned object
  131485. * @param newEmitter The new emitter to use
  131486. * @returns the cloned particle system
  131487. */
  131488. clone(name: string, newEmitter: any): GPUParticleSystem;
  131489. /**
  131490. * Serializes the particle system to a JSON object.
  131491. * @returns the JSON object
  131492. */
  131493. serialize(): any;
  131494. /**
  131495. * Parses a JSON object to create a GPU particle system.
  131496. * @param parsedParticleSystem The JSON object to parse
  131497. * @param scene The scene to create the particle system in
  131498. * @param rootUrl The root url to use to load external dependencies like texture
  131499. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131500. * @returns the parsed GPU particle system
  131501. */
  131502. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131503. }
  131504. }
  131505. declare module BABYLON {
  131506. /**
  131507. * Represents a set of particle systems working together to create a specific effect
  131508. */
  131509. export class ParticleSystemSet implements IDisposable {
  131510. /**
  131511. * Gets or sets base Assets URL
  131512. */
  131513. static BaseAssetsUrl: string;
  131514. private _emitterCreationOptions;
  131515. private _emitterNode;
  131516. /**
  131517. * Gets the particle system list
  131518. */
  131519. systems: IParticleSystem[];
  131520. /**
  131521. * Gets the emitter node used with this set
  131522. */
  131523. get emitterNode(): Nullable<TransformNode>;
  131524. /**
  131525. * Creates a new emitter mesh as a sphere
  131526. * @param options defines the options used to create the sphere
  131527. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131528. * @param scene defines the hosting scene
  131529. */
  131530. setEmitterAsSphere(options: {
  131531. diameter: number;
  131532. segments: number;
  131533. color: Color3;
  131534. }, renderingGroupId: number, scene: Scene): void;
  131535. /**
  131536. * Starts all particle systems of the set
  131537. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131538. */
  131539. start(emitter?: AbstractMesh): void;
  131540. /**
  131541. * Release all associated resources
  131542. */
  131543. dispose(): void;
  131544. /**
  131545. * Serialize the set into a JSON compatible object
  131546. * @returns a JSON compatible representation of the set
  131547. */
  131548. serialize(): any;
  131549. /**
  131550. * Parse a new ParticleSystemSet from a serialized source
  131551. * @param data defines a JSON compatible representation of the set
  131552. * @param scene defines the hosting scene
  131553. * @param gpu defines if we want GPU particles or CPU particles
  131554. * @returns a new ParticleSystemSet
  131555. */
  131556. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131557. }
  131558. }
  131559. declare module BABYLON {
  131560. /**
  131561. * This class is made for on one-liner static method to help creating particle system set.
  131562. */
  131563. export class ParticleHelper {
  131564. /**
  131565. * Gets or sets base Assets URL
  131566. */
  131567. static BaseAssetsUrl: string;
  131568. /**
  131569. * Create a default particle system that you can tweak
  131570. * @param emitter defines the emitter to use
  131571. * @param capacity defines the system capacity (default is 500 particles)
  131572. * @param scene defines the hosting scene
  131573. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131574. * @returns the new Particle system
  131575. */
  131576. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131577. /**
  131578. * This is the main static method (one-liner) of this helper to create different particle systems
  131579. * @param type This string represents the type to the particle system to create
  131580. * @param scene The scene where the particle system should live
  131581. * @param gpu If the system will use gpu
  131582. * @returns the ParticleSystemSet created
  131583. */
  131584. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131585. /**
  131586. * Static function used to export a particle system to a ParticleSystemSet variable.
  131587. * Please note that the emitter shape is not exported
  131588. * @param systems defines the particle systems to export
  131589. * @returns the created particle system set
  131590. */
  131591. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131592. }
  131593. }
  131594. declare module BABYLON {
  131595. interface Engine {
  131596. /**
  131597. * Create an effect to use with particle systems.
  131598. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131599. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131600. * @param uniformsNames defines a list of attribute names
  131601. * @param samplers defines an array of string used to represent textures
  131602. * @param defines defines the string containing the defines to use to compile the shaders
  131603. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131604. * @param onCompiled defines a function to call when the effect creation is successful
  131605. * @param onError defines a function to call when the effect creation has failed
  131606. * @returns the new Effect
  131607. */
  131608. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131609. }
  131610. interface Mesh {
  131611. /**
  131612. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131613. * @returns an array of IParticleSystem
  131614. */
  131615. getEmittedParticleSystems(): IParticleSystem[];
  131616. /**
  131617. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131618. * @returns an array of IParticleSystem
  131619. */
  131620. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131621. }
  131622. /**
  131623. * @hidden
  131624. */
  131625. export var _IDoNeedToBeInTheBuild: number;
  131626. }
  131627. declare module BABYLON {
  131628. /** Defines the 4 color options */
  131629. export enum PointColor {
  131630. /** color value */
  131631. Color = 2,
  131632. /** uv value */
  131633. UV = 1,
  131634. /** random value */
  131635. Random = 0,
  131636. /** stated value */
  131637. Stated = 3
  131638. }
  131639. /**
  131640. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131641. * 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.
  131642. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131643. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131644. *
  131645. * Full documentation here : TO BE ENTERED
  131646. */
  131647. export class PointsCloudSystem implements IDisposable {
  131648. /**
  131649. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131650. * Example : var p = SPS.particles[i];
  131651. */
  131652. particles: CloudPoint[];
  131653. /**
  131654. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131655. */
  131656. nbParticles: number;
  131657. /**
  131658. * This a counter for your own usage. It's not set by any SPS functions.
  131659. */
  131660. counter: number;
  131661. /**
  131662. * The PCS name. This name is also given to the underlying mesh.
  131663. */
  131664. name: string;
  131665. /**
  131666. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131667. */
  131668. mesh: Mesh;
  131669. /**
  131670. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131671. * Please read :
  131672. */
  131673. vars: any;
  131674. /**
  131675. * @hidden
  131676. */
  131677. _size: number;
  131678. private _scene;
  131679. private _promises;
  131680. private _positions;
  131681. private _indices;
  131682. private _normals;
  131683. private _colors;
  131684. private _uvs;
  131685. private _indices32;
  131686. private _positions32;
  131687. private _colors32;
  131688. private _uvs32;
  131689. private _updatable;
  131690. private _isVisibilityBoxLocked;
  131691. private _alwaysVisible;
  131692. private _groups;
  131693. private _groupCounter;
  131694. private _computeParticleColor;
  131695. private _computeParticleTexture;
  131696. private _computeParticleRotation;
  131697. private _computeBoundingBox;
  131698. private _isReady;
  131699. /**
  131700. * Creates a PCS (Points Cloud System) object
  131701. * @param name (String) is the PCS name, this will be the underlying mesh name
  131702. * @param pointSize (number) is the size for each point
  131703. * @param scene (Scene) is the scene in which the PCS is added
  131704. * @param options defines the options of the PCS e.g.
  131705. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131706. */
  131707. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131708. updatable?: boolean;
  131709. });
  131710. /**
  131711. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131712. * If no points were added to the PCS, the returned mesh is just a single point.
  131713. * @returns a promise for the created mesh
  131714. */
  131715. buildMeshAsync(): Promise<Mesh>;
  131716. /**
  131717. * @hidden
  131718. */
  131719. private _buildMesh;
  131720. private _addParticle;
  131721. private _randomUnitVector;
  131722. private _getColorIndicesForCoord;
  131723. private _setPointsColorOrUV;
  131724. private _colorFromTexture;
  131725. private _calculateDensity;
  131726. /**
  131727. * Adds points to the PCS in random positions within a unit sphere
  131728. * @param nb (positive integer) the number of particles to be created from this model
  131729. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131730. * @returns the number of groups in the system
  131731. */
  131732. addPoints(nb: number, pointFunction?: any): number;
  131733. /**
  131734. * Adds points to the PCS from the surface of the model shape
  131735. * @param mesh is any Mesh object that will be used as a surface model for the points
  131736. * @param nb (positive integer) the number of particles to be created from this model
  131737. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131738. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131739. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131740. * @returns the number of groups in the system
  131741. */
  131742. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131743. /**
  131744. * Adds points to the PCS inside the model shape
  131745. * @param mesh is any Mesh object that will be used as a surface model for the points
  131746. * @param nb (positive integer) the number of particles to be created from this model
  131747. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131748. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131749. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131750. * @returns the number of groups in the system
  131751. */
  131752. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131753. /**
  131754. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131755. * This method calls `updateParticle()` for each particle of the SPS.
  131756. * For an animated SPS, it is usually called within the render loop.
  131757. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131758. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131759. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131760. * @returns the PCS.
  131761. */
  131762. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131763. /**
  131764. * Disposes the PCS.
  131765. */
  131766. dispose(): void;
  131767. /**
  131768. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131769. * doc :
  131770. * @returns the PCS.
  131771. */
  131772. refreshVisibleSize(): PointsCloudSystem;
  131773. /**
  131774. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131775. * @param size the size (float) of the visibility box
  131776. * note : this doesn't lock the PCS mesh bounding box.
  131777. * doc :
  131778. */
  131779. setVisibilityBox(size: number): void;
  131780. /**
  131781. * Gets whether the PCS is always visible or not
  131782. * doc :
  131783. */
  131784. get isAlwaysVisible(): boolean;
  131785. /**
  131786. * Sets the PCS as always visible or not
  131787. * doc :
  131788. */
  131789. set isAlwaysVisible(val: boolean);
  131790. /**
  131791. * Tells to `setParticles()` to compute the particle rotations or not
  131792. * Default value : false. The PCS is faster when it's set to false
  131793. * Note : particle rotations are only applied to parent particles
  131794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131795. */
  131796. set computeParticleRotation(val: boolean);
  131797. /**
  131798. * Tells to `setParticles()` to compute the particle colors or not.
  131799. * Default value : true. The PCS is faster when it's set to false.
  131800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131801. */
  131802. set computeParticleColor(val: boolean);
  131803. set computeParticleTexture(val: boolean);
  131804. /**
  131805. * Gets if `setParticles()` computes the particle colors or not.
  131806. * Default value : false. The PCS is faster when it's set to false.
  131807. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131808. */
  131809. get computeParticleColor(): boolean;
  131810. /**
  131811. * Gets if `setParticles()` computes the particle textures or not.
  131812. * Default value : false. The PCS is faster when it's set to false.
  131813. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131814. */
  131815. get computeParticleTexture(): boolean;
  131816. /**
  131817. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131818. */
  131819. set computeBoundingBox(val: boolean);
  131820. /**
  131821. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131822. */
  131823. get computeBoundingBox(): boolean;
  131824. /**
  131825. * This function does nothing. It may be overwritten to set all the particle first values.
  131826. * The PCS doesn't call this function, you may have to call it by your own.
  131827. * doc :
  131828. */
  131829. initParticles(): void;
  131830. /**
  131831. * This function does nothing. It may be overwritten to recycle a particle
  131832. * The PCS doesn't call this function, you can to call it
  131833. * doc :
  131834. * @param particle The particle to recycle
  131835. * @returns the recycled particle
  131836. */
  131837. recycleParticle(particle: CloudPoint): CloudPoint;
  131838. /**
  131839. * Updates a particle : this function should be overwritten by the user.
  131840. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131841. * doc :
  131842. * @example : just set a particle position or velocity and recycle conditions
  131843. * @param particle The particle to update
  131844. * @returns the updated particle
  131845. */
  131846. updateParticle(particle: CloudPoint): CloudPoint;
  131847. /**
  131848. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  131849. * This does nothing and may be overwritten by the user.
  131850. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131852. * @param update the boolean update value actually passed to setParticles()
  131853. */
  131854. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131855. /**
  131856. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  131857. * This will be passed three parameters.
  131858. * This does nothing and may be overwritten by the user.
  131859. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131860. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131861. * @param update the boolean update value actually passed to setParticles()
  131862. */
  131863. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131864. }
  131865. }
  131866. declare module BABYLON {
  131867. /**
  131868. * Represents one particle of a points cloud system.
  131869. */
  131870. export class CloudPoint {
  131871. /**
  131872. * particle global index
  131873. */
  131874. idx: number;
  131875. /**
  131876. * The color of the particle
  131877. */
  131878. color: Nullable<Color4>;
  131879. /**
  131880. * The world space position of the particle.
  131881. */
  131882. position: Vector3;
  131883. /**
  131884. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  131885. */
  131886. rotation: Vector3;
  131887. /**
  131888. * The world space rotation quaternion of the particle.
  131889. */
  131890. rotationQuaternion: Nullable<Quaternion>;
  131891. /**
  131892. * The uv of the particle.
  131893. */
  131894. uv: Nullable<Vector2>;
  131895. /**
  131896. * The current speed of the particle.
  131897. */
  131898. velocity: Vector3;
  131899. /**
  131900. * The pivot point in the particle local space.
  131901. */
  131902. pivot: Vector3;
  131903. /**
  131904. * Must the particle be translated from its pivot point in its local space ?
  131905. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  131906. * Default : false
  131907. */
  131908. translateFromPivot: boolean;
  131909. /**
  131910. * Index of this particle in the global "positions" array (Internal use)
  131911. * @hidden
  131912. */
  131913. _pos: number;
  131914. /**
  131915. * @hidden Index of this particle in the global "indices" array (Internal use)
  131916. */
  131917. _ind: number;
  131918. /**
  131919. * Group this particle belongs to
  131920. */
  131921. _group: PointsGroup;
  131922. /**
  131923. * Group id of this particle
  131924. */
  131925. groupId: number;
  131926. /**
  131927. * Index of the particle in its group id (Internal use)
  131928. */
  131929. idxInGroup: number;
  131930. /**
  131931. * @hidden Particle BoundingInfo object (Internal use)
  131932. */
  131933. _boundingInfo: BoundingInfo;
  131934. /**
  131935. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  131936. */
  131937. _pcs: PointsCloudSystem;
  131938. /**
  131939. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  131940. */
  131941. _stillInvisible: boolean;
  131942. /**
  131943. * @hidden Last computed particle rotation matrix
  131944. */
  131945. _rotationMatrix: number[];
  131946. /**
  131947. * Parent particle Id, if any.
  131948. * Default null.
  131949. */
  131950. parentId: Nullable<number>;
  131951. /**
  131952. * @hidden Internal global position in the PCS.
  131953. */
  131954. _globalPosition: Vector3;
  131955. /**
  131956. * Creates a Point Cloud object.
  131957. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  131958. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  131959. * @param group (PointsGroup) is the group the particle belongs to
  131960. * @param groupId (integer) is the group identifier in the PCS.
  131961. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  131962. * @param pcs defines the PCS it is associated to
  131963. */
  131964. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  131965. /**
  131966. * get point size
  131967. */
  131968. get size(): Vector3;
  131969. /**
  131970. * Set point size
  131971. */
  131972. set size(scale: Vector3);
  131973. /**
  131974. * Legacy support, changed quaternion to rotationQuaternion
  131975. */
  131976. get quaternion(): Nullable<Quaternion>;
  131977. /**
  131978. * Legacy support, changed quaternion to rotationQuaternion
  131979. */
  131980. set quaternion(q: Nullable<Quaternion>);
  131981. /**
  131982. * Returns a boolean. True if the particle intersects a mesh, else false
  131983. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  131984. * @param target is the object (point or mesh) what the intersection is computed against
  131985. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  131986. * @returns true if it intersects
  131987. */
  131988. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  131989. /**
  131990. * get the rotation matrix of the particle
  131991. * @hidden
  131992. */
  131993. getRotationMatrix(m: Matrix): void;
  131994. }
  131995. /**
  131996. * Represents a group of points in a points cloud system
  131997. * * PCS internal tool, don't use it manually.
  131998. */
  131999. export class PointsGroup {
  132000. /**
  132001. * The group id
  132002. * @hidden
  132003. */
  132004. groupID: number;
  132005. /**
  132006. * image data for group (internal use)
  132007. * @hidden
  132008. */
  132009. _groupImageData: Nullable<ArrayBufferView>;
  132010. /**
  132011. * Image Width (internal use)
  132012. * @hidden
  132013. */
  132014. _groupImgWidth: number;
  132015. /**
  132016. * Image Height (internal use)
  132017. * @hidden
  132018. */
  132019. _groupImgHeight: number;
  132020. /**
  132021. * Custom position function (internal use)
  132022. * @hidden
  132023. */
  132024. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132025. /**
  132026. * density per facet for surface points
  132027. * @hidden
  132028. */
  132029. _groupDensity: number[];
  132030. /**
  132031. * Only when points are colored by texture carries pointer to texture list array
  132032. * @hidden
  132033. */
  132034. _textureNb: number;
  132035. /**
  132036. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132037. * PCS internal tool, don't use it manually.
  132038. * @hidden
  132039. */
  132040. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132041. }
  132042. }
  132043. declare module BABYLON {
  132044. interface Scene {
  132045. /** @hidden (Backing field) */
  132046. _physicsEngine: Nullable<IPhysicsEngine>;
  132047. /** @hidden */
  132048. _physicsTimeAccumulator: number;
  132049. /**
  132050. * Gets the current physics engine
  132051. * @returns a IPhysicsEngine or null if none attached
  132052. */
  132053. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132054. /**
  132055. * Enables physics to the current scene
  132056. * @param gravity defines the scene's gravity for the physics engine
  132057. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132058. * @return a boolean indicating if the physics engine was initialized
  132059. */
  132060. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132061. /**
  132062. * Disables and disposes the physics engine associated with the scene
  132063. */
  132064. disablePhysicsEngine(): void;
  132065. /**
  132066. * Gets a boolean indicating if there is an active physics engine
  132067. * @returns a boolean indicating if there is an active physics engine
  132068. */
  132069. isPhysicsEnabled(): boolean;
  132070. /**
  132071. * Deletes a physics compound impostor
  132072. * @param compound defines the compound to delete
  132073. */
  132074. deleteCompoundImpostor(compound: any): void;
  132075. /**
  132076. * An event triggered when physic simulation is about to be run
  132077. */
  132078. onBeforePhysicsObservable: Observable<Scene>;
  132079. /**
  132080. * An event triggered when physic simulation has been done
  132081. */
  132082. onAfterPhysicsObservable: Observable<Scene>;
  132083. }
  132084. interface AbstractMesh {
  132085. /** @hidden */
  132086. _physicsImpostor: Nullable<PhysicsImpostor>;
  132087. /**
  132088. * Gets or sets impostor used for physic simulation
  132089. * @see http://doc.babylonjs.com/features/physics_engine
  132090. */
  132091. physicsImpostor: Nullable<PhysicsImpostor>;
  132092. /**
  132093. * Gets the current physics impostor
  132094. * @see http://doc.babylonjs.com/features/physics_engine
  132095. * @returns a physics impostor or null
  132096. */
  132097. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132098. /** Apply a physic impulse to the mesh
  132099. * @param force defines the force to apply
  132100. * @param contactPoint defines where to apply the force
  132101. * @returns the current mesh
  132102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132103. */
  132104. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132105. /**
  132106. * Creates a physic joint between two meshes
  132107. * @param otherMesh defines the other mesh to use
  132108. * @param pivot1 defines the pivot to use on this mesh
  132109. * @param pivot2 defines the pivot to use on the other mesh
  132110. * @param options defines additional options (can be plugin dependent)
  132111. * @returns the current mesh
  132112. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132113. */
  132114. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132115. /** @hidden */
  132116. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132117. }
  132118. /**
  132119. * Defines the physics engine scene component responsible to manage a physics engine
  132120. */
  132121. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132122. /**
  132123. * The component name helpful to identify the component in the list of scene components.
  132124. */
  132125. readonly name: string;
  132126. /**
  132127. * The scene the component belongs to.
  132128. */
  132129. scene: Scene;
  132130. /**
  132131. * Creates a new instance of the component for the given scene
  132132. * @param scene Defines the scene to register the component in
  132133. */
  132134. constructor(scene: Scene);
  132135. /**
  132136. * Registers the component in a given scene
  132137. */
  132138. register(): void;
  132139. /**
  132140. * Rebuilds the elements related to this component in case of
  132141. * context lost for instance.
  132142. */
  132143. rebuild(): void;
  132144. /**
  132145. * Disposes the component and the associated ressources
  132146. */
  132147. dispose(): void;
  132148. }
  132149. }
  132150. declare module BABYLON {
  132151. /**
  132152. * A helper for physics simulations
  132153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132154. */
  132155. export class PhysicsHelper {
  132156. private _scene;
  132157. private _physicsEngine;
  132158. /**
  132159. * Initializes the Physics helper
  132160. * @param scene Babylon.js scene
  132161. */
  132162. constructor(scene: Scene);
  132163. /**
  132164. * Applies a radial explosion impulse
  132165. * @param origin the origin of the explosion
  132166. * @param radiusOrEventOptions the radius or the options of radial explosion
  132167. * @param strength the explosion strength
  132168. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132169. * @returns A physics radial explosion event, or null
  132170. */
  132171. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132172. /**
  132173. * Applies a radial explosion force
  132174. * @param origin the origin of the explosion
  132175. * @param radiusOrEventOptions the radius or the options of radial explosion
  132176. * @param strength the explosion strength
  132177. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132178. * @returns A physics radial explosion event, or null
  132179. */
  132180. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132181. /**
  132182. * Creates a gravitational field
  132183. * @param origin the origin of the explosion
  132184. * @param radiusOrEventOptions the radius or the options of radial explosion
  132185. * @param strength the explosion strength
  132186. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132187. * @returns A physics gravitational field event, or null
  132188. */
  132189. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132190. /**
  132191. * Creates a physics updraft event
  132192. * @param origin the origin of the updraft
  132193. * @param radiusOrEventOptions the radius or the options of the updraft
  132194. * @param strength the strength of the updraft
  132195. * @param height the height of the updraft
  132196. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132197. * @returns A physics updraft event, or null
  132198. */
  132199. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132200. /**
  132201. * Creates a physics vortex event
  132202. * @param origin the of the vortex
  132203. * @param radiusOrEventOptions the radius or the options of the vortex
  132204. * @param strength the strength of the vortex
  132205. * @param height the height of the vortex
  132206. * @returns a Physics vortex event, or null
  132207. * A physics vortex event or null
  132208. */
  132209. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132210. }
  132211. /**
  132212. * Represents a physics radial explosion event
  132213. */
  132214. class PhysicsRadialExplosionEvent {
  132215. private _scene;
  132216. private _options;
  132217. private _sphere;
  132218. private _dataFetched;
  132219. /**
  132220. * Initializes a radial explosioin event
  132221. * @param _scene BabylonJS scene
  132222. * @param _options The options for the vortex event
  132223. */
  132224. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132225. /**
  132226. * Returns the data related to the radial explosion event (sphere).
  132227. * @returns The radial explosion event data
  132228. */
  132229. getData(): PhysicsRadialExplosionEventData;
  132230. /**
  132231. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132232. * @param impostor A physics imposter
  132233. * @param origin the origin of the explosion
  132234. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132235. */
  132236. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132237. /**
  132238. * Triggers affecterd impostors callbacks
  132239. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132240. */
  132241. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132242. /**
  132243. * Disposes the sphere.
  132244. * @param force Specifies if the sphere should be disposed by force
  132245. */
  132246. dispose(force?: boolean): void;
  132247. /*** Helpers ***/
  132248. private _prepareSphere;
  132249. private _intersectsWithSphere;
  132250. }
  132251. /**
  132252. * Represents a gravitational field event
  132253. */
  132254. class PhysicsGravitationalFieldEvent {
  132255. private _physicsHelper;
  132256. private _scene;
  132257. private _origin;
  132258. private _options;
  132259. private _tickCallback;
  132260. private _sphere;
  132261. private _dataFetched;
  132262. /**
  132263. * Initializes the physics gravitational field event
  132264. * @param _physicsHelper A physics helper
  132265. * @param _scene BabylonJS scene
  132266. * @param _origin The origin position of the gravitational field event
  132267. * @param _options The options for the vortex event
  132268. */
  132269. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132270. /**
  132271. * Returns the data related to the gravitational field event (sphere).
  132272. * @returns A gravitational field event
  132273. */
  132274. getData(): PhysicsGravitationalFieldEventData;
  132275. /**
  132276. * Enables the gravitational field.
  132277. */
  132278. enable(): void;
  132279. /**
  132280. * Disables the gravitational field.
  132281. */
  132282. disable(): void;
  132283. /**
  132284. * Disposes the sphere.
  132285. * @param force The force to dispose from the gravitational field event
  132286. */
  132287. dispose(force?: boolean): void;
  132288. private _tick;
  132289. }
  132290. /**
  132291. * Represents a physics updraft event
  132292. */
  132293. class PhysicsUpdraftEvent {
  132294. private _scene;
  132295. private _origin;
  132296. private _options;
  132297. private _physicsEngine;
  132298. private _originTop;
  132299. private _originDirection;
  132300. private _tickCallback;
  132301. private _cylinder;
  132302. private _cylinderPosition;
  132303. private _dataFetched;
  132304. /**
  132305. * Initializes the physics updraft event
  132306. * @param _scene BabylonJS scene
  132307. * @param _origin The origin position of the updraft
  132308. * @param _options The options for the updraft event
  132309. */
  132310. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132311. /**
  132312. * Returns the data related to the updraft event (cylinder).
  132313. * @returns A physics updraft event
  132314. */
  132315. getData(): PhysicsUpdraftEventData;
  132316. /**
  132317. * Enables the updraft.
  132318. */
  132319. enable(): void;
  132320. /**
  132321. * Disables the updraft.
  132322. */
  132323. disable(): void;
  132324. /**
  132325. * Disposes the cylinder.
  132326. * @param force Specifies if the updraft should be disposed by force
  132327. */
  132328. dispose(force?: boolean): void;
  132329. private getImpostorHitData;
  132330. private _tick;
  132331. /*** Helpers ***/
  132332. private _prepareCylinder;
  132333. private _intersectsWithCylinder;
  132334. }
  132335. /**
  132336. * Represents a physics vortex event
  132337. */
  132338. class PhysicsVortexEvent {
  132339. private _scene;
  132340. private _origin;
  132341. private _options;
  132342. private _physicsEngine;
  132343. private _originTop;
  132344. private _tickCallback;
  132345. private _cylinder;
  132346. private _cylinderPosition;
  132347. private _dataFetched;
  132348. /**
  132349. * Initializes the physics vortex event
  132350. * @param _scene The BabylonJS scene
  132351. * @param _origin The origin position of the vortex
  132352. * @param _options The options for the vortex event
  132353. */
  132354. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132355. /**
  132356. * Returns the data related to the vortex event (cylinder).
  132357. * @returns The physics vortex event data
  132358. */
  132359. getData(): PhysicsVortexEventData;
  132360. /**
  132361. * Enables the vortex.
  132362. */
  132363. enable(): void;
  132364. /**
  132365. * Disables the cortex.
  132366. */
  132367. disable(): void;
  132368. /**
  132369. * Disposes the sphere.
  132370. * @param force
  132371. */
  132372. dispose(force?: boolean): void;
  132373. private getImpostorHitData;
  132374. private _tick;
  132375. /*** Helpers ***/
  132376. private _prepareCylinder;
  132377. private _intersectsWithCylinder;
  132378. }
  132379. /**
  132380. * Options fot the radial explosion event
  132381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132382. */
  132383. export class PhysicsRadialExplosionEventOptions {
  132384. /**
  132385. * The radius of the sphere for the radial explosion.
  132386. */
  132387. radius: number;
  132388. /**
  132389. * The strenth of the explosion.
  132390. */
  132391. strength: number;
  132392. /**
  132393. * The strenght of the force in correspondence to the distance of the affected object
  132394. */
  132395. falloff: PhysicsRadialImpulseFalloff;
  132396. /**
  132397. * Sphere options for the radial explosion.
  132398. */
  132399. sphere: {
  132400. segments: number;
  132401. diameter: number;
  132402. };
  132403. /**
  132404. * Sphere options for the radial explosion.
  132405. */
  132406. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132407. }
  132408. /**
  132409. * Options fot the updraft event
  132410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132411. */
  132412. export class PhysicsUpdraftEventOptions {
  132413. /**
  132414. * The radius of the cylinder for the vortex
  132415. */
  132416. radius: number;
  132417. /**
  132418. * The strenth of the updraft.
  132419. */
  132420. strength: number;
  132421. /**
  132422. * The height of the cylinder for the updraft.
  132423. */
  132424. height: number;
  132425. /**
  132426. * The mode for the the updraft.
  132427. */
  132428. updraftMode: PhysicsUpdraftMode;
  132429. }
  132430. /**
  132431. * Options fot the vortex event
  132432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132433. */
  132434. export class PhysicsVortexEventOptions {
  132435. /**
  132436. * The radius of the cylinder for the vortex
  132437. */
  132438. radius: number;
  132439. /**
  132440. * The strenth of the vortex.
  132441. */
  132442. strength: number;
  132443. /**
  132444. * The height of the cylinder for the vortex.
  132445. */
  132446. height: number;
  132447. /**
  132448. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132449. */
  132450. centripetalForceThreshold: number;
  132451. /**
  132452. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132453. */
  132454. centripetalForceMultiplier: number;
  132455. /**
  132456. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132457. */
  132458. centrifugalForceMultiplier: number;
  132459. /**
  132460. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132461. */
  132462. updraftForceMultiplier: number;
  132463. }
  132464. /**
  132465. * The strenght of the force in correspondence to the distance of the affected object
  132466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132467. */
  132468. export enum PhysicsRadialImpulseFalloff {
  132469. /** Defines that impulse is constant in strength across it's whole radius */
  132470. Constant = 0,
  132471. /** Defines that impulse gets weaker if it's further from the origin */
  132472. Linear = 1
  132473. }
  132474. /**
  132475. * The strength of the force in correspondence to the distance of the affected object
  132476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132477. */
  132478. export enum PhysicsUpdraftMode {
  132479. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132480. Center = 0,
  132481. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132482. Perpendicular = 1
  132483. }
  132484. /**
  132485. * Interface for a physics hit data
  132486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132487. */
  132488. export interface PhysicsHitData {
  132489. /**
  132490. * The force applied at the contact point
  132491. */
  132492. force: Vector3;
  132493. /**
  132494. * The contact point
  132495. */
  132496. contactPoint: Vector3;
  132497. /**
  132498. * The distance from the origin to the contact point
  132499. */
  132500. distanceFromOrigin: number;
  132501. }
  132502. /**
  132503. * Interface for radial explosion event data
  132504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132505. */
  132506. export interface PhysicsRadialExplosionEventData {
  132507. /**
  132508. * A sphere used for the radial explosion event
  132509. */
  132510. sphere: Mesh;
  132511. }
  132512. /**
  132513. * Interface for gravitational field event data
  132514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132515. */
  132516. export interface PhysicsGravitationalFieldEventData {
  132517. /**
  132518. * A sphere mesh used for the gravitational field event
  132519. */
  132520. sphere: Mesh;
  132521. }
  132522. /**
  132523. * Interface for updraft event data
  132524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132525. */
  132526. export interface PhysicsUpdraftEventData {
  132527. /**
  132528. * A cylinder used for the updraft event
  132529. */
  132530. cylinder: Mesh;
  132531. }
  132532. /**
  132533. * Interface for vortex event data
  132534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132535. */
  132536. export interface PhysicsVortexEventData {
  132537. /**
  132538. * A cylinder used for the vortex event
  132539. */
  132540. cylinder: Mesh;
  132541. }
  132542. /**
  132543. * Interface for an affected physics impostor
  132544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132545. */
  132546. export interface PhysicsAffectedImpostorWithData {
  132547. /**
  132548. * The impostor affected by the effect
  132549. */
  132550. impostor: PhysicsImpostor;
  132551. /**
  132552. * The data about the hit/horce from the explosion
  132553. */
  132554. hitData: PhysicsHitData;
  132555. }
  132556. }
  132557. declare module BABYLON {
  132558. /** @hidden */
  132559. export var blackAndWhitePixelShader: {
  132560. name: string;
  132561. shader: string;
  132562. };
  132563. }
  132564. declare module BABYLON {
  132565. /**
  132566. * Post process used to render in black and white
  132567. */
  132568. export class BlackAndWhitePostProcess extends PostProcess {
  132569. /**
  132570. * Linear about to convert he result to black and white (default: 1)
  132571. */
  132572. degree: number;
  132573. /**
  132574. * Creates a black and white post process
  132575. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132576. * @param name The name of the effect.
  132577. * @param options The required width/height ratio to downsize to before computing the render pass.
  132578. * @param camera The camera to apply the render pass to.
  132579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132580. * @param engine The engine which the post process will be applied. (default: current engine)
  132581. * @param reusable If the post process can be reused on the same frame. (default: false)
  132582. */
  132583. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132584. }
  132585. }
  132586. declare module BABYLON {
  132587. /**
  132588. * This represents a set of one or more post processes in Babylon.
  132589. * A post process can be used to apply a shader to a texture after it is rendered.
  132590. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132591. */
  132592. export class PostProcessRenderEffect {
  132593. private _postProcesses;
  132594. private _getPostProcesses;
  132595. private _singleInstance;
  132596. private _cameras;
  132597. private _indicesForCamera;
  132598. /**
  132599. * Name of the effect
  132600. * @hidden
  132601. */
  132602. _name: string;
  132603. /**
  132604. * Instantiates a post process render effect.
  132605. * A post process can be used to apply a shader to a texture after it is rendered.
  132606. * @param engine The engine the effect is tied to
  132607. * @param name The name of the effect
  132608. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132609. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132610. */
  132611. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132612. /**
  132613. * Checks if all the post processes in the effect are supported.
  132614. */
  132615. get isSupported(): boolean;
  132616. /**
  132617. * Updates the current state of the effect
  132618. * @hidden
  132619. */
  132620. _update(): void;
  132621. /**
  132622. * Attaches the effect on cameras
  132623. * @param cameras The camera to attach to.
  132624. * @hidden
  132625. */
  132626. _attachCameras(cameras: Camera): void;
  132627. /**
  132628. * Attaches the effect on cameras
  132629. * @param cameras The camera to attach to.
  132630. * @hidden
  132631. */
  132632. _attachCameras(cameras: Camera[]): void;
  132633. /**
  132634. * Detaches the effect on cameras
  132635. * @param cameras The camera to detatch from.
  132636. * @hidden
  132637. */
  132638. _detachCameras(cameras: Camera): void;
  132639. /**
  132640. * Detatches the effect on cameras
  132641. * @param cameras The camera to detatch from.
  132642. * @hidden
  132643. */
  132644. _detachCameras(cameras: Camera[]): void;
  132645. /**
  132646. * Enables the effect on given cameras
  132647. * @param cameras The camera to enable.
  132648. * @hidden
  132649. */
  132650. _enable(cameras: Camera): void;
  132651. /**
  132652. * Enables the effect on given cameras
  132653. * @param cameras The camera to enable.
  132654. * @hidden
  132655. */
  132656. _enable(cameras: Nullable<Camera[]>): void;
  132657. /**
  132658. * Disables the effect on the given cameras
  132659. * @param cameras The camera to disable.
  132660. * @hidden
  132661. */
  132662. _disable(cameras: Camera): void;
  132663. /**
  132664. * Disables the effect on the given cameras
  132665. * @param cameras The camera to disable.
  132666. * @hidden
  132667. */
  132668. _disable(cameras: Nullable<Camera[]>): void;
  132669. /**
  132670. * Gets a list of the post processes contained in the effect.
  132671. * @param camera The camera to get the post processes on.
  132672. * @returns The list of the post processes in the effect.
  132673. */
  132674. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132675. }
  132676. }
  132677. declare module BABYLON {
  132678. /** @hidden */
  132679. export var extractHighlightsPixelShader: {
  132680. name: string;
  132681. shader: string;
  132682. };
  132683. }
  132684. declare module BABYLON {
  132685. /**
  132686. * 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.
  132687. */
  132688. export class ExtractHighlightsPostProcess extends PostProcess {
  132689. /**
  132690. * The luminance threshold, pixels below this value will be set to black.
  132691. */
  132692. threshold: number;
  132693. /** @hidden */
  132694. _exposure: number;
  132695. /**
  132696. * Post process which has the input texture to be used when performing highlight extraction
  132697. * @hidden
  132698. */
  132699. _inputPostProcess: Nullable<PostProcess>;
  132700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132701. }
  132702. }
  132703. declare module BABYLON {
  132704. /** @hidden */
  132705. export var bloomMergePixelShader: {
  132706. name: string;
  132707. shader: string;
  132708. };
  132709. }
  132710. declare module BABYLON {
  132711. /**
  132712. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132713. */
  132714. export class BloomMergePostProcess extends PostProcess {
  132715. /** Weight of the bloom to be added to the original input. */
  132716. weight: number;
  132717. /**
  132718. * Creates a new instance of @see BloomMergePostProcess
  132719. * @param name The name of the effect.
  132720. * @param originalFromInput Post process which's input will be used for the merge.
  132721. * @param blurred Blurred highlights post process which's output will be used.
  132722. * @param weight Weight of the bloom to be added to the original input.
  132723. * @param options The required width/height ratio to downsize to before computing the render pass.
  132724. * @param camera The camera to apply the render pass to.
  132725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132726. * @param engine The engine which the post process will be applied. (default: current engine)
  132727. * @param reusable If the post process can be reused on the same frame. (default: false)
  132728. * @param textureType Type of textures used when performing the post process. (default: 0)
  132729. * @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)
  132730. */
  132731. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132732. /** Weight of the bloom to be added to the original input. */
  132733. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132734. }
  132735. }
  132736. declare module BABYLON {
  132737. /**
  132738. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132739. */
  132740. export class BloomEffect extends PostProcessRenderEffect {
  132741. private bloomScale;
  132742. /**
  132743. * @hidden Internal
  132744. */
  132745. _effects: Array<PostProcess>;
  132746. /**
  132747. * @hidden Internal
  132748. */
  132749. _downscale: ExtractHighlightsPostProcess;
  132750. private _blurX;
  132751. private _blurY;
  132752. private _merge;
  132753. /**
  132754. * The luminance threshold to find bright areas of the image to bloom.
  132755. */
  132756. get threshold(): number;
  132757. set threshold(value: number);
  132758. /**
  132759. * The strength of the bloom.
  132760. */
  132761. get weight(): number;
  132762. set weight(value: number);
  132763. /**
  132764. * Specifies the size of the bloom blur kernel, relative to the final output size
  132765. */
  132766. get kernel(): number;
  132767. set kernel(value: number);
  132768. /**
  132769. * Creates a new instance of @see BloomEffect
  132770. * @param scene The scene the effect belongs to.
  132771. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132772. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132773. * @param bloomWeight The the strength of bloom.
  132774. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132775. * @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)
  132776. */
  132777. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132778. /**
  132779. * Disposes each of the internal effects for a given camera.
  132780. * @param camera The camera to dispose the effect on.
  132781. */
  132782. disposeEffects(camera: Camera): void;
  132783. /**
  132784. * @hidden Internal
  132785. */
  132786. _updateEffects(): void;
  132787. /**
  132788. * Internal
  132789. * @returns if all the contained post processes are ready.
  132790. * @hidden
  132791. */
  132792. _isReady(): boolean;
  132793. }
  132794. }
  132795. declare module BABYLON {
  132796. /** @hidden */
  132797. export var chromaticAberrationPixelShader: {
  132798. name: string;
  132799. shader: string;
  132800. };
  132801. }
  132802. declare module BABYLON {
  132803. /**
  132804. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132805. */
  132806. export class ChromaticAberrationPostProcess extends PostProcess {
  132807. /**
  132808. * The amount of seperation of rgb channels (default: 30)
  132809. */
  132810. aberrationAmount: number;
  132811. /**
  132812. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132813. */
  132814. radialIntensity: number;
  132815. /**
  132816. * 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))
  132817. */
  132818. direction: Vector2;
  132819. /**
  132820. * 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))
  132821. */
  132822. centerPosition: Vector2;
  132823. /**
  132824. * Creates a new instance ChromaticAberrationPostProcess
  132825. * @param name The name of the effect.
  132826. * @param screenWidth The width of the screen to apply the effect on.
  132827. * @param screenHeight The height of the screen to apply the effect on.
  132828. * @param options The required width/height ratio to downsize to before computing the render pass.
  132829. * @param camera The camera to apply the render pass to.
  132830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132831. * @param engine The engine which the post process will be applied. (default: current engine)
  132832. * @param reusable If the post process can be reused on the same frame. (default: false)
  132833. * @param textureType Type of textures used when performing the post process. (default: 0)
  132834. * @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)
  132835. */
  132836. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132837. }
  132838. }
  132839. declare module BABYLON {
  132840. /** @hidden */
  132841. export var circleOfConfusionPixelShader: {
  132842. name: string;
  132843. shader: string;
  132844. };
  132845. }
  132846. declare module BABYLON {
  132847. /**
  132848. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  132849. */
  132850. export class CircleOfConfusionPostProcess extends PostProcess {
  132851. /**
  132852. * 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.
  132853. */
  132854. lensSize: number;
  132855. /**
  132856. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  132857. */
  132858. fStop: number;
  132859. /**
  132860. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  132861. */
  132862. focusDistance: number;
  132863. /**
  132864. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  132865. */
  132866. focalLength: number;
  132867. private _depthTexture;
  132868. /**
  132869. * Creates a new instance CircleOfConfusionPostProcess
  132870. * @param name The name of the effect.
  132871. * @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.
  132872. * @param options The required width/height ratio to downsize to before computing the render pass.
  132873. * @param camera The camera to apply the render pass to.
  132874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132875. * @param engine The engine which the post process will be applied. (default: current engine)
  132876. * @param reusable If the post process can be reused on the same frame. (default: false)
  132877. * @param textureType Type of textures used when performing the post process. (default: 0)
  132878. * @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)
  132879. */
  132880. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132881. /**
  132882. * 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.
  132883. */
  132884. set depthTexture(value: RenderTargetTexture);
  132885. }
  132886. }
  132887. declare module BABYLON {
  132888. /** @hidden */
  132889. export var colorCorrectionPixelShader: {
  132890. name: string;
  132891. shader: string;
  132892. };
  132893. }
  132894. declare module BABYLON {
  132895. /**
  132896. *
  132897. * This post-process allows the modification of rendered colors by using
  132898. * a 'look-up table' (LUT). This effect is also called Color Grading.
  132899. *
  132900. * The object needs to be provided an url to a texture containing the color
  132901. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  132902. * Use an image editing software to tweak the LUT to match your needs.
  132903. *
  132904. * For an example of a color LUT, see here:
  132905. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  132906. * For explanations on color grading, see here:
  132907. * @see http://udn.epicgames.com/Three/ColorGrading.html
  132908. *
  132909. */
  132910. export class ColorCorrectionPostProcess extends PostProcess {
  132911. private _colorTableTexture;
  132912. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132913. }
  132914. }
  132915. declare module BABYLON {
  132916. /** @hidden */
  132917. export var convolutionPixelShader: {
  132918. name: string;
  132919. shader: string;
  132920. };
  132921. }
  132922. declare module BABYLON {
  132923. /**
  132924. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  132925. * input texture to perform effects such as edge detection or sharpening
  132926. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  132927. */
  132928. export class ConvolutionPostProcess extends PostProcess {
  132929. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132930. kernel: number[];
  132931. /**
  132932. * Creates a new instance ConvolutionPostProcess
  132933. * @param name The name of the effect.
  132934. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  132935. * @param options The required width/height ratio to downsize to before computing the render pass.
  132936. * @param camera The camera to apply the render pass to.
  132937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132938. * @param engine The engine which the post process will be applied. (default: current engine)
  132939. * @param reusable If the post process can be reused on the same frame. (default: false)
  132940. * @param textureType Type of textures used when performing the post process. (default: 0)
  132941. */
  132942. constructor(name: string,
  132943. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132944. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132945. /**
  132946. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132947. */
  132948. static EdgeDetect0Kernel: number[];
  132949. /**
  132950. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132951. */
  132952. static EdgeDetect1Kernel: number[];
  132953. /**
  132954. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132955. */
  132956. static EdgeDetect2Kernel: number[];
  132957. /**
  132958. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132959. */
  132960. static SharpenKernel: number[];
  132961. /**
  132962. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132963. */
  132964. static EmbossKernel: number[];
  132965. /**
  132966. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132967. */
  132968. static GaussianKernel: number[];
  132969. }
  132970. }
  132971. declare module BABYLON {
  132972. /**
  132973. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  132974. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  132975. * based on samples that have a large difference in distance than the center pixel.
  132976. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  132977. */
  132978. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  132979. direction: Vector2;
  132980. /**
  132981. * Creates a new instance CircleOfConfusionPostProcess
  132982. * @param name The name of the effect.
  132983. * @param scene The scene the effect belongs to.
  132984. * @param direction The direction the blur should be applied.
  132985. * @param kernel The size of the kernel used to blur.
  132986. * @param options The required width/height ratio to downsize to before computing the render pass.
  132987. * @param camera The camera to apply the render pass to.
  132988. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  132989. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  132990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132991. * @param engine The engine which the post process will be applied. (default: current engine)
  132992. * @param reusable If the post process can be reused on the same frame. (default: false)
  132993. * @param textureType Type of textures used when performing the post process. (default: 0)
  132994. * @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)
  132995. */
  132996. 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);
  132997. }
  132998. }
  132999. declare module BABYLON {
  133000. /** @hidden */
  133001. export var depthOfFieldMergePixelShader: {
  133002. name: string;
  133003. shader: string;
  133004. };
  133005. }
  133006. declare module BABYLON {
  133007. /**
  133008. * Options to be set when merging outputs from the default pipeline.
  133009. */
  133010. export class DepthOfFieldMergePostProcessOptions {
  133011. /**
  133012. * The original image to merge on top of
  133013. */
  133014. originalFromInput: PostProcess;
  133015. /**
  133016. * Parameters to perform the merge of the depth of field effect
  133017. */
  133018. depthOfField?: {
  133019. circleOfConfusion: PostProcess;
  133020. blurSteps: Array<PostProcess>;
  133021. };
  133022. /**
  133023. * Parameters to perform the merge of bloom effect
  133024. */
  133025. bloom?: {
  133026. blurred: PostProcess;
  133027. weight: number;
  133028. };
  133029. }
  133030. /**
  133031. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133032. */
  133033. export class DepthOfFieldMergePostProcess extends PostProcess {
  133034. private blurSteps;
  133035. /**
  133036. * Creates a new instance of DepthOfFieldMergePostProcess
  133037. * @param name The name of the effect.
  133038. * @param originalFromInput Post process which's input will be used for the merge.
  133039. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133040. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133041. * @param options The required width/height ratio to downsize to before computing the render pass.
  133042. * @param camera The camera to apply the render pass to.
  133043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133044. * @param engine The engine which the post process will be applied. (default: current engine)
  133045. * @param reusable If the post process can be reused on the same frame. (default: false)
  133046. * @param textureType Type of textures used when performing the post process. (default: 0)
  133047. * @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)
  133048. */
  133049. 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);
  133050. /**
  133051. * Updates the effect with the current post process compile time values and recompiles the shader.
  133052. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133053. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133054. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133055. * @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
  133056. * @param onCompiled Called when the shader has been compiled.
  133057. * @param onError Called if there is an error when compiling a shader.
  133058. */
  133059. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133060. }
  133061. }
  133062. declare module BABYLON {
  133063. /**
  133064. * Specifies the level of max blur that should be applied when using the depth of field effect
  133065. */
  133066. export enum DepthOfFieldEffectBlurLevel {
  133067. /**
  133068. * Subtle blur
  133069. */
  133070. Low = 0,
  133071. /**
  133072. * Medium blur
  133073. */
  133074. Medium = 1,
  133075. /**
  133076. * Large blur
  133077. */
  133078. High = 2
  133079. }
  133080. /**
  133081. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133082. */
  133083. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133084. private _circleOfConfusion;
  133085. /**
  133086. * @hidden Internal, blurs from high to low
  133087. */
  133088. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133089. private _depthOfFieldBlurY;
  133090. private _dofMerge;
  133091. /**
  133092. * @hidden Internal post processes in depth of field effect
  133093. */
  133094. _effects: Array<PostProcess>;
  133095. /**
  133096. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133097. */
  133098. set focalLength(value: number);
  133099. get focalLength(): number;
  133100. /**
  133101. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133102. */
  133103. set fStop(value: number);
  133104. get fStop(): number;
  133105. /**
  133106. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133107. */
  133108. set focusDistance(value: number);
  133109. get focusDistance(): number;
  133110. /**
  133111. * 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.
  133112. */
  133113. set lensSize(value: number);
  133114. get lensSize(): number;
  133115. /**
  133116. * Creates a new instance DepthOfFieldEffect
  133117. * @param scene The scene the effect belongs to.
  133118. * @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.
  133119. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133120. * @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)
  133121. */
  133122. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133123. /**
  133124. * Get the current class name of the current effet
  133125. * @returns "DepthOfFieldEffect"
  133126. */
  133127. getClassName(): string;
  133128. /**
  133129. * 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.
  133130. */
  133131. set depthTexture(value: RenderTargetTexture);
  133132. /**
  133133. * Disposes each of the internal effects for a given camera.
  133134. * @param camera The camera to dispose the effect on.
  133135. */
  133136. disposeEffects(camera: Camera): void;
  133137. /**
  133138. * @hidden Internal
  133139. */
  133140. _updateEffects(): void;
  133141. /**
  133142. * Internal
  133143. * @returns if all the contained post processes are ready.
  133144. * @hidden
  133145. */
  133146. _isReady(): boolean;
  133147. }
  133148. }
  133149. declare module BABYLON {
  133150. /** @hidden */
  133151. export var displayPassPixelShader: {
  133152. name: string;
  133153. shader: string;
  133154. };
  133155. }
  133156. declare module BABYLON {
  133157. /**
  133158. * DisplayPassPostProcess which produces an output the same as it's input
  133159. */
  133160. export class DisplayPassPostProcess extends PostProcess {
  133161. /**
  133162. * Creates the DisplayPassPostProcess
  133163. * @param name The name of the effect.
  133164. * @param options The required width/height ratio to downsize to before computing the render pass.
  133165. * @param camera The camera to apply the render pass to.
  133166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133167. * @param engine The engine which the post process will be applied. (default: current engine)
  133168. * @param reusable If the post process can be reused on the same frame. (default: false)
  133169. */
  133170. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133171. }
  133172. }
  133173. declare module BABYLON {
  133174. /** @hidden */
  133175. export var filterPixelShader: {
  133176. name: string;
  133177. shader: string;
  133178. };
  133179. }
  133180. declare module BABYLON {
  133181. /**
  133182. * Applies a kernel filter to the image
  133183. */
  133184. export class FilterPostProcess extends PostProcess {
  133185. /** The matrix to be applied to the image */
  133186. kernelMatrix: Matrix;
  133187. /**
  133188. *
  133189. * @param name The name of the effect.
  133190. * @param kernelMatrix The matrix to be applied to the image
  133191. * @param options The required width/height ratio to downsize to before computing the render pass.
  133192. * @param camera The camera to apply the render pass to.
  133193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133194. * @param engine The engine which the post process will be applied. (default: current engine)
  133195. * @param reusable If the post process can be reused on the same frame. (default: false)
  133196. */
  133197. constructor(name: string,
  133198. /** The matrix to be applied to the image */
  133199. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133200. }
  133201. }
  133202. declare module BABYLON {
  133203. /** @hidden */
  133204. export var fxaaPixelShader: {
  133205. name: string;
  133206. shader: string;
  133207. };
  133208. }
  133209. declare module BABYLON {
  133210. /** @hidden */
  133211. export var fxaaVertexShader: {
  133212. name: string;
  133213. shader: string;
  133214. };
  133215. }
  133216. declare module BABYLON {
  133217. /**
  133218. * Fxaa post process
  133219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133220. */
  133221. export class FxaaPostProcess extends PostProcess {
  133222. /** @hidden */
  133223. texelWidth: number;
  133224. /** @hidden */
  133225. texelHeight: number;
  133226. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133227. private _getDefines;
  133228. }
  133229. }
  133230. declare module BABYLON {
  133231. /** @hidden */
  133232. export var grainPixelShader: {
  133233. name: string;
  133234. shader: string;
  133235. };
  133236. }
  133237. declare module BABYLON {
  133238. /**
  133239. * The GrainPostProcess adds noise to the image at mid luminance levels
  133240. */
  133241. export class GrainPostProcess extends PostProcess {
  133242. /**
  133243. * The intensity of the grain added (default: 30)
  133244. */
  133245. intensity: number;
  133246. /**
  133247. * If the grain should be randomized on every frame
  133248. */
  133249. animated: boolean;
  133250. /**
  133251. * Creates a new instance of @see GrainPostProcess
  133252. * @param name The name of the effect.
  133253. * @param options The required width/height ratio to downsize to before computing the render pass.
  133254. * @param camera The camera to apply the render pass to.
  133255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133256. * @param engine The engine which the post process will be applied. (default: current engine)
  133257. * @param reusable If the post process can be reused on the same frame. (default: false)
  133258. * @param textureType Type of textures used when performing the post process. (default: 0)
  133259. * @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)
  133260. */
  133261. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133262. }
  133263. }
  133264. declare module BABYLON {
  133265. /** @hidden */
  133266. export var highlightsPixelShader: {
  133267. name: string;
  133268. shader: string;
  133269. };
  133270. }
  133271. declare module BABYLON {
  133272. /**
  133273. * Extracts highlights from the image
  133274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133275. */
  133276. export class HighlightsPostProcess extends PostProcess {
  133277. /**
  133278. * Extracts highlights from the image
  133279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133280. * @param name The name of the effect.
  133281. * @param options The required width/height ratio to downsize to before computing the render pass.
  133282. * @param camera The camera to apply the render pass to.
  133283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133284. * @param engine The engine which the post process will be applied. (default: current engine)
  133285. * @param reusable If the post process can be reused on the same frame. (default: false)
  133286. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133287. */
  133288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133289. }
  133290. }
  133291. declare module BABYLON {
  133292. /** @hidden */
  133293. export var mrtFragmentDeclaration: {
  133294. name: string;
  133295. shader: string;
  133296. };
  133297. }
  133298. declare module BABYLON {
  133299. /** @hidden */
  133300. export var geometryPixelShader: {
  133301. name: string;
  133302. shader: string;
  133303. };
  133304. }
  133305. declare module BABYLON {
  133306. /** @hidden */
  133307. export var geometryVertexShader: {
  133308. name: string;
  133309. shader: string;
  133310. };
  133311. }
  133312. declare module BABYLON {
  133313. /** @hidden */
  133314. interface ISavedTransformationMatrix {
  133315. world: Matrix;
  133316. viewProjection: Matrix;
  133317. }
  133318. /**
  133319. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133320. */
  133321. export class GeometryBufferRenderer {
  133322. /**
  133323. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133324. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133325. */
  133326. static readonly POSITION_TEXTURE_TYPE: number;
  133327. /**
  133328. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133329. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133330. */
  133331. static readonly VELOCITY_TEXTURE_TYPE: number;
  133332. /**
  133333. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133334. * in order to compute objects velocities when enableVelocity is set to "true"
  133335. * @hidden
  133336. */
  133337. _previousTransformationMatrices: {
  133338. [index: number]: ISavedTransformationMatrix;
  133339. };
  133340. /**
  133341. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133342. * in order to compute objects velocities when enableVelocity is set to "true"
  133343. * @hidden
  133344. */
  133345. _previousBonesTransformationMatrices: {
  133346. [index: number]: Float32Array;
  133347. };
  133348. /**
  133349. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133350. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133351. */
  133352. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133353. private _scene;
  133354. private _multiRenderTarget;
  133355. private _ratio;
  133356. private _enablePosition;
  133357. private _enableVelocity;
  133358. private _positionIndex;
  133359. private _velocityIndex;
  133360. protected _effect: Effect;
  133361. protected _cachedDefines: string;
  133362. /**
  133363. * Set the render list (meshes to be rendered) used in the G buffer.
  133364. */
  133365. set renderList(meshes: Mesh[]);
  133366. /**
  133367. * Gets wether or not G buffer are supported by the running hardware.
  133368. * This requires draw buffer supports
  133369. */
  133370. get isSupported(): boolean;
  133371. /**
  133372. * Returns the index of the given texture type in the G-Buffer textures array
  133373. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133374. * @returns the index of the given texture type in the G-Buffer textures array
  133375. */
  133376. getTextureIndex(textureType: number): number;
  133377. /**
  133378. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133379. */
  133380. get enablePosition(): boolean;
  133381. /**
  133382. * Sets whether or not objects positions are enabled for the G buffer.
  133383. */
  133384. set enablePosition(enable: boolean);
  133385. /**
  133386. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133387. */
  133388. get enableVelocity(): boolean;
  133389. /**
  133390. * Sets wether or not objects velocities are enabled for the G buffer.
  133391. */
  133392. set enableVelocity(enable: boolean);
  133393. /**
  133394. * Gets the scene associated with the buffer.
  133395. */
  133396. get scene(): Scene;
  133397. /**
  133398. * Gets the ratio used by the buffer during its creation.
  133399. * How big is the buffer related to the main canvas.
  133400. */
  133401. get ratio(): number;
  133402. /** @hidden */
  133403. static _SceneComponentInitialization: (scene: Scene) => void;
  133404. /**
  133405. * Creates a new G Buffer for the scene
  133406. * @param scene The scene the buffer belongs to
  133407. * @param ratio How big is the buffer related to the main canvas.
  133408. */
  133409. constructor(scene: Scene, ratio?: number);
  133410. /**
  133411. * Checks wether everything is ready to render a submesh to the G buffer.
  133412. * @param subMesh the submesh to check readiness for
  133413. * @param useInstances is the mesh drawn using instance or not
  133414. * @returns true if ready otherwise false
  133415. */
  133416. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133417. /**
  133418. * Gets the current underlying G Buffer.
  133419. * @returns the buffer
  133420. */
  133421. getGBuffer(): MultiRenderTarget;
  133422. /**
  133423. * Gets the number of samples used to render the buffer (anti aliasing).
  133424. */
  133425. get samples(): number;
  133426. /**
  133427. * Sets the number of samples used to render the buffer (anti aliasing).
  133428. */
  133429. set samples(value: number);
  133430. /**
  133431. * Disposes the renderer and frees up associated resources.
  133432. */
  133433. dispose(): void;
  133434. protected _createRenderTargets(): void;
  133435. private _copyBonesTransformationMatrices;
  133436. }
  133437. }
  133438. declare module BABYLON {
  133439. interface Scene {
  133440. /** @hidden (Backing field) */
  133441. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133442. /**
  133443. * Gets or Sets the current geometry buffer associated to the scene.
  133444. */
  133445. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133446. /**
  133447. * Enables a GeometryBufferRender and associates it with the scene
  133448. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133449. * @returns the GeometryBufferRenderer
  133450. */
  133451. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133452. /**
  133453. * Disables the GeometryBufferRender associated with the scene
  133454. */
  133455. disableGeometryBufferRenderer(): void;
  133456. }
  133457. /**
  133458. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133459. * in several rendering techniques.
  133460. */
  133461. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133462. /**
  133463. * The component name helpful to identify the component in the list of scene components.
  133464. */
  133465. readonly name: string;
  133466. /**
  133467. * The scene the component belongs to.
  133468. */
  133469. scene: Scene;
  133470. /**
  133471. * Creates a new instance of the component for the given scene
  133472. * @param scene Defines the scene to register the component in
  133473. */
  133474. constructor(scene: Scene);
  133475. /**
  133476. * Registers the component in a given scene
  133477. */
  133478. register(): void;
  133479. /**
  133480. * Rebuilds the elements related to this component in case of
  133481. * context lost for instance.
  133482. */
  133483. rebuild(): void;
  133484. /**
  133485. * Disposes the component and the associated ressources
  133486. */
  133487. dispose(): void;
  133488. private _gatherRenderTargets;
  133489. }
  133490. }
  133491. declare module BABYLON {
  133492. /** @hidden */
  133493. export var motionBlurPixelShader: {
  133494. name: string;
  133495. shader: string;
  133496. };
  133497. }
  133498. declare module BABYLON {
  133499. /**
  133500. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133501. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133502. * As an example, all you have to do is to create the post-process:
  133503. * var mb = new BABYLON.MotionBlurPostProcess(
  133504. * 'mb', // The name of the effect.
  133505. * scene, // The scene containing the objects to blur according to their velocity.
  133506. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133507. * camera // The camera to apply the render pass to.
  133508. * );
  133509. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133510. */
  133511. export class MotionBlurPostProcess extends PostProcess {
  133512. /**
  133513. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133514. */
  133515. motionStrength: number;
  133516. /**
  133517. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133518. */
  133519. get motionBlurSamples(): number;
  133520. /**
  133521. * Sets the number of iterations to be used for motion blur quality
  133522. */
  133523. set motionBlurSamples(samples: number);
  133524. private _motionBlurSamples;
  133525. private _geometryBufferRenderer;
  133526. /**
  133527. * Creates a new instance MotionBlurPostProcess
  133528. * @param name The name of the effect.
  133529. * @param scene The scene containing the objects to blur according to their velocity.
  133530. * @param options The required width/height ratio to downsize to before computing the render pass.
  133531. * @param camera The camera to apply the render pass to.
  133532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133533. * @param engine The engine which the post process will be applied. (default: current engine)
  133534. * @param reusable If the post process can be reused on the same frame. (default: false)
  133535. * @param textureType Type of textures used when performing the post process. (default: 0)
  133536. * @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)
  133537. */
  133538. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133539. /**
  133540. * Excludes the given skinned mesh from computing bones velocities.
  133541. * 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.
  133542. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133543. */
  133544. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133545. /**
  133546. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133547. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133548. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133549. */
  133550. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133551. /**
  133552. * Disposes the post process.
  133553. * @param camera The camera to dispose the post process on.
  133554. */
  133555. dispose(camera?: Camera): void;
  133556. }
  133557. }
  133558. declare module BABYLON {
  133559. /** @hidden */
  133560. export var refractionPixelShader: {
  133561. name: string;
  133562. shader: string;
  133563. };
  133564. }
  133565. declare module BABYLON {
  133566. /**
  133567. * Post process which applies a refractin texture
  133568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133569. */
  133570. export class RefractionPostProcess extends PostProcess {
  133571. /** the base color of the refraction (used to taint the rendering) */
  133572. color: Color3;
  133573. /** simulated refraction depth */
  133574. depth: number;
  133575. /** the coefficient of the base color (0 to remove base color tainting) */
  133576. colorLevel: number;
  133577. private _refTexture;
  133578. private _ownRefractionTexture;
  133579. /**
  133580. * Gets or sets the refraction texture
  133581. * Please note that you are responsible for disposing the texture if you set it manually
  133582. */
  133583. get refractionTexture(): Texture;
  133584. set refractionTexture(value: Texture);
  133585. /**
  133586. * Initializes the RefractionPostProcess
  133587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133588. * @param name The name of the effect.
  133589. * @param refractionTextureUrl Url of the refraction texture to use
  133590. * @param color the base color of the refraction (used to taint the rendering)
  133591. * @param depth simulated refraction depth
  133592. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133593. * @param camera The camera to apply the render pass to.
  133594. * @param options The required width/height ratio to downsize to before computing the render pass.
  133595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133596. * @param engine The engine which the post process will be applied. (default: current engine)
  133597. * @param reusable If the post process can be reused on the same frame. (default: false)
  133598. */
  133599. constructor(name: string, refractionTextureUrl: string,
  133600. /** the base color of the refraction (used to taint the rendering) */
  133601. color: Color3,
  133602. /** simulated refraction depth */
  133603. depth: number,
  133604. /** the coefficient of the base color (0 to remove base color tainting) */
  133605. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133606. /**
  133607. * Disposes of the post process
  133608. * @param camera Camera to dispose post process on
  133609. */
  133610. dispose(camera: Camera): void;
  133611. }
  133612. }
  133613. declare module BABYLON {
  133614. /** @hidden */
  133615. export var sharpenPixelShader: {
  133616. name: string;
  133617. shader: string;
  133618. };
  133619. }
  133620. declare module BABYLON {
  133621. /**
  133622. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133623. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133624. */
  133625. export class SharpenPostProcess extends PostProcess {
  133626. /**
  133627. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133628. */
  133629. colorAmount: number;
  133630. /**
  133631. * How much sharpness should be applied (default: 0.3)
  133632. */
  133633. edgeAmount: number;
  133634. /**
  133635. * Creates a new instance ConvolutionPostProcess
  133636. * @param name The name of the effect.
  133637. * @param options The required width/height ratio to downsize to before computing the render pass.
  133638. * @param camera The camera to apply the render pass to.
  133639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133640. * @param engine The engine which the post process will be applied. (default: current engine)
  133641. * @param reusable If the post process can be reused on the same frame. (default: false)
  133642. * @param textureType Type of textures used when performing the post process. (default: 0)
  133643. * @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)
  133644. */
  133645. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133646. }
  133647. }
  133648. declare module BABYLON {
  133649. /**
  133650. * PostProcessRenderPipeline
  133651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133652. */
  133653. export class PostProcessRenderPipeline {
  133654. private engine;
  133655. private _renderEffects;
  133656. private _renderEffectsForIsolatedPass;
  133657. /**
  133658. * List of inspectable custom properties (used by the Inspector)
  133659. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133660. */
  133661. inspectableCustomProperties: IInspectable[];
  133662. /**
  133663. * @hidden
  133664. */
  133665. protected _cameras: Camera[];
  133666. /** @hidden */
  133667. _name: string;
  133668. /**
  133669. * Gets pipeline name
  133670. */
  133671. get name(): string;
  133672. /** Gets the list of attached cameras */
  133673. get cameras(): Camera[];
  133674. /**
  133675. * Initializes a PostProcessRenderPipeline
  133676. * @param engine engine to add the pipeline to
  133677. * @param name name of the pipeline
  133678. */
  133679. constructor(engine: Engine, name: string);
  133680. /**
  133681. * Gets the class name
  133682. * @returns "PostProcessRenderPipeline"
  133683. */
  133684. getClassName(): string;
  133685. /**
  133686. * If all the render effects in the pipeline are supported
  133687. */
  133688. get isSupported(): boolean;
  133689. /**
  133690. * Adds an effect to the pipeline
  133691. * @param renderEffect the effect to add
  133692. */
  133693. addEffect(renderEffect: PostProcessRenderEffect): void;
  133694. /** @hidden */
  133695. _rebuild(): void;
  133696. /** @hidden */
  133697. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133698. /** @hidden */
  133699. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133700. /** @hidden */
  133701. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133702. /** @hidden */
  133703. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133704. /** @hidden */
  133705. _attachCameras(cameras: Camera, unique: boolean): void;
  133706. /** @hidden */
  133707. _attachCameras(cameras: Camera[], unique: boolean): void;
  133708. /** @hidden */
  133709. _detachCameras(cameras: Camera): void;
  133710. /** @hidden */
  133711. _detachCameras(cameras: Nullable<Camera[]>): void;
  133712. /** @hidden */
  133713. _update(): void;
  133714. /** @hidden */
  133715. _reset(): void;
  133716. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133717. /**
  133718. * Disposes of the pipeline
  133719. */
  133720. dispose(): void;
  133721. }
  133722. }
  133723. declare module BABYLON {
  133724. /**
  133725. * PostProcessRenderPipelineManager class
  133726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133727. */
  133728. export class PostProcessRenderPipelineManager {
  133729. private _renderPipelines;
  133730. /**
  133731. * Initializes a PostProcessRenderPipelineManager
  133732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133733. */
  133734. constructor();
  133735. /**
  133736. * Gets the list of supported render pipelines
  133737. */
  133738. get supportedPipelines(): PostProcessRenderPipeline[];
  133739. /**
  133740. * Adds a pipeline to the manager
  133741. * @param renderPipeline The pipeline to add
  133742. */
  133743. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133744. /**
  133745. * Attaches a camera to the pipeline
  133746. * @param renderPipelineName The name of the pipeline to attach to
  133747. * @param cameras the camera to attach
  133748. * @param unique if the camera can be attached multiple times to the pipeline
  133749. */
  133750. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133751. /**
  133752. * Detaches a camera from the pipeline
  133753. * @param renderPipelineName The name of the pipeline to detach from
  133754. * @param cameras the camera to detach
  133755. */
  133756. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133757. /**
  133758. * Enables an effect by name on a pipeline
  133759. * @param renderPipelineName the name of the pipeline to enable the effect in
  133760. * @param renderEffectName the name of the effect to enable
  133761. * @param cameras the cameras that the effect should be enabled on
  133762. */
  133763. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133764. /**
  133765. * Disables an effect by name on a pipeline
  133766. * @param renderPipelineName the name of the pipeline to disable the effect in
  133767. * @param renderEffectName the name of the effect to disable
  133768. * @param cameras the cameras that the effect should be disabled on
  133769. */
  133770. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133771. /**
  133772. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133773. */
  133774. update(): void;
  133775. /** @hidden */
  133776. _rebuild(): void;
  133777. /**
  133778. * Disposes of the manager and pipelines
  133779. */
  133780. dispose(): void;
  133781. }
  133782. }
  133783. declare module BABYLON {
  133784. interface Scene {
  133785. /** @hidden (Backing field) */
  133786. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133787. /**
  133788. * Gets the postprocess render pipeline manager
  133789. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133790. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133791. */
  133792. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133793. }
  133794. /**
  133795. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133796. */
  133797. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133798. /**
  133799. * The component name helpfull to identify the component in the list of scene components.
  133800. */
  133801. readonly name: string;
  133802. /**
  133803. * The scene the component belongs to.
  133804. */
  133805. scene: Scene;
  133806. /**
  133807. * Creates a new instance of the component for the given scene
  133808. * @param scene Defines the scene to register the component in
  133809. */
  133810. constructor(scene: Scene);
  133811. /**
  133812. * Registers the component in a given scene
  133813. */
  133814. register(): void;
  133815. /**
  133816. * Rebuilds the elements related to this component in case of
  133817. * context lost for instance.
  133818. */
  133819. rebuild(): void;
  133820. /**
  133821. * Disposes the component and the associated ressources
  133822. */
  133823. dispose(): void;
  133824. private _gatherRenderTargets;
  133825. }
  133826. }
  133827. declare module BABYLON {
  133828. /**
  133829. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133830. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133831. */
  133832. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133833. private _scene;
  133834. private _camerasToBeAttached;
  133835. /**
  133836. * ID of the sharpen post process,
  133837. */
  133838. private readonly SharpenPostProcessId;
  133839. /**
  133840. * @ignore
  133841. * ID of the image processing post process;
  133842. */
  133843. readonly ImageProcessingPostProcessId: string;
  133844. /**
  133845. * @ignore
  133846. * ID of the Fast Approximate Anti-Aliasing post process;
  133847. */
  133848. readonly FxaaPostProcessId: string;
  133849. /**
  133850. * ID of the chromatic aberration post process,
  133851. */
  133852. private readonly ChromaticAberrationPostProcessId;
  133853. /**
  133854. * ID of the grain post process
  133855. */
  133856. private readonly GrainPostProcessId;
  133857. /**
  133858. * Sharpen post process which will apply a sharpen convolution to enhance edges
  133859. */
  133860. sharpen: SharpenPostProcess;
  133861. private _sharpenEffect;
  133862. private bloom;
  133863. /**
  133864. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  133865. */
  133866. depthOfField: DepthOfFieldEffect;
  133867. /**
  133868. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133869. */
  133870. fxaa: FxaaPostProcess;
  133871. /**
  133872. * Image post processing pass used to perform operations such as tone mapping or color grading.
  133873. */
  133874. imageProcessing: ImageProcessingPostProcess;
  133875. /**
  133876. * Chromatic aberration post process which will shift rgb colors in the image
  133877. */
  133878. chromaticAberration: ChromaticAberrationPostProcess;
  133879. private _chromaticAberrationEffect;
  133880. /**
  133881. * Grain post process which add noise to the image
  133882. */
  133883. grain: GrainPostProcess;
  133884. private _grainEffect;
  133885. /**
  133886. * Glow post process which adds a glow to emissive areas of the image
  133887. */
  133888. private _glowLayer;
  133889. /**
  133890. * Animations which can be used to tweak settings over a period of time
  133891. */
  133892. animations: Animation[];
  133893. private _imageProcessingConfigurationObserver;
  133894. private _sharpenEnabled;
  133895. private _bloomEnabled;
  133896. private _depthOfFieldEnabled;
  133897. private _depthOfFieldBlurLevel;
  133898. private _fxaaEnabled;
  133899. private _imageProcessingEnabled;
  133900. private _defaultPipelineTextureType;
  133901. private _bloomScale;
  133902. private _chromaticAberrationEnabled;
  133903. private _grainEnabled;
  133904. private _buildAllowed;
  133905. /**
  133906. * Gets active scene
  133907. */
  133908. get scene(): Scene;
  133909. /**
  133910. * Enable or disable the sharpen process from the pipeline
  133911. */
  133912. set sharpenEnabled(enabled: boolean);
  133913. get sharpenEnabled(): boolean;
  133914. private _resizeObserver;
  133915. private _hardwareScaleLevel;
  133916. private _bloomKernel;
  133917. /**
  133918. * Specifies the size of the bloom blur kernel, relative to the final output size
  133919. */
  133920. get bloomKernel(): number;
  133921. set bloomKernel(value: number);
  133922. /**
  133923. * Specifies the weight of the bloom in the final rendering
  133924. */
  133925. private _bloomWeight;
  133926. /**
  133927. * Specifies the luma threshold for the area that will be blurred by the bloom
  133928. */
  133929. private _bloomThreshold;
  133930. private _hdr;
  133931. /**
  133932. * The strength of the bloom.
  133933. */
  133934. set bloomWeight(value: number);
  133935. get bloomWeight(): number;
  133936. /**
  133937. * The strength of the bloom.
  133938. */
  133939. set bloomThreshold(value: number);
  133940. get bloomThreshold(): number;
  133941. /**
  133942. * The scale of the bloom, lower value will provide better performance.
  133943. */
  133944. set bloomScale(value: number);
  133945. get bloomScale(): number;
  133946. /**
  133947. * Enable or disable the bloom from the pipeline
  133948. */
  133949. set bloomEnabled(enabled: boolean);
  133950. get bloomEnabled(): boolean;
  133951. private _rebuildBloom;
  133952. /**
  133953. * If the depth of field is enabled.
  133954. */
  133955. get depthOfFieldEnabled(): boolean;
  133956. set depthOfFieldEnabled(enabled: boolean);
  133957. /**
  133958. * Blur level of the depth of field effect. (Higher blur will effect performance)
  133959. */
  133960. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  133961. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  133962. /**
  133963. * If the anti aliasing is enabled.
  133964. */
  133965. set fxaaEnabled(enabled: boolean);
  133966. get fxaaEnabled(): boolean;
  133967. private _samples;
  133968. /**
  133969. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  133970. */
  133971. set samples(sampleCount: number);
  133972. get samples(): number;
  133973. /**
  133974. * If image processing is enabled.
  133975. */
  133976. set imageProcessingEnabled(enabled: boolean);
  133977. get imageProcessingEnabled(): boolean;
  133978. /**
  133979. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  133980. */
  133981. set glowLayerEnabled(enabled: boolean);
  133982. get glowLayerEnabled(): boolean;
  133983. /**
  133984. * Gets the glow layer (or null if not defined)
  133985. */
  133986. get glowLayer(): Nullable<GlowLayer>;
  133987. /**
  133988. * Enable or disable the chromaticAberration process from the pipeline
  133989. */
  133990. set chromaticAberrationEnabled(enabled: boolean);
  133991. get chromaticAberrationEnabled(): boolean;
  133992. /**
  133993. * Enable or disable the grain process from the pipeline
  133994. */
  133995. set grainEnabled(enabled: boolean);
  133996. get grainEnabled(): boolean;
  133997. /**
  133998. * @constructor
  133999. * @param name - The rendering pipeline name (default: "")
  134000. * @param hdr - If high dynamic range textures should be used (default: true)
  134001. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134002. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134003. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134004. */
  134005. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134006. /**
  134007. * Get the class name
  134008. * @returns "DefaultRenderingPipeline"
  134009. */
  134010. getClassName(): string;
  134011. /**
  134012. * Force the compilation of the entire pipeline.
  134013. */
  134014. prepare(): void;
  134015. private _hasCleared;
  134016. private _prevPostProcess;
  134017. private _prevPrevPostProcess;
  134018. private _setAutoClearAndTextureSharing;
  134019. private _depthOfFieldSceneObserver;
  134020. private _buildPipeline;
  134021. private _disposePostProcesses;
  134022. /**
  134023. * Adds a camera to the pipeline
  134024. * @param camera the camera to be added
  134025. */
  134026. addCamera(camera: Camera): void;
  134027. /**
  134028. * Removes a camera from the pipeline
  134029. * @param camera the camera to remove
  134030. */
  134031. removeCamera(camera: Camera): void;
  134032. /**
  134033. * Dispose of the pipeline and stop all post processes
  134034. */
  134035. dispose(): void;
  134036. /**
  134037. * Serialize the rendering pipeline (Used when exporting)
  134038. * @returns the serialized object
  134039. */
  134040. serialize(): any;
  134041. /**
  134042. * Parse the serialized pipeline
  134043. * @param source Source pipeline.
  134044. * @param scene The scene to load the pipeline to.
  134045. * @param rootUrl The URL of the serialized pipeline.
  134046. * @returns An instantiated pipeline from the serialized object.
  134047. */
  134048. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134049. }
  134050. }
  134051. declare module BABYLON {
  134052. /** @hidden */
  134053. export var lensHighlightsPixelShader: {
  134054. name: string;
  134055. shader: string;
  134056. };
  134057. }
  134058. declare module BABYLON {
  134059. /** @hidden */
  134060. export var depthOfFieldPixelShader: {
  134061. name: string;
  134062. shader: string;
  134063. };
  134064. }
  134065. declare module BABYLON {
  134066. /**
  134067. * BABYLON.JS Chromatic Aberration GLSL Shader
  134068. * Author: Olivier Guyot
  134069. * Separates very slightly R, G and B colors on the edges of the screen
  134070. * Inspired by Francois Tarlier & Martins Upitis
  134071. */
  134072. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134073. /**
  134074. * @ignore
  134075. * The chromatic aberration PostProcess id in the pipeline
  134076. */
  134077. LensChromaticAberrationEffect: string;
  134078. /**
  134079. * @ignore
  134080. * The highlights enhancing PostProcess id in the pipeline
  134081. */
  134082. HighlightsEnhancingEffect: string;
  134083. /**
  134084. * @ignore
  134085. * The depth-of-field PostProcess id in the pipeline
  134086. */
  134087. LensDepthOfFieldEffect: string;
  134088. private _scene;
  134089. private _depthTexture;
  134090. private _grainTexture;
  134091. private _chromaticAberrationPostProcess;
  134092. private _highlightsPostProcess;
  134093. private _depthOfFieldPostProcess;
  134094. private _edgeBlur;
  134095. private _grainAmount;
  134096. private _chromaticAberration;
  134097. private _distortion;
  134098. private _highlightsGain;
  134099. private _highlightsThreshold;
  134100. private _dofDistance;
  134101. private _dofAperture;
  134102. private _dofDarken;
  134103. private _dofPentagon;
  134104. private _blurNoise;
  134105. /**
  134106. * @constructor
  134107. *
  134108. * Effect parameters are as follow:
  134109. * {
  134110. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134111. * edge_blur: number; // from 0 to x (1 for realism)
  134112. * distortion: number; // from 0 to x (1 for realism)
  134113. * grain_amount: number; // from 0 to 1
  134114. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134115. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134116. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134117. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134118. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134119. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134120. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134121. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134122. * }
  134123. * Note: if an effect parameter is unset, effect is disabled
  134124. *
  134125. * @param name The rendering pipeline name
  134126. * @param parameters - An object containing all parameters (see above)
  134127. * @param scene The scene linked to this pipeline
  134128. * @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)
  134129. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134130. */
  134131. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134132. /**
  134133. * Get the class name
  134134. * @returns "LensRenderingPipeline"
  134135. */
  134136. getClassName(): string;
  134137. /**
  134138. * Gets associated scene
  134139. */
  134140. get scene(): Scene;
  134141. /**
  134142. * Gets or sets the edge blur
  134143. */
  134144. get edgeBlur(): number;
  134145. set edgeBlur(value: number);
  134146. /**
  134147. * Gets or sets the grain amount
  134148. */
  134149. get grainAmount(): number;
  134150. set grainAmount(value: number);
  134151. /**
  134152. * Gets or sets the chromatic aberration amount
  134153. */
  134154. get chromaticAberration(): number;
  134155. set chromaticAberration(value: number);
  134156. /**
  134157. * Gets or sets the depth of field aperture
  134158. */
  134159. get dofAperture(): number;
  134160. set dofAperture(value: number);
  134161. /**
  134162. * Gets or sets the edge distortion
  134163. */
  134164. get edgeDistortion(): number;
  134165. set edgeDistortion(value: number);
  134166. /**
  134167. * Gets or sets the depth of field distortion
  134168. */
  134169. get dofDistortion(): number;
  134170. set dofDistortion(value: number);
  134171. /**
  134172. * Gets or sets the darken out of focus amount
  134173. */
  134174. get darkenOutOfFocus(): number;
  134175. set darkenOutOfFocus(value: number);
  134176. /**
  134177. * Gets or sets a boolean indicating if blur noise is enabled
  134178. */
  134179. get blurNoise(): boolean;
  134180. set blurNoise(value: boolean);
  134181. /**
  134182. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134183. */
  134184. get pentagonBokeh(): boolean;
  134185. set pentagonBokeh(value: boolean);
  134186. /**
  134187. * Gets or sets the highlight grain amount
  134188. */
  134189. get highlightsGain(): number;
  134190. set highlightsGain(value: number);
  134191. /**
  134192. * Gets or sets the highlight threshold
  134193. */
  134194. get highlightsThreshold(): number;
  134195. set highlightsThreshold(value: number);
  134196. /**
  134197. * Sets the amount of blur at the edges
  134198. * @param amount blur amount
  134199. */
  134200. setEdgeBlur(amount: number): void;
  134201. /**
  134202. * Sets edge blur to 0
  134203. */
  134204. disableEdgeBlur(): void;
  134205. /**
  134206. * Sets the amout of grain
  134207. * @param amount Amount of grain
  134208. */
  134209. setGrainAmount(amount: number): void;
  134210. /**
  134211. * Set grain amount to 0
  134212. */
  134213. disableGrain(): void;
  134214. /**
  134215. * Sets the chromatic aberration amount
  134216. * @param amount amount of chromatic aberration
  134217. */
  134218. setChromaticAberration(amount: number): void;
  134219. /**
  134220. * Sets chromatic aberration amount to 0
  134221. */
  134222. disableChromaticAberration(): void;
  134223. /**
  134224. * Sets the EdgeDistortion amount
  134225. * @param amount amount of EdgeDistortion
  134226. */
  134227. setEdgeDistortion(amount: number): void;
  134228. /**
  134229. * Sets edge distortion to 0
  134230. */
  134231. disableEdgeDistortion(): void;
  134232. /**
  134233. * Sets the FocusDistance amount
  134234. * @param amount amount of FocusDistance
  134235. */
  134236. setFocusDistance(amount: number): void;
  134237. /**
  134238. * Disables depth of field
  134239. */
  134240. disableDepthOfField(): void;
  134241. /**
  134242. * Sets the Aperture amount
  134243. * @param amount amount of Aperture
  134244. */
  134245. setAperture(amount: number): void;
  134246. /**
  134247. * Sets the DarkenOutOfFocus amount
  134248. * @param amount amount of DarkenOutOfFocus
  134249. */
  134250. setDarkenOutOfFocus(amount: number): void;
  134251. private _pentagonBokehIsEnabled;
  134252. /**
  134253. * Creates a pentagon bokeh effect
  134254. */
  134255. enablePentagonBokeh(): void;
  134256. /**
  134257. * Disables the pentagon bokeh effect
  134258. */
  134259. disablePentagonBokeh(): void;
  134260. /**
  134261. * Enables noise blur
  134262. */
  134263. enableNoiseBlur(): void;
  134264. /**
  134265. * Disables noise blur
  134266. */
  134267. disableNoiseBlur(): void;
  134268. /**
  134269. * Sets the HighlightsGain amount
  134270. * @param amount amount of HighlightsGain
  134271. */
  134272. setHighlightsGain(amount: number): void;
  134273. /**
  134274. * Sets the HighlightsThreshold amount
  134275. * @param amount amount of HighlightsThreshold
  134276. */
  134277. setHighlightsThreshold(amount: number): void;
  134278. /**
  134279. * Disables highlights
  134280. */
  134281. disableHighlights(): void;
  134282. /**
  134283. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134284. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134285. */
  134286. dispose(disableDepthRender?: boolean): void;
  134287. private _createChromaticAberrationPostProcess;
  134288. private _createHighlightsPostProcess;
  134289. private _createDepthOfFieldPostProcess;
  134290. private _createGrainTexture;
  134291. }
  134292. }
  134293. declare module BABYLON {
  134294. /** @hidden */
  134295. export var ssao2PixelShader: {
  134296. name: string;
  134297. shader: string;
  134298. };
  134299. }
  134300. declare module BABYLON {
  134301. /** @hidden */
  134302. export var ssaoCombinePixelShader: {
  134303. name: string;
  134304. shader: string;
  134305. };
  134306. }
  134307. declare module BABYLON {
  134308. /**
  134309. * Render pipeline to produce ssao effect
  134310. */
  134311. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134312. /**
  134313. * @ignore
  134314. * The PassPostProcess id in the pipeline that contains the original scene color
  134315. */
  134316. SSAOOriginalSceneColorEffect: string;
  134317. /**
  134318. * @ignore
  134319. * The SSAO PostProcess id in the pipeline
  134320. */
  134321. SSAORenderEffect: string;
  134322. /**
  134323. * @ignore
  134324. * The horizontal blur PostProcess id in the pipeline
  134325. */
  134326. SSAOBlurHRenderEffect: string;
  134327. /**
  134328. * @ignore
  134329. * The vertical blur PostProcess id in the pipeline
  134330. */
  134331. SSAOBlurVRenderEffect: string;
  134332. /**
  134333. * @ignore
  134334. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134335. */
  134336. SSAOCombineRenderEffect: string;
  134337. /**
  134338. * The output strength of the SSAO post-process. Default value is 1.0.
  134339. */
  134340. totalStrength: number;
  134341. /**
  134342. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134343. */
  134344. maxZ: number;
  134345. /**
  134346. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134347. */
  134348. minZAspect: number;
  134349. private _samples;
  134350. /**
  134351. * Number of samples used for the SSAO calculations. Default value is 8
  134352. */
  134353. set samples(n: number);
  134354. get samples(): number;
  134355. private _textureSamples;
  134356. /**
  134357. * Number of samples to use for antialiasing
  134358. */
  134359. set textureSamples(n: number);
  134360. get textureSamples(): number;
  134361. /**
  134362. * Ratio object used for SSAO ratio and blur ratio
  134363. */
  134364. private _ratio;
  134365. /**
  134366. * Dynamically generated sphere sampler.
  134367. */
  134368. private _sampleSphere;
  134369. /**
  134370. * Blur filter offsets
  134371. */
  134372. private _samplerOffsets;
  134373. private _expensiveBlur;
  134374. /**
  134375. * If bilateral blur should be used
  134376. */
  134377. set expensiveBlur(b: boolean);
  134378. get expensiveBlur(): boolean;
  134379. /**
  134380. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134381. */
  134382. radius: number;
  134383. /**
  134384. * The base color of the SSAO post-process
  134385. * The final result is "base + ssao" between [0, 1]
  134386. */
  134387. base: number;
  134388. /**
  134389. * Support test.
  134390. */
  134391. static get IsSupported(): boolean;
  134392. private _scene;
  134393. private _depthTexture;
  134394. private _normalTexture;
  134395. private _randomTexture;
  134396. private _originalColorPostProcess;
  134397. private _ssaoPostProcess;
  134398. private _blurHPostProcess;
  134399. private _blurVPostProcess;
  134400. private _ssaoCombinePostProcess;
  134401. /**
  134402. * Gets active scene
  134403. */
  134404. get scene(): Scene;
  134405. /**
  134406. * @constructor
  134407. * @param name The rendering pipeline name
  134408. * @param scene The scene linked to this pipeline
  134409. * @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 }
  134410. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134411. */
  134412. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134413. /**
  134414. * Get the class name
  134415. * @returns "SSAO2RenderingPipeline"
  134416. */
  134417. getClassName(): string;
  134418. /**
  134419. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134420. */
  134421. dispose(disableGeometryBufferRenderer?: boolean): void;
  134422. private _createBlurPostProcess;
  134423. /** @hidden */
  134424. _rebuild(): void;
  134425. private _bits;
  134426. private _radicalInverse_VdC;
  134427. private _hammersley;
  134428. private _hemisphereSample_uniform;
  134429. private _generateHemisphere;
  134430. private _createSSAOPostProcess;
  134431. private _createSSAOCombinePostProcess;
  134432. private _createRandomTexture;
  134433. /**
  134434. * Serialize the rendering pipeline (Used when exporting)
  134435. * @returns the serialized object
  134436. */
  134437. serialize(): any;
  134438. /**
  134439. * Parse the serialized pipeline
  134440. * @param source Source pipeline.
  134441. * @param scene The scene to load the pipeline to.
  134442. * @param rootUrl The URL of the serialized pipeline.
  134443. * @returns An instantiated pipeline from the serialized object.
  134444. */
  134445. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134446. }
  134447. }
  134448. declare module BABYLON {
  134449. /** @hidden */
  134450. export var ssaoPixelShader: {
  134451. name: string;
  134452. shader: string;
  134453. };
  134454. }
  134455. declare module BABYLON {
  134456. /**
  134457. * Render pipeline to produce ssao effect
  134458. */
  134459. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134460. /**
  134461. * @ignore
  134462. * The PassPostProcess id in the pipeline that contains the original scene color
  134463. */
  134464. SSAOOriginalSceneColorEffect: string;
  134465. /**
  134466. * @ignore
  134467. * The SSAO PostProcess id in the pipeline
  134468. */
  134469. SSAORenderEffect: string;
  134470. /**
  134471. * @ignore
  134472. * The horizontal blur PostProcess id in the pipeline
  134473. */
  134474. SSAOBlurHRenderEffect: string;
  134475. /**
  134476. * @ignore
  134477. * The vertical blur PostProcess id in the pipeline
  134478. */
  134479. SSAOBlurVRenderEffect: string;
  134480. /**
  134481. * @ignore
  134482. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134483. */
  134484. SSAOCombineRenderEffect: string;
  134485. /**
  134486. * The output strength of the SSAO post-process. Default value is 1.0.
  134487. */
  134488. totalStrength: number;
  134489. /**
  134490. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134491. */
  134492. radius: number;
  134493. /**
  134494. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134495. * Must not be equal to fallOff and superior to fallOff.
  134496. * Default value is 0.0075
  134497. */
  134498. area: number;
  134499. /**
  134500. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134501. * Must not be equal to area and inferior to area.
  134502. * Default value is 0.000001
  134503. */
  134504. fallOff: number;
  134505. /**
  134506. * The base color of the SSAO post-process
  134507. * The final result is "base + ssao" between [0, 1]
  134508. */
  134509. base: number;
  134510. private _scene;
  134511. private _depthTexture;
  134512. private _randomTexture;
  134513. private _originalColorPostProcess;
  134514. private _ssaoPostProcess;
  134515. private _blurHPostProcess;
  134516. private _blurVPostProcess;
  134517. private _ssaoCombinePostProcess;
  134518. private _firstUpdate;
  134519. /**
  134520. * Gets active scene
  134521. */
  134522. get scene(): Scene;
  134523. /**
  134524. * @constructor
  134525. * @param name - The rendering pipeline name
  134526. * @param scene - The scene linked to this pipeline
  134527. * @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 }
  134528. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134529. */
  134530. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134531. /**
  134532. * Get the class name
  134533. * @returns "SSAORenderingPipeline"
  134534. */
  134535. getClassName(): string;
  134536. /**
  134537. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134538. */
  134539. dispose(disableDepthRender?: boolean): void;
  134540. private _createBlurPostProcess;
  134541. /** @hidden */
  134542. _rebuild(): void;
  134543. private _createSSAOPostProcess;
  134544. private _createSSAOCombinePostProcess;
  134545. private _createRandomTexture;
  134546. }
  134547. }
  134548. declare module BABYLON {
  134549. /** @hidden */
  134550. export var standardPixelShader: {
  134551. name: string;
  134552. shader: string;
  134553. };
  134554. }
  134555. declare module BABYLON {
  134556. /**
  134557. * Standard rendering pipeline
  134558. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134559. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134560. */
  134561. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134562. /**
  134563. * Public members
  134564. */
  134565. /**
  134566. * Post-process which contains the original scene color before the pipeline applies all the effects
  134567. */
  134568. originalPostProcess: Nullable<PostProcess>;
  134569. /**
  134570. * Post-process used to down scale an image x4
  134571. */
  134572. downSampleX4PostProcess: Nullable<PostProcess>;
  134573. /**
  134574. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134575. */
  134576. brightPassPostProcess: Nullable<PostProcess>;
  134577. /**
  134578. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134579. */
  134580. blurHPostProcesses: PostProcess[];
  134581. /**
  134582. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134583. */
  134584. blurVPostProcesses: PostProcess[];
  134585. /**
  134586. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134587. */
  134588. textureAdderPostProcess: Nullable<PostProcess>;
  134589. /**
  134590. * Post-process used to create volumetric lighting effect
  134591. */
  134592. volumetricLightPostProcess: Nullable<PostProcess>;
  134593. /**
  134594. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134595. */
  134596. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134597. /**
  134598. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134599. */
  134600. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134601. /**
  134602. * Post-process used to merge the volumetric light effect and the real scene color
  134603. */
  134604. volumetricLightMergePostProces: Nullable<PostProcess>;
  134605. /**
  134606. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134607. */
  134608. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134609. /**
  134610. * Base post-process used to calculate the average luminance of the final image for HDR
  134611. */
  134612. luminancePostProcess: Nullable<PostProcess>;
  134613. /**
  134614. * Post-processes used to create down sample post-processes in order to get
  134615. * the average luminance of the final image for HDR
  134616. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134617. */
  134618. luminanceDownSamplePostProcesses: PostProcess[];
  134619. /**
  134620. * Post-process used to create a HDR effect (light adaptation)
  134621. */
  134622. hdrPostProcess: Nullable<PostProcess>;
  134623. /**
  134624. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134625. */
  134626. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134627. /**
  134628. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134629. */
  134630. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134631. /**
  134632. * Post-process used to merge the final HDR post-process and the real scene color
  134633. */
  134634. hdrFinalPostProcess: Nullable<PostProcess>;
  134635. /**
  134636. * Post-process used to create a lens flare effect
  134637. */
  134638. lensFlarePostProcess: Nullable<PostProcess>;
  134639. /**
  134640. * Post-process that merges the result of the lens flare post-process and the real scene color
  134641. */
  134642. lensFlareComposePostProcess: Nullable<PostProcess>;
  134643. /**
  134644. * Post-process used to create a motion blur effect
  134645. */
  134646. motionBlurPostProcess: Nullable<PostProcess>;
  134647. /**
  134648. * Post-process used to create a depth of field effect
  134649. */
  134650. depthOfFieldPostProcess: Nullable<PostProcess>;
  134651. /**
  134652. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134653. */
  134654. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134655. /**
  134656. * Represents the brightness threshold in order to configure the illuminated surfaces
  134657. */
  134658. brightThreshold: number;
  134659. /**
  134660. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134661. */
  134662. blurWidth: number;
  134663. /**
  134664. * Sets if the blur for highlighted surfaces must be only horizontal
  134665. */
  134666. horizontalBlur: boolean;
  134667. /**
  134668. * Gets the overall exposure used by the pipeline
  134669. */
  134670. get exposure(): number;
  134671. /**
  134672. * Sets the overall exposure used by the pipeline
  134673. */
  134674. set exposure(value: number);
  134675. /**
  134676. * Texture used typically to simulate "dirty" on camera lens
  134677. */
  134678. lensTexture: Nullable<Texture>;
  134679. /**
  134680. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134681. */
  134682. volumetricLightCoefficient: number;
  134683. /**
  134684. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134685. */
  134686. volumetricLightPower: number;
  134687. /**
  134688. * Used the set the blur intensity to smooth the volumetric lights
  134689. */
  134690. volumetricLightBlurScale: number;
  134691. /**
  134692. * Light (spot or directional) used to generate the volumetric lights rays
  134693. * The source light must have a shadow generate so the pipeline can get its
  134694. * depth map
  134695. */
  134696. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134697. /**
  134698. * For eye adaptation, represents the minimum luminance the eye can see
  134699. */
  134700. hdrMinimumLuminance: number;
  134701. /**
  134702. * For eye adaptation, represents the decrease luminance speed
  134703. */
  134704. hdrDecreaseRate: number;
  134705. /**
  134706. * For eye adaptation, represents the increase luminance speed
  134707. */
  134708. hdrIncreaseRate: number;
  134709. /**
  134710. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134711. */
  134712. get hdrAutoExposure(): boolean;
  134713. /**
  134714. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134715. */
  134716. set hdrAutoExposure(value: boolean);
  134717. /**
  134718. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134719. */
  134720. lensColorTexture: Nullable<Texture>;
  134721. /**
  134722. * The overall strengh for the lens flare effect
  134723. */
  134724. lensFlareStrength: number;
  134725. /**
  134726. * Dispersion coefficient for lens flare ghosts
  134727. */
  134728. lensFlareGhostDispersal: number;
  134729. /**
  134730. * Main lens flare halo width
  134731. */
  134732. lensFlareHaloWidth: number;
  134733. /**
  134734. * Based on the lens distortion effect, defines how much the lens flare result
  134735. * is distorted
  134736. */
  134737. lensFlareDistortionStrength: number;
  134738. /**
  134739. * Configures the blur intensity used for for lens flare (halo)
  134740. */
  134741. lensFlareBlurWidth: number;
  134742. /**
  134743. * Lens star texture must be used to simulate rays on the flares and is available
  134744. * in the documentation
  134745. */
  134746. lensStarTexture: Nullable<Texture>;
  134747. /**
  134748. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134749. * flare effect by taking account of the dirt texture
  134750. */
  134751. lensFlareDirtTexture: Nullable<Texture>;
  134752. /**
  134753. * Represents the focal length for the depth of field effect
  134754. */
  134755. depthOfFieldDistance: number;
  134756. /**
  134757. * Represents the blur intensity for the blurred part of the depth of field effect
  134758. */
  134759. depthOfFieldBlurWidth: number;
  134760. /**
  134761. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134762. */
  134763. get motionStrength(): number;
  134764. /**
  134765. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134766. */
  134767. set motionStrength(strength: number);
  134768. /**
  134769. * Gets wether or not the motion blur post-process is object based or screen based.
  134770. */
  134771. get objectBasedMotionBlur(): boolean;
  134772. /**
  134773. * Sets wether or not the motion blur post-process should be object based or screen based
  134774. */
  134775. set objectBasedMotionBlur(value: boolean);
  134776. /**
  134777. * List of animations for the pipeline (IAnimatable implementation)
  134778. */
  134779. animations: Animation[];
  134780. /**
  134781. * Private members
  134782. */
  134783. private _scene;
  134784. private _currentDepthOfFieldSource;
  134785. private _basePostProcess;
  134786. private _fixedExposure;
  134787. private _currentExposure;
  134788. private _hdrAutoExposure;
  134789. private _hdrCurrentLuminance;
  134790. private _motionStrength;
  134791. private _isObjectBasedMotionBlur;
  134792. private _floatTextureType;
  134793. private _camerasToBeAttached;
  134794. private _ratio;
  134795. private _bloomEnabled;
  134796. private _depthOfFieldEnabled;
  134797. private _vlsEnabled;
  134798. private _lensFlareEnabled;
  134799. private _hdrEnabled;
  134800. private _motionBlurEnabled;
  134801. private _fxaaEnabled;
  134802. private _motionBlurSamples;
  134803. private _volumetricLightStepsCount;
  134804. private _samples;
  134805. /**
  134806. * @ignore
  134807. * Specifies if the bloom pipeline is enabled
  134808. */
  134809. get BloomEnabled(): boolean;
  134810. set BloomEnabled(enabled: boolean);
  134811. /**
  134812. * @ignore
  134813. * Specifies if the depth of field pipeline is enabed
  134814. */
  134815. get DepthOfFieldEnabled(): boolean;
  134816. set DepthOfFieldEnabled(enabled: boolean);
  134817. /**
  134818. * @ignore
  134819. * Specifies if the lens flare pipeline is enabed
  134820. */
  134821. get LensFlareEnabled(): boolean;
  134822. set LensFlareEnabled(enabled: boolean);
  134823. /**
  134824. * @ignore
  134825. * Specifies if the HDR pipeline is enabled
  134826. */
  134827. get HDREnabled(): boolean;
  134828. set HDREnabled(enabled: boolean);
  134829. /**
  134830. * @ignore
  134831. * Specifies if the volumetric lights scattering effect is enabled
  134832. */
  134833. get VLSEnabled(): boolean;
  134834. set VLSEnabled(enabled: boolean);
  134835. /**
  134836. * @ignore
  134837. * Specifies if the motion blur effect is enabled
  134838. */
  134839. get MotionBlurEnabled(): boolean;
  134840. set MotionBlurEnabled(enabled: boolean);
  134841. /**
  134842. * Specifies if anti-aliasing is enabled
  134843. */
  134844. get fxaaEnabled(): boolean;
  134845. set fxaaEnabled(enabled: boolean);
  134846. /**
  134847. * Specifies the number of steps used to calculate the volumetric lights
  134848. * Typically in interval [50, 200]
  134849. */
  134850. get volumetricLightStepsCount(): number;
  134851. set volumetricLightStepsCount(count: number);
  134852. /**
  134853. * Specifies the number of samples used for the motion blur effect
  134854. * Typically in interval [16, 64]
  134855. */
  134856. get motionBlurSamples(): number;
  134857. set motionBlurSamples(samples: number);
  134858. /**
  134859. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134860. */
  134861. get samples(): number;
  134862. set samples(sampleCount: number);
  134863. /**
  134864. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134865. * @constructor
  134866. * @param name The rendering pipeline name
  134867. * @param scene The scene linked to this pipeline
  134868. * @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)
  134869. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  134870. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134871. */
  134872. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  134873. private _buildPipeline;
  134874. private _createDownSampleX4PostProcess;
  134875. private _createBrightPassPostProcess;
  134876. private _createBlurPostProcesses;
  134877. private _createTextureAdderPostProcess;
  134878. private _createVolumetricLightPostProcess;
  134879. private _createLuminancePostProcesses;
  134880. private _createHdrPostProcess;
  134881. private _createLensFlarePostProcess;
  134882. private _createDepthOfFieldPostProcess;
  134883. private _createMotionBlurPostProcess;
  134884. private _getDepthTexture;
  134885. private _disposePostProcesses;
  134886. /**
  134887. * Dispose of the pipeline and stop all post processes
  134888. */
  134889. dispose(): void;
  134890. /**
  134891. * Serialize the rendering pipeline (Used when exporting)
  134892. * @returns the serialized object
  134893. */
  134894. serialize(): any;
  134895. /**
  134896. * Parse the serialized pipeline
  134897. * @param source Source pipeline.
  134898. * @param scene The scene to load the pipeline to.
  134899. * @param rootUrl The URL of the serialized pipeline.
  134900. * @returns An instantiated pipeline from the serialized object.
  134901. */
  134902. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  134903. /**
  134904. * Luminance steps
  134905. */
  134906. static LuminanceSteps: number;
  134907. }
  134908. }
  134909. declare module BABYLON {
  134910. /** @hidden */
  134911. export var tonemapPixelShader: {
  134912. name: string;
  134913. shader: string;
  134914. };
  134915. }
  134916. declare module BABYLON {
  134917. /** Defines operator used for tonemapping */
  134918. export enum TonemappingOperator {
  134919. /** Hable */
  134920. Hable = 0,
  134921. /** Reinhard */
  134922. Reinhard = 1,
  134923. /** HejiDawson */
  134924. HejiDawson = 2,
  134925. /** Photographic */
  134926. Photographic = 3
  134927. }
  134928. /**
  134929. * Defines a post process to apply tone mapping
  134930. */
  134931. export class TonemapPostProcess extends PostProcess {
  134932. private _operator;
  134933. /** Defines the required exposure adjustement */
  134934. exposureAdjustment: number;
  134935. /**
  134936. * Creates a new TonemapPostProcess
  134937. * @param name defines the name of the postprocess
  134938. * @param _operator defines the operator to use
  134939. * @param exposureAdjustment defines the required exposure adjustement
  134940. * @param camera defines the camera to use (can be null)
  134941. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  134942. * @param engine defines the hosting engine (can be ignore if camera is set)
  134943. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  134944. */
  134945. constructor(name: string, _operator: TonemappingOperator,
  134946. /** Defines the required exposure adjustement */
  134947. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  134948. }
  134949. }
  134950. declare module BABYLON {
  134951. /** @hidden */
  134952. export var depthVertexShader: {
  134953. name: string;
  134954. shader: string;
  134955. };
  134956. }
  134957. declare module BABYLON {
  134958. /** @hidden */
  134959. export var volumetricLightScatteringPixelShader: {
  134960. name: string;
  134961. shader: string;
  134962. };
  134963. }
  134964. declare module BABYLON {
  134965. /** @hidden */
  134966. export var volumetricLightScatteringPassVertexShader: {
  134967. name: string;
  134968. shader: string;
  134969. };
  134970. }
  134971. declare module BABYLON {
  134972. /** @hidden */
  134973. export var volumetricLightScatteringPassPixelShader: {
  134974. name: string;
  134975. shader: string;
  134976. };
  134977. }
  134978. declare module BABYLON {
  134979. /**
  134980. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  134981. */
  134982. export class VolumetricLightScatteringPostProcess extends PostProcess {
  134983. private _volumetricLightScatteringPass;
  134984. private _volumetricLightScatteringRTT;
  134985. private _viewPort;
  134986. private _screenCoordinates;
  134987. private _cachedDefines;
  134988. /**
  134989. * If not undefined, the mesh position is computed from the attached node position
  134990. */
  134991. attachedNode: {
  134992. position: Vector3;
  134993. };
  134994. /**
  134995. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  134996. */
  134997. customMeshPosition: Vector3;
  134998. /**
  134999. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135000. */
  135001. useCustomMeshPosition: boolean;
  135002. /**
  135003. * If the post-process should inverse the light scattering direction
  135004. */
  135005. invert: boolean;
  135006. /**
  135007. * The internal mesh used by the post-process
  135008. */
  135009. mesh: Mesh;
  135010. /**
  135011. * @hidden
  135012. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135013. */
  135014. get useDiffuseColor(): boolean;
  135015. set useDiffuseColor(useDiffuseColor: boolean);
  135016. /**
  135017. * Array containing the excluded meshes not rendered in the internal pass
  135018. */
  135019. excludedMeshes: AbstractMesh[];
  135020. /**
  135021. * Controls the overall intensity of the post-process
  135022. */
  135023. exposure: number;
  135024. /**
  135025. * Dissipates each sample's contribution in range [0, 1]
  135026. */
  135027. decay: number;
  135028. /**
  135029. * Controls the overall intensity of each sample
  135030. */
  135031. weight: number;
  135032. /**
  135033. * Controls the density of each sample
  135034. */
  135035. density: number;
  135036. /**
  135037. * @constructor
  135038. * @param name The post-process name
  135039. * @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)
  135040. * @param camera The camera that the post-process will be attached to
  135041. * @param mesh The mesh used to create the light scattering
  135042. * @param samples The post-process quality, default 100
  135043. * @param samplingModeThe post-process filtering mode
  135044. * @param engine The babylon engine
  135045. * @param reusable If the post-process is reusable
  135046. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135047. */
  135048. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135049. /**
  135050. * Returns the string "VolumetricLightScatteringPostProcess"
  135051. * @returns "VolumetricLightScatteringPostProcess"
  135052. */
  135053. getClassName(): string;
  135054. private _isReady;
  135055. /**
  135056. * Sets the new light position for light scattering effect
  135057. * @param position The new custom light position
  135058. */
  135059. setCustomMeshPosition(position: Vector3): void;
  135060. /**
  135061. * Returns the light position for light scattering effect
  135062. * @return Vector3 The custom light position
  135063. */
  135064. getCustomMeshPosition(): Vector3;
  135065. /**
  135066. * Disposes the internal assets and detaches the post-process from the camera
  135067. */
  135068. dispose(camera: Camera): void;
  135069. /**
  135070. * Returns the render target texture used by the post-process
  135071. * @return the render target texture used by the post-process
  135072. */
  135073. getPass(): RenderTargetTexture;
  135074. private _meshExcluded;
  135075. private _createPass;
  135076. private _updateMeshScreenCoordinates;
  135077. /**
  135078. * Creates a default mesh for the Volumeric Light Scattering post-process
  135079. * @param name The mesh name
  135080. * @param scene The scene where to create the mesh
  135081. * @return the default mesh
  135082. */
  135083. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135084. }
  135085. }
  135086. declare module BABYLON {
  135087. interface Scene {
  135088. /** @hidden (Backing field) */
  135089. _boundingBoxRenderer: BoundingBoxRenderer;
  135090. /** @hidden (Backing field) */
  135091. _forceShowBoundingBoxes: boolean;
  135092. /**
  135093. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135094. */
  135095. forceShowBoundingBoxes: boolean;
  135096. /**
  135097. * Gets the bounding box renderer associated with the scene
  135098. * @returns a BoundingBoxRenderer
  135099. */
  135100. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135101. }
  135102. interface AbstractMesh {
  135103. /** @hidden (Backing field) */
  135104. _showBoundingBox: boolean;
  135105. /**
  135106. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135107. */
  135108. showBoundingBox: boolean;
  135109. }
  135110. /**
  135111. * Component responsible of rendering the bounding box of the meshes in a scene.
  135112. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135113. */
  135114. export class BoundingBoxRenderer implements ISceneComponent {
  135115. /**
  135116. * The component name helpfull to identify the component in the list of scene components.
  135117. */
  135118. readonly name: string;
  135119. /**
  135120. * The scene the component belongs to.
  135121. */
  135122. scene: Scene;
  135123. /**
  135124. * Color of the bounding box lines placed in front of an object
  135125. */
  135126. frontColor: Color3;
  135127. /**
  135128. * Color of the bounding box lines placed behind an object
  135129. */
  135130. backColor: Color3;
  135131. /**
  135132. * Defines if the renderer should show the back lines or not
  135133. */
  135134. showBackLines: boolean;
  135135. /**
  135136. * @hidden
  135137. */
  135138. renderList: SmartArray<BoundingBox>;
  135139. private _colorShader;
  135140. private _vertexBuffers;
  135141. private _indexBuffer;
  135142. private _fillIndexBuffer;
  135143. private _fillIndexData;
  135144. /**
  135145. * Instantiates a new bounding box renderer in a scene.
  135146. * @param scene the scene the renderer renders in
  135147. */
  135148. constructor(scene: Scene);
  135149. /**
  135150. * Registers the component in a given scene
  135151. */
  135152. register(): void;
  135153. private _evaluateSubMesh;
  135154. private _activeMesh;
  135155. private _prepareRessources;
  135156. private _createIndexBuffer;
  135157. /**
  135158. * Rebuilds the elements related to this component in case of
  135159. * context lost for instance.
  135160. */
  135161. rebuild(): void;
  135162. /**
  135163. * @hidden
  135164. */
  135165. reset(): void;
  135166. /**
  135167. * Render the bounding boxes of a specific rendering group
  135168. * @param renderingGroupId defines the rendering group to render
  135169. */
  135170. render(renderingGroupId: number): void;
  135171. /**
  135172. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135173. * @param mesh Define the mesh to render the occlusion bounding box for
  135174. */
  135175. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135176. /**
  135177. * Dispose and release the resources attached to this renderer.
  135178. */
  135179. dispose(): void;
  135180. }
  135181. }
  135182. declare module BABYLON {
  135183. /** @hidden */
  135184. export var depthPixelShader: {
  135185. name: string;
  135186. shader: string;
  135187. };
  135188. }
  135189. declare module BABYLON {
  135190. /**
  135191. * This represents a depth renderer in Babylon.
  135192. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135193. */
  135194. export class DepthRenderer {
  135195. private _scene;
  135196. private _depthMap;
  135197. private _effect;
  135198. private readonly _storeNonLinearDepth;
  135199. private readonly _clearColor;
  135200. /** Get if the depth renderer is using packed depth or not */
  135201. readonly isPacked: boolean;
  135202. private _cachedDefines;
  135203. private _camera;
  135204. /**
  135205. * Specifiess that the depth renderer will only be used within
  135206. * the camera it is created for.
  135207. * This can help forcing its rendering during the camera processing.
  135208. */
  135209. useOnlyInActiveCamera: boolean;
  135210. /** @hidden */
  135211. static _SceneComponentInitialization: (scene: Scene) => void;
  135212. /**
  135213. * Instantiates a depth renderer
  135214. * @param scene The scene the renderer belongs to
  135215. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135216. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135217. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135218. */
  135219. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135220. /**
  135221. * Creates the depth rendering effect and checks if the effect is ready.
  135222. * @param subMesh The submesh to be used to render the depth map of
  135223. * @param useInstances If multiple world instances should be used
  135224. * @returns if the depth renderer is ready to render the depth map
  135225. */
  135226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135227. /**
  135228. * Gets the texture which the depth map will be written to.
  135229. * @returns The depth map texture
  135230. */
  135231. getDepthMap(): RenderTargetTexture;
  135232. /**
  135233. * Disposes of the depth renderer.
  135234. */
  135235. dispose(): void;
  135236. }
  135237. }
  135238. declare module BABYLON {
  135239. interface Scene {
  135240. /** @hidden (Backing field) */
  135241. _depthRenderer: {
  135242. [id: string]: DepthRenderer;
  135243. };
  135244. /**
  135245. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135246. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135247. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135248. * @returns the created depth renderer
  135249. */
  135250. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135251. /**
  135252. * Disables a depth renderer for a given camera
  135253. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135254. */
  135255. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135256. }
  135257. /**
  135258. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135259. * in several rendering techniques.
  135260. */
  135261. export class DepthRendererSceneComponent implements ISceneComponent {
  135262. /**
  135263. * The component name helpfull to identify the component in the list of scene components.
  135264. */
  135265. readonly name: string;
  135266. /**
  135267. * The scene the component belongs to.
  135268. */
  135269. scene: Scene;
  135270. /**
  135271. * Creates a new instance of the component for the given scene
  135272. * @param scene Defines the scene to register the component in
  135273. */
  135274. constructor(scene: Scene);
  135275. /**
  135276. * Registers the component in a given scene
  135277. */
  135278. register(): void;
  135279. /**
  135280. * Rebuilds the elements related to this component in case of
  135281. * context lost for instance.
  135282. */
  135283. rebuild(): void;
  135284. /**
  135285. * Disposes the component and the associated ressources
  135286. */
  135287. dispose(): void;
  135288. private _gatherRenderTargets;
  135289. private _gatherActiveCameraRenderTargets;
  135290. }
  135291. }
  135292. declare module BABYLON {
  135293. /** @hidden */
  135294. export var outlinePixelShader: {
  135295. name: string;
  135296. shader: string;
  135297. };
  135298. }
  135299. declare module BABYLON {
  135300. /** @hidden */
  135301. export var outlineVertexShader: {
  135302. name: string;
  135303. shader: string;
  135304. };
  135305. }
  135306. declare module BABYLON {
  135307. interface Scene {
  135308. /** @hidden */
  135309. _outlineRenderer: OutlineRenderer;
  135310. /**
  135311. * Gets the outline renderer associated with the scene
  135312. * @returns a OutlineRenderer
  135313. */
  135314. getOutlineRenderer(): OutlineRenderer;
  135315. }
  135316. interface AbstractMesh {
  135317. /** @hidden (Backing field) */
  135318. _renderOutline: boolean;
  135319. /**
  135320. * Gets or sets a boolean indicating if the outline must be rendered as well
  135321. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135322. */
  135323. renderOutline: boolean;
  135324. /** @hidden (Backing field) */
  135325. _renderOverlay: boolean;
  135326. /**
  135327. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135328. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135329. */
  135330. renderOverlay: boolean;
  135331. }
  135332. /**
  135333. * This class is responsible to draw bothe outline/overlay of meshes.
  135334. * It should not be used directly but through the available method on mesh.
  135335. */
  135336. export class OutlineRenderer implements ISceneComponent {
  135337. /**
  135338. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135339. */
  135340. private static _StencilReference;
  135341. /**
  135342. * The name of the component. Each component must have a unique name.
  135343. */
  135344. name: string;
  135345. /**
  135346. * The scene the component belongs to.
  135347. */
  135348. scene: Scene;
  135349. /**
  135350. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135351. */
  135352. zOffset: number;
  135353. private _engine;
  135354. private _effect;
  135355. private _cachedDefines;
  135356. private _savedDepthWrite;
  135357. /**
  135358. * Instantiates a new outline renderer. (There could be only one per scene).
  135359. * @param scene Defines the scene it belongs to
  135360. */
  135361. constructor(scene: Scene);
  135362. /**
  135363. * Register the component to one instance of a scene.
  135364. */
  135365. register(): void;
  135366. /**
  135367. * Rebuilds the elements related to this component in case of
  135368. * context lost for instance.
  135369. */
  135370. rebuild(): void;
  135371. /**
  135372. * Disposes the component and the associated ressources.
  135373. */
  135374. dispose(): void;
  135375. /**
  135376. * Renders the outline in the canvas.
  135377. * @param subMesh Defines the sumesh to render
  135378. * @param batch Defines the batch of meshes in case of instances
  135379. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135380. */
  135381. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135382. /**
  135383. * Returns whether or not the outline renderer is ready for a given submesh.
  135384. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135385. * @param subMesh Defines the submesh to check readyness for
  135386. * @param useInstances Defines wheter wee are trying to render instances or not
  135387. * @returns true if ready otherwise false
  135388. */
  135389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135390. private _beforeRenderingMesh;
  135391. private _afterRenderingMesh;
  135392. }
  135393. }
  135394. declare module BABYLON {
  135395. /**
  135396. * Defines the basic options interface of a Sprite Frame Source Size.
  135397. */
  135398. export interface ISpriteJSONSpriteSourceSize {
  135399. /**
  135400. * number of the original width of the Frame
  135401. */
  135402. w: number;
  135403. /**
  135404. * number of the original height of the Frame
  135405. */
  135406. h: number;
  135407. }
  135408. /**
  135409. * Defines the basic options interface of a Sprite Frame Data.
  135410. */
  135411. export interface ISpriteJSONSpriteFrameData {
  135412. /**
  135413. * number of the x offset of the Frame
  135414. */
  135415. x: number;
  135416. /**
  135417. * number of the y offset of the Frame
  135418. */
  135419. y: number;
  135420. /**
  135421. * number of the width of the Frame
  135422. */
  135423. w: number;
  135424. /**
  135425. * number of the height of the Frame
  135426. */
  135427. h: number;
  135428. }
  135429. /**
  135430. * Defines the basic options interface of a JSON Sprite.
  135431. */
  135432. export interface ISpriteJSONSprite {
  135433. /**
  135434. * string name of the Frame
  135435. */
  135436. filename: string;
  135437. /**
  135438. * ISpriteJSONSpriteFrame basic object of the frame data
  135439. */
  135440. frame: ISpriteJSONSpriteFrameData;
  135441. /**
  135442. * boolean to flag is the frame was rotated.
  135443. */
  135444. rotated: boolean;
  135445. /**
  135446. * boolean to flag is the frame was trimmed.
  135447. */
  135448. trimmed: boolean;
  135449. /**
  135450. * ISpriteJSONSpriteFrame basic object of the source data
  135451. */
  135452. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135453. /**
  135454. * ISpriteJSONSpriteFrame basic object of the source data
  135455. */
  135456. sourceSize: ISpriteJSONSpriteSourceSize;
  135457. }
  135458. /**
  135459. * Defines the basic options interface of a JSON atlas.
  135460. */
  135461. export interface ISpriteJSONAtlas {
  135462. /**
  135463. * Array of objects that contain the frame data.
  135464. */
  135465. frames: Array<ISpriteJSONSprite>;
  135466. /**
  135467. * object basic object containing the sprite meta data.
  135468. */
  135469. meta?: object;
  135470. }
  135471. }
  135472. declare module BABYLON {
  135473. /** @hidden */
  135474. export var spriteMapPixelShader: {
  135475. name: string;
  135476. shader: string;
  135477. };
  135478. }
  135479. declare module BABYLON {
  135480. /** @hidden */
  135481. export var spriteMapVertexShader: {
  135482. name: string;
  135483. shader: string;
  135484. };
  135485. }
  135486. declare module BABYLON {
  135487. /**
  135488. * Defines the basic options interface of a SpriteMap
  135489. */
  135490. export interface ISpriteMapOptions {
  135491. /**
  135492. * Vector2 of the number of cells in the grid.
  135493. */
  135494. stageSize?: Vector2;
  135495. /**
  135496. * Vector2 of the size of the output plane in World Units.
  135497. */
  135498. outputSize?: Vector2;
  135499. /**
  135500. * Vector3 of the position of the output plane in World Units.
  135501. */
  135502. outputPosition?: Vector3;
  135503. /**
  135504. * Vector3 of the rotation of the output plane.
  135505. */
  135506. outputRotation?: Vector3;
  135507. /**
  135508. * number of layers that the system will reserve in resources.
  135509. */
  135510. layerCount?: number;
  135511. /**
  135512. * number of max animation frames a single cell will reserve in resources.
  135513. */
  135514. maxAnimationFrames?: number;
  135515. /**
  135516. * number cell index of the base tile when the system compiles.
  135517. */
  135518. baseTile?: number;
  135519. /**
  135520. * boolean flip the sprite after its been repositioned by the framing data.
  135521. */
  135522. flipU?: boolean;
  135523. /**
  135524. * Vector3 scalar of the global RGB values of the SpriteMap.
  135525. */
  135526. colorMultiply?: Vector3;
  135527. }
  135528. /**
  135529. * Defines the IDisposable interface in order to be cleanable from resources.
  135530. */
  135531. export interface ISpriteMap extends IDisposable {
  135532. /**
  135533. * String name of the SpriteMap.
  135534. */
  135535. name: string;
  135536. /**
  135537. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135538. */
  135539. atlasJSON: ISpriteJSONAtlas;
  135540. /**
  135541. * Texture of the SpriteMap.
  135542. */
  135543. spriteSheet: Texture;
  135544. /**
  135545. * The parameters to initialize the SpriteMap with.
  135546. */
  135547. options: ISpriteMapOptions;
  135548. }
  135549. /**
  135550. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135551. */
  135552. export class SpriteMap implements ISpriteMap {
  135553. /** The Name of the spriteMap */
  135554. name: string;
  135555. /** The JSON file with the frame and meta data */
  135556. atlasJSON: ISpriteJSONAtlas;
  135557. /** The systems Sprite Sheet Texture */
  135558. spriteSheet: Texture;
  135559. /** Arguments passed with the Constructor */
  135560. options: ISpriteMapOptions;
  135561. /** Public Sprite Storage array, parsed from atlasJSON */
  135562. sprites: Array<ISpriteJSONSprite>;
  135563. /** Returns the Number of Sprites in the System */
  135564. get spriteCount(): number;
  135565. /** Returns the Position of Output Plane*/
  135566. get position(): Vector3;
  135567. /** Returns the Position of Output Plane*/
  135568. set position(v: Vector3);
  135569. /** Returns the Rotation of Output Plane*/
  135570. get rotation(): Vector3;
  135571. /** Returns the Rotation of Output Plane*/
  135572. set rotation(v: Vector3);
  135573. /** Sets the AnimationMap*/
  135574. get animationMap(): RawTexture;
  135575. /** Sets the AnimationMap*/
  135576. set animationMap(v: RawTexture);
  135577. /** Scene that the SpriteMap was created in */
  135578. private _scene;
  135579. /** Texture Buffer of Float32 that holds tile frame data*/
  135580. private _frameMap;
  135581. /** Texture Buffers of Float32 that holds tileMap data*/
  135582. private _tileMaps;
  135583. /** Texture Buffer of Float32 that holds Animation Data*/
  135584. private _animationMap;
  135585. /** Custom ShaderMaterial Central to the System*/
  135586. private _material;
  135587. /** Custom ShaderMaterial Central to the System*/
  135588. private _output;
  135589. /** Systems Time Ticker*/
  135590. private _time;
  135591. /**
  135592. * Creates a new SpriteMap
  135593. * @param name defines the SpriteMaps Name
  135594. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135595. * @param spriteSheet is the Texture that the Sprites are on.
  135596. * @param options a basic deployment configuration
  135597. * @param scene The Scene that the map is deployed on
  135598. */
  135599. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135600. /**
  135601. * Returns tileID location
  135602. * @returns Vector2 the cell position ID
  135603. */
  135604. getTileID(): Vector2;
  135605. /**
  135606. * Gets the UV location of the mouse over the SpriteMap.
  135607. * @returns Vector2 the UV position of the mouse interaction
  135608. */
  135609. getMousePosition(): Vector2;
  135610. /**
  135611. * Creates the "frame" texture Buffer
  135612. * -------------------------------------
  135613. * Structure of frames
  135614. * "filename": "Falling-Water-2.png",
  135615. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135616. * "rotated": true,
  135617. * "trimmed": true,
  135618. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135619. * "sourceSize": {"w":32,"h":32}
  135620. * @returns RawTexture of the frameMap
  135621. */
  135622. private _createFrameBuffer;
  135623. /**
  135624. * Creates the tileMap texture Buffer
  135625. * @param buffer normally and array of numbers, or a false to generate from scratch
  135626. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135627. * @returns RawTexture of the tileMap
  135628. */
  135629. private _createTileBuffer;
  135630. /**
  135631. * Modifies the data of the tileMaps
  135632. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135633. * @param pos is the iVector2 Coordinates of the Tile
  135634. * @param tile The SpriteIndex of the new Tile
  135635. */
  135636. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135637. /**
  135638. * Creates the animationMap texture Buffer
  135639. * @param buffer normally and array of numbers, or a false to generate from scratch
  135640. * @returns RawTexture of the animationMap
  135641. */
  135642. private _createTileAnimationBuffer;
  135643. /**
  135644. * Modifies the data of the animationMap
  135645. * @param cellID is the Index of the Sprite
  135646. * @param _frame is the target Animation frame
  135647. * @param toCell is the Target Index of the next frame of the animation
  135648. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135649. * @param speed is a global scalar of the time variable on the map.
  135650. */
  135651. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135652. /**
  135653. * Exports the .tilemaps file
  135654. */
  135655. saveTileMaps(): void;
  135656. /**
  135657. * Imports the .tilemaps file
  135658. * @param url of the .tilemaps file
  135659. */
  135660. loadTileMaps(url: string): void;
  135661. /**
  135662. * Release associated resources
  135663. */
  135664. dispose(): void;
  135665. }
  135666. }
  135667. declare module BABYLON {
  135668. /**
  135669. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135670. * @see http://doc.babylonjs.com/babylon101/sprites
  135671. */
  135672. export class SpritePackedManager extends SpriteManager {
  135673. /** defines the packed manager's name */
  135674. name: string;
  135675. /**
  135676. * Creates a new sprite manager from a packed sprite sheet
  135677. * @param name defines the manager's name
  135678. * @param imgUrl defines the sprite sheet url
  135679. * @param capacity defines the maximum allowed number of sprites
  135680. * @param scene defines the hosting scene
  135681. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135682. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135683. * @param samplingMode defines the smapling mode to use with spritesheet
  135684. * @param fromPacked set to true; do not alter
  135685. */
  135686. constructor(
  135687. /** defines the packed manager's name */
  135688. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135689. }
  135690. }
  135691. declare module BABYLON {
  135692. /**
  135693. * Defines the list of states available for a task inside a AssetsManager
  135694. */
  135695. export enum AssetTaskState {
  135696. /**
  135697. * Initialization
  135698. */
  135699. INIT = 0,
  135700. /**
  135701. * Running
  135702. */
  135703. RUNNING = 1,
  135704. /**
  135705. * Done
  135706. */
  135707. DONE = 2,
  135708. /**
  135709. * Error
  135710. */
  135711. ERROR = 3
  135712. }
  135713. /**
  135714. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135715. */
  135716. export abstract class AbstractAssetTask {
  135717. /**
  135718. * Task name
  135719. */ name: string;
  135720. /**
  135721. * Callback called when the task is successful
  135722. */
  135723. onSuccess: (task: any) => void;
  135724. /**
  135725. * Callback called when the task is not successful
  135726. */
  135727. onError: (task: any, message?: string, exception?: any) => void;
  135728. /**
  135729. * Creates a new AssetsManager
  135730. * @param name defines the name of the task
  135731. */
  135732. constructor(
  135733. /**
  135734. * Task name
  135735. */ name: string);
  135736. private _isCompleted;
  135737. private _taskState;
  135738. private _errorObject;
  135739. /**
  135740. * Get if the task is completed
  135741. */
  135742. get isCompleted(): boolean;
  135743. /**
  135744. * Gets the current state of the task
  135745. */
  135746. get taskState(): AssetTaskState;
  135747. /**
  135748. * Gets the current error object (if task is in error)
  135749. */
  135750. get errorObject(): {
  135751. message?: string;
  135752. exception?: any;
  135753. };
  135754. /**
  135755. * Internal only
  135756. * @hidden
  135757. */
  135758. _setErrorObject(message?: string, exception?: any): void;
  135759. /**
  135760. * Execute the current task
  135761. * @param scene defines the scene where you want your assets to be loaded
  135762. * @param onSuccess is a callback called when the task is successfully executed
  135763. * @param onError is a callback called if an error occurs
  135764. */
  135765. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135766. /**
  135767. * Execute the current task
  135768. * @param scene defines the scene where you want your assets to be loaded
  135769. * @param onSuccess is a callback called when the task is successfully executed
  135770. * @param onError is a callback called if an error occurs
  135771. */
  135772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135773. /**
  135774. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135775. * This can be used with failed tasks that have the reason for failure fixed.
  135776. */
  135777. reset(): void;
  135778. private onErrorCallback;
  135779. private onDoneCallback;
  135780. }
  135781. /**
  135782. * Define the interface used by progress events raised during assets loading
  135783. */
  135784. export interface IAssetsProgressEvent {
  135785. /**
  135786. * Defines the number of remaining tasks to process
  135787. */
  135788. remainingCount: number;
  135789. /**
  135790. * Defines the total number of tasks
  135791. */
  135792. totalCount: number;
  135793. /**
  135794. * Defines the task that was just processed
  135795. */
  135796. task: AbstractAssetTask;
  135797. }
  135798. /**
  135799. * Class used to share progress information about assets loading
  135800. */
  135801. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135802. /**
  135803. * Defines the number of remaining tasks to process
  135804. */
  135805. remainingCount: number;
  135806. /**
  135807. * Defines the total number of tasks
  135808. */
  135809. totalCount: number;
  135810. /**
  135811. * Defines the task that was just processed
  135812. */
  135813. task: AbstractAssetTask;
  135814. /**
  135815. * Creates a AssetsProgressEvent
  135816. * @param remainingCount defines the number of remaining tasks to process
  135817. * @param totalCount defines the total number of tasks
  135818. * @param task defines the task that was just processed
  135819. */
  135820. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135821. }
  135822. /**
  135823. * Define a task used by AssetsManager to load meshes
  135824. */
  135825. export class MeshAssetTask extends AbstractAssetTask {
  135826. /**
  135827. * Defines the name of the task
  135828. */
  135829. name: string;
  135830. /**
  135831. * Defines the list of mesh's names you want to load
  135832. */
  135833. meshesNames: any;
  135834. /**
  135835. * Defines the root url to use as a base to load your meshes and associated resources
  135836. */
  135837. rootUrl: string;
  135838. /**
  135839. * Defines the filename of the scene to load from
  135840. */
  135841. sceneFilename: string;
  135842. /**
  135843. * Gets the list of loaded meshes
  135844. */
  135845. loadedMeshes: Array<AbstractMesh>;
  135846. /**
  135847. * Gets the list of loaded particle systems
  135848. */
  135849. loadedParticleSystems: Array<IParticleSystem>;
  135850. /**
  135851. * Gets the list of loaded skeletons
  135852. */
  135853. loadedSkeletons: Array<Skeleton>;
  135854. /**
  135855. * Gets the list of loaded animation groups
  135856. */
  135857. loadedAnimationGroups: Array<AnimationGroup>;
  135858. /**
  135859. * Callback called when the task is successful
  135860. */
  135861. onSuccess: (task: MeshAssetTask) => void;
  135862. /**
  135863. * Callback called when the task is successful
  135864. */
  135865. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  135866. /**
  135867. * Creates a new MeshAssetTask
  135868. * @param name defines the name of the task
  135869. * @param meshesNames defines the list of mesh's names you want to load
  135870. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  135871. * @param sceneFilename defines the filename of the scene to load from
  135872. */
  135873. constructor(
  135874. /**
  135875. * Defines the name of the task
  135876. */
  135877. name: string,
  135878. /**
  135879. * Defines the list of mesh's names you want to load
  135880. */
  135881. meshesNames: any,
  135882. /**
  135883. * Defines the root url to use as a base to load your meshes and associated resources
  135884. */
  135885. rootUrl: string,
  135886. /**
  135887. * Defines the filename of the scene to load from
  135888. */
  135889. sceneFilename: string);
  135890. /**
  135891. * Execute the current task
  135892. * @param scene defines the scene where you want your assets to be loaded
  135893. * @param onSuccess is a callback called when the task is successfully executed
  135894. * @param onError is a callback called if an error occurs
  135895. */
  135896. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135897. }
  135898. /**
  135899. * Define a task used by AssetsManager to load text content
  135900. */
  135901. export class TextFileAssetTask extends AbstractAssetTask {
  135902. /**
  135903. * Defines the name of the task
  135904. */
  135905. name: string;
  135906. /**
  135907. * Defines the location of the file to load
  135908. */
  135909. url: string;
  135910. /**
  135911. * Gets the loaded text string
  135912. */
  135913. text: string;
  135914. /**
  135915. * Callback called when the task is successful
  135916. */
  135917. onSuccess: (task: TextFileAssetTask) => void;
  135918. /**
  135919. * Callback called when the task is successful
  135920. */
  135921. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  135922. /**
  135923. * Creates a new TextFileAssetTask object
  135924. * @param name defines the name of the task
  135925. * @param url defines the location of the file to load
  135926. */
  135927. constructor(
  135928. /**
  135929. * Defines the name of the task
  135930. */
  135931. name: string,
  135932. /**
  135933. * Defines the location of the file to load
  135934. */
  135935. url: string);
  135936. /**
  135937. * Execute the current task
  135938. * @param scene defines the scene where you want your assets to be loaded
  135939. * @param onSuccess is a callback called when the task is successfully executed
  135940. * @param onError is a callback called if an error occurs
  135941. */
  135942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135943. }
  135944. /**
  135945. * Define a task used by AssetsManager to load binary data
  135946. */
  135947. export class BinaryFileAssetTask extends AbstractAssetTask {
  135948. /**
  135949. * Defines the name of the task
  135950. */
  135951. name: string;
  135952. /**
  135953. * Defines the location of the file to load
  135954. */
  135955. url: string;
  135956. /**
  135957. * Gets the lodaded data (as an array buffer)
  135958. */
  135959. data: ArrayBuffer;
  135960. /**
  135961. * Callback called when the task is successful
  135962. */
  135963. onSuccess: (task: BinaryFileAssetTask) => void;
  135964. /**
  135965. * Callback called when the task is successful
  135966. */
  135967. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  135968. /**
  135969. * Creates a new BinaryFileAssetTask object
  135970. * @param name defines the name of the new task
  135971. * @param url defines the location of the file to load
  135972. */
  135973. constructor(
  135974. /**
  135975. * Defines the name of the task
  135976. */
  135977. name: string,
  135978. /**
  135979. * Defines the location of the file to load
  135980. */
  135981. url: string);
  135982. /**
  135983. * Execute the current task
  135984. * @param scene defines the scene where you want your assets to be loaded
  135985. * @param onSuccess is a callback called when the task is successfully executed
  135986. * @param onError is a callback called if an error occurs
  135987. */
  135988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135989. }
  135990. /**
  135991. * Define a task used by AssetsManager to load images
  135992. */
  135993. export class ImageAssetTask extends AbstractAssetTask {
  135994. /**
  135995. * Defines the name of the task
  135996. */
  135997. name: string;
  135998. /**
  135999. * Defines the location of the image to load
  136000. */
  136001. url: string;
  136002. /**
  136003. * Gets the loaded images
  136004. */
  136005. image: HTMLImageElement;
  136006. /**
  136007. * Callback called when the task is successful
  136008. */
  136009. onSuccess: (task: ImageAssetTask) => void;
  136010. /**
  136011. * Callback called when the task is successful
  136012. */
  136013. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136014. /**
  136015. * Creates a new ImageAssetTask
  136016. * @param name defines the name of the task
  136017. * @param url defines the location of the image to load
  136018. */
  136019. constructor(
  136020. /**
  136021. * Defines the name of the task
  136022. */
  136023. name: string,
  136024. /**
  136025. * Defines the location of the image to load
  136026. */
  136027. url: string);
  136028. /**
  136029. * Execute the current task
  136030. * @param scene defines the scene where you want your assets to be loaded
  136031. * @param onSuccess is a callback called when the task is successfully executed
  136032. * @param onError is a callback called if an error occurs
  136033. */
  136034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136035. }
  136036. /**
  136037. * Defines the interface used by texture loading tasks
  136038. */
  136039. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136040. /**
  136041. * Gets the loaded texture
  136042. */
  136043. texture: TEX;
  136044. }
  136045. /**
  136046. * Define a task used by AssetsManager to load 2D textures
  136047. */
  136048. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136049. /**
  136050. * Defines the name of the task
  136051. */
  136052. name: string;
  136053. /**
  136054. * Defines the location of the file to load
  136055. */
  136056. url: string;
  136057. /**
  136058. * Defines if mipmap should not be generated (default is false)
  136059. */
  136060. noMipmap?: boolean | undefined;
  136061. /**
  136062. * Defines if texture must be inverted on Y axis (default is false)
  136063. */
  136064. invertY?: boolean | undefined;
  136065. /**
  136066. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136067. */
  136068. samplingMode: number;
  136069. /**
  136070. * Gets the loaded texture
  136071. */
  136072. texture: Texture;
  136073. /**
  136074. * Callback called when the task is successful
  136075. */
  136076. onSuccess: (task: TextureAssetTask) => void;
  136077. /**
  136078. * Callback called when the task is successful
  136079. */
  136080. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136081. /**
  136082. * Creates a new TextureAssetTask object
  136083. * @param name defines the name of the task
  136084. * @param url defines the location of the file to load
  136085. * @param noMipmap defines if mipmap should not be generated (default is false)
  136086. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136087. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136088. */
  136089. constructor(
  136090. /**
  136091. * Defines the name of the task
  136092. */
  136093. name: string,
  136094. /**
  136095. * Defines the location of the file to load
  136096. */
  136097. url: string,
  136098. /**
  136099. * Defines if mipmap should not be generated (default is false)
  136100. */
  136101. noMipmap?: boolean | undefined,
  136102. /**
  136103. * Defines if texture must be inverted on Y axis (default is false)
  136104. */
  136105. invertY?: boolean | undefined,
  136106. /**
  136107. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136108. */
  136109. samplingMode?: number);
  136110. /**
  136111. * Execute the current task
  136112. * @param scene defines the scene where you want your assets to be loaded
  136113. * @param onSuccess is a callback called when the task is successfully executed
  136114. * @param onError is a callback called if an error occurs
  136115. */
  136116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136117. }
  136118. /**
  136119. * Define a task used by AssetsManager to load cube textures
  136120. */
  136121. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136122. /**
  136123. * Defines the name of the task
  136124. */
  136125. name: string;
  136126. /**
  136127. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136128. */
  136129. url: string;
  136130. /**
  136131. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136132. */
  136133. extensions?: string[] | undefined;
  136134. /**
  136135. * Defines if mipmaps should not be generated (default is false)
  136136. */
  136137. noMipmap?: boolean | undefined;
  136138. /**
  136139. * Defines the explicit list of files (undefined by default)
  136140. */
  136141. files?: string[] | undefined;
  136142. /**
  136143. * Gets the loaded texture
  136144. */
  136145. texture: CubeTexture;
  136146. /**
  136147. * Callback called when the task is successful
  136148. */
  136149. onSuccess: (task: CubeTextureAssetTask) => void;
  136150. /**
  136151. * Callback called when the task is successful
  136152. */
  136153. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136154. /**
  136155. * Creates a new CubeTextureAssetTask
  136156. * @param name defines the name of the task
  136157. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136158. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136159. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136160. * @param files defines the explicit list of files (undefined by default)
  136161. */
  136162. constructor(
  136163. /**
  136164. * Defines the name of the task
  136165. */
  136166. name: string,
  136167. /**
  136168. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136169. */
  136170. url: string,
  136171. /**
  136172. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136173. */
  136174. extensions?: string[] | undefined,
  136175. /**
  136176. * Defines if mipmaps should not be generated (default is false)
  136177. */
  136178. noMipmap?: boolean | undefined,
  136179. /**
  136180. * Defines the explicit list of files (undefined by default)
  136181. */
  136182. files?: string[] | undefined);
  136183. /**
  136184. * Execute the current task
  136185. * @param scene defines the scene where you want your assets to be loaded
  136186. * @param onSuccess is a callback called when the task is successfully executed
  136187. * @param onError is a callback called if an error occurs
  136188. */
  136189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136190. }
  136191. /**
  136192. * Define a task used by AssetsManager to load HDR cube textures
  136193. */
  136194. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136195. /**
  136196. * Defines the name of the task
  136197. */
  136198. name: string;
  136199. /**
  136200. * Defines the location of the file to load
  136201. */
  136202. url: string;
  136203. /**
  136204. * Defines the desired size (the more it increases the longer the generation will be)
  136205. */
  136206. size: number;
  136207. /**
  136208. * Defines if mipmaps should not be generated (default is false)
  136209. */
  136210. noMipmap: boolean;
  136211. /**
  136212. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136213. */
  136214. generateHarmonics: boolean;
  136215. /**
  136216. * 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)
  136217. */
  136218. gammaSpace: boolean;
  136219. /**
  136220. * Internal Use Only
  136221. */
  136222. reserved: boolean;
  136223. /**
  136224. * Gets the loaded texture
  136225. */
  136226. texture: HDRCubeTexture;
  136227. /**
  136228. * Callback called when the task is successful
  136229. */
  136230. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136231. /**
  136232. * Callback called when the task is successful
  136233. */
  136234. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136235. /**
  136236. * Creates a new HDRCubeTextureAssetTask object
  136237. * @param name defines the name of the task
  136238. * @param url defines the location of the file to load
  136239. * @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.
  136240. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136241. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136242. * @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)
  136243. * @param reserved Internal use only
  136244. */
  136245. constructor(
  136246. /**
  136247. * Defines the name of the task
  136248. */
  136249. name: string,
  136250. /**
  136251. * Defines the location of the file to load
  136252. */
  136253. url: string,
  136254. /**
  136255. * Defines the desired size (the more it increases the longer the generation will be)
  136256. */
  136257. size: number,
  136258. /**
  136259. * Defines if mipmaps should not be generated (default is false)
  136260. */
  136261. noMipmap?: boolean,
  136262. /**
  136263. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136264. */
  136265. generateHarmonics?: boolean,
  136266. /**
  136267. * 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)
  136268. */
  136269. gammaSpace?: boolean,
  136270. /**
  136271. * Internal Use Only
  136272. */
  136273. reserved?: boolean);
  136274. /**
  136275. * Execute the current task
  136276. * @param scene defines the scene where you want your assets to be loaded
  136277. * @param onSuccess is a callback called when the task is successfully executed
  136278. * @param onError is a callback called if an error occurs
  136279. */
  136280. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136281. }
  136282. /**
  136283. * Define a task used by AssetsManager to load Equirectangular cube textures
  136284. */
  136285. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136286. /**
  136287. * Defines the name of the task
  136288. */
  136289. name: string;
  136290. /**
  136291. * Defines the location of the file to load
  136292. */
  136293. url: string;
  136294. /**
  136295. * Defines the desired size (the more it increases the longer the generation will be)
  136296. */
  136297. size: number;
  136298. /**
  136299. * Defines if mipmaps should not be generated (default is false)
  136300. */
  136301. noMipmap: boolean;
  136302. /**
  136303. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136304. * but the standard material would require them in Gamma space) (default is true)
  136305. */
  136306. gammaSpace: boolean;
  136307. /**
  136308. * Gets the loaded texture
  136309. */
  136310. texture: EquiRectangularCubeTexture;
  136311. /**
  136312. * Callback called when the task is successful
  136313. */
  136314. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136315. /**
  136316. * Callback called when the task is successful
  136317. */
  136318. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136319. /**
  136320. * Creates a new EquiRectangularCubeTextureAssetTask object
  136321. * @param name defines the name of the task
  136322. * @param url defines the location of the file to load
  136323. * @param size defines the desired size (the more it increases the longer the generation will be)
  136324. * If the size is omitted this implies you are using a preprocessed cubemap.
  136325. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136326. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136327. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136328. * (default is true)
  136329. */
  136330. constructor(
  136331. /**
  136332. * Defines the name of the task
  136333. */
  136334. name: string,
  136335. /**
  136336. * Defines the location of the file to load
  136337. */
  136338. url: string,
  136339. /**
  136340. * Defines the desired size (the more it increases the longer the generation will be)
  136341. */
  136342. size: number,
  136343. /**
  136344. * Defines if mipmaps should not be generated (default is false)
  136345. */
  136346. noMipmap?: boolean,
  136347. /**
  136348. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136349. * but the standard material would require them in Gamma space) (default is true)
  136350. */
  136351. gammaSpace?: boolean);
  136352. /**
  136353. * Execute the current task
  136354. * @param scene defines the scene where you want your assets to be loaded
  136355. * @param onSuccess is a callback called when the task is successfully executed
  136356. * @param onError is a callback called if an error occurs
  136357. */
  136358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136359. }
  136360. /**
  136361. * This class can be used to easily import assets into a scene
  136362. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136363. */
  136364. export class AssetsManager {
  136365. private _scene;
  136366. private _isLoading;
  136367. protected _tasks: AbstractAssetTask[];
  136368. protected _waitingTasksCount: number;
  136369. protected _totalTasksCount: number;
  136370. /**
  136371. * Callback called when all tasks are processed
  136372. */
  136373. onFinish: (tasks: AbstractAssetTask[]) => void;
  136374. /**
  136375. * Callback called when a task is successful
  136376. */
  136377. onTaskSuccess: (task: AbstractAssetTask) => void;
  136378. /**
  136379. * Callback called when a task had an error
  136380. */
  136381. onTaskError: (task: AbstractAssetTask) => void;
  136382. /**
  136383. * Callback called when a task is done (whatever the result is)
  136384. */
  136385. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136386. /**
  136387. * Observable called when all tasks are processed
  136388. */
  136389. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136390. /**
  136391. * Observable called when a task had an error
  136392. */
  136393. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136394. /**
  136395. * Observable called when all tasks were executed
  136396. */
  136397. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136398. /**
  136399. * Observable called when a task is done (whatever the result is)
  136400. */
  136401. onProgressObservable: Observable<IAssetsProgressEvent>;
  136402. /**
  136403. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136405. */
  136406. useDefaultLoadingScreen: boolean;
  136407. /**
  136408. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136409. * when all assets have been downloaded.
  136410. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136411. */
  136412. autoHideLoadingUI: boolean;
  136413. /**
  136414. * Creates a new AssetsManager
  136415. * @param scene defines the scene to work on
  136416. */
  136417. constructor(scene: Scene);
  136418. /**
  136419. * Add a MeshAssetTask to the list of active tasks
  136420. * @param taskName defines the name of the new task
  136421. * @param meshesNames defines the name of meshes to load
  136422. * @param rootUrl defines the root url to use to locate files
  136423. * @param sceneFilename defines the filename of the scene file
  136424. * @returns a new MeshAssetTask object
  136425. */
  136426. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136427. /**
  136428. * Add a TextFileAssetTask to the list of active tasks
  136429. * @param taskName defines the name of the new task
  136430. * @param url defines the url of the file to load
  136431. * @returns a new TextFileAssetTask object
  136432. */
  136433. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136434. /**
  136435. * Add a BinaryFileAssetTask to the list of active tasks
  136436. * @param taskName defines the name of the new task
  136437. * @param url defines the url of the file to load
  136438. * @returns a new BinaryFileAssetTask object
  136439. */
  136440. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136441. /**
  136442. * Add a ImageAssetTask to the list of active tasks
  136443. * @param taskName defines the name of the new task
  136444. * @param url defines the url of the file to load
  136445. * @returns a new ImageAssetTask object
  136446. */
  136447. addImageTask(taskName: string, url: string): ImageAssetTask;
  136448. /**
  136449. * Add a TextureAssetTask to the list of active tasks
  136450. * @param taskName defines the name of the new task
  136451. * @param url defines the url of the file to load
  136452. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136453. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136454. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136455. * @returns a new TextureAssetTask object
  136456. */
  136457. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136458. /**
  136459. * Add a CubeTextureAssetTask to the list of active tasks
  136460. * @param taskName defines the name of the new task
  136461. * @param url defines the url of the file to load
  136462. * @param extensions defines the extension to use to load the cube map (can be null)
  136463. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136464. * @param files defines the list of files to load (can be null)
  136465. * @returns a new CubeTextureAssetTask object
  136466. */
  136467. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136468. /**
  136469. *
  136470. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136471. * @param taskName defines the name of the new task
  136472. * @param url defines the url of the file to load
  136473. * @param size defines the size you want for the cubemap (can be null)
  136474. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136475. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136476. * @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)
  136477. * @param reserved Internal use only
  136478. * @returns a new HDRCubeTextureAssetTask object
  136479. */
  136480. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136481. /**
  136482. *
  136483. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136484. * @param taskName defines the name of the new task
  136485. * @param url defines the url of the file to load
  136486. * @param size defines the size you want for the cubemap (can be null)
  136487. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136488. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136489. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136490. * @returns a new EquiRectangularCubeTextureAssetTask object
  136491. */
  136492. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136493. /**
  136494. * Remove a task from the assets manager.
  136495. * @param task the task to remove
  136496. */
  136497. removeTask(task: AbstractAssetTask): void;
  136498. private _decreaseWaitingTasksCount;
  136499. private _runTask;
  136500. /**
  136501. * Reset the AssetsManager and remove all tasks
  136502. * @return the current instance of the AssetsManager
  136503. */
  136504. reset(): AssetsManager;
  136505. /**
  136506. * Start the loading process
  136507. * @return the current instance of the AssetsManager
  136508. */
  136509. load(): AssetsManager;
  136510. /**
  136511. * Start the loading process as an async operation
  136512. * @return a promise returning the list of failed tasks
  136513. */
  136514. loadAsync(): Promise<void>;
  136515. }
  136516. }
  136517. declare module BABYLON {
  136518. /**
  136519. * Wrapper class for promise with external resolve and reject.
  136520. */
  136521. export class Deferred<T> {
  136522. /**
  136523. * The promise associated with this deferred object.
  136524. */
  136525. readonly promise: Promise<T>;
  136526. private _resolve;
  136527. private _reject;
  136528. /**
  136529. * The resolve method of the promise associated with this deferred object.
  136530. */
  136531. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136532. /**
  136533. * The reject method of the promise associated with this deferred object.
  136534. */
  136535. get reject(): (reason?: any) => void;
  136536. /**
  136537. * Constructor for this deferred object.
  136538. */
  136539. constructor();
  136540. }
  136541. }
  136542. declare module BABYLON {
  136543. /**
  136544. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136545. */
  136546. export class MeshExploder {
  136547. private _centerMesh;
  136548. private _meshes;
  136549. private _meshesOrigins;
  136550. private _toCenterVectors;
  136551. private _scaledDirection;
  136552. private _newPosition;
  136553. private _centerPosition;
  136554. /**
  136555. * Explodes meshes from a center mesh.
  136556. * @param meshes The meshes to explode.
  136557. * @param centerMesh The mesh to be center of explosion.
  136558. */
  136559. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136560. private _setCenterMesh;
  136561. /**
  136562. * Get class name
  136563. * @returns "MeshExploder"
  136564. */
  136565. getClassName(): string;
  136566. /**
  136567. * "Exploded meshes"
  136568. * @returns Array of meshes with the centerMesh at index 0.
  136569. */
  136570. getMeshes(): Array<Mesh>;
  136571. /**
  136572. * Explodes meshes giving a specific direction
  136573. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136574. */
  136575. explode(direction?: number): void;
  136576. }
  136577. }
  136578. declare module BABYLON {
  136579. /**
  136580. * Class used to help managing file picking and drag'n'drop
  136581. */
  136582. export class FilesInput {
  136583. /**
  136584. * List of files ready to be loaded
  136585. */
  136586. static get FilesToLoad(): {
  136587. [key: string]: File;
  136588. };
  136589. /**
  136590. * Callback called when a file is processed
  136591. */
  136592. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136593. private _engine;
  136594. private _currentScene;
  136595. private _sceneLoadedCallback;
  136596. private _progressCallback;
  136597. private _additionalRenderLoopLogicCallback;
  136598. private _textureLoadingCallback;
  136599. private _startingProcessingFilesCallback;
  136600. private _onReloadCallback;
  136601. private _errorCallback;
  136602. private _elementToMonitor;
  136603. private _sceneFileToLoad;
  136604. private _filesToLoad;
  136605. /**
  136606. * Creates a new FilesInput
  136607. * @param engine defines the rendering engine
  136608. * @param scene defines the hosting scene
  136609. * @param sceneLoadedCallback callback called when scene is loaded
  136610. * @param progressCallback callback called to track progress
  136611. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136612. * @param textureLoadingCallback callback called when a texture is loading
  136613. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136614. * @param onReloadCallback callback called when a reload is requested
  136615. * @param errorCallback callback call if an error occurs
  136616. */
  136617. 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);
  136618. private _dragEnterHandler;
  136619. private _dragOverHandler;
  136620. private _dropHandler;
  136621. /**
  136622. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136623. * @param elementToMonitor defines the DOM element to track
  136624. */
  136625. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136626. /**
  136627. * Release all associated resources
  136628. */
  136629. dispose(): void;
  136630. private renderFunction;
  136631. private drag;
  136632. private drop;
  136633. private _traverseFolder;
  136634. private _processFiles;
  136635. /**
  136636. * Load files from a drop event
  136637. * @param event defines the drop event to use as source
  136638. */
  136639. loadFiles(event: any): void;
  136640. private _processReload;
  136641. /**
  136642. * Reload the current scene from the loaded files
  136643. */
  136644. reload(): void;
  136645. }
  136646. }
  136647. declare module BABYLON {
  136648. /**
  136649. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136651. */
  136652. export class SceneOptimization {
  136653. /**
  136654. * Defines the priority of this optimization (0 by default which means first in the list)
  136655. */
  136656. priority: number;
  136657. /**
  136658. * Gets a string describing the action executed by the current optimization
  136659. * @returns description string
  136660. */
  136661. getDescription(): string;
  136662. /**
  136663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136664. * @param scene defines the current scene where to apply this optimization
  136665. * @param optimizer defines the current optimizer
  136666. * @returns true if everything that can be done was applied
  136667. */
  136668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136669. /**
  136670. * Creates the SceneOptimization object
  136671. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136672. * @param desc defines the description associated with the optimization
  136673. */
  136674. constructor(
  136675. /**
  136676. * Defines the priority of this optimization (0 by default which means first in the list)
  136677. */
  136678. priority?: number);
  136679. }
  136680. /**
  136681. * Defines an optimization used to reduce the size of render target textures
  136682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136683. */
  136684. export class TextureOptimization extends SceneOptimization {
  136685. /**
  136686. * Defines the priority of this optimization (0 by default which means first in the list)
  136687. */
  136688. priority: number;
  136689. /**
  136690. * 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
  136691. */
  136692. maximumSize: number;
  136693. /**
  136694. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136695. */
  136696. step: number;
  136697. /**
  136698. * Gets a string describing the action executed by the current optimization
  136699. * @returns description string
  136700. */
  136701. getDescription(): string;
  136702. /**
  136703. * Creates the TextureOptimization object
  136704. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136705. * @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
  136706. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136707. */
  136708. constructor(
  136709. /**
  136710. * Defines the priority of this optimization (0 by default which means first in the list)
  136711. */
  136712. priority?: number,
  136713. /**
  136714. * 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
  136715. */
  136716. maximumSize?: number,
  136717. /**
  136718. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136719. */
  136720. step?: number);
  136721. /**
  136722. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136723. * @param scene defines the current scene where to apply this optimization
  136724. * @param optimizer defines the current optimizer
  136725. * @returns true if everything that can be done was applied
  136726. */
  136727. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136728. }
  136729. /**
  136730. * Defines an optimization used to increase or decrease the rendering resolution
  136731. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136732. */
  136733. export class HardwareScalingOptimization extends SceneOptimization {
  136734. /**
  136735. * Defines the priority of this optimization (0 by default which means first in the list)
  136736. */
  136737. priority: number;
  136738. /**
  136739. * Defines the maximum scale to use (2 by default)
  136740. */
  136741. maximumScale: number;
  136742. /**
  136743. * Defines the step to use between two passes (0.5 by default)
  136744. */
  136745. step: number;
  136746. private _currentScale;
  136747. private _directionOffset;
  136748. /**
  136749. * Gets a string describing the action executed by the current optimization
  136750. * @return description string
  136751. */
  136752. getDescription(): string;
  136753. /**
  136754. * Creates the HardwareScalingOptimization object
  136755. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136756. * @param maximumScale defines the maximum scale to use (2 by default)
  136757. * @param step defines the step to use between two passes (0.5 by default)
  136758. */
  136759. constructor(
  136760. /**
  136761. * Defines the priority of this optimization (0 by default which means first in the list)
  136762. */
  136763. priority?: number,
  136764. /**
  136765. * Defines the maximum scale to use (2 by default)
  136766. */
  136767. maximumScale?: number,
  136768. /**
  136769. * Defines the step to use between two passes (0.5 by default)
  136770. */
  136771. step?: number);
  136772. /**
  136773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136774. * @param scene defines the current scene where to apply this optimization
  136775. * @param optimizer defines the current optimizer
  136776. * @returns true if everything that can be done was applied
  136777. */
  136778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136779. }
  136780. /**
  136781. * Defines an optimization used to remove shadows
  136782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136783. */
  136784. export class ShadowsOptimization extends SceneOptimization {
  136785. /**
  136786. * Gets a string describing the action executed by the current optimization
  136787. * @return description string
  136788. */
  136789. getDescription(): string;
  136790. /**
  136791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136792. * @param scene defines the current scene where to apply this optimization
  136793. * @param optimizer defines the current optimizer
  136794. * @returns true if everything that can be done was applied
  136795. */
  136796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136797. }
  136798. /**
  136799. * Defines an optimization used to turn post-processes off
  136800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136801. */
  136802. export class PostProcessesOptimization extends SceneOptimization {
  136803. /**
  136804. * Gets a string describing the action executed by the current optimization
  136805. * @return description string
  136806. */
  136807. getDescription(): string;
  136808. /**
  136809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136810. * @param scene defines the current scene where to apply this optimization
  136811. * @param optimizer defines the current optimizer
  136812. * @returns true if everything that can be done was applied
  136813. */
  136814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136815. }
  136816. /**
  136817. * Defines an optimization used to turn lens flares off
  136818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136819. */
  136820. export class LensFlaresOptimization extends SceneOptimization {
  136821. /**
  136822. * Gets a string describing the action executed by the current optimization
  136823. * @return description string
  136824. */
  136825. getDescription(): string;
  136826. /**
  136827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136828. * @param scene defines the current scene where to apply this optimization
  136829. * @param optimizer defines the current optimizer
  136830. * @returns true if everything that can be done was applied
  136831. */
  136832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136833. }
  136834. /**
  136835. * Defines an optimization based on user defined callback.
  136836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136837. */
  136838. export class CustomOptimization extends SceneOptimization {
  136839. /**
  136840. * Callback called to apply the custom optimization.
  136841. */
  136842. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  136843. /**
  136844. * Callback called to get custom description
  136845. */
  136846. onGetDescription: () => string;
  136847. /**
  136848. * Gets a string describing the action executed by the current optimization
  136849. * @returns description string
  136850. */
  136851. getDescription(): string;
  136852. /**
  136853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136854. * @param scene defines the current scene where to apply this optimization
  136855. * @param optimizer defines the current optimizer
  136856. * @returns true if everything that can be done was applied
  136857. */
  136858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136859. }
  136860. /**
  136861. * Defines an optimization used to turn particles off
  136862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136863. */
  136864. export class ParticlesOptimization extends SceneOptimization {
  136865. /**
  136866. * Gets a string describing the action executed by the current optimization
  136867. * @return description string
  136868. */
  136869. getDescription(): string;
  136870. /**
  136871. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136872. * @param scene defines the current scene where to apply this optimization
  136873. * @param optimizer defines the current optimizer
  136874. * @returns true if everything that can be done was applied
  136875. */
  136876. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136877. }
  136878. /**
  136879. * Defines an optimization used to turn render targets off
  136880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136881. */
  136882. export class RenderTargetsOptimization extends SceneOptimization {
  136883. /**
  136884. * Gets a string describing the action executed by the current optimization
  136885. * @return description string
  136886. */
  136887. getDescription(): string;
  136888. /**
  136889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136890. * @param scene defines the current scene where to apply this optimization
  136891. * @param optimizer defines the current optimizer
  136892. * @returns true if everything that can be done was applied
  136893. */
  136894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136895. }
  136896. /**
  136897. * Defines an optimization used to merge meshes with compatible materials
  136898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136899. */
  136900. export class MergeMeshesOptimization extends SceneOptimization {
  136901. private static _UpdateSelectionTree;
  136902. /**
  136903. * Gets or sets a boolean which defines if optimization octree has to be updated
  136904. */
  136905. static get UpdateSelectionTree(): boolean;
  136906. /**
  136907. * Gets or sets a boolean which defines if optimization octree has to be updated
  136908. */
  136909. static set UpdateSelectionTree(value: boolean);
  136910. /**
  136911. * Gets a string describing the action executed by the current optimization
  136912. * @return description string
  136913. */
  136914. getDescription(): string;
  136915. private _canBeMerged;
  136916. /**
  136917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136918. * @param scene defines the current scene where to apply this optimization
  136919. * @param optimizer defines the current optimizer
  136920. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  136921. * @returns true if everything that can be done was applied
  136922. */
  136923. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  136924. }
  136925. /**
  136926. * Defines a list of options used by SceneOptimizer
  136927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136928. */
  136929. export class SceneOptimizerOptions {
  136930. /**
  136931. * Defines the target frame rate to reach (60 by default)
  136932. */
  136933. targetFrameRate: number;
  136934. /**
  136935. * Defines the interval between two checkes (2000ms by default)
  136936. */
  136937. trackerDuration: number;
  136938. /**
  136939. * Gets the list of optimizations to apply
  136940. */
  136941. optimizations: SceneOptimization[];
  136942. /**
  136943. * Creates a new list of options used by SceneOptimizer
  136944. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  136945. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  136946. */
  136947. constructor(
  136948. /**
  136949. * Defines the target frame rate to reach (60 by default)
  136950. */
  136951. targetFrameRate?: number,
  136952. /**
  136953. * Defines the interval between two checkes (2000ms by default)
  136954. */
  136955. trackerDuration?: number);
  136956. /**
  136957. * Add a new optimization
  136958. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  136959. * @returns the current SceneOptimizerOptions
  136960. */
  136961. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  136962. /**
  136963. * Add a new custom optimization
  136964. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  136965. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  136966. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136967. * @returns the current SceneOptimizerOptions
  136968. */
  136969. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  136970. /**
  136971. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  136972. * @param targetFrameRate defines the target frame rate (60 by default)
  136973. * @returns a SceneOptimizerOptions object
  136974. */
  136975. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136976. /**
  136977. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  136978. * @param targetFrameRate defines the target frame rate (60 by default)
  136979. * @returns a SceneOptimizerOptions object
  136980. */
  136981. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136982. /**
  136983. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  136984. * @param targetFrameRate defines the target frame rate (60 by default)
  136985. * @returns a SceneOptimizerOptions object
  136986. */
  136987. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  136988. }
  136989. /**
  136990. * Class used to run optimizations in order to reach a target frame rate
  136991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136992. */
  136993. export class SceneOptimizer implements IDisposable {
  136994. private _isRunning;
  136995. private _options;
  136996. private _scene;
  136997. private _currentPriorityLevel;
  136998. private _targetFrameRate;
  136999. private _trackerDuration;
  137000. private _currentFrameRate;
  137001. private _sceneDisposeObserver;
  137002. private _improvementMode;
  137003. /**
  137004. * Defines an observable called when the optimizer reaches the target frame rate
  137005. */
  137006. onSuccessObservable: Observable<SceneOptimizer>;
  137007. /**
  137008. * Defines an observable called when the optimizer enables an optimization
  137009. */
  137010. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137011. /**
  137012. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137013. */
  137014. onFailureObservable: Observable<SceneOptimizer>;
  137015. /**
  137016. * Gets a boolean indicating if the optimizer is in improvement mode
  137017. */
  137018. get isInImprovementMode(): boolean;
  137019. /**
  137020. * Gets the current priority level (0 at start)
  137021. */
  137022. get currentPriorityLevel(): number;
  137023. /**
  137024. * Gets the current frame rate checked by the SceneOptimizer
  137025. */
  137026. get currentFrameRate(): number;
  137027. /**
  137028. * Gets or sets the current target frame rate (60 by default)
  137029. */
  137030. get targetFrameRate(): number;
  137031. /**
  137032. * Gets or sets the current target frame rate (60 by default)
  137033. */
  137034. set targetFrameRate(value: number);
  137035. /**
  137036. * Gets or sets the current interval between two checks (every 2000ms by default)
  137037. */
  137038. get trackerDuration(): number;
  137039. /**
  137040. * Gets or sets the current interval between two checks (every 2000ms by default)
  137041. */
  137042. set trackerDuration(value: number);
  137043. /**
  137044. * Gets the list of active optimizations
  137045. */
  137046. get optimizations(): SceneOptimization[];
  137047. /**
  137048. * Creates a new SceneOptimizer
  137049. * @param scene defines the scene to work on
  137050. * @param options defines the options to use with the SceneOptimizer
  137051. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137052. * @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)
  137053. */
  137054. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137055. /**
  137056. * Stops the current optimizer
  137057. */
  137058. stop(): void;
  137059. /**
  137060. * Reset the optimizer to initial step (current priority level = 0)
  137061. */
  137062. reset(): void;
  137063. /**
  137064. * Start the optimizer. By default it will try to reach a specific framerate
  137065. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137066. */
  137067. start(): void;
  137068. private _checkCurrentState;
  137069. /**
  137070. * Release all resources
  137071. */
  137072. dispose(): void;
  137073. /**
  137074. * Helper function to create a SceneOptimizer with one single line of code
  137075. * @param scene defines the scene to work on
  137076. * @param options defines the options to use with the SceneOptimizer
  137077. * @param onSuccess defines a callback to call on success
  137078. * @param onFailure defines a callback to call on failure
  137079. * @returns the new SceneOptimizer object
  137080. */
  137081. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137082. }
  137083. }
  137084. declare module BABYLON {
  137085. /**
  137086. * Class used to serialize a scene into a string
  137087. */
  137088. export class SceneSerializer {
  137089. /**
  137090. * Clear cache used by a previous serialization
  137091. */
  137092. static ClearCache(): void;
  137093. /**
  137094. * Serialize a scene into a JSON compatible object
  137095. * @param scene defines the scene to serialize
  137096. * @returns a JSON compatible object
  137097. */
  137098. static Serialize(scene: Scene): any;
  137099. /**
  137100. * Serialize a mesh into a JSON compatible object
  137101. * @param toSerialize defines the mesh to serialize
  137102. * @param withParents defines if parents must be serialized as well
  137103. * @param withChildren defines if children must be serialized as well
  137104. * @returns a JSON compatible object
  137105. */
  137106. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137107. }
  137108. }
  137109. declare module BABYLON {
  137110. /**
  137111. * Class used to host texture specific utilities
  137112. */
  137113. export class TextureTools {
  137114. /**
  137115. * Uses the GPU to create a copy texture rescaled at a given size
  137116. * @param texture Texture to copy from
  137117. * @param width defines the desired width
  137118. * @param height defines the desired height
  137119. * @param useBilinearMode defines if bilinear mode has to be used
  137120. * @return the generated texture
  137121. */
  137122. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137123. }
  137124. }
  137125. declare module BABYLON {
  137126. /**
  137127. * This represents the different options available for the video capture.
  137128. */
  137129. export interface VideoRecorderOptions {
  137130. /** Defines the mime type of the video. */
  137131. mimeType: string;
  137132. /** Defines the FPS the video should be recorded at. */
  137133. fps: number;
  137134. /** Defines the chunk size for the recording data. */
  137135. recordChunckSize: number;
  137136. /** The audio tracks to attach to the recording. */
  137137. audioTracks?: MediaStreamTrack[];
  137138. }
  137139. /**
  137140. * This can help with recording videos from BabylonJS.
  137141. * This is based on the available WebRTC functionalities of the browser.
  137142. *
  137143. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137144. */
  137145. export class VideoRecorder {
  137146. private static readonly _defaultOptions;
  137147. /**
  137148. * Returns whether or not the VideoRecorder is available in your browser.
  137149. * @param engine Defines the Babylon Engine.
  137150. * @returns true if supported otherwise false.
  137151. */
  137152. static IsSupported(engine: Engine): boolean;
  137153. private readonly _options;
  137154. private _canvas;
  137155. private _mediaRecorder;
  137156. private _recordedChunks;
  137157. private _fileName;
  137158. private _resolve;
  137159. private _reject;
  137160. /**
  137161. * True when a recording is already in progress.
  137162. */
  137163. get isRecording(): boolean;
  137164. /**
  137165. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137166. * @param engine Defines the BabylonJS Engine you wish to record.
  137167. * @param options Defines options that can be used to customize the capture.
  137168. */
  137169. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137170. /**
  137171. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137172. */
  137173. stopRecording(): void;
  137174. /**
  137175. * Starts recording the canvas for a max duration specified in parameters.
  137176. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137177. * If null no automatic download will start and you can rely on the promise to get the data back.
  137178. * @param maxDuration Defines the maximum recording time in seconds.
  137179. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137180. * @return A promise callback at the end of the recording with the video data in Blob.
  137181. */
  137182. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137183. /**
  137184. * Releases internal resources used during the recording.
  137185. */
  137186. dispose(): void;
  137187. private _handleDataAvailable;
  137188. private _handleError;
  137189. private _handleStop;
  137190. }
  137191. }
  137192. declare module BABYLON {
  137193. /**
  137194. * Class containing a set of static utilities functions for screenshots
  137195. */
  137196. export class ScreenshotTools {
  137197. /**
  137198. * Captures a screenshot of the current rendering
  137199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137200. * @param engine defines the rendering engine
  137201. * @param camera defines the source camera
  137202. * @param size This parameter can be set to a single number or to an object with the
  137203. * following (optional) properties: precision, width, height. If a single number is passed,
  137204. * it will be used for both width and height. If an object is passed, the screenshot size
  137205. * will be derived from the parameters. The precision property is a multiplier allowing
  137206. * rendering at a higher or lower resolution
  137207. * @param successCallback defines the callback receives a single parameter which contains the
  137208. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137209. * src parameter of an <img> to display it
  137210. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137211. * Check your browser for supported MIME types
  137212. */
  137213. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137214. /**
  137215. * Captures a screenshot of the current rendering
  137216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137217. * @param engine defines the rendering engine
  137218. * @param camera defines the source camera
  137219. * @param size This parameter can be set to a single number or to an object with the
  137220. * following (optional) properties: precision, width, height. If a single number is passed,
  137221. * it will be used for both width and height. If an object is passed, the screenshot size
  137222. * will be derived from the parameters. The precision property is a multiplier allowing
  137223. * rendering at a higher or lower resolution
  137224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137225. * Check your browser for supported MIME types
  137226. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137227. * to the src parameter of an <img> to display it
  137228. */
  137229. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137230. /**
  137231. * Generates an image screenshot from the specified camera.
  137232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137233. * @param engine The engine to use for rendering
  137234. * @param camera The camera to use for rendering
  137235. * @param size This parameter can be set to a single number or to an object with the
  137236. * following (optional) properties: precision, width, height. If a single number is passed,
  137237. * it will be used for both width and height. If an object is passed, the screenshot size
  137238. * will be derived from the parameters. The precision property is a multiplier allowing
  137239. * rendering at a higher or lower resolution
  137240. * @param successCallback The callback receives a single parameter which contains the
  137241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137242. * src parameter of an <img> to display it
  137243. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137244. * Check your browser for supported MIME types
  137245. * @param samples Texture samples (default: 1)
  137246. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137247. * @param fileName A name for for the downloaded file.
  137248. */
  137249. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137250. /**
  137251. * Generates an image screenshot from the specified camera.
  137252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137253. * @param engine The engine to use for rendering
  137254. * @param camera The camera to use for rendering
  137255. * @param size This parameter can be set to a single number or to an object with the
  137256. * following (optional) properties: precision, width, height. If a single number is passed,
  137257. * it will be used for both width and height. If an object is passed, the screenshot size
  137258. * will be derived from the parameters. The precision property is a multiplier allowing
  137259. * rendering at a higher or lower resolution
  137260. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137261. * Check your browser for supported MIME types
  137262. * @param samples Texture samples (default: 1)
  137263. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137264. * @param fileName A name for for the downloaded file.
  137265. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137266. * to the src parameter of an <img> to display it
  137267. */
  137268. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137269. /**
  137270. * Gets height and width for screenshot size
  137271. * @private
  137272. */
  137273. private static _getScreenshotSize;
  137274. }
  137275. }
  137276. declare module BABYLON {
  137277. /**
  137278. * Interface for a data buffer
  137279. */
  137280. export interface IDataBuffer {
  137281. /**
  137282. * Reads bytes from the data buffer.
  137283. * @param byteOffset The byte offset to read
  137284. * @param byteLength The byte length to read
  137285. * @returns A promise that resolves when the bytes are read
  137286. */
  137287. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137288. /**
  137289. * The byte length of the buffer.
  137290. */
  137291. readonly byteLength: number;
  137292. }
  137293. /**
  137294. * Utility class for reading from a data buffer
  137295. */
  137296. export class DataReader {
  137297. /**
  137298. * The data buffer associated with this data reader.
  137299. */
  137300. readonly buffer: IDataBuffer;
  137301. /**
  137302. * The current byte offset from the beginning of the data buffer.
  137303. */
  137304. byteOffset: number;
  137305. private _dataView;
  137306. private _dataByteOffset;
  137307. /**
  137308. * Constructor
  137309. * @param buffer The buffer to read
  137310. */
  137311. constructor(buffer: IDataBuffer);
  137312. /**
  137313. * Loads the given byte length.
  137314. * @param byteLength The byte length to load
  137315. * @returns A promise that resolves when the load is complete
  137316. */
  137317. loadAsync(byteLength: number): Promise<void>;
  137318. /**
  137319. * Read a unsigned 32-bit integer from the currently loaded data range.
  137320. * @returns The 32-bit integer read
  137321. */
  137322. readUint32(): number;
  137323. /**
  137324. * Read a byte array from the currently loaded data range.
  137325. * @param byteLength The byte length to read
  137326. * @returns The byte array read
  137327. */
  137328. readUint8Array(byteLength: number): Uint8Array;
  137329. /**
  137330. * Read a string from the currently loaded data range.
  137331. * @param byteLength The byte length to read
  137332. * @returns The string read
  137333. */
  137334. readString(byteLength: number): string;
  137335. /**
  137336. * Skips the given byte length the currently loaded data range.
  137337. * @param byteLength The byte length to skip
  137338. */
  137339. skipBytes(byteLength: number): void;
  137340. }
  137341. }
  137342. declare module BABYLON {
  137343. /**
  137344. * A cursor which tracks a point on a path
  137345. */
  137346. export class PathCursor {
  137347. private path;
  137348. /**
  137349. * Stores path cursor callbacks for when an onchange event is triggered
  137350. */
  137351. private _onchange;
  137352. /**
  137353. * The value of the path cursor
  137354. */
  137355. value: number;
  137356. /**
  137357. * The animation array of the path cursor
  137358. */
  137359. animations: Animation[];
  137360. /**
  137361. * Initializes the path cursor
  137362. * @param path The path to track
  137363. */
  137364. constructor(path: Path2);
  137365. /**
  137366. * Gets the cursor point on the path
  137367. * @returns A point on the path cursor at the cursor location
  137368. */
  137369. getPoint(): Vector3;
  137370. /**
  137371. * Moves the cursor ahead by the step amount
  137372. * @param step The amount to move the cursor forward
  137373. * @returns This path cursor
  137374. */
  137375. moveAhead(step?: number): PathCursor;
  137376. /**
  137377. * Moves the cursor behind by the step amount
  137378. * @param step The amount to move the cursor back
  137379. * @returns This path cursor
  137380. */
  137381. moveBack(step?: number): PathCursor;
  137382. /**
  137383. * Moves the cursor by the step amount
  137384. * If the step amount is greater than one, an exception is thrown
  137385. * @param step The amount to move the cursor
  137386. * @returns This path cursor
  137387. */
  137388. move(step: number): PathCursor;
  137389. /**
  137390. * Ensures that the value is limited between zero and one
  137391. * @returns This path cursor
  137392. */
  137393. private ensureLimits;
  137394. /**
  137395. * Runs onchange callbacks on change (used by the animation engine)
  137396. * @returns This path cursor
  137397. */
  137398. private raiseOnChange;
  137399. /**
  137400. * Executes a function on change
  137401. * @param f A path cursor onchange callback
  137402. * @returns This path cursor
  137403. */
  137404. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137405. }
  137406. }
  137407. declare module BABYLON {
  137408. /** @hidden */
  137409. export var blurPixelShader: {
  137410. name: string;
  137411. shader: string;
  137412. };
  137413. }
  137414. declare module BABYLON {
  137415. /** @hidden */
  137416. export var pointCloudVertexDeclaration: {
  137417. name: string;
  137418. shader: string;
  137419. };
  137420. }
  137421. // Mixins
  137422. interface Window {
  137423. mozIndexedDB: IDBFactory;
  137424. webkitIndexedDB: IDBFactory;
  137425. msIndexedDB: IDBFactory;
  137426. webkitURL: typeof URL;
  137427. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137428. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137429. WebGLRenderingContext: WebGLRenderingContext;
  137430. MSGesture: MSGesture;
  137431. CANNON: any;
  137432. AudioContext: AudioContext;
  137433. webkitAudioContext: AudioContext;
  137434. PointerEvent: any;
  137435. Math: Math;
  137436. Uint8Array: Uint8ArrayConstructor;
  137437. Float32Array: Float32ArrayConstructor;
  137438. mozURL: typeof URL;
  137439. msURL: typeof URL;
  137440. VRFrameData: any; // WebVR, from specs 1.1
  137441. DracoDecoderModule: any;
  137442. setImmediate(handler: (...args: any[]) => void): number;
  137443. }
  137444. interface HTMLCanvasElement {
  137445. requestPointerLock(): void;
  137446. msRequestPointerLock?(): void;
  137447. mozRequestPointerLock?(): void;
  137448. webkitRequestPointerLock?(): void;
  137449. /** Track wether a record is in progress */
  137450. isRecording: boolean;
  137451. /** Capture Stream method defined by some browsers */
  137452. captureStream(fps?: number): MediaStream;
  137453. }
  137454. interface CanvasRenderingContext2D {
  137455. msImageSmoothingEnabled: boolean;
  137456. }
  137457. interface MouseEvent {
  137458. mozMovementX: number;
  137459. mozMovementY: number;
  137460. webkitMovementX: number;
  137461. webkitMovementY: number;
  137462. msMovementX: number;
  137463. msMovementY: number;
  137464. }
  137465. interface Navigator {
  137466. mozGetVRDevices: (any: any) => any;
  137467. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137468. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137469. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137470. webkitGetGamepads(): Gamepad[];
  137471. msGetGamepads(): Gamepad[];
  137472. webkitGamepads(): Gamepad[];
  137473. }
  137474. interface HTMLVideoElement {
  137475. mozSrcObject: any;
  137476. }
  137477. interface Math {
  137478. fround(x: number): number;
  137479. imul(a: number, b: number): number;
  137480. }
  137481. interface WebGLRenderingContext {
  137482. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137483. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137484. vertexAttribDivisor(index: number, divisor: number): void;
  137485. createVertexArray(): any;
  137486. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137487. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137488. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137489. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137490. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137491. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137492. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137493. // Queries
  137494. createQuery(): WebGLQuery;
  137495. deleteQuery(query: WebGLQuery): void;
  137496. beginQuery(target: number, query: WebGLQuery): void;
  137497. endQuery(target: number): void;
  137498. getQueryParameter(query: WebGLQuery, pname: number): any;
  137499. getQuery(target: number, pname: number): any;
  137500. MAX_SAMPLES: number;
  137501. RGBA8: number;
  137502. READ_FRAMEBUFFER: number;
  137503. DRAW_FRAMEBUFFER: number;
  137504. UNIFORM_BUFFER: number;
  137505. HALF_FLOAT_OES: number;
  137506. RGBA16F: number;
  137507. RGBA32F: number;
  137508. R32F: number;
  137509. RG32F: number;
  137510. RGB32F: number;
  137511. R16F: number;
  137512. RG16F: number;
  137513. RGB16F: number;
  137514. RED: number;
  137515. RG: number;
  137516. R8: number;
  137517. RG8: number;
  137518. UNSIGNED_INT_24_8: number;
  137519. DEPTH24_STENCIL8: number;
  137520. MIN: number;
  137521. MAX: number;
  137522. /* Multiple Render Targets */
  137523. drawBuffers(buffers: number[]): void;
  137524. readBuffer(src: number): void;
  137525. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137526. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137527. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137528. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137529. // Occlusion Query
  137530. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137531. ANY_SAMPLES_PASSED: number;
  137532. QUERY_RESULT_AVAILABLE: number;
  137533. QUERY_RESULT: number;
  137534. }
  137535. interface WebGLProgram {
  137536. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137537. }
  137538. interface EXT_disjoint_timer_query {
  137539. QUERY_COUNTER_BITS_EXT: number;
  137540. TIME_ELAPSED_EXT: number;
  137541. TIMESTAMP_EXT: number;
  137542. GPU_DISJOINT_EXT: number;
  137543. QUERY_RESULT_EXT: number;
  137544. QUERY_RESULT_AVAILABLE_EXT: number;
  137545. queryCounterEXT(query: WebGLQuery, target: number): void;
  137546. createQueryEXT(): WebGLQuery;
  137547. beginQueryEXT(target: number, query: WebGLQuery): void;
  137548. endQueryEXT(target: number): void;
  137549. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137550. deleteQueryEXT(query: WebGLQuery): void;
  137551. }
  137552. interface WebGLUniformLocation {
  137553. _currentState: any;
  137554. }
  137555. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137556. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137557. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137558. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137559. interface WebGLRenderingContext {
  137560. readonly RASTERIZER_DISCARD: number;
  137561. readonly DEPTH_COMPONENT24: number;
  137562. readonly TEXTURE_3D: number;
  137563. readonly TEXTURE_2D_ARRAY: number;
  137564. readonly TEXTURE_COMPARE_FUNC: number;
  137565. readonly TEXTURE_COMPARE_MODE: number;
  137566. readonly COMPARE_REF_TO_TEXTURE: number;
  137567. readonly TEXTURE_WRAP_R: number;
  137568. readonly HALF_FLOAT: number;
  137569. readonly RGB8: number;
  137570. readonly RED_INTEGER: number;
  137571. readonly RG_INTEGER: number;
  137572. readonly RGB_INTEGER: number;
  137573. readonly RGBA_INTEGER: number;
  137574. readonly R8_SNORM: number;
  137575. readonly RG8_SNORM: number;
  137576. readonly RGB8_SNORM: number;
  137577. readonly RGBA8_SNORM: number;
  137578. readonly R8I: number;
  137579. readonly RG8I: number;
  137580. readonly RGB8I: number;
  137581. readonly RGBA8I: number;
  137582. readonly R8UI: number;
  137583. readonly RG8UI: number;
  137584. readonly RGB8UI: number;
  137585. readonly RGBA8UI: number;
  137586. readonly R16I: number;
  137587. readonly RG16I: number;
  137588. readonly RGB16I: number;
  137589. readonly RGBA16I: number;
  137590. readonly R16UI: number;
  137591. readonly RG16UI: number;
  137592. readonly RGB16UI: number;
  137593. readonly RGBA16UI: number;
  137594. readonly R32I: number;
  137595. readonly RG32I: number;
  137596. readonly RGB32I: number;
  137597. readonly RGBA32I: number;
  137598. readonly R32UI: number;
  137599. readonly RG32UI: number;
  137600. readonly RGB32UI: number;
  137601. readonly RGBA32UI: number;
  137602. readonly RGB10_A2UI: number;
  137603. readonly R11F_G11F_B10F: number;
  137604. readonly RGB9_E5: number;
  137605. readonly RGB10_A2: number;
  137606. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137607. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137608. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137609. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137610. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137611. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137612. 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;
  137613. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137614. readonly TRANSFORM_FEEDBACK: number;
  137615. readonly INTERLEAVED_ATTRIBS: number;
  137616. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137617. createTransformFeedback(): WebGLTransformFeedback;
  137618. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137619. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137620. beginTransformFeedback(primitiveMode: number): void;
  137621. endTransformFeedback(): void;
  137622. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137623. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137624. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137625. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137626. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137627. }
  137628. interface ImageBitmap {
  137629. readonly width: number;
  137630. readonly height: number;
  137631. close(): void;
  137632. }
  137633. interface WebGLQuery extends WebGLObject {
  137634. }
  137635. declare var WebGLQuery: {
  137636. prototype: WebGLQuery;
  137637. new(): WebGLQuery;
  137638. };
  137639. interface WebGLSampler extends WebGLObject {
  137640. }
  137641. declare var WebGLSampler: {
  137642. prototype: WebGLSampler;
  137643. new(): WebGLSampler;
  137644. };
  137645. interface WebGLSync extends WebGLObject {
  137646. }
  137647. declare var WebGLSync: {
  137648. prototype: WebGLSync;
  137649. new(): WebGLSync;
  137650. };
  137651. interface WebGLTransformFeedback extends WebGLObject {
  137652. }
  137653. declare var WebGLTransformFeedback: {
  137654. prototype: WebGLTransformFeedback;
  137655. new(): WebGLTransformFeedback;
  137656. };
  137657. interface WebGLVertexArrayObject extends WebGLObject {
  137658. }
  137659. declare var WebGLVertexArrayObject: {
  137660. prototype: WebGLVertexArrayObject;
  137661. new(): WebGLVertexArrayObject;
  137662. };
  137663. // Type definitions for WebVR API
  137664. // Project: https://w3c.github.io/webvr/
  137665. // Definitions by: six a <https://github.com/lostfictions>
  137666. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137667. interface VRDisplay extends EventTarget {
  137668. /**
  137669. * Dictionary of capabilities describing the VRDisplay.
  137670. */
  137671. readonly capabilities: VRDisplayCapabilities;
  137672. /**
  137673. * z-depth defining the far plane of the eye view frustum
  137674. * enables mapping of values in the render target depth
  137675. * attachment to scene coordinates. Initially set to 10000.0.
  137676. */
  137677. depthFar: number;
  137678. /**
  137679. * z-depth defining the near plane of the eye view frustum
  137680. * enables mapping of values in the render target depth
  137681. * attachment to scene coordinates. Initially set to 0.01.
  137682. */
  137683. depthNear: number;
  137684. /**
  137685. * An identifier for this distinct VRDisplay. Used as an
  137686. * association point in the Gamepad API.
  137687. */
  137688. readonly displayId: number;
  137689. /**
  137690. * A display name, a user-readable name identifying it.
  137691. */
  137692. readonly displayName: string;
  137693. readonly isConnected: boolean;
  137694. readonly isPresenting: boolean;
  137695. /**
  137696. * If this VRDisplay supports room-scale experiences, the optional
  137697. * stage attribute contains details on the room-scale parameters.
  137698. */
  137699. readonly stageParameters: VRStageParameters | null;
  137700. /**
  137701. * Passing the value returned by `requestAnimationFrame` to
  137702. * `cancelAnimationFrame` will unregister the callback.
  137703. * @param handle Define the hanle of the request to cancel
  137704. */
  137705. cancelAnimationFrame(handle: number): void;
  137706. /**
  137707. * Stops presenting to the VRDisplay.
  137708. * @returns a promise to know when it stopped
  137709. */
  137710. exitPresent(): Promise<void>;
  137711. /**
  137712. * Return the current VREyeParameters for the given eye.
  137713. * @param whichEye Define the eye we want the parameter for
  137714. * @returns the eye parameters
  137715. */
  137716. getEyeParameters(whichEye: string): VREyeParameters;
  137717. /**
  137718. * Populates the passed VRFrameData with the information required to render
  137719. * the current frame.
  137720. * @param frameData Define the data structure to populate
  137721. * @returns true if ok otherwise false
  137722. */
  137723. getFrameData(frameData: VRFrameData): boolean;
  137724. /**
  137725. * Get the layers currently being presented.
  137726. * @returns the list of VR layers
  137727. */
  137728. getLayers(): VRLayer[];
  137729. /**
  137730. * Return a VRPose containing the future predicted pose of the VRDisplay
  137731. * when the current frame will be presented. The value returned will not
  137732. * change until JavaScript has returned control to the browser.
  137733. *
  137734. * The VRPose will contain the position, orientation, velocity,
  137735. * and acceleration of each of these properties.
  137736. * @returns the pose object
  137737. */
  137738. getPose(): VRPose;
  137739. /**
  137740. * Return the current instantaneous pose of the VRDisplay, with no
  137741. * prediction applied.
  137742. * @returns the current instantaneous pose
  137743. */
  137744. getImmediatePose(): VRPose;
  137745. /**
  137746. * The callback passed to `requestAnimationFrame` will be called
  137747. * any time a new frame should be rendered. When the VRDisplay is
  137748. * presenting the callback will be called at the native refresh
  137749. * rate of the HMD. When not presenting this function acts
  137750. * identically to how window.requestAnimationFrame acts. Content should
  137751. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137752. * asynchronously from other displays and at differing refresh rates.
  137753. * @param callback Define the eaction to run next frame
  137754. * @returns the request handle it
  137755. */
  137756. requestAnimationFrame(callback: FrameRequestCallback): number;
  137757. /**
  137758. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137759. * Repeat calls while already presenting will update the VRLayers being displayed.
  137760. * @param layers Define the list of layer to present
  137761. * @returns a promise to know when the request has been fulfilled
  137762. */
  137763. requestPresent(layers: VRLayer[]): Promise<void>;
  137764. /**
  137765. * Reset the pose for this display, treating its current position and
  137766. * orientation as the "origin/zero" values. VRPose.position,
  137767. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137768. * updated when calling resetPose(). This should be called in only
  137769. * sitting-space experiences.
  137770. */
  137771. resetPose(): void;
  137772. /**
  137773. * The VRLayer provided to the VRDisplay will be captured and presented
  137774. * in the HMD. Calling this function has the same effect on the source
  137775. * canvas as any other operation that uses its source image, and canvases
  137776. * created without preserveDrawingBuffer set to true will be cleared.
  137777. * @param pose Define the pose to submit
  137778. */
  137779. submitFrame(pose?: VRPose): void;
  137780. }
  137781. declare var VRDisplay: {
  137782. prototype: VRDisplay;
  137783. new(): VRDisplay;
  137784. };
  137785. interface VRLayer {
  137786. leftBounds?: number[] | Float32Array | null;
  137787. rightBounds?: number[] | Float32Array | null;
  137788. source?: HTMLCanvasElement | null;
  137789. }
  137790. interface VRDisplayCapabilities {
  137791. readonly canPresent: boolean;
  137792. readonly hasExternalDisplay: boolean;
  137793. readonly hasOrientation: boolean;
  137794. readonly hasPosition: boolean;
  137795. readonly maxLayers: number;
  137796. }
  137797. interface VREyeParameters {
  137798. /** @deprecated */
  137799. readonly fieldOfView: VRFieldOfView;
  137800. readonly offset: Float32Array;
  137801. readonly renderHeight: number;
  137802. readonly renderWidth: number;
  137803. }
  137804. interface VRFieldOfView {
  137805. readonly downDegrees: number;
  137806. readonly leftDegrees: number;
  137807. readonly rightDegrees: number;
  137808. readonly upDegrees: number;
  137809. }
  137810. interface VRFrameData {
  137811. readonly leftProjectionMatrix: Float32Array;
  137812. readonly leftViewMatrix: Float32Array;
  137813. readonly pose: VRPose;
  137814. readonly rightProjectionMatrix: Float32Array;
  137815. readonly rightViewMatrix: Float32Array;
  137816. readonly timestamp: number;
  137817. }
  137818. interface VRPose {
  137819. readonly angularAcceleration: Float32Array | null;
  137820. readonly angularVelocity: Float32Array | null;
  137821. readonly linearAcceleration: Float32Array | null;
  137822. readonly linearVelocity: Float32Array | null;
  137823. readonly orientation: Float32Array | null;
  137824. readonly position: Float32Array | null;
  137825. readonly timestamp: number;
  137826. }
  137827. interface VRStageParameters {
  137828. sittingToStandingTransform?: Float32Array;
  137829. sizeX?: number;
  137830. sizeY?: number;
  137831. }
  137832. interface Navigator {
  137833. getVRDisplays(): Promise<VRDisplay[]>;
  137834. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137835. }
  137836. interface Window {
  137837. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137838. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137839. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137840. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137841. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137842. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  137843. }
  137844. interface Gamepad {
  137845. readonly displayId: number;
  137846. }
  137847. type XRSessionMode =
  137848. | "inline"
  137849. | "immersive-vr"
  137850. | "immersive-ar";
  137851. type XRReferenceSpaceType =
  137852. | "viewer"
  137853. | "local"
  137854. | "local-floor"
  137855. | "bounded-floor"
  137856. | "unbounded";
  137857. type XREnvironmentBlendMode =
  137858. | "opaque"
  137859. | "additive"
  137860. | "alpha-blend";
  137861. type XRVisibilityState =
  137862. | "visible"
  137863. | "visible-blurred"
  137864. | "hidden";
  137865. type XRHandedness =
  137866. | "none"
  137867. | "left"
  137868. | "right";
  137869. type XRTargetRayMode =
  137870. | "gaze"
  137871. | "tracked-pointer"
  137872. | "screen";
  137873. type XREye =
  137874. | "none"
  137875. | "left"
  137876. | "right";
  137877. interface XRSpace extends EventTarget {
  137878. }
  137879. interface XRRenderState {
  137880. depthNear?: number;
  137881. depthFar?: number;
  137882. inlineVerticalFieldOfView?: number;
  137883. baseLayer?: XRWebGLLayer;
  137884. }
  137885. interface XRInputSource {
  137886. handedness: XRHandedness;
  137887. targetRayMode: XRTargetRayMode;
  137888. targetRaySpace: XRSpace;
  137889. gripSpace: XRSpace | undefined;
  137890. gamepad: Gamepad | undefined;
  137891. profiles: Array<string>;
  137892. }
  137893. interface XRSession extends XRAnchorCreator {
  137894. addEventListener: Function;
  137895. removeEventListener: Function;
  137896. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137897. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  137898. requestAnimationFrame: Function;
  137899. end(): Promise<void>;
  137900. renderState: XRRenderState;
  137901. inputSources: Array<XRInputSource>;
  137902. // AR hit test
  137903. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  137904. updateWorldTrackingState(options: {
  137905. planeDetectionState?: { enabled: boolean; }
  137906. }): void;
  137907. }
  137908. interface XRReferenceSpace extends XRSpace {
  137909. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  137910. onreset: any;
  137911. }
  137912. type XRPlaneSet = Set<XRPlane>;
  137913. type XRAnchorSet = Set<XRAnchor>;
  137914. interface XRFrame {
  137915. session: XRSession;
  137916. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  137917. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  137918. // Anchors
  137919. trackedAnchors?: XRAnchorSet;
  137920. // Planes
  137921. worldInformation: {
  137922. detectedPlanes?: XRPlaneSet;
  137923. };
  137924. }
  137925. interface XRViewerPose extends XRPose {
  137926. views: Array<XRView>;
  137927. }
  137928. interface XRPose {
  137929. transform: XRRigidTransform;
  137930. emulatedPosition: boolean;
  137931. }
  137932. interface XRWebGLLayerOptions {
  137933. antialias?: boolean;
  137934. depth?: boolean;
  137935. stencil?: boolean;
  137936. alpha?: boolean;
  137937. multiview?: boolean;
  137938. framebufferScaleFactor?: number;
  137939. }
  137940. declare var XRWebGLLayer: {
  137941. prototype: XRWebGLLayer;
  137942. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  137943. };
  137944. interface XRWebGLLayer {
  137945. framebuffer: WebGLFramebuffer;
  137946. framebufferWidth: number;
  137947. framebufferHeight: number;
  137948. getViewport: Function;
  137949. }
  137950. declare class XRRigidTransform {
  137951. constructor(matrix: Float32Array);
  137952. position: DOMPointReadOnly;
  137953. orientation: DOMPointReadOnly;
  137954. matrix: Float32Array;
  137955. inverse: XRRigidTransform;
  137956. }
  137957. interface XRView {
  137958. eye: XREye;
  137959. projectionMatrix: Float32Array;
  137960. transform: XRRigidTransform;
  137961. }
  137962. interface XRInputSourceChangeEvent {
  137963. session: XRSession;
  137964. removed: Array<XRInputSource>;
  137965. added: Array<XRInputSource>;
  137966. }
  137967. interface XRInputSourceEvent extends Event {
  137968. readonly frame: XRFrame;
  137969. readonly inputSource: XRInputSource;
  137970. }
  137971. // Experimental(er) features
  137972. declare class XRRay {
  137973. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  137974. origin: DOMPointReadOnly;
  137975. direction: DOMPointReadOnly;
  137976. matrix: Float32Array;
  137977. }
  137978. interface XRHitResult {
  137979. hitMatrix: Float32Array;
  137980. }
  137981. interface XRAnchor {
  137982. // remove?
  137983. id?: string;
  137984. anchorSpace: XRSpace;
  137985. lastChangedTime: number;
  137986. detach(): void;
  137987. }
  137988. interface XRPlane extends XRAnchorCreator {
  137989. orientation: "Horizontal" | "Vertical";
  137990. planeSpace: XRSpace;
  137991. polygon: Array<DOMPointReadOnly>;
  137992. lastChangedTime: number;
  137993. }
  137994. interface XRAnchorCreator {
  137995. // AR Anchors
  137996. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  137997. }